diff --git a/src/views/flow/components/payMx.vue b/src/views/flow/components/payMx.vue index a7d6a01..fbb70bb 100644 --- a/src/views/flow/components/payMx.vue +++ b/src/views/flow/components/payMx.vue @@ -130,9 +130,9 @@
-
+ { const gid = row.sourceFlowId if (!acc[gid]) acc[gid] = [] @@ -485,20 +485,38 @@ import {getToken} from "@/utils/auth"; const rows = groupMap[gid] let count = 0 let totalCount = 0 - let allToRemain = true + // 判断"所有明细数量都完全补齐":需要检查该分组下的所有明细 + console.log(`当前分组gid: ${gid}`) + console.log(`this.list中所有sourceFlowId:`, this.list.map(r => r.sourceFlowId)) + const allItemsInGroup = this.list.filter(r => r.sourceFlowId == gid) + console.log(`匹配到的明细数量: ${allItemsInGroup.length}`) + let allCompleted = true + + // 先检查勾选行的数量校验 rows.forEach(item => { const payNum = Number(item.payNum) const num = Number(item.num) const hasPay = Number(item.hasPayNum) - const remain = num - hasPay if (isNaN(payNum) || payNum === 0 || payNum > num) count++ if (payNum + hasPay > num) totalCount++ - // 判断是否每一条都“正好补齐剩余” - if (!(payNum > 0 && Math.abs(payNum - remain) < 1e-6)) { - allToRemain = false - } - }) - if (count > 0) { + }) + + // 检查该分组下所有明细是否都已完成(勾选的+未勾选的) + allItemsInGroup.forEach(item => { + const hasPay = Number(item.hasPayNum) + const num = Number(item.num) + // 如果这条明细在勾选列表中,需要加上本次报销数量 + const selectedItem = rows.find(r => r.id === item.id) + const totalPay = hasPay + (selectedItem ? Number(selectedItem.payNum) : 0) + console.log(`分组${gid}明细${item.id}: hasPay=${hasPay}, payNum=${selectedItem ? selectedItem.payNum : 0}, totalPay=${totalPay}, num=${num}, 是否完成=${totalPay >= num}`) + if (totalPay < num) { + allCompleted = false + } + }) + + console.log(`分组${gid} allCompleted:`, allCompleted, `总明细数:${allItemsInGroup.length}`) + + if (count > 0) { this.$message({ message: `【${idToTitle[gid] || gid}】报销数量不能为0或报销数量大于总数量`, duration: 2000, @@ -515,7 +533,7 @@ import {getToken} from "@/utils/auth"; return } // 记录需要自动置为“最后一笔”的分组,统一在提交前弹一次提示 - if (allToRemain && this.fundlogFormMap[gid] && !this.fundlogFormMap[gid].isLast) { + if (allCompleted && this.fundlogFormMap[gid] && !this.fundlogFormMap[gid].isLast) { groupsToAutoEnd.push(gid) } } @@ -577,11 +595,7 @@ import {getToken} from "@/utils/auth"; // 从明细中聚合主数据:合同ID串与金额合计 const contractIdStr = Array.from(new Set(wuzicaigou_items.map(i => i.contract_id).filter(Boolean))).join(',') - // 金额按每个区块的申请金额求和(同一支付内不重复累加明细) - const amtTotal = (this.payList || []).reduce((sum, p) => { - const form = this.fundlogFormMap[p.id] || {} - return sum + (Number(form.applyMoney) || 0) - }, 0) + const amtTotal = wuzicaigou_items.reduce((sum, i) => sum + (Number(i.group_apply_money || i.apply_money) || 0), 0) // 从合同列表聚合展示数据 const sumMoney = (contracts || []).reduce((sum, c) => sum + (Number(c?.money) || 0), 0) diff --git a/src/views/flow/create.vue b/src/views/flow/create.vue index 6482747..50fbf2e 100644 --- a/src/views/flow/create.vue +++ b/src/views/flow/create.vue @@ -15,7 +15,7 @@ @@ -330,10 +307,6 @@ export default { }, data() { return { - timeId:'', - isShowTime:false, - selectedDateTime:'', - selectedDateType:'', isShowModal:false, contractUrl:'', printKey: 0, @@ -855,7 +828,7 @@ export default { } }) } - + } console.log("copyForm",copyForm,this.fields) console.log("this.writeableFields",this.writeableFields) @@ -916,43 +889,24 @@ export default { async cellDblclickEvent({ row, column }) { // if(this.$store.state.user.username !== 'admin') return - if(!this.$store.state.user.roles.includes("全局流程监管")) return if(column.field === 'created_at' || column.field === 'updated_at') { - this.timeId = row.id - this.selectedDateType = column.field - this.selectedDateTime = row[column.field] - this.isShowTime = true - // this.$prompt('请输入时间', '提示', { - // confirmButtonText: '确定', - // cancelButtonText: '取消', - // inputPattern: /^(?:19|20)[0-9][0-9]-(?:(?:0[1-9])|(?:1[0-2]))-(?:(?:[0-2][1-9])|(?:[1-3][0-1])) (?:(?:[0-2][0-3])|(?:[0-1][0-9])):[0-5][0-9]:[0-5][0-9]$/, - // inputErrorMessage: '时间格式不正确' - // }).then(({ value }) => { - // updateNodeTime({ - // id: row.id, - // date: value, - // date_type: column.field - // }).then(_ => { - // this.$message.success('更新成功') - // this.getConfig() - // }) - // }) + this.$prompt('请输入时间', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + inputPattern: /^(?:19|20)[0-9][0-9]-(?:(?:0[1-9])|(?:1[0-2]))-(?:(?:[0-2][1-9])|(?:[1-3][0-1])) (?:(?:[0-2][0-3])|(?:[0-1][0-9])):[0-5][0-9]:[0-5][0-9]$/, + inputErrorMessage: '时间格式不正确' + }).then(({ value }) => { + updateNodeTime({ + id: row.id, + date: value, + date_type: column.field + }).then(_ => { + this.$message.success('更新成功') + this.getConfig() + }) + }) } }, - updateTime(){ - updateNodeTime({ - id: this.timeId, - date: this.selectedDateTime, - date_type:this.selectedDateType, - }).then((_) => { - this.$message.success("更新成功"); - this.timeId = '' - this.selectedDateTime = '' - this.selectedDateType = '' - this.isShowTime = false - this.getConfig() - }); - }, }, computed: { device() {