提交 a6bd0797 编写于 作者: Skyeye云's avatar Skyeye云

【ERP】采购退货单商品选择修改

上级 8ddabba8
//根据那一列的值进行变化,默认根据数量 // 根据那一列的值进行变化,默认根据数量
var showTdByEdit = 'rkNum'; var showTdByEdit = 'rkNum';
//表格的序号
var rowNum = 1;
// 兼容动态表单 // 兼容动态表单
var layedit, form; var layedit, form;
...@@ -24,10 +22,7 @@ layui.config({ ...@@ -24,10 +22,7 @@ layui.config({
form = layui.form; form = layui.form;
var inoutitemHtml = "";//支出项目 var inoutitemHtml = "";//支出项目
var priceNum = 1;
var usetableTemplate = $("#usetableTemplate").html(),
otherTemplate = $("#otherTemplate").html();
var selOption = getFileContent('tpl/template/select-option.tpl'); var selOption = getFileContent('tpl/template/select-option.tpl');
//已经选择的商品集合key:表格的行trId,value:商品信息 //已经选择的商品集合key:表格的行trId,value:商品信息
var allChooseProduct = {}; var allChooseProduct = {};
...@@ -56,38 +51,60 @@ layui.config({ ...@@ -56,38 +51,60 @@ layui.config({
erpOrderUtil.getDepotList(function (json){ erpOrderUtil.getDepotList(function (json){
// 加载仓库数据 // 加载仓库数据
$("#depotId").html(getDataUseHandlebars(selOption, json)); $("#depotId").html(getDataUseHandlebars(selOption, json));
// 初始化一行数据 });
addRow();
// 商品
initTableChooseUtil.initTable({
id: "productList",
cols: [
{id: 'materialId', title: '商品(型号)', formType: 'chooseInput', width: '150', iconClassName: 'chooseProductBtn', verify: 'required'},
{id: 'mUnitId', title: '单位', formType: 'select', width: '50', verify: 'required', layFilter: 'selectUnitProperty'},
{id: 'currentTock', title: '库存', formType: 'detail', width: '80'},
{id: 'rkNum', title: '数量', formType: 'input', width: '80', className: 'change-input rkNum', verify: 'required|number', value: '1'},
{id: 'unitPrice', title: '单价', formType: 'input', width: '80', className: 'change-input unitPrice', verify: 'required|money'},
{id: 'amountOfMoney', title: '金额', formType: 'input', width: '80', className: 'change-input amountOfMoney', verify: 'required|money'},
{id: 'taxRate', title: '税率(%)', formType: 'input', width: '80', className: 'change-input taxRate', verify: 'required|double', value: '0.00'},
{id: 'taxMoney', title: '税额', formType: 'input', width: '80', className: 'change-input taxMoney', verify: 'required|money'},
{id: 'taxUnitPrice', title: '含税单价', formType: 'input', width: '80', className: 'change-input taxUnitPrice', verify: 'required|money'},
{id: 'taxLastMoney', title: '合计价税', formType: 'input', width: '80', className: 'change-input taxLastMoney', verify: 'required|money'},
{id: 'remark', title: '备注', formType: 'input', width: '100'}
],
deleteRowCallback: function (trcusid) {
delete allChooseProduct[trcusid];
// 计算价格
calculatedTotalPrice();
},
addRowCallback: function (trcusid) {
// 设置根据某列变化的颜色
$("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'});
},
form: form,
minData: 1
});
// 其他费用
initTableChooseUtil.initTable({
id: "otherPriceTableList",
cols: [
{id: 'inoutitemId', title: '支出项目', formType: 'select', width: '120', verify: 'required', modelHtml: inoutitemHtml},
{id: 'otherPrice', title: '费用合计:0.00', formType: 'input', width: '120', className: 'otherPrice', verify: 'required|money', colHeaderId: 'otherPriceTotal'}
],
deleteRowCallback: function (trcusid) {
calculationPrice();
},
addRowCallback: function (trcusid) {
calculationPrice();
},
form: form
}); });
// 加载动态表单 // 加载动态表单
dsFormUtil.loadPageByCode("dsFormShow", sysDsFormWithCodeType["outIsPurchaseReturns"]["code"], null); dsFormUtil.loadPageByCode("dsFormShow", sysDsFormWithCodeType["outIsPurchaseReturns"]["code"], null);
matchingLanguage(); matchingLanguage();
//商品规格加载变化事件
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.estimatePurchasePrice.toFixed(2));//单价
return false;
}
});
} else {
$("#unitPrice" + thisRowNum).val("0.00");//重置单价为空
}
//加载库存 // 商品规格加载变化事件
loadTockByDepotAndMUnit(thisRowNum, $("#depotId").val()); mUnitChangeEvent(form, allChooseProduct);
//计算价格
calculatedTotalPrice();
});
// 仓库变化事件 // 仓库变化事件
form.on('select(depotId)', function(data) { form.on('select(depotId)', function(data) {
...@@ -121,63 +138,42 @@ layui.config({ ...@@ -121,63 +138,42 @@ layui.config({
}); });
function saveData(subType, approvalId) { function saveData(subType, approvalId) {
//获取已选商品数据 var result = initTableChooseUtil.getDataList('productList');
var rowTr = $("#useTable tr"); if (!result.checkResult) {
if(rowTr.length == 0) {
winui.window.msg('请选择商品.', {icon: 2, time: 2000});
return false; return false;
} }
var tableData = new Array(); var noError = false;
var noError = false; //循环遍历表格数据时,是否有其他错误信息 var tableData = [];
$.each(rowTr, function(i, item) { $.each(result.dataList, function(i, item) {
//获取行编号 //获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", ""); var thisRowKey = item["trcusid"].replace("tr", "");
//表格数量对象 if (parseInt(item.rkNum) == 0) {
var rkNum = $("#rkNum" + rowNum); $("#rkNum" + thisRowKey).addClass("layui-form-danger");
if(parseInt(rkNum.val()) == 0) { $("#rkNum" + thisRowKey).focus();
rkNum.addClass("layui-form-danger");
rkNum.focus();
winui.window.msg('数量不能为0', {icon: 2, time: 2000}); winui.window.msg('数量不能为0', {icon: 2, time: 2000});
noError = true; noError = true;
return false; return false;
} }
//商品对象 //商品对象
var product = allChooseProduct["tr" + rowNum.toString()]; var product = allChooseProduct["tr" + thisRowKey];
if(inTableDataArrayByAssetarId(product.productId, $("#unitId" + rowNum).val(), tableData)) { if (inTableDataArrayByAssetarId(product.productId, item.mUnitId, tableData)) {
winui.window.msg('一张单中不允许出现相同单位的商品信息.', {icon: 2, time: 2000}); winui.window.msg('一张单中不允许出现相同单位的商品信息.', {icon: 2, time: 2000});
noError = true; noError = true;
return false; return false;
} }
var row = { item["materialId"] = product.productId;
depotId: $("#depotId").val(), item["depotId"] = $("#depotId").val();
materialId: $("#materialId" + rowNum).val(), tableData.push(item);
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);
}); });
if(noError) { if (noError) {
return false; return false;
} }
//获取其他费用
var rowPriceTr = $("#otherPriceTable tr"); // 其他费用
var tablePriceData = new Array(); var otherPriceResult = initTableChooseUtil.getDataList('otherPriceTableList');
var otherMoney = 0; var otherMoney = 0;
$.each(rowPriceTr, function(i, item) { $.each(otherPriceResult.dataList, function(i, item) {
//获取行编号 otherMoney += parseFloat(isNull(item.otherPrice) ? 0 : item.otherPrice);
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);
}); });
var params = { var params = {
...@@ -191,7 +187,7 @@ layui.config({ ...@@ -191,7 +187,7 @@ layui.config({
changeAmount: isNull($("#changeAmount").val()) ? "0.00" : $("#changeAmount").val(), changeAmount: isNull($("#changeAmount").val()) ? "0.00" : $("#changeAmount").val(),
depotheadStr: JSON.stringify(tableData), depotheadStr: JSON.stringify(tableData),
otherMoney: otherMoney.toFixed(2), otherMoney: otherMoney.toFixed(2),
otherMoneyList: JSON.stringify(tablePriceData), otherMoneyList: JSON.stringify(otherPriceResult.dataList),
submitType: submitType, submitType: submitType,
subType: subType, subType: subType,
approvalId: approvalId approvalId: approvalId
...@@ -203,152 +199,19 @@ layui.config({ ...@@ -203,152 +199,19 @@ layui.config({
}}); }});
} }
/*********************** 商品表格操作 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
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", "#supplierNameSel", function (e) { $("body").on("click", "#supplierNameSel", function (e) {
sysSupplierUtil.openSysSupplierChoosePage(function (supplierMation){ sysSupplierUtil.openSysSupplierChoosePage(function (supplierMation){
$("#supplierName").val(supplierMation.supplierName); $("#supplierName").val(supplierMation.supplierName);
}); });
}); });
//商品选择 // 加载选品选择事件
$("body").on("click", ".chooseProductBtn", function (e) { initChooseProductBtnEnent(form, function(trId, chooseProductMation) {
var trId = $(this).parent().parent().attr("trcusid"); // 商品赋值
erpOrderUtil.openMaterialChooseChoosePage(function (chooseProductMation) { allChooseProduct[trId] = chooseProductMation;
//获取表格行号
var thisRowNum = 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}));
form.render('select');
//计算价格
calculatedTotalPrice();
});
});
/*********************** 商品表格操作 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();
});
//新增行
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() { $("body").on("click", "#cancle", function() {
parent.layer.close(index); parent.layer.close(index);
}); });
......
//根据那一列的值进行变化,默认根据数量 // 根据那一列的值进行变化,默认根据数量
var showTdByEdit = 'rkNum'; var showTdByEdit = 'rkNum';
//表格的序号
var rowNum = 1;
// 兼容动态表单 // 兼容动态表单
var layedit, form; var layedit, form;
...@@ -24,10 +22,7 @@ layui.config({ ...@@ -24,10 +22,7 @@ layui.config({
form = layui.form; form = layui.form;
var inoutitemHtml = "";//支出项目 var inoutitemHtml = "";//支出项目
var priceNum = 1;
var usetableTemplate = $("#usetableTemplate").html(),
otherTemplate = $("#otherTemplate").html();
var selOption = getFileContent('tpl/template/select-option.tpl'); var selOption = getFileContent('tpl/template/select-option.tpl');
//已经选择的商品集合key:表格的行trId,value:商品信息 //已经选择的商品集合key:表格的行trId,value:商品信息
var allChooseProduct = {}; var allChooseProduct = {};
...@@ -83,37 +78,47 @@ layui.config({ ...@@ -83,37 +78,47 @@ layui.config({
$("#arrears").html(json.bean.arrears.toFixed(2)); $("#arrears").html(json.bean.arrears.toFixed(2));
$("#otherPriceTotal").html("费用合计:" + json.bean.otherMoney.toFixed(2)); $("#otherPriceTotal").html("费用合计:" + json.bean.otherMoney.toFixed(2));
//加载列表项 initTable();
$.each(json.bean.norms, function(i, item){
addRow(); // 回显商品列表
if(i == 0){ initTableChooseUtil.deleteAllRow('productList');
$.each(json.bean.norms, function(i, item) {
if (i == 0) {
$("#depotId").val(item.depotId); $("#depotId").val(item.depotId);
} }
//将规格所属的商品信息加入到对象中存储 var params = {
allChooseProduct["tr" + (rowNum - 1)] = item.product; "materialId": item.product.productName + "(" + item.product.productModel + ")",
//单位回显 "mUnitId": {
$("#unitId" + (rowNum - 1)).html(getDataUseHandlebars(selOption, {rows: item.product.unitList})); "html": getDataUseHandlebars(selOption, {rows: item.product.unitList}),
$("#unitId" + (rowNum - 1)).val(item.mUnitId); "value": item.mUnitId
//商品回显 },
$("#materialId" + (rowNum - 1)).val(item.product.productName + "(" + item.product.productModel + ")"); "currentTock": item.currentTock,
$("#currentTock" + (rowNum - 1)).html(item.currentTock);//库存回显 "rkNum": item.operNum,
//数量回显 "unitPrice": item.unitPrice.toFixed(2),
$("#rkNum" + (rowNum - 1)).val(item.operNum); "amountOfMoney": item.allPrice.toFixed(2),
$("#unitPrice" + (rowNum - 1)).val(item.unitPrice.toFixed(2)); "taxRate": item.taxRate.toFixed(2),
$("#amountOfMoney" + (rowNum - 1)).val(item.allPrice.toFixed(2)); "taxMoney": item.taxMoney.toFixed(2),
$("#taxRate" + (rowNum - 1)).val(item.taxRate.toFixed(2)); "taxUnitPrice": item.taxUnitPrice.toFixed(2),
$("#taxMoney" + (rowNum - 1)).val(item.taxMoney.toFixed(2)); "taxLastMoney": item.taxLastMoney.toFixed(2),
$("#taxUnitPrice" + (rowNum - 1)).val(item.taxUnitPrice.toFixed(2)); "remark": item.remark
$("#taxLastMoney" + (rowNum - 1)).val(item.taxLastMoney.toFixed(2)); };
$("#remark" + (rowNum - 1)).val(item.remark); var trcusid = initTableChooseUtil.resetData('productList', params);
// 将规格所属的商品信息加入到对象中存储
allChooseProduct[trcusid] = item.product;
}); });
//加载其他费用 // 回显其他费用
$.each(json.bean.otherMoneyList, function(i, item){ initTableChooseUtil.deleteAllRow('otherPriceTableList');
addPriceRow(); $.each(json.bean.otherMoneyList, function(i, item) {
$("#inoutitemId" + (priceNum - 1)).val(item.inoutitemId); var params = {
$("#otherPrice" + (priceNum - 1)).val(parseFloat(item.otherPrice).toFixed(2)); "inoutitemId": {
"value": item.inoutitemId
},
"otherPrice": parseFloat(item.otherPrice).toFixed(2)
};
initTableChooseUtil.resetData('otherPriceTableList', params);
}); });
erpOrderUtil.orderEditPageSetBtnBySubmitType(submitType, json.bean.state); erpOrderUtil.orderEditPageSetBtnBySubmitType(submitType, json.bean.state);
textool.init({eleId: 'remark', maxlength: 200}); textool.init({eleId: 'remark', maxlength: 200});
...@@ -126,29 +131,55 @@ layui.config({ ...@@ -126,29 +131,55 @@ layui.config({
}}); }});
} }
//商品规格加载变化事件 function initTable() {
form.on('select(selectUnitProperty)', function(data) { // 商品
var thisRowValue = data.value; initTableChooseUtil.initTable({
var thisRowNum = data.elem.id.replace("unitId", "");//获取当前行 id: "productList",
//当前当前行选中的商品信息 cols: [
if(!isNull(thisRowValue) && thisRowValue != '请选择') { {id: 'materialId', title: '商品(型号)', formType: 'chooseInput', width: '150', iconClassName: 'chooseProductBtn', verify: 'required'},
var product = allChooseProduct["tr" + thisRowNum.toString()]; {id: 'mUnitId', title: '单位', formType: 'select', width: '50', verify: 'required', layFilter: 'selectUnitProperty'},
$.each(product.unitList, function(j, bean) { {id: 'currentTock', title: '库存', formType: 'detail', width: '80'},
if(thisRowValue == bean.id){//获取规格 {id: 'rkNum', title: '数量', formType: 'input', width: '80', className: 'change-input rkNum', verify: 'required|number', value: '1'},
//获取当前行数量 {id: 'unitPrice', title: '单价', formType: 'input', width: '80', className: 'change-input unitPrice', verify: 'required|money'},
var rkNum = parseInt($("#rkNum" + thisRowNum).val()); {id: 'amountOfMoney', title: '金额', formType: 'input', width: '80', className: 'change-input amountOfMoney', verify: 'required|money'},
$("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 {id: 'taxRate', title: '税率(%)', formType: 'input', width: '80', className: 'change-input taxRate', verify: 'required|double', value: '0.00'},
return false; {id: 'taxMoney', title: '税额', formType: 'input', width: '80', className: 'change-input taxMoney', verify: 'required|money'},
} {id: 'taxUnitPrice', title: '含税单价', formType: 'input', width: '80', className: 'change-input taxUnitPrice', verify: 'required|money'},
}); {id: 'taxLastMoney', title: '合计价税', formType: 'input', width: '80', className: 'change-input taxLastMoney', verify: 'required|money'},
} else { {id: 'remark', title: '备注', formType: 'input', width: '100'}
$("#unitPrice" + thisRowNum).val("0.00");//重置单价为空 ],
} deleteRowCallback: function (trcusid) {
//加载库存 delete allChooseProduct[trcusid];
loadTockByDepotAndMUnit(thisRowNum, $("#depotId").val()); // 计算价格
//计算价格 calculatedTotalPrice();
calculatedTotalPrice(); },
}); addRowCallback: function (trcusid) {
// 设置根据某列变化的颜色
$("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'});
},
form: form,
minData: 1
});
// 其他费用
initTableChooseUtil.initTable({
id: "otherPriceTableList",
cols: [
{id: 'inoutitemId', title: '支出项目', formType: 'select', width: '120', verify: 'required', modelHtml: inoutitemHtml},
{id: 'otherPrice', title: '费用合计:0.00', formType: 'input', width: '120', className: 'otherPrice', verify: 'required|money', colHeaderId: 'otherPriceTotal'}
],
deleteRowCallback: function (trcusid) {
calculationPrice();
},
addRowCallback: function (trcusid) {
calculationPrice();
},
form: form
});
}
// 商品规格加载变化事件
mUnitChangeEvent(form, allChooseProduct);
// 仓库变化事件 // 仓库变化事件
form.on('select(depotId)', function(data) { form.on('select(depotId)', function(data) {
...@@ -190,63 +221,42 @@ layui.config({ ...@@ -190,63 +221,42 @@ layui.config({
}); });
function saveData(subType, approvalId) { function saveData(subType, approvalId) {
//获取已选商品数据 var result = initTableChooseUtil.getDataList('productList');
var rowTr = $("#useTable tr"); if (!result.checkResult) {
if(rowTr.length == 0) {
winui.window.msg('请选择商品.', {icon: 2, time: 2000});
return false; return false;
} }
var tableData = new Array(); var noError = false;
var noError = false; //循环遍历表格数据时,是否有其他错误信息 var tableData = [];
$.each(rowTr, function(i, item) { $.each(result.dataList, function(i, item) {
//获取行编号 //获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", ""); var thisRowKey = item["trcusid"].replace("tr", "");
//表格数量对象 if (parseInt(item.rkNum) == 0) {
var rkNum = $("#rkNum" + rowNum); $("#rkNum" + thisRowKey).addClass("layui-form-danger");
if(parseInt(rkNum.val()) == 0) { $("#rkNum" + thisRowKey).focus();
rkNum.addClass("layui-form-danger");
rkNum.focus();
winui.window.msg('数量不能为0', {icon: 2, time: 2000}); winui.window.msg('数量不能为0', {icon: 2, time: 2000});
noError = true; noError = true;
return false; return false;
} }
//商品对象 //商品对象
var product = allChooseProduct["tr" + rowNum.toString()]; var product = allChooseProduct["tr" + thisRowKey];
if(inTableDataArrayByAssetarId(product.productId, $("#unitId" + rowNum).val(), tableData)) { if (inTableDataArrayByAssetarId(product.productId, item.mUnitId, tableData)) {
winui.window.msg('一张单中不允许出现相同单位的商品信息.', {icon: 2, time: 2000}); winui.window.msg('一张单中不允许出现相同单位的商品信息.', {icon: 2, time: 2000});
noError = true; noError = true;
return false; return false;
} }
var row = { item["materialId"] = product.productId;
depotId: $("#depotId").val(), item["depotId"] = $("#depotId").val();
materialId: $("#materialId" + rowNum).val(), tableData.push(item);
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);
}); });
if(noError) { if (noError) {
return false; return false;
} }
//获取其他费用
var rowPriceTr = $("#otherPriceTable tr"); // 其他费用
var tablePriceData = new Array(); var otherPriceResult = initTableChooseUtil.getDataList('otherPriceTableList');
var otherMoney = 0; var otherMoney = 0;
$.each(rowPriceTr, function(i, item) { $.each(otherPriceResult.dataList, function(i, item) {
//获取行编号 otherMoney += parseFloat(isNull(item.otherPrice) ? 0 : item.otherPrice);
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);
}); });
var params = { var params = {
...@@ -260,7 +270,7 @@ layui.config({ ...@@ -260,7 +270,7 @@ layui.config({
changeAmount: isNull($("#changeAmount").val()) ? "0.00" : $("#changeAmount").val(), changeAmount: isNull($("#changeAmount").val()) ? "0.00" : $("#changeAmount").val(),
depotheadStr: JSON.stringify(tableData), depotheadStr: JSON.stringify(tableData),
otherMoney: otherMoney.toFixed(2), otherMoney: otherMoney.toFixed(2),
otherMoneyList: JSON.stringify(tablePriceData), otherMoneyList: JSON.stringify(otherPriceResult.dataList),
subType: subType, subType: subType,
submitType: submitType, submitType: submitType,
approvalId: approvalId, approvalId: approvalId,
...@@ -273,59 +283,6 @@ layui.config({ ...@@ -273,59 +283,6 @@ layui.config({
}}); }});
} }
/*********************** 商品表格操作 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
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", "#supplierNameSel", function (e) { $("body").on("click", "#supplierNameSel", function (e) {
sysSupplierUtil.openSysSupplierChoosePage(function (supplierMation){ sysSupplierUtil.openSysSupplierChoosePage(function (supplierMation){
...@@ -333,91 +290,11 @@ layui.config({ ...@@ -333,91 +290,11 @@ layui.config({
}); });
}); });
//商品选择 // 加载选品选择事件
$("body").on("click", ".chooseProductBtn", function (e) { initChooseProductBtnEnent(form, function(trId, chooseProductMation) {
var trId = $(this).parent().parent().attr("trcusid"); // 商品赋值
erpOrderUtil.openMaterialChooseChoosePage(function (chooseProductMation) { allChooseProduct[trId] = chooseProductMation;
//获取表格行号
var thisRowNum = 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}));
form.render('select');
//计算价格
calculatedTotalPrice();
});
});
/*********************** 商品表格操作 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();
});
//新增行
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() { $("body").on("click", "#cancle", function() {
parent.layer.close(index); parent.layer.close(index);
......
...@@ -35,33 +35,8 @@ ...@@ -35,33 +35,8 @@
</div> </div>
<div class="layui-form-item layui-col-xs12"> <div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">列表项<i class="red">*</i></label> <label class="layui-form-label">列表项<i class="red">*</i></label>
<div class="layui-input-block"> <div class="layui-input-block" id="productList">
<div class="winui-toolbar">
<div class="winui-tool" style="text-align: left;">
<button id="addRow" class="winui-toolbtn" type="button"><i class="fa fa-plus" aria-hidden="true"></i>新增行</button>
<button id="deleteRow" class="winui-toolbtn" type="button"><i class="fa fa-trash-o" aria-hidden="true"></i>删除行</button>
</div>
</div>
<table class="layui-table">
<thead>
<tr>
<th style="width: 30px;"></th>
<th style="width: 150px;">商品(型号)</th>
<th style="width: 50px;">单位</th>
<th style="width: 80px;">库存</th>
<th style="width: 80px;">数量</th>
<th style="width: 80px;">单价</th>
<th style="width: 80px;">金额</th>
<th style="width: 80px;">税率(%)</th>
<th style="width: 80px;">税额</th>
<th style="width: 80px;">含税单价</th>
<th style="width: 80px;">合计价税</th>
<th style="min-width: 100px;">备注</th>
</tr>
</thead>
<tbody id="useTable" class="insurance-table">
</tbody>
</table>
</div> </div>
</div> </div>
<div class="layui-form-item layui-col-xs3"> <div class="layui-form-item layui-col-xs3">
...@@ -130,24 +105,8 @@ ...@@ -130,24 +105,8 @@
</div> </div>
<div class="layui-form-item layui-col-xs12"> <div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">其他费用</label> <label class="layui-form-label">其他费用</label>
<div class="layui-input-block"> <div class="layui-input-block" id="otherPriceTableList">
<div class="winui-toolbar">
<div class="winui-tool" style="text-align: left;">
<button id="addPriceRow" class="winui-toolbtn" type="button"><i class="fa fa-plus" aria-hidden="true"></i>新增行</button>
<button id="deletePriceRow" class="winui-toolbtn" type="button"><i class="fa fa-trash-o" aria-hidden="true"></i>删除行</button>
</div>
</div>
<table class="layui-table">
<thead>
<tr>
<th style="width: 30px;"></th>
<th style="width: 120px;">支出项目:</th>
<th id="otherPriceTotal" style="width: 120px;">费用合计:0.00</th>
</tr>
</thead>
<tbody id="otherPriceTable" class="insurance-table">
</tbody>
</table>
</div> </div>
</div> </div>
<div id="dsFormShow"> <div id="dsFormShow">
...@@ -164,36 +123,6 @@ ...@@ -164,36 +123,6 @@
</form> </form>
</div> </div>
<!-- usetableTemplate -->
<script type="text/x-handlebars-template" id="usetableTemplate">
<tr trcusid="{{trId}}">
<td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td>
<td>
<input type="text" id="{{materialId}}" name="{{materialId}}" placeholder="请选择商品" class="layui-input" readonly="readonly"/>
<i class="fa fa-plus-circle input-icon chooseProductBtn" style="top: 12px;"></i>
</td>
<td><select id="{{unitId}}" lay-filter="selectUnitProperty" lay-search win-verify="required"></select></td>
<td id="{{currentTock}}"></td>
<td><input type="text" class="layui-input change-input rkNum" value="1" id="{{rkNum}}" win-verify="required|number"/></td>
<td><input type="text" class="layui-input change-input unitPrice" id="{{unitPrice}}" win-verify="required|money"/></td>
<td><input type="text" class="layui-input change-input amountOfMoney" id="{{amountOfMoney}}" win-verify="required|money"/></td>
<td><input type="text" class="layui-input change-input taxRate" value="0.00" id="{{taxRate}}" win-verify="required|double"/></td>
<td><input type="text" class="layui-input change-input taxMoney" id="{{taxMoney}}" win-verify="required|money"/></td>
<td><input type="text" class="layui-input change-input taxUnitPrice" id="{{taxUnitPrice}}" win-verify="required|money"/></td>
<td><input type="text" class="layui-input change-input taxLastMoney" id="{{taxLastMoney}}" win-verify="required|money"/></td>
<td><input type="text" class="layui-input" id="{{remark}}"/></td>
</tr>
</script>
<!-- otherTemplate -->
<script type="text/x-handlebars-template" id="otherTemplate">
<tr trcusid="{{trId}}">
<td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td>
<td><select id="{{inoutitemId}}" lay-search win-verify="required"></select></td>
<td><input type="text" class="layui-input otherPrice" id="{{otherPrice}}" win-verify="required||money"/></td>
</tr>
</script>
<script src="../../assets/lib/layui/layui.js"></script> <script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script> <script src="../../assets/lib/layui/custom.js"></script>
<script src="../../js/erpcommon/calculatePrice.js"></script> <script src="../../js/erpcommon/calculatePrice.js"></script>
......
...@@ -35,33 +35,8 @@ ...@@ -35,33 +35,8 @@
</div> </div>
<div class="layui-form-item layui-col-xs12"> <div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">列表项<i class="red">*</i></label> <label class="layui-form-label">列表项<i class="red">*</i></label>
<div class="layui-input-block"> <div class="layui-input-block" id="productList">
<div class="winui-toolbar">
<div class="winui-tool" style="text-align: left;">
<button id="addRow" class="winui-toolbtn" type="button"><i class="fa fa-plus" aria-hidden="true"></i>新增行</button>
<button id="deleteRow" class="winui-toolbtn" type="button"><i class="fa fa-trash-o" aria-hidden="true"></i>删除行</button>
</div>
</div>
<table class="layui-table">
<thead>
<tr>
<th style="width: 30px;"></th>
<th style="width: 150px;">商品(型号)</th>
<th style="width: 50px;">单位</th>
<th style="width: 80px;">库存</th>
<th style="width: 80px;">数量</th>
<th style="width: 80px;">单价</th>
<th style="width: 80px;">金额</th>
<th style="width: 80px;">税率(%)</th>
<th style="width: 80px;">税额</th>
<th style="width: 80px;">含税单价</th>
<th style="width: 80px;">合计价税</th>
<th style="min-width: 100px;">备注</th>
</tr>
</thead>
<tbody id="useTable" class="insurance-table">
</tbody>
</table>
</div> </div>
</div> </div>
<div class="layui-form-item layui-col-xs3"> <div class="layui-form-item layui-col-xs3">
...@@ -130,24 +105,8 @@ ...@@ -130,24 +105,8 @@
</div> </div>
<div class="layui-form-item layui-col-xs12"> <div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">其他费用</label> <label class="layui-form-label">其他费用</label>
<div class="layui-input-block"> <div class="layui-input-block" id="otherPriceTableList">
<div class="winui-toolbar">
<div class="winui-tool" style="text-align: left;">
<button id="addPriceRow" class="winui-toolbtn" type="button"><i class="fa fa-plus" aria-hidden="true"></i>新增行</button>
<button id="deletePriceRow" class="winui-toolbtn" type="button"><i class="fa fa-trash-o" aria-hidden="true"></i>删除行</button>
</div>
</div>
<table class="layui-table">
<thead>
<tr>
<th style="width: 30px;"></th>
<th style="width: 120px;">支出项目:</th>
<th id="otherPriceTotal" style="width: 120px;">费用合计:0.00</th>
</tr>
</thead>
<tbody id="otherPriceTable" class="insurance-table">
</tbody>
</table>
</div> </div>
</div> </div>
<div id="dsFormShow"> <div id="dsFormShow">
...@@ -165,36 +124,6 @@ ...@@ -165,36 +124,6 @@
</form> </form>
</div> </div>
<!-- usetableTemplate -->
<script type="text/x-handlebars-template" id="usetableTemplate">
<tr trcusid="{{trId}}">
<td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td>
<td>
<input type="text" id="{{materialId}}" name="{{materialId}}" placeholder="请选择商品" class="layui-input" readonly="readonly"/>
<i class="fa fa-plus-circle input-icon chooseProductBtn" style="top: 12px;"></i>
</td>
<td><select id="{{unitId}}" lay-filter="selectUnitProperty" lay-search win-verify="required"></select></td>
<td id="{{currentTock}}"></td>
<td><input type="text" class="layui-input change-input rkNum" value="1" id="{{rkNum}}" win-verify="required|number"/></td>
<td><input type="text" class="layui-input change-input unitPrice" id="{{unitPrice}}" win-verify="required|money"/></td>
<td><input type="text" class="layui-input change-input amountOfMoney" id="{{amountOfMoney}}" win-verify="required|money"/></td>
<td><input type="text" class="layui-input change-input taxRate" value="0.00" id="{{taxRate}}" win-verify="required|double"/></td>
<td><input type="text" class="layui-input change-input taxMoney" id="{{taxMoney}}" win-verify="required|money"/></td>
<td><input type="text" class="layui-input change-input taxUnitPrice" id="{{taxUnitPrice}}" win-verify="required|money"/></td>
<td><input type="text" class="layui-input change-input taxLastMoney" id="{{taxLastMoney}}" win-verify="required|money"/></td>
<td><input type="text" class="layui-input" id="{{remark}}"/></td>
</tr>
</script>
<!-- otherTemplate -->
<script type="text/x-handlebars-template" id="otherTemplate">
<tr trcusid="{{trId}}">
<td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td>
<td><select id="{{inoutitemId}}" lay-search win-verify="required"></select></td>
<td><input type="text" class="layui-input otherPrice" id="{{otherPrice}}" win-verify="required||money"/></td>
</tr>
</script>
<script src="../../assets/lib/layui/layui.js"></script> <script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script> <script src="../../assets/lib/layui/custom.js"></script>
<script src="../../js/erpcommon/calculatePrice.js"></script> <script src="../../js/erpcommon/calculatePrice.js"></script>
......
...@@ -253,6 +253,9 @@ var initTableChooseUtil = { ...@@ -253,6 +253,9 @@ var initTableChooseUtil = {
var options = initTableChooseUtil.setting[tableDivId]; var options = initTableChooseUtil.setting[tableDivId];
var trcusid = initTableChooseUtil.addRow(tableDivId); var trcusid = initTableChooseUtil.addRow(tableDivId);
initTableChooseUtil.setCols(options.cols, data, trcusid); initTableChooseUtil.setCols(options.cols, data, trcusid);
if (typeof (options.addRowCallback) == "function") {
options.addRowCallback(trcusid);
}
return trcusid; return trcusid;
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册