From 3b78a0801cbaadbbe9383357c685a6381ffd923d Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Sat, 2 Nov 2024 10:43:44 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E9=94=80=E5=94=AE=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E6=8C=89=E7=85=A7=E4=B8=87=E6=9D=90=E8=B0=83=E6=95=B4=EF=BC=9A?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=80=E5=94=AE=E4=BC=B0=E4=BB=B7=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E6=B7=BB=E5=8A=A0=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=9A=E8=BF=90=E8=BE=93=E6=88=90=E6=9C=AC=E5=92=8C=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E6=88=90=E6=9C=AC=E7=94=B1=E4=B8=9A=E5=8A=A1=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=EF=BC=9B=E4=BF=AE=E6=94=B9=E9=94=80=E5=94=AE=E4=BC=B0?= =?UTF-8?q?=E4=BB=B7=E5=B7=A5=E7=A8=8B=E6=B7=BB=E5=8A=A0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=9A=E5=BC=80=E5=8F=91=E6=88=90=E6=9C=AC=E7=94=B1=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E6=B7=BB=E5=8A=A0=EF=BC=8C=E8=BF=90=E8=BE=93=E6=88=90?= =?UTF-8?q?=E6=9C=AC=E5=92=8C=E6=9C=8D=E5=8A=A1=E6=88=90=E6=9C=AC=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=BA=E5=8F=AA=E8=AF=BB=EF=BC=9B=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2=EF=BC=9A?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=8D=E5=90=AB=E7=A8=8E=E5=8D=95=E4=BB=B7?= =?UTF-8?q?=E5=92=8C=E5=90=AB=E7=A8=8E=E5=8D=95=E4=BB=B7=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=80=BC=E9=BB=98=E8=AE=A4=E4=B8=BA=E2=80=9Dempty=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/sales/estimate/add.html | 118 +++++++++++++++++- .../sales/estimate/engineeringAdd.html | 92 +++++++++----- .../templates/sales/estimate/purchaseAdd.html | 37 ++++++ 3 files changed, 216 insertions(+), 31 deletions(-) diff --git a/ruoyi-admin/src/main/resources/templates/sales/estimate/add.html b/ruoyi-admin/src/main/resources/templates/sales/estimate/add.html index 25f0d47f..c6247979 100644 --- a/ruoyi-admin/src/main/resources/templates/sales/estimate/add.html +++ b/ruoyi-admin/src/main/resources/templates/sales/estimate/add.html @@ -129,7 +129,8 @@ return obj; }, {}); - + // 设置一个标志来跟踪任何错误 + var hasError = false; // 销售估价物料 var estimateMaterialTable = $('#bootstrap-table').bootstrapTable('getData'); @@ -173,9 +174,43 @@ estimateMaterialDataList[index].materialGearPosition = value; // 更新料号档位 }); + // 遍历主表中的每一项 + estimateMaterialTable.forEach(function(row, index) { + var noTaxShippingCosts = $('#noTaxShippingCosts' + index).val(); + var noTaxServiceCosts = $('#noTaxServiceCosts' + index).val(); + + if (!noTaxShippingCosts && noTaxShippingCosts !== '0') { + $.modal.alertWarning("运输成本不能为空,请填写第 " + (parseInt(index) + 1) + " 行的运输成本"); + hasError = true; + return; // 退出循环,阻止进一步处理 + } + if (!noTaxServiceCosts && noTaxServiceCosts !== '0') { + $.modal.alertWarning("服务成本不能为空,请填写第 " + (parseInt(index) + 1) + " 行的服务成本"); + hasError = true; + return; // 退出循环,阻止进一步处理 + } + + // 更新 estimateMaterialDataList 中对应的记录 + estimateMaterialDataList[index].noTaxShippingCosts = noTaxShippingCosts; + estimateMaterialDataList[index].noTaxServiceCosts = noTaxServiceCosts; + + // 获取子表数据 + if (row.childTableData) { + // 如果子表数据存在,则合并到 estimateMaterialDataList 中 + estimateMaterialDataList[index].salesEstimateDetailMaterialList = row.childTableData; + } + }); + + if (hasError) { + return; // 存在错误,阻止提交 + } + + + const combinedData = Object.assign({}, estimateData, { salesEstimateDetailList: estimateMaterialDataList, }); + // 合并表单数据和表格数据 console.log(combinedData) // 使用 JSON.stringify() 序列化数据 @@ -222,6 +257,10 @@ showToggle: false, showColumns: false, modalName: "销售估价详情", + detailView: true, + onExpandRow : function(index, row, $detail) { + initChildTable(index, row, $detail); + }, editFiled:"noTaxRmb", columns: [ { @@ -360,6 +399,81 @@ $.table.init(options); }); + + // 存储子表的状态 + var childTableStates = {}; + initChildTable = function(index, row, $detail) { + var parentRow = row; + var childTableId = 'child_table_'+index; + $detail.html('
'); + $('#'+childTableId).bootstrapTable({ + columns: [ + { + title: '销售估价详情ID', + field: 'estimateDetailId', + visible: false + }, + { + title: '销售估价详情物料ID', + field: 'estimateDetailMaterialId', + visible: false + }, + { + title: '物料名称', + field: 'materialName', + }, + { + title: '物料类型', + field: 'materialType', + formatter: function(value, row, index) { + return $.table.selectCategoryLabel(materialTypeDatas, value); + } + }, + { + title: '物料单位', + field: 'materialUnit', + }, + { + title: '物料描述', + field: 'materialDescribe', + }, + { + title: '用量', + field: 'useNum', + }, + { + title: '操作', + align: 'center', + formatter: function (value, row, index) { + return '删除'; + } + } + ], + }).on('load-success.bs.table', function(data) { + // 当子表加载完成后,将子表数据保存到主表行中 + parentRow.childTableData = data.rows; + }); + // 设置子表的初始状态为展开 + childTableStates[index] = true; + // 动态生成 form 表单 + var formHtml = '
'; + formHtml += '

运输、服务

'; + formHtml += '
'; + formHtml += ''; + formHtml += ''; + formHtml += '
'; + formHtml += '
'; + formHtml += ''; + formHtml += ''; + formHtml += '
'; + formHtml += '
'; + + // 将 form 表单添加到子表下面 + $detail.append(formHtml); + }; + + + //逻辑新增一行物料数据 function estimateDoSubmit(index, layero, uniqueId) { console.log(uniqueId); @@ -401,7 +515,7 @@ materialUnit: rowData.unit, materialProcessMethod: rowData.processMethod, materialDeptType: rowData.warehouseDept, - materialNum: 0 + materialNum: "" }); } else { $.modal.alertError("不能选择已添加过的相同物料"); diff --git a/ruoyi-admin/src/main/resources/templates/sales/estimate/engineeringAdd.html b/ruoyi-admin/src/main/resources/templates/sales/estimate/engineeringAdd.html index 054824c5..42a67518 100644 --- a/ruoyi-admin/src/main/resources/templates/sales/estimate/engineeringAdd.html +++ b/ruoyi-admin/src/main/resources/templates/sales/estimate/engineeringAdd.html @@ -330,8 +330,6 @@ $.table.init(options); }); - // 存储子表的状态 - var childTableStates = {}; initChildTable = function(index, row, $detail) { var parentRow = row; var childTableId = 'child_table_'+index; @@ -345,14 +343,29 @@ estimateDetailId:parentRow.estimateDetailId }, columns: [ - { + { + title: '销售估价详情物料ID', + field: 'estimateDetailMaterialId', + visible: false + }, + { title: '销售估价详情ID', field: 'estimateDetailId', visible: false }, { - title: '销售估价详情物料ID', - field: 'estimateDetailMaterialId', + title: '不含税开发成本', + field: 'noTaxDevelopCosts', + visible: false + }, + { + title: '不含税运输成本', + field: 'noTaxShippingCosts', + visible: false + }, + { + title: '不含税服务成本', + field: 'noTaxServiceCosts', visible: false }, { @@ -386,31 +399,52 @@ } } ], - }).on('load-success.bs.table', function(data) { - // 当子表加载完成后,将子表数据保存到主表行中 - parentRow.childTableData = data.rows; + + onLoadSuccess: function(data) { + // 初始化成本数据为一个空对象 + var costs = {}; + + // 如果 data 是一个对象,将其转换为单元素数组 + if (typeof data === 'object' && !Array.isArray(data)) { + data = [data]; + } + + // 检查数据是否有效 + if (data.length > 0 && data[0].rows && data[0].rows.length > 0) { + // 使用第一条数据 + var firstRow = data[0].rows[0]; + costs.noTaxDevelopCosts = firstRow.noTaxDevelopCosts || ''; + costs.noTaxShippingCosts = firstRow.noTaxShippingCosts || ''; + costs.noTaxServiceCosts = firstRow.noTaxServiceCosts || ''; + } else { + // 如果没有数据,设置所有成本字段为空字符串 + costs.noTaxDevelopCosts = ''; + costs.noTaxShippingCosts = ''; + costs.noTaxServiceCosts = ''; + } + + // 动态生成 form 表单 + var formHtml = '
'; + formHtml += '

运输、服务、开发成本

'; + formHtml += '
'; + formHtml += ''; + formHtml += ''; + formHtml += '
'; + formHtml += '
'; + formHtml += ''; + formHtml += ''; + formHtml += '
'; + formHtml += '
'; + formHtml += ''; + formHtml += ''; + formHtml += '
'; + formHtml += '
'; + + // 将 form 表单添加到子表下面 + $detail.append(formHtml); + } }); - // 设置子表的初始状态为展开 - childTableStates[index] = true; - // 动态生成 form 表单 - var formHtml = '
'; - formHtml += '

运输、服务、开发成本

'; - formHtml += '
'; - formHtml += ''; - formHtml += ''; - formHtml += '
'; - formHtml += '
'; - formHtml += ''; - formHtml += ''; - formHtml += '
'; - formHtml += '
'; - formHtml += ''; - formHtml += ''; - formHtml += '
'; - formHtml += '
'; - - // 将 form 表单添加到子表下面 - $detail.append(formHtml); + }; function queryParams(params) { diff --git a/ruoyi-admin/src/main/resources/templates/sales/estimate/purchaseAdd.html b/ruoyi-admin/src/main/resources/templates/sales/estimate/purchaseAdd.html index d5a9021f..3c7ad3de 100644 --- a/ruoyi-admin/src/main/resources/templates/sales/estimate/purchaseAdd.html +++ b/ruoyi-admin/src/main/resources/templates/sales/estimate/purchaseAdd.html @@ -407,6 +407,24 @@ return '不含税采购单价不能为空'; } } + }, + formatter: function (value, row) { + // 检查 row 是否存在 + if (!row) { + return ""; + } + + // 检查 storageLocation 是否存在 + if (row.storageLocation === undefined || row.storageLocation === null) { + return ""; + } + + // 根据 storageLocation 的值决定返回值 + if (row.storageLocation) { + return row.storageLocation; + } else { + return value; + } } }, { @@ -420,7 +438,26 @@ return '含税采购单价不能为空'; } } + }, + formatter: function (value, row) { + // 检查 row 是否存在 + if (!row) { + return ""; + } + + // 检查 storageLocation 是否存在 + if (row.storageLocation === undefined || row.storageLocation === null) { + return ""; + } + + // 根据 storageLocation 的值决定返回值 + if (row.storageLocation) { + return row.storageLocation; + } else { + return value; + } } + }, { title: '操作',