From d4bd51714ae72e8b82eac552673b62e7286136d8 Mon Sep 17 00:00:00 2001 From: hayu <1604366271@qq.com> Date: Wed, 4 Feb 2026 10:54:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=8F=91=E8=B4=A7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../child/send_out_supplement.js | 51 +++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/js/aq_demand_plan/child/send_out_supplement.js b/js/aq_demand_plan/child/send_out_supplement.js index f1ae26a..3724522 100644 --- a/js/aq_demand_plan/child/send_out_supplement.js +++ b/js/aq_demand_plan/child/send_out_supplement.js @@ -201,11 +201,11 @@ function beforeSubmitApply() { if (hasError) break; // 第二步:校验采购量+利库量不可全部为0 - if (cgNum + lkNum <= 0) { - layer.msg('序号为' + (i + 1) + '的数据,请填写采购量或利库量(不可全部为0)', { icon: 7 }); - hasError = true; - break; - } + // if (cgNum + lkNum <= 0) { + // layer.msg('序号为' + (i + 1) + '的数据,请填写采购量或利库量(不可全部为0)', { icon: 7 }); + // hasError = true; + // break; + // } o.cgTotal = cgNum; o.lkTotal = lkNum; @@ -226,6 +226,20 @@ function beforeSubmitApply() { // 若存在错误,直接返回,不执行后续逻辑 if (hasError) return; + + if (targetData && targetData.length > 0) { + targetData = targetData.filter(item => { + // 过滤条件:采购总量+利库总量 > 0 + return (parseInt(item.cgTotal || 0) + parseInt(item.lkTotal || 0)) > 0; + }); + + // 如果过滤后没有数据,提示用户并返回 + if (targetData.length === 0) { + layer.msg('请填写有效的采购量或利库量(不可全部为0)', { icon: 7 }); + return; + } + } + // 第四步:仅当无任何错误时,才判断是否需要弹出总量超需用量的确认框 if (confirmIndex > -1) { layer.confirm('序号为' + (confirmIndex + 1) + '的数据,采购量+利库量总和大于需要量,是否确认提交?', { @@ -245,6 +259,33 @@ function submitApply() { let data = form.val('formInfo'); let dataList = getBaseTableData(); + + // ========== 过滤采购量和利库量都为0的数据 ========== + // 第一步:过滤主数据列表,只保留有有效数值的条目 + dataList = dataList.filter(item => { + // 先计算当前条目的采购总量和利库总量 + let cgTotal = 0, lkTotal = 0; + if (item.supList && item.supList.length > 0) { + item.supList.forEach(supItem => { + cgTotal += parseInt(supItem.cgNum || 0); + lkTotal += parseInt(supItem.lkNum || 0); + }); + } + // 过滤条件:采购总量+利库总量 > 0 + return (cgTotal + lkTotal) > 0; + }); + + // 第二步:进一步过滤每个条目中的supList,移除其中采购量和利库量都为0的子项 + dataList.forEach(item => { + if (item.supList && item.supList.length > 0) { + item.supList = item.supList.filter(supItem => { + let cgNum = parseInt(supItem.cgNum || 0); + let lkNum = parseInt(supItem.lkNum || 0); + return (cgNum + lkNum) > 0; + }); + } + }); + data.id = dataObj.id; data.detailsList = dataList; data.planId = objParam.id;