diff --git a/erp/src/main/resources/template/js/purchaseorder/purchaseorderpurchase.js b/erp/src/main/resources/template/js/purchaseorder/purchaseorderpurchase.js index fa870188690ae15e012f442be393f8f471a0481f..356d7fd19e04c12b928a9d49599c13d17263456e 100644 --- a/erp/src/main/resources/template/js/purchaseorder/purchaseorderpurchase.js +++ b/erp/src/main/resources/template/js/purchaseorder/purchaseorderpurchase.js @@ -158,8 +158,6 @@ layui.config({ 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));//单价 return false; } @@ -174,6 +172,11 @@ layui.config({ calculatedTotalPrice(); }); + // 仓库变化事件 + form.on('select(depotId)', function(data) { + loadMaterialDepotStockByDepotId(data.value); + }); + // 保存为草稿 form.on('submit(formAddBean)', function(data) { if(winui.verifyForm(data.elem)) { diff --git a/erp/src/main/resources/template/js/salesorder/salesorderpurchase.js b/erp/src/main/resources/template/js/salesorder/salesorderpurchase.js index 8449e673f82292dce0f611c92880252bb4b8d366..6b229c717b76424710cce729b34243b2dfafc068 100644 --- a/erp/src/main/resources/template/js/salesorder/salesorderpurchase.js +++ b/erp/src/main/resources/template/js/salesorder/salesorderpurchase.js @@ -14,491 +14,529 @@ var showTdByEdit = 'rkNum'; //表格的序号 var rowNum = 1, priceNum = 1; +// 兼容动态表单 +var layedit, form; + layui.config({ base: basePath, version: skyeyeVersion }).extend({ window: 'js/winui.window' -}).define(['window', 'jquery', 'winui', 'laydate', 'textool'], function(exports) { +}).define(['window', 'jquery', 'winui', 'laydate', 'textool', 'tagEditor'].concat(dsFormUtil.mastHaveImport), function(exports) { winui.renderColor(); - layui.use(['form', 'tagEditor'], function(form) { - var index = parent.layer.getFrameIndex(window.name); - var $ = layui.$, - laydate = layui.laydate, - textool = layui.textool; - var inoutitemHtml = "";//支出项目 - var salesManList = new Array();//销售人员 - - var xsddOrderNum = "";//销售订单编号 - - var usetableTemplate = $("#usetableTemplate").html(), - otherTemplate = $("#otherTemplate").html(); - var selOption = getFileContent('tpl/template/select-option.tpl'); - //已经选择的商品集合key:表格的行trId,value:商品信息 - var allChooseProduct = {}; - - //事故时间 - laydate.render({ - elem: '#operTime', - type: 'datetime', - value: getFormatDate(), - trigger: 'click' - }); - - // 初始化账户 - systemCommonUtil.getSysAccountListByType(function(json){ - // 加载账户数据 - $("#accountId").html(getDataUseHandlebars(selOption, json)); - }); + var index = parent.layer.getFrameIndex(window.name); + var $ = layui.$, + laydate = layui.laydate, + textool = layui.textool; - // 初始化支出项目 - systemCommonUtil.getSysInoutitemListByType(2, function(json){ - // 加载支出项目 - inoutitemHtml = getDataUseHandlebars(selOption, json); - }); + layedit = layui.layedit, + form = layui.form; - // 初始化仓库 - erpOrderUtil.getDepotList(function (json){ - // 加载仓库数据 - $("#depotId").html(getDataUseHandlebars(selOption, json)); - // 初始化回显数据 - initDataShow(); - }); + var inoutitemHtml = "";//支出项目 + var salesManList = new Array();//销售人员 - //初始化回显数据 - function initDataShow(){ - AjaxPostUtil.request({url: reqBasePath + "salesorder008", params: {rowId: parent.rowId}, type: 'json', method: "GET", callback: function(json) { - if(json.returnCode == 0) { - if(isNull(json.bean)){ - $("#showForm").html(""); - winui.window.msg('数据不存在~', {icon: 2, time: 2000}); - return; - } - //客户信息赋值 - customerMation = { - id: json.bean.organId, - customName: json.bean.customName - } - - xsddOrderNum = json.bean.defaultNumber; - $("#customName").val(json.bean.customName); - $("#xsddOrderNum").html(xsddOrderNum); - $("#accountId").val(json.bean.accountId); - $("#payType").val(json.bean.payType); - $("#allPrice").html(json.bean.totalPrice.toFixed(2)); - $("#taxLastMoneyPrice").html(json.bean.taxLastMoneyPrice.toFixed(2)); - $("#remark").val(json.bean.remark); - $("#discount").val(json.bean.discount.toFixed(2)); - $("#discountMoney").val(json.bean.discountMoney.toFixed(2)); - $("#discountLastMoney").html(json.bean.discountLastMoney.toFixed(2)); - $("#changeAmount").val(json.bean.changeAmount.toFixed(2)); - $("#arrears").html(json.bean.arrears.toFixed(2)); - $("#otherPriceTotal").html("费用合计:" + json.bean.otherMoney.toFixed(2)); - - //加载列表项 - $.each(json.bean.items, 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.mUnitId); - //商品回显 - $("#materialId" + (rowNum - 1)).val(item.product.productName + "(" + item.product.productModel + ")"); - $("#currentTock" + (rowNum - 1)).html(item.currentTock); - //订单剩余数量 - $("#nowNum" + (rowNum - 1)).html(isNull(item.nowNumber) ? 0 : item.nowNumber); - $("#rkNum" + (rowNum - 1)).val(isNull(item.nowNumber) ? 0 : item.nowNumber); - $("#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)); - $("#remark" + (rowNum - 1)).val(item.remark); - }); - - //加载其他费用 - $.each(json.bean.otherMoneyList, function(i, item){ - addPriceRow(); - $("#inoutitemId" + (priceNum - 1)).val(item.inoutitemId); - $("#otherPrice" + (priceNum - 1)).val(parseFloat(item.otherPrice).toFixed(2)); - }); - - var userNames = ""; - salesManList = json.bean.userInfo; - $.each(salesManList, function (i, item) { - userNames += item.name + ','; - }); - //人员选择 - $('#salesMan').tagEditor({ - initialTags: userNames.split(','), - placeholder: '请选择销售人员', - beforeTagDelete: function(field, editor, tags, val) { - var inArray = -1; - $.each(salesManList, function(i, item) { - if(val === item.name) { - inArray = i; - return false; - } - }); - if(inArray != -1) { //如果该元素在集合中存在 - salesManList.splice(inArray, 1); - } - } - }); - - textool.init({ - eleId: 'remark', - maxlength: 200, - tools: ['count', 'copy', 'reset', 'clear'] - }); - - matchingLanguage(); - form.render(); - } else { - winui.window.msg(json.returnMessage, {icon: 2, time: 2000}, function(){ - parent.layer.close(index); - parent.refreshCode = '-9999'; - }); - } - }}); - } - - //商品规格加载变化事件 - form.on('select(selectUnitProperty)', function(data) { - var thisRowValue = data.value; - var thisRowNum = data.elem.id.replace("unitId", "");//获取当前行 - //当前当前行选中的商品信息 - 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.salePrice.toFixed(2));//单价 - return false; - } - }); - } else { - $("#unitPrice" + thisRowNum).val("0.00");//重置单价为空 - } - - //加载库存 - loadTockByDepotAndMUnit(thisRowNum, $("#depotId").val()); - //计算价格 - calculatedTotalPrice(); - }); - - form.on('submit(formEditBean)', function(data) { - if(winui.verifyForm(data.elem)) { - if(isNull(customerMation.id)){ - winui.window.msg('请选择客户.', {icon: 2, time: 2000}); - return false; + var xsddOrderNum = "";//销售订单编号 + + var usetableTemplate = $("#usetableTemplate").html(), + otherTemplate = $("#otherTemplate").html(); + var selOption = getFileContent('tpl/template/select-option.tpl'); + //已经选择的商品集合key:表格的行trId,value:商品信息 + var allChooseProduct = {}; + + // 获取单据提交类型 + var submitType = erpOrderUtil.getSubmitTypeByOrderType(systemOrderType["outIsSalesOutlet"]["orderType"]); + + //事故时间 + laydate.render({ + elem: '#operTime', + type: 'datetime', + value: getFormatDate(), + trigger: 'click' + }); + + // 初始化账户 + systemCommonUtil.getSysAccountListByType(function(json){ + // 加载账户数据 + $("#accountId").html(getDataUseHandlebars(selOption, json)); + }); + + // 初始化支出项目 + systemCommonUtil.getSysInoutitemListByType(2, function(json){ + // 加载支出项目 + inoutitemHtml = getDataUseHandlebars(selOption, json); + }); + + // 初始化仓库 + erpOrderUtil.getDepotList(function (json){ + // 加载仓库数据 + $("#depotId").html(getDataUseHandlebars(selOption, json)); + // 初始化回显数据 + initDataShow(); + }); + + // 加载动态表单 + dsFormUtil.loadPageByCode("dsFormShow", sysDsFormWithCodeType["outIsSalesOutlet"]["code"]); + + //初始化回显数据 + function initDataShow(){ + AjaxPostUtil.request({url: reqBasePath + "salesorder008", params: {rowId: parent.rowId}, type: 'json', method: "GET", callback: function(json) { + if(json.returnCode == 0) { + if(isNull(json.bean)){ + $("#showForm").html(""); + winui.window.msg('数据不存在~', {icon: 2, time: 2000}); + return; } - //获取已选商品数据 - var rowTr = $("#useTable tr"); - if(rowTr.length == 0) { - winui.window.msg('请选择商品.', {icon: 2, time: 2000}); - return false; + //客户信息赋值 + customerMation = { + id: json.bean.organId, + customName: json.bean.customName } - var tableData = new Array(); - var noError = false; //循环遍历表格数据时,是否有其他错误信息 - var isStandard = false;//判断是否超标 - $.each(rowTr, 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(); - winui.window.msg('数量不能为0', {icon: 2, time: 2000}); - noError = true; - return false; - } - if(parseInt($("#rkNum" + rowNum).val()) > parseInt($("#nowNum" + rowNum).html())){ - isStandard = true; - } - //商品对象 - var product = allChooseProduct["tr" + rowNum.toString()]; - if(inTableDataArrayByAssetarId(product.productId, $("#unitId" + rowNum).val(), tableData)) { - winui.window.msg('一张单中不允许出现相同单位的商品信息.', {icon: 2, time: 2000}); - noError = true; - return false; - } - var row = { - depotId: $("#depotId").val(), - materialId: $("#materialId" + rowNum).val(), - mUnitId: $("#unitId" + rowNum).val(), - rkNum: $("#rkNum" + rowNum).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); + + xsddOrderNum = json.bean.defaultNumber; + $("#customName").val(json.bean.customName); + $("#xsddOrderNum").html(xsddOrderNum); + $("#accountId").val(json.bean.accountId); + $("#payType").val(json.bean.payType); + $("#allPrice").html(json.bean.totalPrice.toFixed(2)); + $("#taxLastMoneyPrice").html(json.bean.taxLastMoneyPrice.toFixed(2)); + $("#remark").val(json.bean.remark); + $("#discount").val(json.bean.discount.toFixed(2)); + $("#discountMoney").val(json.bean.discountMoney.toFixed(2)); + $("#discountLastMoney").html(json.bean.discountLastMoney.toFixed(2)); + $("#changeAmount").val(json.bean.changeAmount.toFixed(2)); + $("#arrears").html(json.bean.arrears.toFixed(2)); + $("#otherPriceTotal").html("费用合计:" + json.bean.otherMoney.toFixed(2)); + + //加载列表项 + $.each(json.bean.items, 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.mUnitId); + //商品回显 + $("#materialId" + (rowNum - 1)).val(item.product.productName + "(" + item.product.productModel + ")"); + $("#currentTock" + (rowNum - 1)).html(item.currentTock); + //订单剩余数量 + $("#nowNum" + (rowNum - 1)).html(isNull(item.nowNumber) ? 0 : item.nowNumber); + $("#rkNum" + (rowNum - 1)).val(isNull(item.nowNumber) ? 0 : item.nowNumber); + $("#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)); + $("#remark" + (rowNum - 1)).val(item.remark); }); - if(noError) { - return false; - } - //获取其他费用 - var rowPriceTr = $("#otherPriceTable tr"); - var tablePriceData = new Array(); - var otherMoney = 0; - $.each(rowPriceTr, function(i, item) { - //获取行编号 - var rowNum = $(item).attr("trcusid").replace("tr", ""); - var row = { - inoutitemId: $("#inoutitemId" + rowNum).val(), - otherPrice: $("#otherPrice" + rowNum).val() - }; - otherMoney += parseFloat(isNull($("#otherPrice" + rowNum).val()) ? 0 : $("#otherPrice" + rowNum).val()); - tablePriceData.push(row); + + //加载其他费用 + $.each(json.bean.otherMoneyList, function(i, item){ + addPriceRow(); + $("#inoutitemId" + (priceNum - 1)).val(item.inoutitemId); + $("#otherPrice" + (priceNum - 1)).val(parseFloat(item.otherPrice).toFixed(2)); }); - - var salesMan = ""; + + var userNames = ""; + salesManList = json.bean.userInfo; $.each(salesManList, function (i, item) { - salesMan += item.id + ','; - }); - - var params = { - supplierId: customerMation.id,//客户 - operTime: $("#operTime").val(), - accountId: $("#accountId").val(), - payType: $("#payType").val(), - remark: $("#remark").val(), - discount: isNull($("#discount").val()) ? "0.00" : $("#discount").val(), - discountMoney: isNull($("#discountMoney").val()) ? "0.00" : $("#discountMoney").val(), - changeAmount: isNull($("#changeAmount").val()) ? "0.00" : $("#changeAmount").val(), - depotheadStr: JSON.stringify(tableData), - otherMoney: otherMoney.toFixed(2), - otherMoneyList: JSON.stringify(tablePriceData), - xsddOrderNum: xsddOrderNum, - rowId: parent.rowId, - salesMan: salesMan - }; - if(isStandard){ - layer.confirm('该出库单已超出销售单数量,是否继续?', { icon: 3, title: '超标提示' }, function (i) { - AjaxPostUtil.request({url: reqBasePath + "salesorder009", params: params, type: 'json', method: "PUT", callback: function(json) { - if(json.returnCode == 0) { - parent.layer.close(index); - parent.refreshCode = '0'; - } else { - winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + userNames += item.name + ','; + }); + //人员选择 + $('#salesMan').tagEditor({ + initialTags: userNames.split(','), + placeholder: '请选择销售人员', + beforeTagDelete: function(field, editor, tags, val) { + var inArray = -1; + $.each(salesManList, function(i, item) { + if(val === item.name) { + inArray = i; + return false; } - }}); - }); - }else{ - AjaxPostUtil.request({url: reqBasePath + "salesorder009", params: params, type: 'json', method: "PUT", callback: function(json) { - if(json.returnCode == 0) { - parent.layer.close(index); - parent.refreshCode = '0'; - } else { - winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + }); + if(inArray != -1) { //如果该元素在集合中存在 + salesManList.splice(inArray, 1); } - }}); - } + } + }); + + textool.init({ + eleId: 'remark', + maxlength: 200, + tools: ['count', 'copy', 'reset', 'clear'] + }); + + matchingLanguage(); + form.render(); + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}, function(){ + parent.layer.close(index); + parent.refreshCode = '-9999'; + }); } + }}); + } + + //商品规格加载变化事件 + form.on('select(selectUnitProperty)', function(data) { + var thisRowValue = data.value; + var thisRowNum = data.elem.id.replace("unitId", "");//获取当前行 + //当前当前行选中的商品信息 + if(!isNull(thisRowValue) && thisRowValue != '请选择') { + var product = allChooseProduct["tr" + thisRowNum.toString()]; + $.each(product.unitList, function(j, bean) { + if(thisRowValue == bean.id){//获取规格 + $("#unitPrice" + thisRowNum).val(bean.salePrice.toFixed(2));//单价 + return false; + } + }); + } else { + $("#unitPrice" + thisRowNum).val("0.00");//重置单价为空 + } + + //加载库存 + loadTockByDepotAndMUnit(thisRowNum, $("#depotId").val()); + //计算价格 + calculatedTotalPrice(); + }); + + // 仓库变化事件 + form.on('select(depotId)', function(data) { + loadMaterialDepotStockByDepotId(data.value); + }); + + // 保存为草稿 + form.on('submit(formAddBean)', function(data) { + if(winui.verifyForm(data.elem)) { + saveData("1", ""); + } + return false; + }); + + // 走工作流的提交审批 + form.on('submit(formSubOneBean)', function(data) { + if(winui.verifyForm(data.elem)) { + activitiUtil.startProcess(sysActivitiModel["outIsSalesOutlet"]["key"], function (approvalId) { + saveData("2", approvalId); + }); + } + return false; + }); + + // 不走工作流的提交 + form.on('submit(formSubTwoBean)', function(data) { + if(winui.verifyForm(data.elem)) { + saveData("2", ""); + } + return false; + }); + + function saveData(subType, approvalId){ + if(isNull(customerMation.id)){ + winui.window.msg('请选择客户.', {icon: 2, time: 2000}); return false; + } + //获取已选商品数据 + var rowTr = $("#useTable tr"); + if(rowTr.length == 0) { + winui.window.msg('请选择商品.', {icon: 2, time: 2000}); + return false; + } + var tableData = new Array(); + var noError = false; //循环遍历表格数据时,是否有其他错误信息 + var isStandard = false;//判断是否超标 + $.each(rowTr, 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(); + winui.window.msg('数量不能为0', {icon: 2, time: 2000}); + noError = true; + return false; + } + if(parseInt($("#rkNum" + rowNum).val()) > parseInt($("#nowNum" + rowNum).html())){ + isStandard = true; + } + //商品对象 + var product = allChooseProduct["tr" + rowNum.toString()]; + if(inTableDataArrayByAssetarId(product.productId, $("#unitId" + rowNum).val(), tableData)) { + winui.window.msg('一张单中不允许出现相同单位的商品信息.', {icon: 2, time: 2000}); + noError = true; + return false; + } + var row = { + depotId: $("#depotId").val(), + materialId: $("#materialId" + rowNum).val(), + mUnitId: $("#unitId" + rowNum).val(), + rkNum: $("#rkNum" + rowNum).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); }); - - //人员选择 - $("body").on("click", "#toSalesManSelPeople", function(e){ - userReturnList = [].concat(salesManList); - _openNewWindows({ - url: "../../tpl/common/sysusersel.html", - title: "人员选择", - pageId: "sysuserselpage", - area: ['80vw', '80vh'], - callBack: function(refreshCode){ - if (refreshCode == '0') { - //移除所有tag - var tags = $('#salesMan').tagEditor('getTags')[0].tags; - for (i = 0; i < tags.length; i++) { - $('#salesMan').tagEditor('removeTag', tags[i]); - } - salesManList = [].concat(userReturnList); - //添加新的tag - $.each(salesManList, function(i, item){ - $('#salesMan').tagEditor('addTag', item.name); - }); - } else if (refreshCode == '-9999') { - winui.window.msg(systemLanguage["com.skyeye.operationFailed"][languageType], {icon: 2,time: 2000}); - } - }}); - }); - -/*********************** 商品表格操作 start ****************************/ - //新增行 - $("body").on("click", "#addRow", function() { - addRow(); + if(noError) { + return false; + } + //获取其他费用 + var rowPriceTr = $("#otherPriceTable tr"); + var tablePriceData = new Array(); + var otherMoney = 0; + $.each(rowPriceTr, function(i, item) { + //获取行编号 + var rowNum = $(item).attr("trcusid").replace("tr", ""); + var row = { + inoutitemId: $("#inoutitemId" + rowNum).val(), + otherPrice: $("#otherPrice" + rowNum).val() + }; + otherMoney += parseFloat(isNull($("#otherPrice" + rowNum).val()) ? 0 : $("#otherPrice" + rowNum).val()); + tablePriceData.push(row); }); - //删除行 - $("body").on("click", "#deleteRow", function() { - deleteRow(); - //计算价格 - calculatedTotalPrice(); + var salesMan = ""; + $.each(salesManList, function (i, item) { + salesMan += item.id + ','; }); - //新增行 - function addRow() { - var par = { - id: "row" + rowNum.toString(), //checkbox的id - trId: "tr" + rowNum.toString(), //行的id - materialId: "materialId" + rowNum.toString(), //商品id - unitId: "unitId" + rowNum.toString(), //规格id - currentTock: "currentTock" + rowNum.toString(), //库存id - nowNum: "nowNum" + rowNum.toString(), //剩余数量id - rkNum: "rkNum" + rowNum.toString(), //数量id - unitPrice: "unitPrice" + rowNum.toString(), //单价id - amountOfMoney: "amountOfMoney" + rowNum.toString(), //金额id - taxRate: "taxRate" + rowNum.toString(), //税率id - taxMoney: "taxMoney" + rowNum.toString(), //税额id - taxUnitPrice: "taxUnitPrice" + rowNum.toString(), //含税单价id - taxLastMoney: "taxLastMoney" + rowNum.toString(), //含税合计id - remark: "remark" + rowNum.toString() //备注id - }; - $("#useTable").append(getDataUseHandlebars(usetableTemplate, par)); - form.render(); - rowNum++; - //设置根据某列变化的颜色 - $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + var params = { + supplierId: customerMation.id,//客户 + operTime: $("#operTime").val(), + accountId: $("#accountId").val(), + payType: $("#payType").val(), + remark: $("#remark").val(), + discount: isNull($("#discount").val()) ? "0.00" : $("#discount").val(), + discountMoney: isNull($("#discountMoney").val()) ? "0.00" : $("#discountMoney").val(), + changeAmount: isNull($("#changeAmount").val()) ? "0.00" : $("#changeAmount").val(), + depotheadStr: JSON.stringify(tableData), + otherMoney: otherMoney.toFixed(2), + otherMoneyList: JSON.stringify(tablePriceData), + xsddOrderNum: xsddOrderNum, + rowId: parent.rowId, + salesMan: salesMan, + submitType: submitType, + subType: subType, + approvalId: approvalId + }; + if(isStandard){ + layer.confirm('该出库单已超出销售单数量,是否继续?', { icon: 3, title: '超标提示' }, function (i) { + sendRequest(params) + }); + }else{ + sendRequest(params) } + } - //删除行 - function deleteRow() { - var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']:checked"); - if(checkRow.length > 0) { - $.each(checkRow, function(i, item) { - //删除allChooseProduct已选择的商品信息 - var trId = $(item).parent().parent().attr("trcusid"); - allChooseProduct[trId] = undefined; - //移除界面上的信息 - $(item).parent().parent().remove(); - }); + function sendRequest(params){ + AjaxPostUtil.request({url: reqBasePath + "salesorder009", params: params, type: 'json', method: "PUT", callback: function(json) { + if(json.returnCode == 0) { + dsFormUtil.savePageData("dsFormShow", json.bean.id); + parent.layer.close(index); + parent.refreshCode = '0'; } else { - winui.window.msg('请选择要删除的行', {icon: 2, time: 2000}); + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); } + }}); + } + + //人员选择 + $("body").on("click", "#toSalesManSelPeople", function(e){ + userReturnList = [].concat(salesManList); + _openNewWindows({ + url: "../../tpl/common/sysusersel.html", + title: "人员选择", + pageId: "sysuserselpage", + area: ['80vw', '80vh'], + callBack: function(refreshCode){ + if (refreshCode == '0') { + //移除所有tag + var tags = $('#salesMan').tagEditor('getTags')[0].tags; + for (i = 0; i < tags.length; i++) { + $('#salesMan').tagEditor('removeTag', tags[i]); + } + salesManList = [].concat(userReturnList); + //添加新的tag + $.each(salesManList, function(i, item){ + $('#salesMan').tagEditor('addTag', item.name); + }); + } else if (refreshCode == '-9999') { + winui.window.msg(systemLanguage["com.skyeye.operationFailed"][languageType], {icon: 2,time: 2000}); + } + }}); + }); + +/*********************** 商品表格操作 start ****************************/ + //新增行 + $("body").on("click", "#addRow", function() { + addRow(); + }); + + //删除行 + $("body").on("click", "#deleteRow", function() { + deleteRow(); + //计算价格 + calculatedTotalPrice(); + }); + + //新增行 + function addRow() { + var par = { + id: "row" + rowNum.toString(), //checkbox的id + trId: "tr" + rowNum.toString(), //行的id + materialId: "materialId" + rowNum.toString(), //商品id + unitId: "unitId" + rowNum.toString(), //规格id + currentTock: "currentTock" + rowNum.toString(), //库存id + nowNum: "nowNum" + rowNum.toString(), //剩余数量id + rkNum: "rkNum" + rowNum.toString(), //数量id + unitPrice: "unitPrice" + rowNum.toString(), //单价id + amountOfMoney: "amountOfMoney" + rowNum.toString(), //金额id + taxRate: "taxRate" + rowNum.toString(), //税率id + taxMoney: "taxMoney" + rowNum.toString(), //税额id + taxUnitPrice: "taxUnitPrice" + rowNum.toString(), //含税单价id + taxLastMoney: "taxLastMoney" + rowNum.toString(), //含税合计id + remark: "remark" + rowNum.toString() //备注id + }; + $("#useTable").append(getDataUseHandlebars(usetableTemplate, par)); + form.render(); + rowNum++; + //设置根据某列变化的颜色 + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + } + + //删除行 + function deleteRow() { + var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']:checked"); + if(checkRow.length > 0) { + $.each(checkRow, function(i, item) { + //删除allChooseProduct已选择的商品信息 + var trId = $(item).parent().parent().attr("trcusid"); + allChooseProduct[trId] = undefined; + //移除界面上的信息 + $(item).parent().parent().remove(); + }); + } else { + winui.window.msg('请选择要删除的行', {icon: 2, time: 2000}); } - - //客户选择 - $("body").on("click", "#customMationSel", function(e){ - _openNewWindows({ - url: "../../tpl/customermanage/customerChoose.html", - title: "选择客户", - pageId: "customerchooselist", - area: ['90vw', '90vh'], - callBack: function(refreshCode){ - if (refreshCode == '0') { - $("#customName").val(customerMation.customName); - } else if (refreshCode == '-9999') { - winui.window.msg(systemLanguage["com.skyeye.operationFailed"][languageType], {icon: 2,time: 2000}); - } - }}); - }); - - //商品选择 - $("body").on("click", ".chooseProductBtn", function(e){ - var trId = $(this).parent().parent().attr("trcusid"); - _openNewWindows({ - url: "../../tpl/material/materialChoose.html", - title: "选择商品", - pageId: "productlist", - area: ['90vw', '90vh'], - callBack: function(refreshCode){ - if (refreshCode == '0') { - //获取表格行号 - var thisRowNum = trId.replace("tr", ""); - //商品赋值 - allChooseProduct[trId] = productMation; - //表格商品名称赋值 - $("#materialId" + thisRowNum.toString()).val(allChooseProduct[trId].productName + "(" + allChooseProduct[trId].productModel + ")"); - //表格单位赋值 - $("#unitId" + thisRowNum.toString()).html(getDataUseHandlebars(selOption, {rows: allChooseProduct[trId].unitList})); - form.render('select'); - //计算价格 - calculatedTotalPrice(); - } else if (refreshCode == '-9999') { - winui.window.msg(systemLanguage["com.skyeye.operationFailed"][languageType], {icon: 2,time: 2000}); - } - }}); - }); - + } + + //客户选择 + $("body").on("click", "#customMationSel", function(e){ + _openNewWindows({ + url: "../../tpl/customermanage/customerChoose.html", + title: "选择客户", + pageId: "customerchooselist", + area: ['90vw', '90vh'], + callBack: function(refreshCode){ + if (refreshCode == '0') { + $("#customName").val(customerMation.customName); + } else if (refreshCode == '-9999') { + winui.window.msg(systemLanguage["com.skyeye.operationFailed"][languageType], {icon: 2,time: 2000}); + } + }}); + }); + + //商品选择 + $("body").on("click", ".chooseProductBtn", function(e){ + var trId = $(this).parent().parent().attr("trcusid"); + _openNewWindows({ + url: "../../tpl/material/materialChoose.html", + title: "选择商品", + pageId: "productlist", + area: ['90vw', '90vh'], + callBack: function(refreshCode){ + if (refreshCode == '0') { + //获取表格行号 + var thisRowNum = trId.replace("tr", ""); + //商品赋值 + allChooseProduct[trId] = productMation; + //表格商品名称赋值 + $("#materialId" + thisRowNum.toString()).val(allChooseProduct[trId].productName + "(" + allChooseProduct[trId].productModel + ")"); + //表格单位赋值 + $("#unitId" + thisRowNum.toString()).html(getDataUseHandlebars(selOption, {rows: allChooseProduct[trId].unitList})); + form.render('select'); + //计算价格 + calculatedTotalPrice(); + } else if (refreshCode == '-9999') { + winui.window.msg(systemLanguage["com.skyeye.operationFailed"][languageType], {icon: 2,time: 2000}); + } + }}); + }); + /*********************** 商品表格操作 end ****************************/ /*********************** 其他费用表格操作 start ****************************/ - - //其他费用变化 - $("body").on("input", ".otherPrice", function() { - //计算价格 - calculationPrice(); - }); - $("body").on("change", ".otherPrice", function() { - //计算价格 - calculationPrice(); - }); - - //计算其他费用总价格 - function calculationPrice(){ - var rowTr = $("#otherPriceTable tr"); - var allPrice = 0; - $.each(rowTr, function(i, item) { - //获取行坐标 - var rowNum = $(item).attr("trcusid").replace("tr", ""); - //获取 - var otherPrice = parseFloat(isNull($("#otherPrice" + rowNum).val()) ? 0 : $("#otherPrice" + rowNum).val()); - allPrice += otherPrice; - }); - $("#otherPriceTotal").html("费用合计:" + allPrice.toFixed(2)); - } - - //新增行 - $("body").on("click", "#addPriceRow", function() { - addPriceRow(); - }); - //删除行 - $("body").on("click", "#deletePriceRow", function() { - deletePriceRow(); + //其他费用变化 + $("body").on("input", ".otherPrice", function() { + //计算价格 + calculationPrice(); + }); + $("body").on("change", ".otherPrice", function() { + //计算价格 + calculationPrice(); + }); + + //计算其他费用总价格 + function calculationPrice(){ + var rowTr = $("#otherPriceTable tr"); + var allPrice = 0; + $.each(rowTr, function(i, item) { + //获取行坐标 + var rowNum = $(item).attr("trcusid").replace("tr", ""); + //获取 + var otherPrice = parseFloat(isNull($("#otherPrice" + rowNum).val()) ? 0 : $("#otherPrice" + rowNum).val()); + allPrice += otherPrice; }); + $("#otherPriceTotal").html("费用合计:" + allPrice.toFixed(2)); + } - //新增行 - function addPriceRow() { - var par = { - id: "row" + priceNum.toString(), //checkbox的id - trId: "tr" + priceNum.toString(), //行的id - inoutitemId: "inoutitemId" + priceNum.toString(), //支出项目id - otherPrice: "otherPrice" + priceNum.toString() //金额id - }; - $("#otherPriceTable").append(getDataUseHandlebars(otherTemplate, par)); - //赋值给支出项目 - $("#" + "inoutitemId" + priceNum.toString()).html(inoutitemHtml); - form.render('select'); - form.render('checkbox'); - priceNum++; - } + //新增行 + $("body").on("click", "#addPriceRow", function() { + addPriceRow(); + }); - //删除行 - function deletePriceRow() { - var checkRow = $("#otherPriceTable input[type='checkbox'][name='tableCheckRow']:checked"); - if(checkRow.length > 0) { - $.each(checkRow, function(i, item) { - $(item).parent().parent().remove(); - }); - } else { - winui.window.msg('请选择要删除的行', {icon: 2, time: 2000}); - } - //计算价格 - calculationPrice(); + //删除行 + $("body").on("click", "#deletePriceRow", function() { + deletePriceRow(); + }); + + //新增行 + function addPriceRow() { + var par = { + id: "row" + priceNum.toString(), //checkbox的id + trId: "tr" + priceNum.toString(), //行的id + inoutitemId: "inoutitemId" + priceNum.toString(), //支出项目id + otherPrice: "otherPrice" + priceNum.toString() //金额id + }; + $("#otherPriceTable").append(getDataUseHandlebars(otherTemplate, par)); + //赋值给支出项目 + $("#" + "inoutitemId" + priceNum.toString()).html(inoutitemHtml); + form.render('select'); + form.render('checkbox'); + priceNum++; + } + + //删除行 + function deletePriceRow() { + var checkRow = $("#otherPriceTable input[type='checkbox'][name='tableCheckRow']:checked"); + if(checkRow.length > 0) { + $.each(checkRow, function(i, item) { + $(item).parent().parent().remove(); + }); + } else { + winui.window.msg('请选择要删除的行', {icon: 2, time: 2000}); } + //计算价格 + calculationPrice(); + } /*********************** 其他费用表格操作 end ****************************/ - - $("body").on("click", "#cancle", function() { - parent.layer.close(index); - }); + + $("body").on("click", "#cancle", function() { + parent.layer.close(index); }); }); \ No newline at end of file diff --git a/erp/src/main/resources/template/js/salesoutlet/salesoutletadd.js b/erp/src/main/resources/template/js/salesoutlet/salesoutletadd.js index 6663d479d10f808c0096a2db0c889a8dd0144181..5d30e235c6917580dc5a5b8a4afe9f5fc168e7e9 100644 --- a/erp/src/main/resources/template/js/salesoutlet/salesoutletadd.js +++ b/erp/src/main/resources/template/js/salesoutlet/salesoutletadd.js @@ -92,8 +92,6 @@ layui.config({ 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.salePrice.toFixed(2));//单价 return false; } diff --git a/erp/src/main/resources/template/tpl/purchaseorder/purchaseorderpurchase.html b/erp/src/main/resources/template/tpl/purchaseorder/purchaseorderpurchase.html index ffbd2da468c351c5346a53fb35c9d3d388b18c53..793a42cc30cf38ddb39463ad0179a72cd5ce62ae 100644 --- a/erp/src/main/resources/template/tpl/purchaseorder/purchaseorderpurchase.html +++ b/erp/src/main/resources/template/tpl/purchaseorder/purchaseorderpurchase.html @@ -31,7 +31,7 @@
-
diff --git a/erp/src/main/resources/template/tpl/salesorder/salesorderpurchase.html b/erp/src/main/resources/template/tpl/salesorder/salesorderpurchase.html index d3fb7c8c83a13a75865e8a0266a1bdd5f01401b3..fa1b6b885d4d5cf16ac25967b0c714291cc44f0c 100644 --- a/erp/src/main/resources/template/tpl/salesorder/salesorderpurchase.html +++ b/erp/src/main/resources/template/tpl/salesorder/salesorderpurchase.html @@ -31,7 +31,7 @@
-
@@ -161,10 +161,15 @@
+
+ +
- - + + + +