18个文件已修改
675 ■■■■ 已修改文件
api/src/main/java/com/ruoyi/api/third/controller/ReceivableBillApiController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/controller/PayableBillManagementController.java 71 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/controller/ReceivableBillManagementController.java 66 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/domain/PayableBillManagement.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/domain/PayableBillManagementLog.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/domain/ReceivableBillManagement.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/domain/ReceivableBillManagementLog.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/domain/dto/PayableAuditLog.java 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/domain/dto/PayableBillApiDto.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/domain/dto/ReceivableAuditLog.java 59 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/domain/dto/ReceivableBillApiDto.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/service/impl/TmsAuditLogPushServiceImpl.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/resources/mapper/cwgl/PayableBillManagementMapper.xml 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/resources/mapper/cwgl/ReceivableBillManagementMapper.xml 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ui/admin-ui3/src/api/cwgl/payableBillManagement.ts 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ui/admin-ui3/src/api/cwgl/receivableBillManagement.ts 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ui/admin-ui3/src/views/cwgl/payableBillManagement/index.vue 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ui/admin-ui3/src/views/cwgl/receivableBillManagement/index.vue 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/src/main/java/com/ruoyi/api/third/controller/ReceivableBillApiController.java
@@ -182,6 +182,7 @@
        billManagement.setSettlementPeriod(billDto.getSettlementPeriod());
        billManagement.setStatus(billDto.getStatus() != null ? billDto.getStatus() : "draft");
        billManagement.setAuditStatus(billDto.getAuditStatus() != null ? billDto.getAuditStatus() : 0);
        billManagement.setSourceSystemId(billDto.getSourceSystemId());
        billManagement.setRemark(billDto.getRemark());
        billManagement.setCreateTime(DateUtils.getNowDate());
        billManagement.setCreateBy("api_system");
@@ -428,6 +429,7 @@
        // 设置其他信息
        billManagement.setStatus(billDto.getStatus() != null ? billDto.getStatus() : "draft");
        billManagement.setAuditStatus(billDto.getAuditStatus() != null ? billDto.getAuditStatus() : 0);
        billManagement.setSourceSystemId(billDto.getSourceSystemId());
        billManagement.setRemark(billDto.getRemark());
        billManagement.setCreateTime(DateUtils.getNowDate());
        billManagement.setCreateBy("api_system");
service/src/main/java/com/ruoyi/cwgl/controller/PayableBillManagementController.java
@@ -1,6 +1,9 @@
package com.ruoyi.cwgl.controller;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -21,10 +24,12 @@
import java.util.Objects;
import com.ruoyi.cwgl.domain.InvoiceManage;
import com.ruoyi.cwgl.domain.PayableBillManagement;
import com.ruoyi.cwgl.domain.PayableBillManagementLog;
import com.ruoyi.cwgl.domain.PayableInvoiceBusiness;
import com.ruoyi.cwgl.domain.dto.BillAuditDto;
import com.ruoyi.cwgl.domain.dto.PayableAuditLog;
import com.ruoyi.cwgl.service.IInvoiceManageService;
import com.ruoyi.cwgl.service.IPayableBillManagementLogService;
import com.ruoyi.cwgl.service.IPayableBillManagementService;
import com.ruoyi.cwgl.service.IPayableInvoiceBusinessService;
import com.ruoyi.cwgl.service.ITmsAuditLogPushService;
@@ -52,6 +57,9 @@
    @Autowired
    private ITmsAuditLogPushService tmsAuditLogPushService;
    @Autowired
    private IPayableBillManagementLogService payableBillManagementLogService;
@@ -210,7 +218,7 @@
            // 6. 如果来源系统是TMS,推送审核日志到TMS
            if (tmsAuditLogPushService.isPayableBillFromTms(bill.getSystemNo())) {
                try {
                    PayableAuditLog auditLog = createPayableAuditLog(billAuditDto, bill, beforeAuditStatus);
                    PayableAuditLog auditLog = createPayableAuditLog(billAuditDto, bill);
                    tmsAuditLogPushService.pushPayableAuditLog(auditLog);
                } catch (Exception e) {
                    logger.error("推送应付账单审核日志到TMS失败,账单ID:{}", bill.getId(), e);
@@ -229,13 +237,30 @@
     * 保存应付账单审核日志
     */
    private void savePayableAuditLog(BillAuditDto billAuditDto, PayableBillManagement bill, Integer beforeAuditStatus) {
        // 这里需要实现日志记录逻辑
        // 可以使用原有的日志服务或系统日志
        logger.info("应付账单审核日志 - 账单ID:{},账单编号:{},审核前状态:{},审核结果:{},审核意见:{}",
            bill.getId(), bill.getSystemNo(),
            getAuditStatusText(beforeAuditStatus),
            getAuditResultText(billAuditDto.getAuditResult()),
            billAuditDto.getAuditComment() != null ? billAuditDto.getAuditComment() : "无");
        try {
            PayableBillManagementLog log = new PayableBillManagementLog();
            log.setBillId(bill.getId());
            log.setSourceSystemId(bill.getSourceSystemId()); // 设置来源系统ID
            log.setCreateBy(getUsername());
            log.setCreateTime(new Date());
            // 构建操作说明
            String operation = String.format("应付账单审核 - 账单编号:%s,审核前状态:%s,审核结果:%s,审核意见:%s",
                bill.getSystemNo(),
                getAuditStatusText(beforeAuditStatus),
                getAuditResultText(billAuditDto.getAuditResult()),
                billAuditDto.getAuditComment() != null ? billAuditDto.getAuditComment() : "无");
            log.setOperation(operation);
            // 保存到数据库
            payableBillManagementLogService.insertPayableBillManagementLog(log);
            logger.info("应付账单审核日志保存成功 - 账单ID:{},来源系统ID:{}", bill.getId(), bill.getSourceSystemId());
        } catch (Exception e) {
            logger.error("保存应付账单审核日志失败,账单ID:{}", bill.getId(), e);
            // 日志保存失败不影响主流程,只记录错误日志
        }
    }
    /**
@@ -264,19 +289,25 @@
    /**
     * 创建应付账单审核日志对象
     */
    private PayableAuditLog createPayableAuditLog(BillAuditDto billAuditDto, PayableBillManagement bill, Integer beforeAuditStatus) {
    private PayableAuditLog createPayableAuditLog(BillAuditDto billAuditDto, PayableBillManagement bill) {
        PayableAuditLog auditLog = new PayableAuditLog();
        auditLog.setBillId(bill.getId());
        auditLog.setBillNo(bill.getSystemNo());
        auditLog.setBillName(bill.getBillName());
        auditLog.setSupplierName(bill.getSupplierName());
        auditLog.setSourceSystem(tmsAuditLogPushService.getPayableBillSourceSystem(bill.getSystemNo()));
        auditLog.setBeforeAuditStatus(beforeAuditStatus);
        auditLog.setAuditResult(billAuditDto.getAuditResult());
        auditLog.setAuditComment(billAuditDto.getAuditComment());
        auditLog.setAuditUser(getUsername());
        auditLog.setAuditTime(new java.util.Date());
        auditLog.setTotalAmount(bill.getTotalAmount());
        auditLog.setHeadId(bill.getSourceSystemId());
        auditLog.setCreateBy(getUsername());
        auditLog.setCreateTime(new Date());
        String opertion = "";
        if (billAuditDto.getAuditResult() != null&& billAuditDto.getAuditResult().equals(1)) {
            opertion = "审核通过";
            if (StringUtils.isNotEmpty(billAuditDto.getAuditComment())){
                opertion +=  ",审核意见 :" + billAuditDto.getAuditComment();
            }
        }else {
            opertion = "审核驳回";
            if (StringUtils.isNotEmpty(billAuditDto.getAuditComment())){
                opertion += ",审核意见:" + billAuditDto.getAuditComment();
            }
        }        auditLog.setOperation(opertion);
        return auditLog;
    }
}
service/src/main/java/com/ruoyi/cwgl/controller/ReceivableBillManagementController.java
@@ -1,7 +1,9 @@
package com.ruoyi.cwgl.controller;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.cwgl.domain.ReceivableBillCustomerSummary;
import com.ruoyi.cwgl.domain.vo.ReceivableBillAccountAnalysisVo;
import com.ruoyi.cwgl.domain.vo.ReceivableBillAgingAnalysisVo;
@@ -25,10 +27,12 @@
import java.util.Objects;
import com.ruoyi.cwgl.domain.InvoiceManage;
import com.ruoyi.cwgl.domain.ReceivableBillManagement;
import com.ruoyi.cwgl.domain.ReceivableBillManagementLog;
import com.ruoyi.cwgl.domain.ReceivableInvoiceBusiness;
import com.ruoyi.cwgl.domain.dto.BillAuditDto;
import com.ruoyi.cwgl.domain.dto.ReceivableAuditLog;
import com.ruoyi.cwgl.service.IInvoiceManageService;
import com.ruoyi.cwgl.service.IReceivableBillManagementLogService;
import com.ruoyi.cwgl.service.IReceivableBillManagementService;
import com.ruoyi.cwgl.service.IReceivableInvoiceBusinessService;
import com.ruoyi.cwgl.service.ITmsAuditLogPushService;
@@ -56,6 +60,9 @@
    @Autowired
    private ITmsAuditLogPushService tmsAuditLogPushService;
    @Autowired
    private IReceivableBillManagementLogService receivableBillManagementLogService;
@@ -307,13 +314,30 @@
     * 保存应收账单审核日志
     */
    private void saveReceivableAuditLog(BillAuditDto billAuditDto, ReceivableBillManagement bill, Integer beforeAuditStatus) {
        // 这里需要实现日志记录逻辑
        // 可以使用原有的日志服务或系统日志
        logger.info("应收账单审核日志 - 账单ID:{},账单编号:{},审核前状态:{},审核结果:{},审核意见:{}",
            bill.getId(), bill.getSystemNo(),
            getAuditStatusText(beforeAuditStatus),
            getAuditResultText(billAuditDto.getAuditResult()),
            billAuditDto.getAuditComment() != null ? billAuditDto.getAuditComment() : "无");
        try {
            ReceivableBillManagementLog log = new ReceivableBillManagementLog();
            log.setBillId(bill.getId());
            log.setSourceSystemId(bill.getSourceSystemId()); // 设置来源系统ID
            log.setCreateBy(getUsername());
            log.setCreateTime(new Date());
            // 构建操作说明
            String operation = String.format("应收账单审核 - 账单编号:%s,审核前状态:%s,审核结果:%s,审核意见:%s",
                bill.getSystemNo(),
                getAuditStatusText(beforeAuditStatus),
                getAuditResultText(billAuditDto.getAuditResult()),
                billAuditDto.getAuditComment() != null ? billAuditDto.getAuditComment() : "无");
            log.setOperation(operation);
            // 保存到数据库
            receivableBillManagementLogService.insertReceivableBillManagementLog(log);
            logger.info("应收账单审核日志保存成功 - 账单ID:{},来源系统ID:{}", bill.getId(), bill.getSourceSystemId());
        } catch (Exception e) {
            logger.error("保存应收账单审核日志失败,账单ID:{}", bill.getId(), e);
            // 日志保存失败不影响主流程,只记录错误日志
        }
    }
    /**
@@ -344,17 +368,23 @@
     */
    private ReceivableAuditLog createReceivableAuditLog(BillAuditDto billAuditDto, ReceivableBillManagement bill, Integer beforeAuditStatus) {
        ReceivableAuditLog auditLog = new ReceivableAuditLog();
        auditLog.setBillId(bill.getId());
        auditLog.setBillNo(bill.getSystemNo());
        auditLog.setBillName(bill.getBillName());
        auditLog.setCustomerName(bill.getCustomerName());
        auditLog.setSourceSystem(tmsAuditLogPushService.getReceivableBillSourceSystem(bill.getSystemNo()));
        auditLog.setBeforeAuditStatus(beforeAuditStatus);
        auditLog.setAuditResult(billAuditDto.getAuditResult());
        auditLog.setAuditComment(billAuditDto.getAuditComment());
        auditLog.setAuditUser(getUsername());
        auditLog.setAuditTime(new java.util.Date());
        auditLog.setTotalAmount(bill.getTotalAmount());
        auditLog.setHeadId(bill.getSourceSystemId());
        auditLog.setCreateBy(getUsername());
        auditLog.setCreateTime(new Date());
        String opertion = "";
        if (billAuditDto.getAuditResult() != null&& billAuditDto.getAuditResult().equals(1)) {
            opertion = "审核通过";
            if (StringUtils.isNotEmpty(billAuditDto.getAuditComment())){
                opertion +=  ",审核意见 :" + billAuditDto.getAuditComment();
            }
        }else {
            opertion = "审核驳回";
            if (StringUtils.isNotEmpty(billAuditDto.getAuditComment())){
                opertion += ",审核意见:" + billAuditDto.getAuditComment();
            }
        }
        auditLog.setOperation(opertion);
        return auditLog;
    }
    
service/src/main/java/com/ruoyi/cwgl/domain/PayableBillManagement.java
@@ -190,6 +190,12 @@
        @TableField("audit_status")
    private Integer auditStatus;
    /** 来源系统ID(用于审核推送时识别目标TMS系统) */
    @Excel(name = "来源系统ID")
        @TableField("source_system_id")
    private Integer sourceSystemId;
    /** 备注 */
    @Excel(name = "备注")
service/src/main/java/com/ruoyi/cwgl/domain/PayableBillManagementLog.java
@@ -44,5 +44,10 @@
        @TableField("operation")
    private String operation;
    /** 来源系统ID(用于审核推送时识别目标TMS系统) */
    @Excel(name = "来源系统ID")
        @TableField("source_system_id")
    private Integer sourceSystemId;
}
service/src/main/java/com/ruoyi/cwgl/domain/ReceivableBillManagement.java
@@ -351,6 +351,12 @@
        @TableField("audit_status")
    private Integer auditStatus;
    /** 来源系统ID(用于审核推送时识别目标TMS系统) */
    @Excel(name = "来源系统ID")
        @TableField("source_system_id")
    private Integer sourceSystemId;
    /** 备注 */
    @Excel(name = "备注")
service/src/main/java/com/ruoyi/cwgl/domain/ReceivableBillManagementLog.java
@@ -44,5 +44,10 @@
        @TableField("operation")
    private String operation;
    /** 来源系统ID(用于审核推送时识别目标TMS系统) */
    @Excel(name = "来源系统ID")
        @TableField("source_system_id")
    private Integer sourceSystemId;
}
service/src/main/java/com/ruoyi/cwgl/domain/dto/PayableAuditLog.java
@@ -1,5 +1,8 @@
package com.ruoyi.cwgl.domain.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
import java.util.Date;
@@ -9,58 +12,21 @@
@Data
public class PayableAuditLog {
    /**
     * 账单ID
     */
    private Integer billId;
    /** 应付账单id */
    /**
     * 账单编号
     */
    private String billNo;
    @TableField("head_id")
    private Integer headId;
    /**
     * 账单名称
     */
    private String billName;
    /**
     * 供应商名称
     */
    private String supplierName;
    /** 创建者 */
    private String createBy;
    /**
     * 来源系统
     */
    private String sourceSystem;
    /**
     * 审核前状态
     */
    private Integer beforeAuditStatus;
    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createTime;
    /**
     * 审核结果
     */
    private Integer auditResult;
    /**
     * 审核意见
     */
    private String auditComment;
    /**
     * 审核人
     */
    private String auditUser;
    /**
     * 审核时间
     */
    private Date auditTime;
    /**
     * 总金额
     */
    private java.math.BigDecimal totalAmount;
    /** 操作说明 */
    private String operation;
}
service/src/main/java/com/ruoyi/cwgl/domain/dto/PayableBillApiDto.java
@@ -112,6 +112,9 @@
        /** 备注 */
        private String remark;
        /** 来源系统ID(用于审核推送时识别目标TMS系统) */
        private Integer sourceSystemId;
    }
    /**
service/src/main/java/com/ruoyi/cwgl/domain/dto/ReceivableAuditLog.java
@@ -1,5 +1,8 @@
package com.ruoyi.cwgl.domain.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
import java.util.Date;
@@ -9,58 +12,20 @@
@Data
public class ReceivableAuditLog {
    /**
     * 账单ID
     */
    private Integer billId;
    /** 应收账单id */
    /**
     * 账单编号
     */
    private String billNo;
    private Integer headId;
    /**
     * 账单名称
     */
    private String billName;
    /**
     * 客户名称
     */
    private String customerName;
    /** 创建者 */
    private String createBy;
    /**
     * 来源系统
     */
    private String sourceSystem;
    /**
     * 审核前状态
     */
    private Integer beforeAuditStatus;
    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createTime;
    /**
     * 审核结果
     */
    private Integer auditResult;
    /**
     * 审核意见
     */
    private String auditComment;
    /**
     * 审核人
     */
    private String auditUser;
    /**
     * 审核时间
     */
    private Date auditTime;
    /**
     * 总金额
     */
    private java.math.BigDecimal totalAmount;
    /** 操作说明 */
    private String operation;
}
service/src/main/java/com/ruoyi/cwgl/domain/dto/ReceivableBillApiDto.java
@@ -136,6 +136,9 @@
        /** 备注 */
        private String remark;
        /** 来源系统ID(用于审核推送时识别目标TMS系统) */
        private Integer sourceSystemId;
    }
    /**
service/src/main/java/com/ruoyi/cwgl/service/impl/TmsAuditLogPushServiceImpl.java
@@ -41,7 +41,7 @@
            
            log.info("推送应付账单审核日志到TMS: {}", jsonBody);
            
            String response = HttpUtils.sendPost(url, jsonBody);
            String response = sendJsonPost(url, jsonBody);
            log.info("TMS应付账单审核日志推送响应: {}", response);
            
            return true;
@@ -59,7 +59,7 @@
            
            log.info("推送应收账单审核日志到TMS: {}", jsonBody);
            
            String response = HttpUtils.sendPost(url, jsonBody);
            String response = sendJsonPost(url, jsonBody);
            log.info("TMS应收账单审核日志推送响应: {}", response);
            
            return true;
@@ -70,6 +70,74 @@
    }
    /**
     * 发送JSON格式的POST请求
     * @param url 请求URL
     * @param jsonBody JSON请求体
     * @return 响应内容
     */
    private String sendJsonPost(String url, String jsonBody) {
        java.net.HttpURLConnection connection = null;
        try {
            java.net.URL realUrl = new java.net.URL(url);
            connection = (java.net.HttpURLConnection) realUrl.openConnection();
            // 设置请求属性
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
            connection.setRequestProperty("Accept", "application/json");
            connection.setRequestProperty("User-Agent", "Mozilla/5.0");
            // 设置连接参数
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setUseCaches(false);
            // 设置超时时间
            connection.setConnectTimeout(10000); // 10秒连接超时
            connection.setReadTimeout(30000);   // 30秒读取超时
            // 发送请求体
            try (java.io.OutputStream os = connection.getOutputStream()) {
                os.write(jsonBody.getBytes(java.nio.charset.StandardCharsets.UTF_8));
                os.flush();
            }
            // 获取响应
            int responseCode = connection.getResponseCode();
            if (responseCode == java.net.HttpURLConnection.HTTP_OK) {
                try (java.io.BufferedReader in = new java.io.BufferedReader(
                        new java.io.InputStreamReader(connection.getInputStream(), java.nio.charset.StandardCharsets.UTF_8))) {
                    StringBuilder response = new StringBuilder();
                    String line;
                    while ((line = in.readLine()) != null) {
                        response.append(line);
                    }
                    return response.toString();
                }
            } else {
                // 处理错误响应
                try (java.io.BufferedReader in = new java.io.BufferedReader(
                        new java.io.InputStreamReader(connection.getErrorStream(), java.nio.charset.StandardCharsets.UTF_8))) {
                    StringBuilder errorResponse = new StringBuilder();
                    String line;
                    while ((line = in.readLine()) != null) {
                        errorResponse.append(line);
                    }
                    throw new RuntimeException("HTTP请求失败,状态码: " + responseCode + ", 响应: " + errorResponse.toString());
                }
            }
        } catch (Exception e) {
            log.error("发送JSON POST请求失败,URL: {}", url, e);
            throw new RuntimeException("发送JSON POST请求失败: " + e.getMessage(), e);
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }
    }
    /**
     * 判断应付账单是否来自TMS系统
     * @param billNo 账单编号
     * @return 是否来自TMS系统
service/src/main/resources/mapper/cwgl/PayableBillManagementMapper.xml
@@ -29,6 +29,7 @@
        <result property="billDueDate"    column="bill_due_date"    />
        <result property="status"    column="status"    />
        <result property="auditStatus"    column="audit_status"    />
        <result property="sourceSystemId"    column="source_system_id"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
@@ -38,7 +39,7 @@
    </resultMap>
    <sql id="selectPayableBillManagementVo">
        select thisTab.id, thisTab.system_no, thisTab.bill_name, thisTab.supplier_name, thisTab.is_internal_settlement, thisTab.internal_settlement_unit, thisTab.document_count, thisTab.total_amount, thisTab.currency, thisTab.discount_amount, thisTab.paid_amount, thisTab.pending_amount, thisTab.exchange_rate, thisTab.cny_amount, thisTab.period_type, thisTab.business_start_date, thisTab.business_end_date, thisTab.billing_start_date, thisTab.billing_end_date, thisTab.bill_generate_date, thisTab.bill_send_date, thisTab.bill_due_date, thisTab.status, thisTab.audit_status, thisTab.remark, thisTab.create_by, thisTab.create_time, thisTab.update_by, thisTab.update_time, thisTab.deleted from payable_bill_management AS thisTab
        select thisTab.id, thisTab.system_no, thisTab.bill_name, thisTab.supplier_name, thisTab.is_internal_settlement, thisTab.internal_settlement_unit, thisTab.document_count, thisTab.total_amount, thisTab.currency, thisTab.discount_amount, thisTab.paid_amount, thisTab.pending_amount, thisTab.exchange_rate, thisTab.cny_amount, thisTab.period_type, thisTab.business_start_date, thisTab.business_end_date, thisTab.billing_start_date, thisTab.billing_end_date, thisTab.bill_generate_date, thisTab.bill_send_date, thisTab.bill_due_date, thisTab.status, thisTab.audit_status, thisTab.source_system_id, thisTab.remark, thisTab.create_by, thisTab.create_time, thisTab.update_by, thisTab.update_time, thisTab.deleted from payable_bill_management AS thisTab
    </sql>
    <sql id="selectPayableBillManagementVoCount">
        select count(0) from payable_bill_management as thisTab
@@ -132,6 +133,7 @@
            <if test="billDueDate != null">bill_due_date,</if>
            <if test="status != null">status,</if>
            <if test="auditStatus != null">audit_status,</if>
            <if test="sourceSystemId != null">source_system_id,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
@@ -163,6 +165,7 @@
            <if test="billDueDate != null">#{billDueDate},</if>
            <if test="status != null">#{status},</if>
            <if test="auditStatus != null">#{auditStatus},</if>
            <if test="sourceSystemId != null">#{sourceSystemId},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
@@ -175,11 +178,11 @@
    <insert id="insertPayableBillManagementBatch" parameterType="java.util.List"  useGeneratedKeys="true" keyProperty="id">
        insert into payable_bill_management
        <trim prefix="(" suffix=") values" suffixOverrides=",">
            id,system_no,bill_name,supplier_name,is_internal_settlement,internal_settlement_unit,document_count,total_amount,currency,discount_amount,paid_amount,pending_amount,exchange_rate,cny_amount,period_type,business_start_date,business_end_date,billing_start_date,billing_end_date,bill_generate_date,bill_send_date,bill_due_date,status,audit_status,remark,create_by,create_time,update_by,update_time,deleted,
            id,system_no,bill_name,supplier_name,is_internal_settlement,internal_settlement_unit,document_count,total_amount,currency,discount_amount,paid_amount,pending_amount,exchange_rate,cny_amount,period_type,business_start_date,business_end_date,billing_start_date,billing_end_date,bill_generate_date,bill_send_date,bill_due_date,status,audit_status,source_system_id,remark,create_by,create_time,update_by,update_time,deleted,
        </trim>
        <foreach item="item" index="index" collection="list" separator=",">
            <trim prefix="(" suffix=") " suffixOverrides=",">
                #{item.id},#{item.systemNo},#{item.billName},#{item.supplierName},#{item.isInternalSettlement},#{item.internalSettlementUnit},#{item.documentCount},#{item.totalAmount},#{item.currency},#{item.discountAmount},#{item.paidAmount},#{item.pendingAmount},#{item.exchangeRate},#{item.cnyAmount},#{item.periodType},#{item.businessStartDate},#{item.businessEndDate},#{item.billingStartDate},#{item.billingEndDate},#{item.billGenerateDate},#{item.billSendDate},#{item.billDueDate},#{item.status},#{item.auditStatus},#{item.remark},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.deleted},
            <trim prefix="(" suffix=")" suffixOverrides=",">
                #{item.id},#{item.systemNo},#{item.billName},#{item.supplierName},#{item.isInternalSettlement},#{item.internalSettlementUnit},#{item.documentCount},#{item.totalAmount},#{item.currency},#{item.discountAmount},#{item.paidAmount},#{item.pendingAmount},#{item.exchangeRate},#{item.cnyAmount},#{item.periodType},#{item.businessStartDate},#{item.businessEndDate},#{item.billingStartDate},#{item.billingEndDate},#{item.billGenerateDate},#{item.billSendDate},#{item.billDueDate},#{item.status},#{item.auditStatus},#{item.sourceSystemId},#{item.remark},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.deleted},
            </trim>
        </foreach>
    </insert>
@@ -211,6 +214,7 @@
            <if test="billDueDate != null">bill_due_date = #{billDueDate},</if>
            <if test="status != null">status = #{status},</if>
            <if test="auditStatus != null">audit_status = #{auditStatus},</if>
            <if test="sourceSystemId != null">source_system_id = #{sourceSystemId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
@@ -247,6 +251,8 @@
                <if test="item.billSendDate != null">bill_send_date = #{item.billSendDate},</if>
                <if test="item.billDueDate != null">bill_due_date = #{item.billDueDate},</if>
                <if test="item.status != null">status = #{item.status},</if>
                <if test="item.auditStatus != null">audit_status = #{item.auditStatus},</if>
                <if test="item.sourceSystemId != null">source_system_id = #{item.sourceSystemId},</if>
                <if test="item.remark != null">remark = #{item.remark},</if>
                <if test="item.createBy != null">create_by = #{item.createBy},</if>
                <if test="item.createTime != null">create_time = #{item.createTime},</if>
service/src/main/resources/mapper/cwgl/ReceivableBillManagementMapper.xml
@@ -41,6 +41,7 @@
        <result property="overdueInterest"    column="overdue_interest"    />
        <result property="status"    column="status"    />
        <result property="auditStatus"    column="audit_status"    />
        <result property="sourceSystemId"    column="source_system_id"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
@@ -83,7 +84,7 @@
    </resultMap>
    <sql id="selectReceivableBillManagementVo">
        select thisTab.id, thisTab.system_no, thisTab.bill_name, thisTab.customer_name, thisTab.payee, thisTab.responsible_person, thisTab.responsible_leader, thisTab.settlement_method, thisTab.business_type, thisTab.promotion_requirement, thisTab.is_internal_settlement, thisTab.internal_settlement_unit, thisTab.document_count, thisTab.total_amount, thisTab.currency, thisTab.discount_amount, thisTab.received_amount, thisTab.pending_amount, thisTab.exchange_rate, thisTab.cny_amount, thisTab.period_type, thisTab.business_start_date, thisTab.business_end_date, thisTab.billing_start_date, thisTab.billing_end_date, thisTab.bill_generate_date, thisTab.bill_send_date, thisTab.bill_due_date, thisTab.due_in_30_days, thisTab.overdue_amount, thisTab.overdue_1_to_30_days, thisTab.overdue_31_to_60_days, thisTab.overdue_61_to_90_days, thisTab.overdue_91_to_180_days, thisTab.overdue_181_to_365_days, thisTab.overdue_over_1_year, thisTab.overdue_days, thisTab.settlement_category, thisTab.settlement_period, thisTab.nc_settlement_date, thisTab.nc_settlement_amount, thisTab.account_remark, thisTab.overdue_interest, thisTab.status, thisTab.audit_status, thisTab.remark, thisTab.create_by, thisTab.create_time, thisTab.update_by, thisTab.update_time, thisTab.deleted from receivable_bill_management AS thisTab
        select thisTab.id, thisTab.system_no, thisTab.bill_name, thisTab.customer_name, thisTab.payee, thisTab.responsible_person, thisTab.responsible_leader, thisTab.settlement_method, thisTab.business_type, thisTab.promotion_requirement, thisTab.is_internal_settlement, thisTab.internal_settlement_unit, thisTab.document_count, thisTab.total_amount, thisTab.currency, thisTab.discount_amount, thisTab.received_amount, thisTab.pending_amount, thisTab.exchange_rate, thisTab.cny_amount, thisTab.period_type, thisTab.business_start_date, thisTab.business_end_date, thisTab.billing_start_date, thisTab.billing_end_date, thisTab.bill_generate_date, thisTab.bill_send_date, thisTab.bill_due_date, thisTab.due_in_30_days, thisTab.overdue_amount, thisTab.overdue_1_to_30_days, thisTab.overdue_31_to_60_days, thisTab.overdue_61_to_90_days, thisTab.overdue_91_to_180_days, thisTab.overdue_181_to_365_days, thisTab.overdue_over_1_year, thisTab.overdue_days, thisTab.settlement_category, thisTab.settlement_period, thisTab.nc_settlement_date, thisTab.nc_settlement_amount, thisTab.account_remark, thisTab.overdue_interest, thisTab.status, thisTab.audit_status, thisTab.source_system_id, thisTab.remark, thisTab.create_by, thisTab.create_time, thisTab.update_by, thisTab.update_time, thisTab.deleted from receivable_bill_management AS thisTab
    </sql>
    <sql id="selectReceivableBillManagementVoCount">
        select count(0) from receivable_bill_management as thisTab
@@ -201,6 +202,7 @@
            <if test="overdueInterest != null">overdue_interest,</if>
            <if test="status != null">status,</if>
            <if test="auditStatus != null">audit_status,</if>
            <if test="sourceSystemId != null">source_system_id,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
@@ -244,6 +246,7 @@
            <if test="overdueInterest != null">#{overdueInterest},</if>
            <if test="status != null">#{status},</if>
            <if test="auditStatus != null">#{auditStatus},</if>
            <if test="sourceSystemId != null">#{sourceSystemId},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
@@ -256,11 +259,11 @@
    <insert id="insertReceivableBillManagementBatch" parameterType="java.util.List"  useGeneratedKeys="true" keyProperty="id">
        insert into receivable_bill_management
        <trim prefix="(" suffix=") values" suffixOverrides=",">
            system_no,bill_name,customer_name,payee,responsible_person,responsible_leader,settlement_method,business_type,promotion_requirement,is_internal_settlement,internal_settlement_unit,document_count,total_amount,currency,discount_amount,received_amount,pending_amount,exchange_rate,cny_amount,period_type,business_start_date,business_end_date,billing_start_date,billing_end_date,bill_generate_date,bill_send_date,bill_due_date,settlement_category,settlement_period,nc_settlement_date,nc_settlement_amount,account_remark,overdue_interest,status,audit_status,remark,create_by,create_time,update_by,update_time,deleted,
            system_no,bill_name,customer_name,payee,responsible_person,responsible_leader,settlement_method,business_type,promotion_requirement,is_internal_settlement,internal_settlement_unit,document_count,total_amount,currency,discount_amount,received_amount,pending_amount,exchange_rate,cny_amount,period_type,business_start_date,business_end_date,billing_start_date,billing_end_date,bill_generate_date,bill_send_date,bill_due_date,settlement_category,settlement_period,nc_settlement_date,nc_settlement_amount,account_remark,overdue_interest,status,audit_status,source_system_id,remark,create_by,create_time,update_by,update_time,deleted,
        </trim>
        <foreach item="item" index="index" collection="list" separator=",">
            <trim prefix="(" suffix=") " suffixOverrides=",">
                #{item.systemNo},#{item.billName},#{item.customerName},#{item.payee},#{item.responsiblePerson},#{item.responsibleLeader},#{item.settlementMethod},#{item.businessType},#{item.promotionRequirement},#{item.isInternalSettlement},#{item.internalSettlementUnit},#{item.documentCount},#{item.totalAmount},#{item.currency},#{item.discountAmount},#{item.receivedAmount},#{item.pendingAmount},#{item.exchangeRate},#{item.cnyAmount},#{item.periodType},#{item.businessStartDate},#{item.businessEndDate},#{item.billingStartDate},#{item.billingEndDate},#{item.billGenerateDate},#{item.billSendDate},#{item.billDueDate},#{item.settlementCategory},#{item.settlementPeriod},#{item.ncSettlementDate},#{item.ncSettlementAmount},#{item.accountRemark},#{item.overdueInterest},#{item.status},#{item.auditStatus},#{item.remark},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.deleted},
                #{item.systemNo},#{item.billName},#{item.customerName},#{item.payee},#{item.responsiblePerson},#{item.responsibleLeader},#{item.settlementMethod},#{item.businessType},#{item.promotionRequirement},#{item.isInternalSettlement},#{item.internalSettlementUnit},#{item.documentCount},#{item.totalAmount},#{item.currency},#{item.discountAmount},#{item.receivedAmount},#{item.pendingAmount},#{item.exchangeRate},#{item.cnyAmount},#{item.periodType},#{item.businessStartDate},#{item.businessEndDate},#{item.billingStartDate},#{item.billingEndDate},#{item.billGenerateDate},#{item.billSendDate},#{item.billDueDate},#{item.settlementCategory},#{item.settlementPeriod},#{item.ncSettlementDate},#{item.ncSettlementAmount},#{item.accountRemark},#{item.overdueInterest},#{item.status},#{item.auditStatus},#{item.sourceSystemId},#{item.remark},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.deleted},
            </trim>
        </foreach>
    </insert>
@@ -304,6 +307,7 @@
            <if test="overdueInterest != null">overdue_interest = #{overdueInterest},</if>
            <if test="status != null">status = #{status},</if>
            <if test="auditStatus != null">audit_status = #{auditStatus},</if>
            <if test="sourceSystemId != null">source_system_id = #{sourceSystemId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
@@ -353,6 +357,7 @@
                <if test="item.overdueInterest != null">overdue_interest = #{item.overdueInterest},</if>
                <if test="item.status != null">status = #{item.status},</if>
                <if test="item.auditStatus != null">audit_status = #{item.auditStatus},</if>
                <if test="item.sourceSystemId != null">source_system_id = #{item.sourceSystemId},</if>
                <if test="item.remark != null">remark = #{item.remark},</if>
                <if test="item.createBy != null">create_by = #{item.createBy},</if>
                <if test="item.createTime != null">create_time = #{item.createTime},</if>
ui/admin-ui3/src/api/cwgl/payableBillManagement.ts
@@ -87,4 +87,14 @@
        method: 'post',
        data
    })
}
/**
 * 审核应付账单管理
 */
export const receivableBillManagementAudit:requestType = (data) => {
    return request({
        url: '/cwgl/receivableBillManagement/audit',
        method: 'put',
        data
    })
}
ui/admin-ui3/src/api/cwgl/receivableBillManagement.ts
@@ -87,4 +87,15 @@
        url: '/cwgl/receivableBillManagement/invoice/amount/' + id,
        method:'get'
    })
}
/**
 * 审核应收账单管理
 */
export const receivableBillManagementAudit:requestType = (data) => {
    return request({
        url: '/cwgl/receivableBillManagement/audit',
        method: 'put',
        data
    })
}
ui/admin-ui3/src/views/cwgl/payableBillManagement/index.vue
@@ -31,6 +31,11 @@
          :underline="false" plain :size="size" @click="handleViewHistory(row)"
          v-hasPermi="['cwgl:payableBillManagement:list']"> 结算明细
        </el-link>
             <el-link class="link-btn" v-if="row.auditStatus == 0 || row.auditStatus == 2" type="primary" :underline="false" plain :size="size"
          @click="handleAuditClick(row)"
          v-hasPermi="['cwgl:receivableBillManagement:audit']">
          审核
        </el-link>
        <el-link class="link-btn" type="primary" :underline="false" plain :size="size" @click="handleViewFeeDetail(row)"
          v-hasPermi="['cwgl:payableBillManagement:view']"> 详情
        </el-link>
@@ -52,15 +57,42 @@
  <!-- 开票 -->
  <makeOutInvoice ref="makeOutInvoiceRef" :type="makeType"  :InvoiceDetails="InvoiceDetails" @success="makeOutInvoiceFresh" />
     <el-dialog title="账单审核" v-model="auditDialogVisible" width="500px" append-to-body>
    <el-form :model="auditForm" :rules="auditRules" ref="auditFormRef" label-width="100px">
      <!-- <el-form-item label="账单ID" prop="billId">
        <el-input v-model="auditForm.billId" disabled />
      </el-form-item> -->
      <!-- <el-form-item label="账单类型" prop="billType">
        <el-select v-model="auditForm.billType" placeholder="请选择" style="width: 100%" disabled>
          <el-option label="应收" :value="0" />
          <el-option label="应付" :value="1" />
        </el-select>
      </el-form-item> -->
      <el-form-item label="审核结果" prop="auditResult">
        <el-radio-group v-model="auditForm.auditResult" @change="handleAuditResultChange" >
          <el-radio :label="1">通过</el-radio>
          <el-radio :label="2">驳回</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="审核意见" prop="auditComment">
        <el-input v-model="auditForm.auditComment" type="textarea" :rows="3" placeholder="请输入审核意见" />
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="auditDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitAudit">确 定1</el-button>
      </span>
    </template>
  </el-dialog>
</template>
<script setup name="payableBillManagement" lang="ts">
import { payableBillManagementInvoice,invoiceAmount,PayableBillManagementI,payableBillManagementVoid, addPayableBillManagement, delPayableBillManagement, exportPayableBillManagement, getPayableBillManagement, listPayableBillManagement, updatePayableBillManagement } from "@/api/cwgl/payableBillManagement";
import { payableBillManagementInvoice,invoiceAmount,PayableBillManagementI,payableBillManagementVoid, addPayableBillManagement, delPayableBillManagement, exportPayableBillManagement, getPayableBillManagement, listPayableBillManagement, updatePayableBillManagement,receivableBillManagementAudit } from "@/api/cwgl/payableBillManagement";
import useCurrentInstance from "@/utils/useCurrentInstance";
import { listPayableInvoiceBusiness,} from "@/api/cwgl/payableInvoiceBusiness";
import { computed, reactive, ref, toRefs } from "vue";
import { computed, reactive, ref, toRefs,nextTick } from "vue";
import { PagesInterface, PageQueryInterface } from "@/utils/globalInterface";
import { usePagePlus } from "@/hooks/usePagePlus";
import { hasPermission } from "@/utils/permissionUtils";
@@ -471,4 +503,92 @@
    }
  })
}
  const auditDialogVisible = ref(false);
  const auditFormRef = ref();
  // 审核表单数据
  const auditForm = reactive({
    billId: null as number | null,
    billType: null as number | null, // 0:应收, 1:应付
    auditResult: null as number | null, // 1:通过, 2:驳回
    auditComment: ''
  });
  const getAuditRules = () => {
    return {
      billId: [{ required: true, message: '账单ID不能为空', trigger: 'blur' }],
      billType: [{ required: true, message: '账单类型不能为空', trigger: 'change' }],
      auditResult: [{ required: true, message: '审核结果不能为空', trigger: 'change' }],
      // 动态规则:如果 auditResult 为 2 (驳回),则必填
      auditComment: [
        {
          required: auditForm.auditResult === 2,
          message: '驳回时必须填写审核意见',
          trigger: 'blur'
        }
      ]
    };
  };
  const validateAuditComment = (rule: any, value: any, callback: any) => {
    if (auditForm.auditResult === 2 && !value) {
      callback(new Error('驳回时必须填写审核意见'));
    } else {
      callback();
    }
  };
  // 表单校验规则
  const auditRules = {
    billId: [{ required: true, message: '账单ID不能为空', trigger: 'blur' }],
    billType: [{ required: true, message: '账单类型不能为空', trigger: 'change' }],
    auditResult: [{ required: true, message: '审核结果不能为空', trigger: 'change' }],
     auditComment: [{ validator: validateAuditComment, trigger: 'blur' }]
  };
  const handleAuditResultChange = (val: number) => {
    // 当切换审核结果时,立即触发表单校验,以更新审核意见字段的错误提示状态
    if (auditFormRef.value) {
      auditFormRef.value.validateField('auditComment');
    }
    // 可选:如果选择通过,可以清空之前填写的驳回意见,或者保留看业务需求
    // if (val === 1) {
    //   auditForm.auditComment = '';
    // }
  };
  /**
   * 点击审核按钮
   */
  const handleAuditClick = (row: any) => {
    // 重置表单
    auditForm.billId = row.id;
    auditForm.billType = 1;
    auditForm.auditResult = null;
    auditForm.auditComment = '';
    // 重置校验状态
    nextTick(() => {
      if (auditFormRef.value) {
        auditFormRef.value.clearValidate();
      }
    });
    auditDialogVisible.value = true;
  };
  /**
   * 提交审核
   */
  const submitAudit = () => {
    auditFormRef.value.validate((valid: boolean) => {
      if (valid) {
        receivableBillManagementAudit(auditForm).then(res => {
          if (res.code === 200) {
            proxy.$modal.msgSuccess(res.msg);
            auditDialogVisible.value = false;
            onLoad(page.value); // 刷新列表
          }
        });
      }
    });
  };
</script>
ui/admin-ui3/src/views/cwgl/receivableBillManagement/index.vue
@@ -35,6 +35,12 @@
        <el-link class="link-btn" type="primary" :underline="false" plain :size="size" @click="handleViewFeeDetail(row)"
          v-hasPermi="['cwgl:receivableBillManagement:view']"> 详情
        </el-link>
        <el-link class="link-btn" v-if="row.auditStatus == 0 || row.auditStatus == 2" type="primary" :underline="false" plain :size="size"
          @click="handleAuditClick(row)"
          v-hasPermi="['cwgl:receivableBillManagement:audit']">
          审核
        </el-link>
        
        <el-link class="link-btn" v-if="row.status == 0" type="primary"
        :underline="false"
@@ -56,14 +62,44 @@
  <NestedDetailDialog ref="feeDetailRef" :type="activeType" />
  <OperationLogModal ref="logModalRef" />
  <BillEditDialog ref="billDialogRef" @submit="handleBillSubmit" />
   <el-dialog title="账单审核" v-model="auditDialogVisible" width="500px" append-to-body>
    <el-form :model="auditForm" :rules="auditRules" ref="auditFormRef" label-width="100px">
      <!-- <el-form-item label="账单ID" prop="billId">
        <el-input v-model="auditForm.billId" disabled />
      </el-form-item> -->
      <!-- <el-form-item label="账单类型" prop="billType">
        <el-select v-model="auditForm.billType" placeholder="请选择" style="width: 100%" disabled>
          <el-option label="应收" :value="0" />
          <el-option label="应付" :value="1" />
        </el-select>
      </el-form-item> -->
      <el-form-item label="审核结果" prop="auditResult">
        <el-radio-group v-model="auditForm.auditResult" @change="handleAuditResultChange" >
          <el-radio :label="1">通过</el-radio>
          <el-radio :label="2">驳回</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="审核意见" prop="auditComment">
        <el-input v-model="auditForm.auditComment" type="textarea" :rows="3" placeholder="请输入审核意见" />
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="auditDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitAudit">确 定</el-button>
      </span>
    </template>
  </el-dialog>
</template>
<script setup name="receivableBillManagement" lang="ts">
  import { listReceivableInvoiceBusiness} from "@/api/cwgl/receivableInvoiceBusiness";
import { receivableBillManagementInvoice,invoiceAmount,ReceivableBillManagementI, addReceivableBillManagement, delReceivableBillManagement, exportReceivableBillManagement, getReceivableBillManagement, listReceivableBillManagement, updateReceivableBillManagement,receivableBillManagementVoid } from "@/api/cwgl/receivableBillManagement";
import { receivableBillManagementInvoice,invoiceAmount,ReceivableBillManagementI, addReceivableBillManagement, delReceivableBillManagement, exportReceivableBillManagement, getReceivableBillManagement, listReceivableBillManagement, updateReceivableBillManagement,receivableBillManagementVoid,receivableBillManagementAudit } from "@/api/cwgl/receivableBillManagement";
import useCurrentInstance from "@/utils/useCurrentInstance";
import { computed, reactive, ref, toRefs } from "vue";
import { computed, reactive, ref, toRefs,nextTick } from "vue";
import { PagesInterface, PageQueryInterface } from "@/utils/globalInterface";
import { usePagePlus } from "@/hooks/usePagePlus";
import { hasPermission } from "@/utils/permissionUtils";
@@ -306,8 +342,21 @@
      minWidth: 200,
    },
    auditStatus: {
      label: '审核状态',
      minWidth: 120,
      fixed: 'right',
      type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/sys_accounts_statement',
      search: true,
      rules: [
        {
          required: true,
          message: "状态不能为空", trigger: "blur"
        }
      ],
    },
    status: {
      label: '状态',
      label: '结算状态',
      minWidth: 120,
      fixed: 'right',
      type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/sys_bill_status',
@@ -480,4 +529,94 @@
  });
};
 // --- 新增:审核相关逻辑 ---
  const auditDialogVisible = ref(false);
  const auditFormRef = ref();
  // 审核表单数据
  const auditForm = reactive({
    billId: null as number | null,
    billType: null as number | null, // 0:应收, 1:应付
    auditResult: null as number | null, // 1:通过, 2:驳回
    auditComment: ''
  });
  const getAuditRules = () => {
    return {
      billId: [{ required: true, message: '账单ID不能为空', trigger: 'blur' }],
      billType: [{ required: true, message: '账单类型不能为空', trigger: 'change' }],
      auditResult: [{ required: true, message: '审核结果不能为空', trigger: 'change' }],
      // 动态规则:如果 auditResult 为 2 (驳回),则必填
      auditComment: [
        {
          required: auditForm.auditResult === 2,
          message: '驳回时必须填写审核意见',
          trigger: 'blur'
        }
      ]
    };
  };
  const validateAuditComment = (rule: any, value: any, callback: any) => {
    if (auditForm.auditResult === 2 && !value) {
      callback(new Error('驳回时必须填写审核意见'));
    } else {
      callback();
    }
  };
  // 表单校验规则
  const auditRules = {
    billId: [{ required: true, message: '账单ID不能为空', trigger: 'blur' }],
    billType: [{ required: true, message: '账单类型不能为空', trigger: 'change' }],
    auditResult: [{ required: true, message: '审核结果不能为空', trigger: 'change' }],
     auditComment: [{ validator: validateAuditComment, trigger: 'blur' }]
  };
  const handleAuditResultChange = (val: number) => {
    // 当切换审核结果时,立即触发表单校验,以更新审核意见字段的错误提示状态
    if (auditFormRef.value) {
      auditFormRef.value.validateField('auditComment');
    }
    // 可选:如果选择通过,可以清空之前填写的驳回意见,或者保留看业务需求
    // if (val === 1) {
    //   auditForm.auditComment = '';
    // }
  };
  /**
   * 点击审核按钮
   */
  const handleAuditClick = (row: any) => {
    // 重置表单
    auditForm.billId = row.id;
    auditForm.billType = 0;
    auditForm.auditResult = null;
    auditForm.auditComment = '';
    // 重置校验状态
    nextTick(() => {
      if (auditFormRef.value) {
        auditFormRef.value.clearValidate();
      }
    });
    auditDialogVisible.value = true;
  };
  /**
   * 提交审核
   */
  const submitAudit = () => {
    auditFormRef.value.validate((valid: boolean) => {
      if (valid) {
        receivableBillManagementAudit(auditForm).then(res => {
          if (res.code === 200) {
            proxy.$modal.msgSuccess(res.msg);
            auditDialogVisible.value = false;
            onLoad(page.value); // 刷新列表
          }
        });
      }
    });
  };
</script>