diff --git a/erp/src/main/resources/template/js/erpcommon/calculatePrice.js b/erp/src/main/resources/template/js/erpcommon/calculatePrice.js index ecbe28e08cb6db2182877a10df60a8b9bb406218..4eae6c71021f35043a4d0185ae1105ac533c537e 100644 --- a/erp/src/main/resources/template/js/erpcommon/calculatePrice.js +++ b/erp/src/main/resources/template/js/erpcommon/calculatePrice.js @@ -1,154 +1,154 @@ -//计算总价 +// 计算总价 function calculatedTotalPrice() { var allPrice = 0, taxLastMoneyPrice = 0; - $.each(initTableChooseUtil.getDataRowIndex('productList'), function(i, item) { - //获取行坐标 - var rowNum = item; - //获取数量 - var rkNum = parseInt(isNull($("#rkNum" + rowNum).val()) ? 0 : $("#rkNum" + rowNum).val()); - //获取单价 - var unitPrice = parseFloat(isNull($("#unitPrice" + rowNum).val()) ? 0 : $("#unitPrice" + rowNum).val()); - //获取税率 - var taxRate = parseFloat(isNull($("#taxRate" + rowNum).val()) ? 0 : $("#taxRate" + rowNum).val()) / 100; - - if('rkNum' === showTdByEdit){//数量 + $.each(initTableChooseUtil.getDataRowIndex('productList'), function (i, item) { + // 获取行坐标 + var thisRowKey = item; + // 获取数量 + var rkNum = parseInt(isNull($("#rkNum" + thisRowKey).val()) ? 0 : $("#rkNum" + thisRowKey).val()); + // 获取单价 + var unitPrice = parseFloat(isNull($("#unitPrice" + thisRowKey).val()) ? 0 : $("#unitPrice" + thisRowKey).val()); + // 获取税率 + var taxRate = parseFloat(isNull($("#taxRate" + thisRowKey).val()) ? 0 : $("#taxRate" + thisRowKey).val()) / 100; + + if ('rkNum' === showTdByEdit) {//数量 //输出金额 - $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + $("#amountOfMoney" + thisRowKey).val((rkNum * unitPrice).toFixed(2)); //输出税额=数量*税率*单价 - $("#taxMoney" + rowNum).val((rkNum * taxRate * unitPrice).toFixed(2)); + $("#taxMoney" + thisRowKey).val((rkNum * taxRate * unitPrice).toFixed(2)); //输出含税单价 - $("#taxUnitPrice" + rowNum).val((taxRate * unitPrice + unitPrice).toFixed(2)); + $("#taxUnitPrice" + thisRowKey).val((taxRate * unitPrice + unitPrice).toFixed(2)); //输出合计价税 - $("#taxLastMoney" + rowNum).val((rkNum * taxRate * unitPrice + rkNum * unitPrice).toFixed(2)); - }else if('unitPrice' === showTdByEdit){//单价 + $("#taxLastMoney" + thisRowKey).val((rkNum * taxRate * unitPrice + rkNum * unitPrice).toFixed(2)); + } else if ('unitPrice' === showTdByEdit) {//单价 //输出金额 - $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + $("#amountOfMoney" + thisRowKey).val((rkNum * unitPrice).toFixed(2)); //输出税额=数量*税率*单价 - $("#taxMoney" + rowNum).val((rkNum * taxRate * unitPrice).toFixed(2)); + $("#taxMoney" + thisRowKey).val((rkNum * taxRate * unitPrice).toFixed(2)); //输出含税单价 - $("#taxUnitPrice" + rowNum).val((taxRate * unitPrice + unitPrice).toFixed(2)); + $("#taxUnitPrice" + thisRowKey).val((taxRate * unitPrice + unitPrice).toFixed(2)); //输出合计价税 - $("#taxLastMoney" + rowNum).val((rkNum * taxRate * unitPrice + rkNum * unitPrice).toFixed(2)); - }else if('amountOfMoney' === showTdByEdit){//金额 + $("#taxLastMoney" + thisRowKey).val((rkNum * taxRate * unitPrice + rkNum * unitPrice).toFixed(2)); + } else if ('amountOfMoney' === showTdByEdit) {//金额 //获取金额 - var amountOfMoney = parseFloat(isNull($("#amountOfMoney" + rowNum).val()) ? 0 : $("#amountOfMoney" + rowNum).val()); + var amountOfMoney = parseFloat(isNull($("#amountOfMoney" + thisRowKey).val()) ? 0 : $("#amountOfMoney" + thisRowKey).val()); //输出税额=金额*税率 - $("#taxMoney" + rowNum).val((amountOfMoney * taxRate).toFixed(2)); + $("#taxMoney" + thisRowKey).val((amountOfMoney * taxRate).toFixed(2)); //输出单价,含税单价,合计价税 - if(rkNum != 0){ - $("#unitPrice" + rowNum).val((amountOfMoney / rkNum).toFixed(2)); - $("#taxUnitPrice" + rowNum).val((amountOfMoney / rkNum * taxRate + amountOfMoney / rkNum).toFixed(2)); - $("#taxLastMoney" + rowNum).val((amountOfMoney * taxRate + amountOfMoney).toFixed(2)); + if (rkNum != 0) { + $("#unitPrice" + thisRowKey).val((amountOfMoney / rkNum).toFixed(2)); + $("#taxUnitPrice" + thisRowKey).val((amountOfMoney / rkNum * taxRate + amountOfMoney / rkNum).toFixed(2)); + $("#taxLastMoney" + thisRowKey).val((amountOfMoney * taxRate + amountOfMoney).toFixed(2)); } else { - $("#unitPrice" + rowNum).val('0.00'); - $("#taxUnitPrice" + rowNum).val('0.00'); - $("#taxLastMoney" + rowNum).val('0.00'); + $("#unitPrice" + thisRowKey).val('0.00'); + $("#taxUnitPrice" + thisRowKey).val('0.00'); + $("#taxLastMoney" + thisRowKey).val('0.00'); } - }else if('taxRate' === showTdByEdit){//税率 + } else if ('taxRate' === showTdByEdit) {//税率 //输出金额 - $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + $("#amountOfMoney" + thisRowKey).val((rkNum * unitPrice).toFixed(2)); //输出税额=数量*税率*单价 - $("#taxMoney" + rowNum).val((rkNum * taxRate * unitPrice).toFixed(2)); + $("#taxMoney" + thisRowKey).val((rkNum * taxRate * unitPrice).toFixed(2)); //输出含税单价 - $("#taxUnitPrice" + rowNum).val((taxRate * unitPrice + unitPrice).toFixed(2)); + $("#taxUnitPrice" + thisRowKey).val((taxRate * unitPrice + unitPrice).toFixed(2)); //输出合计价税 - $("#taxLastMoney" + rowNum).val((rkNum * taxRate * unitPrice + rkNum * unitPrice).toFixed(2)); - }else if('taxMoney' === showTdByEdit){//税额 + $("#taxLastMoney" + thisRowKey).val((rkNum * taxRate * unitPrice + rkNum * unitPrice).toFixed(2)); + } else if ('taxMoney' === showTdByEdit) {//税额 //获取税额 - var taxMoney = parseFloat(isNull($("#taxMoney" + rowNum).val()) ? 0 : $("#taxMoney" + rowNum).val()); + var taxMoney = parseFloat(isNull($("#taxMoney" + thisRowKey).val()) ? 0 : $("#taxMoney" + thisRowKey).val()); //输出金额 - $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + $("#amountOfMoney" + thisRowKey).val((rkNum * unitPrice).toFixed(2)); //获取金额 - var amountOfMoney = parseFloat(isNull($("#amountOfMoney" + rowNum).val()) ? 0 : $("#amountOfMoney" + rowNum).val()); + var amountOfMoney = parseFloat(isNull($("#amountOfMoney" + thisRowKey).val()) ? 0 : $("#amountOfMoney" + thisRowKey).val()); //输出含税单价,合计价税,税率 - if(rkNum != 0){ - if(unitPrice != 0){ - $("#taxUnitPrice" + rowNum).val((taxMoney / rkNum + unitPrice).toFixed(2)); - $("#taxRate" + rowNum).val((taxMoney / unitPrice / rkNum * 100).toFixed(2)); + if (rkNum != 0) { + if (unitPrice != 0) { + $("#taxUnitPrice" + thisRowKey).val((taxMoney / rkNum + unitPrice).toFixed(2)); + $("#taxRate" + thisRowKey).val((taxMoney / unitPrice / rkNum * 100).toFixed(2)); } else { - $("#taxUnitPrice" + rowNum).val('0.00'); - $("#taxRate" + rowNum).val('0.00'); - $("#unitPrice" + rowNum).val('0.00'); - $("#amountOfMoney" + rowNum).val('0.00'); + $("#taxUnitPrice" + thisRowKey).val('0.00'); + $("#taxRate" + thisRowKey).val('0.00'); + $("#unitPrice" + thisRowKey).val('0.00'); + $("#amountOfMoney" + thisRowKey).val('0.00'); } - if(amountOfMoney != 0){ - $("#taxLastMoney" + rowNum).val((amountOfMoney + taxMoney).toFixed(2)); + if (amountOfMoney != 0) { + $("#taxLastMoney" + thisRowKey).val((amountOfMoney + taxMoney).toFixed(2)); } else { - $("#taxLastMoney" + rowNum).val('0.00'); + $("#taxLastMoney" + thisRowKey).val('0.00'); } } else { - $("#taxUnitPrice" + rowNum).val('0.00'); - $("#taxLastMoney" + rowNum).val('0.00'); + $("#taxUnitPrice" + thisRowKey).val('0.00'); + $("#taxLastMoney" + thisRowKey).val('0.00'); } - }else if('taxUnitPrice' === showTdByEdit){//含税单价 + } else if ('taxUnitPrice' === showTdByEdit) {//含税单价 //获取含税单价 - var taxUnitPrice = parseFloat(isNull($("#taxUnitPrice" + rowNum).val()) ? 0 : $("#taxUnitPrice" + rowNum).val()); - if(taxUnitPrice == 0){ - $("#taxLastMoney" + rowNum).val('0.00'); - $("#unitPrice" + rowNum).val('0.00'); - $("#amountOfMoney" + rowNum).val('0.00'); - $("#taxMoney" + rowNum).val('0.00'); - $("#taxRate" + rowNum).val('0.00'); + var taxUnitPrice = parseFloat(isNull($("#taxUnitPrice" + thisRowKey).val()) ? 0 : $("#taxUnitPrice" + thisRowKey).val()); + if (taxUnitPrice == 0) { + $("#taxLastMoney" + thisRowKey).val('0.00'); + $("#unitPrice" + thisRowKey).val('0.00'); + $("#amountOfMoney" + thisRowKey).val('0.00'); + $("#taxMoney" + thisRowKey).val('0.00'); + $("#taxRate" + thisRowKey).val('0.00'); return; } //输出合计价税,税额,税率 - if(unitPrice != 0){ - if(rkNum != 0 ){ - $("#taxLastMoney" + rowNum).val((taxUnitPrice * rkNum).toFixed(2)); - $("#amountOfMoney" + rowNum).val((unitPrice * rowNum).toFixed(2)); + if (unitPrice != 0) { + if (rkNum != 0) { + $("#taxLastMoney" + thisRowKey).val((taxUnitPrice * rkNum).toFixed(2)); + $("#amountOfMoney" + thisRowKey).val((unitPrice * thisRowKey).toFixed(2)); } else { - $("#taxLastMoney" + rowNum).val('0.00'); - $("#amountOfMoney" + rowNum).val('0.00'); + $("#taxLastMoney" + thisRowKey).val('0.00'); + $("#amountOfMoney" + thisRowKey).val('0.00'); } - $("#taxMoney" + rowNum).val((taxUnitPrice - unitPrice).toFixed(2)); - $("#taxRate" + rowNum).val(((taxUnitPrice / unitPrice - 1) * 100).toFixed(2)); - + $("#taxMoney" + thisRowKey).val((taxUnitPrice - unitPrice).toFixed(2)); + $("#taxRate" + thisRowKey).val(((taxUnitPrice / unitPrice - 1) * 100).toFixed(2)); + } else { - $("#taxLastMoney" + rowNum).val('0.00'); - $("#unitPrice" + rowNum).val('0.00'); - $("#amountOfMoney" + rowNum).val('0.00'); - $("#taxMoney" + rowNum).val('0.00'); - $("#taxRate" + rowNum).val('0.00'); + $("#taxLastMoney" + thisRowKey).val('0.00'); + $("#unitPrice" + thisRowKey).val('0.00'); + $("#amountOfMoney" + thisRowKey).val('0.00'); + $("#taxMoney" + thisRowKey).val('0.00'); + $("#taxRate" + thisRowKey).val('0.00'); } - }else if('taxLastMoney' === showTdByEdit){//合计价税 + } else if ('taxLastMoney' === showTdByEdit) {//合计价税 //获取合计价税 - var taxLastMoney = parseFloat(isNull($("#taxLastMoney" + rowNum).val()) ? 0 : $("#taxLastMoney" + rowNum).val()); - if(taxLastMoney == 0){ - $("#taxUnitPrice" + rowNum).val('0.00'); - $("#unitPrice" + rowNum).val('0.00'); - $("#amountOfMoney" + rowNum).val('0.00'); - $("#taxMoney" + rowNum).val('0.00'); - $("#taxRate" + rowNum).val('0.00'); + var taxLastMoney = parseFloat(isNull($("#taxLastMoney" + thisRowKey).val()) ? 0 : $("#taxLastMoney" + thisRowKey).val()); + if (taxLastMoney == 0) { + $("#taxUnitPrice" + thisRowKey).val('0.00'); + $("#unitPrice" + thisRowKey).val('0.00'); + $("#amountOfMoney" + thisRowKey).val('0.00'); + $("#taxMoney" + thisRowKey).val('0.00'); + $("#taxRate" + thisRowKey).val('0.00'); return; } //输出含税单价,税额,税率 - if(rkNum != 0 ){ - if(unitPrice != 0){ - $("#taxUnitPrice" + rowNum).val((taxLastMoney / rkNum).toFixed(2)); - $("#taxMoney" + rowNum).val((taxLastMoney / rkNum - unitPrice).toFixed(2)); - $("#taxRate" + rowNum).val(((taxLastMoney / rkNum / unitPrice - 1 ) * 100).toFixed(2)); - $("#amountOfMoney" + rowNum).val((unitPrice * rkNum).toFixed(2)); + if (rkNum != 0) { + if (unitPrice != 0) { + $("#taxUnitPrice" + thisRowKey).val((taxLastMoney / rkNum).toFixed(2)); + $("#taxMoney" + thisRowKey).val((taxLastMoney / rkNum - unitPrice).toFixed(2)); + $("#taxRate" + thisRowKey).val(((taxLastMoney / rkNum / unitPrice - 1) * 100).toFixed(2)); + $("#amountOfMoney" + thisRowKey).val((unitPrice * rkNum).toFixed(2)); } else { - $("#amountOfMoney" + rowNum).val('0.00'); - $("#taxMoney" + rowNum).val('0.00'); - $("#taxUnitPrice" + rowNum).val('0.00'); - $("#unitPrice" + rowNum).val('0.00'); + $("#amountOfMoney" + thisRowKey).val('0.00'); + $("#taxMoney" + thisRowKey).val('0.00'); + $("#taxUnitPrice" + thisRowKey).val('0.00'); + $("#unitPrice" + thisRowKey).val('0.00'); } } else { - $("#taxUnitPrice" + rowNum).val('0.00'); - $("#unitPrice" + rowNum).val('0.00'); - $("#amountOfMoney" + rowNum).val('0.00'); - $("#taxMoney" + rowNum).val('0.00'); - $("#taxRate" + rowNum).val('0.00'); + $("#taxUnitPrice" + thisRowKey).val('0.00'); + $("#unitPrice" + thisRowKey).val('0.00'); + $("#amountOfMoney" + thisRowKey).val('0.00'); + $("#taxMoney" + thisRowKey).val('0.00'); + $("#taxRate" + thisRowKey).val('0.00'); } } - allPrice += parseFloat($("#amountOfMoney" + rowNum).val()); - taxLastMoneyPrice += parseFloat($("#taxLastMoney" + rowNum).val()); + allPrice += parseFloat($("#amountOfMoney" + thisRowKey).val()); + taxLastMoneyPrice += parseFloat($("#taxLastMoney" + thisRowKey).val()); }); $("#allPrice").html(allPrice.toFixed(2)); $("#taxLastMoneyPrice").html(taxLastMoneyPrice.toFixed(2)); - + //优惠率计算 var discount = parseFloat(isNull($("#discount").val()) ? 0 : $("#discount").val()); //输出优惠金额 diff --git a/erp/src/main/resources/template/js/erpcommon/loadStock.js b/erp/src/main/resources/template/js/erpcommon/loadStock.js index 6760c930fbfa3b70741328af9c94075515cc2f2b..a68d86d43fc3c444574e908770066d025389aa7c 100644 --- a/erp/src/main/resources/template/js/erpcommon/loadStock.js +++ b/erp/src/main/resources/template/js/erpcommon/loadStock.js @@ -1,53 +1,55 @@ /** * 根据规格加载库存 + * * @param rowNum 表格行坐标 * @param depotId 仓库id */ -function loadTockByDepotAndMUnit(rowNum, depotId){ - //获取当前选中的规格 - var chooseUnitId = $("#unitId" + rowNum).val(); - //当规格不为空时 - if(!isNull(chooseUnitId)){ +function loadTockByDepotAndMUnit(rowNum, depotId) { + // 获取当前选中的规格 + var chooseUnitId = $("#mUnitId" + rowNum).val(); + // 当规格不为空时 + if (!isNull(chooseUnitId)) { // 获取库存 getStockAjaxByDepotAndNormsId(chooseUnitId, depotId, function (json) { var currentTock = 0; - if(!isNull(json.bean)){ + if (!isNull(json.bean)) { currentTock = json.bean.currentTock; } $("#currentTock" + rowNum).html(currentTock); }); } else { - //否则重置库存为空 + // 否则重置库存为空 $("#currentTock" + rowNum).html(""); } } /** * 根据仓库id加载表格中已经选择的商品规格的库存 + * * @param depotId 仓库id */ -function loadMaterialDepotStockByDepotId(depotId){ +function loadMaterialDepotStockByDepotId(depotId) { var rowTr = $("#useTable tr"); var normsIds = new Array(); var normsIdsNum = new Array(); - $.each(rowTr, function(i, item) { + $.each(rowTr, function (i, item) { // 获取行坐标 var rowNum = $(item).attr("trcusid").replace("tr", ""); var unitId = $("#unitId" + rowNum).val(); - if(!isNull(unitId)){ + if (!isNull(unitId)) { normsIds.push(unitId); normsIdsNum.push(rowNum); } }); - if(normsIds.length == 0){ + if (normsIds.length == 0) { return; } // 获取库存 getStockAjaxByDepotAndNormsId(normsIds.join(','), depotId, function (json) { - if(normsIds.length == 1){ + if (normsIds.length == 1) { $("#currentTock" + normsIdsNum[0]).html(json.bean.currentTock); } else { - $.each(normsIdsNum, function(i, item) { + $.each(normsIdsNum, function (i, item) { $("#currentTock" + normsIdsNum[i]).html(json.rows[i].currentTock); }); } @@ -60,8 +62,12 @@ function loadMaterialDepotStockByDepotId(depotId){ * @param depotId 仓库id,可为空 * @param callBack 回调函数 */ -function getStockAjaxByDepotAndNormsId(normsIds, depotId, callBack){ - AjaxPostUtil.request({url: flowableBasePath + "material011", params: {depotId: depotId, normsIds: normsIds}, type: 'json', method: "POST", callback: function(json) { +function getStockAjaxByDepotAndNormsId(normsIds, depotId, callBack) { + var params = { + depotId: depotId, + normsIds: normsIds + }; + AjaxPostUtil.request({url: flowableBasePath + "material011", params: params, type: 'json', method: "POST", callback: function(json) { if(typeof(callBack) == "function") { callBack(json); } diff --git a/erp/src/main/resources/template/js/purchaseorder/purchaseorderadd.js b/erp/src/main/resources/template/js/purchaseorder/purchaseorderadd.js index a5791f0d56313c4a4d68a0028f3cbe94f65ac24f..4d5152ce226afe0dcd97457c07e3370d63935471 100644 --- a/erp/src/main/resources/template/js/purchaseorder/purchaseorderadd.js +++ b/erp/src/main/resources/template/js/purchaseorder/purchaseorderadd.js @@ -4,8 +4,6 @@ var productionMation = {}; // 根据那一列的值进行变化,默认根据数量 var showTdByEdit = 'rkNum'; -// 表格的序号 -var rowNum = 1; // 兼容动态表单 var layedit, form; @@ -61,12 +59,12 @@ layui.config({ {id: 'taxLastMoney', title: '合计价税', formType: 'input', width: '80', className: 'change-input taxLastMoney', verify: 'required|money'}, {id: 'remark', title: '备注', formType: 'input', width: '100'} ], - deleteRowCallback: function (trId) { - allChooseProduct[trId] = undefined; + deleteRowCallback: function (trcusid) { + delete allChooseProduct[trcusid]; // 计算价格 calculatedTotalPrice(); }, - addRowCallback: function (rowIndexStr) { + addRowCallback: function (trcusid) { // 设置根据某列变化的颜色 $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); }, @@ -80,26 +78,27 @@ layui.config({ // 商品规格加载变化事件 form.on('select(selectUnitProperty)', function(data) { var thisRowValue = data.value; - var thisRowNum = data.elem.id.replace("unitId", "");//获取当前行 + var thisRowKey = data.elem.id.replace("mUnitId", "").toString(); // 当前当前行选中的商品信息 - if(!isNull(thisRowValue) && thisRowValue != '请选择') { - var product = allChooseProduct["tr" + thisRowNum.toString()]; - $.each(product.unitList, function(j, bean) { - if(thisRowValue == bean.id){//获取规格 - //获取当前行数量 - var rkNum = parseInt($("#rkNum" + thisRowNum).val()); - $("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 - $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 + if (!isNull(thisRowValue)) { + var product = allChooseProduct["tr" + thisRowKey]; + $.each(product.unitList, function (j, bean) { + if (thisRowValue == bean.id) { + var rkNum = parseInt($("#rkNum" + thisRowKey).val()); + // 设置单价和金额 + $("#unitPrice" + thisRowKey).val(bean.estimatePurchasePrice.toFixed(2)); + $("#amountOfMoney" + thisRowKey).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2)); return false; } }); } else { - $("#unitPrice" + thisRowNum).val("0.00");//重置单价为空 - $("#amountOfMoney" + thisRowNum).val("0.00");//重置金额为空 + // 重置单价以及金额为空 + $("#unitPrice" + thisRowKey).val("0.00"); + $("#amountOfMoney" + thisRowKey).val("0.00"); } // 加载库存 - loadTockByDepotAndMUnit(thisRowNum, ""); + loadTockByDepotAndMUnit(thisRowKey, ""); // 计算价格 calculatedTotalPrice(); }); @@ -130,48 +129,31 @@ layui.config({ return false; }); - function saveData(subType, approvalId){ - //获取已选商品数据 - var rowTr = $("#useTable tr"); - if(rowTr.length == 0) { - winui.window.msg('请选择商品.', {icon: 2, time: 2000}); - return false; - } - var tableData = new Array(); - var noError = false; //循环遍历表格数据时,是否有其他错误信息 - $.each(rowTr, function(i, item) { + function saveData(subType, approvalId) { + var dataList = initTableChooseUtil.getDataList('productList'); + var noError = false; + var tableData = []; + $.each(dataList, function(i, item) { //获取行编号 - var rowNum = $(item).attr("trcusid").replace("tr", ""); - //表格数量对象 - var rkNum = $("#rkNum" + rowNum); - if(parseInt(rkNum.val()) == 0) { - rkNum.addClass("layui-form-danger"); - rkNum.focus(); + var thisRowKey = item["trcusid"].replace("tr", ""); + if (parseInt(item.rkNum) == 0) { + $("#rkNum" + thisRowKey).addClass("layui-form-danger"); + $("#rkNum" + thisRowKey).focus(); winui.window.msg('数量不能为0', {icon: 2, time: 2000}); noError = true; return false; } //商品对象 - var product = allChooseProduct["tr" + rowNum.toString()]; - if(inTableDataArrayByAssetarId(product.productId, $("#unitId" + rowNum).val(), tableData)) { + var product = allChooseProduct["tr" + thisRowKey]; + if (inTableDataArrayByAssetarId(product.productId, item.mUnitId, tableData)) { winui.window.msg('一张单中不允许出现相同单位的商品信息.', {icon: 2, time: 2000}); noError = true; return false; } - var row = { - materialId: product.productId, - mUnitId: $("#unitId" + rowNum).val(), - rkNum: rkNum.val(), - unitPrice: $("#unitPrice" + rowNum).val(), - taxRate: $("#taxRate" + rowNum).val(), - taxMoney: $("#taxMoney" + rowNum).val(), - taxUnitPrice: $("#taxUnitPrice" + rowNum).val(), - taxLastMoney: $("#taxLastMoney" + rowNum).val(), - remark: $("#remark" + rowNum).val() - }; - tableData.push(row); + item["materialId"] = product.productId; + tableData.push(item); }); - if(noError) { + if (noError) { return false; } @@ -200,69 +182,63 @@ layui.config({ // 供应商选择 $("body").on("click", "#supplierNameSel", function (e) { - sysSupplierUtil.openSysSupplierChoosePage(function (supplierMation){ + sysSupplierUtil.openSysSupplierChoosePage(function (supplierMation) { $("#supplierName").val(supplierMation.supplierName); }); }); - //商品选择 + // 商品选择 $("body").on("click", ".chooseProductBtn", function (e) { var trId = $(this).parent().parent().attr("trcusid"); erpOrderUtil.openMaterialChooseChoosePage(function (chooseProductMation) { - //获取表格行号 - var thisRowNum = trId.replace("tr", ""); - //商品赋值 + // 获取表格行号 + var thisRowKey = trId.replace("tr", ""); + // 商品赋值 allChooseProduct[trId] = chooseProductMation; - //表格商品名称赋值 - $("#materialId" + thisRowNum.toString()).val(allChooseProduct[trId].productName + "(" + allChooseProduct[trId].productModel + ")"); - //表格单位赋值 - $("#unitId" + thisRowNum.toString()).html(getDataUseHandlebars(selOption, {rows: allChooseProduct[trId].unitList})); + // 表格商品名称赋值 + $("#materialId" + thisRowKey.toString()).val(chooseProductMation.productName + "(" + chooseProductMation.productModel + ")"); + // 表格单位赋值 + $("#mUnitId" + thisRowKey.toString()).html(getDataUseHandlebars(selOption, {rows: chooseProductMation.unitList})); form.render('select'); //计算价格 calculatedTotalPrice(); }); }); - //生产计划单选择 + // 生产计划单选择 $("body").on("click", "#productionOrderSel", function (e) { _openNewWindows({ url: "../../tpl/erpProduction/erpProductionNoSuccessChoose.html", title: "选择生产计划单", pageId: "erpProductionNoSuccessChoose", area: ['90vw', '90vh'], - callBack: function(refreshCode){ + callBack: function(refreshCode) { $("#productionOrder").val(productionMation.defaultNumber); - //移除之前填写的所有行 - var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']"); - $.each(checkRow, function(i, item) { - //删除allChooseProduct已选择的商品信息 - var trId = $(item).parent().parent().attr("trcusid"); - allChooseProduct[trId] = undefined; - //移除界面上的信息 - $(item).parent().parent().remove(); - }); - $.each(productionMation.norms, function(i, item){ - addRow(); - //将规格所属的商品信息加入到对象中存储 - allChooseProduct["tr" + (rowNum - 1)] = item.product; - //单位回显 - $("#unitId" + (rowNum - 1)).html(getDataUseHandlebars(selOption, {rows: item.product.unitList})); - $("#unitId" + (rowNum - 1)).val(item.normsId); - //商品回显 - $("#materialId" + (rowNum - 1)).val(item.product.productName + "(" + item.product.productModel + ")"); - $("#currentTock" + (rowNum - 1)).html(item.currentTock);//库存回显 - $("#rkNum" + (rowNum - 1)).val(item.needNum); - $("#unitPrice" + (rowNum - 1)).val(item.unitPrice.toFixed(2)); - $("#amountOfMoney" + (rowNum - 1)).val(item.allPrice.toFixed(2)); - $("#taxRate" + (rowNum - 1)).val(item.taxRate.toFixed(2)); - $("#taxMoney" + (rowNum - 1)).val(item.taxMoney.toFixed(2)); - $("#taxUnitPrice" + (rowNum - 1)).val(item.taxUnitPrice.toFixed(2)); - $("#taxLastMoney" + (rowNum - 1)).val(item.taxLastMoney.toFixed(2)); + initTableChooseUtil.deleteAllRow('productList'); + $.each(productionMation.norms, function(i, item) { + var params = { + "materialId": item.product.productName + "(" + item.product.productModel + ")", + "mUnitId": { + "html": getDataUseHandlebars(selOption, {rows: item.product.unitList}), + "value": item.normsId + }, + "currentTock": item.currentTock, + "rkNum": item.needNum, + "unitPrice": item.unitPrice.toFixed(2), + "amountOfMoney": item.allPrice.toFixed(2), + "taxRate": item.taxRate.toFixed(2), + "taxMoney": item.taxMoney.toFixed(2), + "taxUnitPrice": item.taxUnitPrice.toFixed(2), + "taxLastMoney": item.taxLastMoney.toFixed(2) + }; + var trcusid = initTableChooseUtil.resetData('productList', params); + // 将规格所属的商品信息加入到对象中存储 + allChooseProduct[trcusid] = item.product; }); - //渲染 + // 渲染 form.render(); - //计算价格 + // 计算价格 calculatedTotalPrice(); }}); }); diff --git a/erp/src/main/resources/template/tpl/purchaseorder/purchaseorderadd.html b/erp/src/main/resources/template/tpl/purchaseorder/purchaseorderadd.html index f6aea137f1bb01f79c230099641a3315bf966bc3..fe0b8da0e5f1d91dc911d74cc622c65fe5ce1f84 100644 --- a/erp/src/main/resources/template/tpl/purchaseorder/purchaseorderadd.html +++ b/erp/src/main/resources/template/tpl/purchaseorder/purchaseorderadd.html @@ -42,32 +42,7 @@