|
|
|
@ -130,9 +130,9 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="xy-table-item-content" style="margin-left:10px">
|
|
|
|
<div class="xy-table-item-content" style="margin-left:10px">
|
|
|
|
<el-switch v-model="fundlogFormMap[pay.id].isLast" />
|
|
|
|
<el-switch v-model="fundlogFormMap[pay.id].isLast" />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<vxe-table :ref="'table_' + pay.id" stripe style="margin-top: 6px" keep-source :column-config="{ resizable: true }"
|
|
|
|
<vxe-table :ref="'table_' + pay.id" stripe style="margin-top: 6px" keep-source :column-config="{ resizable: true }"
|
|
|
|
:print-config="{}" :export-config="{}" :expand-config="{
|
|
|
|
:print-config="{}" :export-config="{}" :expand-config="{
|
|
|
|
accordion: true,
|
|
|
|
accordion: true,
|
|
|
|
@ -457,23 +457,23 @@ import {getToken} from "@/utils/auth";
|
|
|
|
for (const gid of groupIds) {
|
|
|
|
for (const gid of groupIds) {
|
|
|
|
const form = this.fundlogFormMap[gid] || {}
|
|
|
|
const form = this.fundlogFormMap[gid] || {}
|
|
|
|
if (!form.applyMoney || Number(form.applyMoney) <= 0) {
|
|
|
|
if (!form.applyMoney || Number(form.applyMoney) <= 0) {
|
|
|
|
this.$message({
|
|
|
|
this.$message({
|
|
|
|
message: `【${idToTitle[gid] || gid}】请填写本次申请付款金额`,
|
|
|
|
message: `【${idToTitle[gid] || gid}】请填写本次申请付款金额`,
|
|
|
|
duration: 2000,
|
|
|
|
duration: 2000,
|
|
|
|
type: 'warning'
|
|
|
|
type: 'warning'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!form.type) {
|
|
|
|
if (!form.type) {
|
|
|
|
this.$message({
|
|
|
|
this.$message({
|
|
|
|
message: `【${idToTitle[gid] || gid}】请选择款项类型`,
|
|
|
|
message: `【${idToTitle[gid] || gid}】请选择款项类型`,
|
|
|
|
duration: 2000,
|
|
|
|
duration: 2000,
|
|
|
|
type: 'warning'
|
|
|
|
type: 'warning'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 数量校验:按分组逐块处理,并在“等于总数量”时自动设置该块为最后一笔
|
|
|
|
}
|
|
|
|
|
|
|
|
// 数量校验:按分组逐块处理,并在“所有明细都等于总数量”时自动设置该块为最后一笔
|
|
|
|
const groupMap = records.reduce((acc, row) => {
|
|
|
|
const groupMap = records.reduce((acc, row) => {
|
|
|
|
const gid = row.sourceFlowId
|
|
|
|
const gid = row.sourceFlowId
|
|
|
|
if (!acc[gid]) acc[gid] = []
|
|
|
|
if (!acc[gid]) acc[gid] = []
|
|
|
|
@ -485,20 +485,38 @@ import {getToken} from "@/utils/auth";
|
|
|
|
const rows = groupMap[gid]
|
|
|
|
const rows = groupMap[gid]
|
|
|
|
let count = 0
|
|
|
|
let count = 0
|
|
|
|
let totalCount = 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 => {
|
|
|
|
rows.forEach(item => {
|
|
|
|
const payNum = Number(item.payNum)
|
|
|
|
const payNum = Number(item.payNum)
|
|
|
|
const num = Number(item.num)
|
|
|
|
const num = Number(item.num)
|
|
|
|
const hasPay = Number(item.hasPayNum)
|
|
|
|
const hasPay = Number(item.hasPayNum)
|
|
|
|
const remain = num - hasPay
|
|
|
|
|
|
|
|
if (isNaN(payNum) || payNum === 0 || payNum > num) count++
|
|
|
|
if (isNaN(payNum) || payNum === 0 || payNum > num) count++
|
|
|
|
if (payNum + hasPay > num) totalCount++
|
|
|
|
if (payNum + hasPay > num) totalCount++
|
|
|
|
// 判断是否每一条都“正好补齐剩余”
|
|
|
|
})
|
|
|
|
if (!(payNum > 0 && Math.abs(payNum - remain) < 1e-6)) {
|
|
|
|
|
|
|
|
allToRemain = false
|
|
|
|
// 检查该分组下所有明细是否都已完成(勾选的+未勾选的)
|
|
|
|
}
|
|
|
|
allItemsInGroup.forEach(item => {
|
|
|
|
})
|
|
|
|
const hasPay = Number(item.hasPayNum)
|
|
|
|
if (count > 0) {
|
|
|
|
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({
|
|
|
|
this.$message({
|
|
|
|
message: `【${idToTitle[gid] || gid}】报销数量不能为0或报销数量大于总数量`,
|
|
|
|
message: `【${idToTitle[gid] || gid}】报销数量不能为0或报销数量大于总数量`,
|
|
|
|
duration: 2000,
|
|
|
|
duration: 2000,
|
|
|
|
@ -515,7 +533,7 @@ import {getToken} from "@/utils/auth";
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 记录需要自动置为“最后一笔”的分组,统一在提交前弹一次提示
|
|
|
|
// 记录需要自动置为“最后一笔”的分组,统一在提交前弹一次提示
|
|
|
|
if (allToRemain && this.fundlogFormMap[gid] && !this.fundlogFormMap[gid].isLast) {
|
|
|
|
if (allCompleted && this.fundlogFormMap[gid] && !this.fundlogFormMap[gid].isLast) {
|
|
|
|
groupsToAutoEnd.push(gid)
|
|
|
|
groupsToAutoEnd.push(gid)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -577,11 +595,7 @@ import {getToken} from "@/utils/auth";
|
|
|
|
|
|
|
|
|
|
|
|
// 从明细中聚合主数据:合同ID串与金额合计
|
|
|
|
// 从明细中聚合主数据:合同ID串与金额合计
|
|
|
|
const contractIdStr = Array.from(new Set(wuzicaigou_items.map(i => i.contract_id).filter(Boolean))).join(',')
|
|
|
|
const contractIdStr = Array.from(new Set(wuzicaigou_items.map(i => i.contract_id).filter(Boolean))).join(',')
|
|
|
|
// 金额按每个区块的申请金额求和(同一支付内不重复累加明细)
|
|
|
|
const amtTotal = wuzicaigou_items.reduce((sum, i) => sum + (Number(i.group_apply_money || i.apply_money) || 0), 0)
|
|
|
|
const amtTotal = (this.payList || []).reduce((sum, p) => {
|
|
|
|
|
|
|
|
const form = this.fundlogFormMap[p.id] || {}
|
|
|
|
|
|
|
|
return sum + (Number(form.applyMoney) || 0)
|
|
|
|
|
|
|
|
}, 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 从合同列表聚合展示数据
|
|
|
|
// 从合同列表聚合展示数据
|
|
|
|
const sumMoney = (contracts || []).reduce((sum, c) => sum + (Number(c?.money) || 0), 0)
|
|
|
|
const sumMoney = (contracts || []).reduce((sum, c) => sum + (Number(c?.money) || 0), 0)
|
|
|
|
|