“bc563c642c9a4e86dbbc73473eb93787b0c31e6e”上不存在“deploy/cpp_infer/CMakeLists_system.txt”
提交 2a1ca080 编写于 作者: Skyeye云's avatar Skyeye云

【ERP】采购订单子单据表格拆分完成

上级 6021d7c5
//计算总价 // 计算总价
function calculatedTotalPrice() { function calculatedTotalPrice() {
var allPrice = 0, taxLastMoneyPrice = 0; var allPrice = 0, taxLastMoneyPrice = 0;
$.each(initTableChooseUtil.getDataRowIndex('productList'), function(i, item) { $.each(initTableChooseUtil.getDataRowIndex('productList'), function (i, item) {
//获取行坐标 // 获取行坐标
var rowNum = item; var thisRowKey = item;
//获取数量 // 获取数量
var rkNum = parseInt(isNull($("#rkNum" + rowNum).val()) ? 0 : $("#rkNum" + rowNum).val()); var rkNum = parseInt(isNull($("#rkNum" + thisRowKey).val()) ? 0 : $("#rkNum" + thisRowKey).val());
//获取单价 // 获取单价
var unitPrice = parseFloat(isNull($("#unitPrice" + rowNum).val()) ? 0 : $("#unitPrice" + rowNum).val()); var unitPrice = parseFloat(isNull($("#unitPrice" + thisRowKey).val()) ? 0 : $("#unitPrice" + thisRowKey).val());
//获取税率 // 获取税率
var taxRate = parseFloat(isNull($("#taxRate" + rowNum).val()) ? 0 : $("#taxRate" + rowNum).val()) / 100; var taxRate = parseFloat(isNull($("#taxRate" + thisRowKey).val()) ? 0 : $("#taxRate" + thisRowKey).val()) / 100;
if('rkNum' === showTdByEdit){//数量 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)); $("#taxLastMoney" + thisRowKey).val((rkNum * taxRate * unitPrice + rkNum * unitPrice).toFixed(2));
}else if('unitPrice' === showTdByEdit){//单价 } 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)); $("#taxLastMoney" + thisRowKey).val((rkNum * taxRate * unitPrice + rkNum * unitPrice).toFixed(2));
}else if('amountOfMoney' === showTdByEdit){//金额 } 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){ if (rkNum != 0) {
$("#unitPrice" + rowNum).val((amountOfMoney / rkNum).toFixed(2)); $("#unitPrice" + thisRowKey).val((amountOfMoney / rkNum).toFixed(2));
$("#taxUnitPrice" + rowNum).val((amountOfMoney / rkNum * taxRate + amountOfMoney / rkNum).toFixed(2)); $("#taxUnitPrice" + thisRowKey).val((amountOfMoney / rkNum * taxRate + amountOfMoney / rkNum).toFixed(2));
$("#taxLastMoney" + rowNum).val((amountOfMoney * taxRate + amountOfMoney).toFixed(2)); $("#taxLastMoney" + thisRowKey).val((amountOfMoney * taxRate + amountOfMoney).toFixed(2));
} else { } else {
$("#unitPrice" + rowNum).val('0.00'); $("#unitPrice" + thisRowKey).val('0.00');
$("#taxUnitPrice" + rowNum).val('0.00'); $("#taxUnitPrice" + thisRowKey).val('0.00');
$("#taxLastMoney" + rowNum).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)); $("#taxLastMoney" + thisRowKey).val((rkNum * taxRate * unitPrice + rkNum * unitPrice).toFixed(2));
}else if('taxMoney' === showTdByEdit){//税额 } 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 (rkNum != 0) {
if(unitPrice != 0){ if (unitPrice != 0) {
$("#taxUnitPrice" + rowNum).val((taxMoney / rkNum + unitPrice).toFixed(2)); $("#taxUnitPrice" + thisRowKey).val((taxMoney / rkNum + unitPrice).toFixed(2));
$("#taxRate" + rowNum).val((taxMoney / unitPrice / rkNum * 100).toFixed(2)); $("#taxRate" + thisRowKey).val((taxMoney / unitPrice / rkNum * 100).toFixed(2));
} else { } else {
$("#taxUnitPrice" + rowNum).val('0.00'); $("#taxUnitPrice" + thisRowKey).val('0.00');
$("#taxRate" + rowNum).val('0.00'); $("#taxRate" + thisRowKey).val('0.00');
$("#unitPrice" + rowNum).val('0.00'); $("#unitPrice" + thisRowKey).val('0.00');
$("#amountOfMoney" + rowNum).val('0.00'); $("#amountOfMoney" + thisRowKey).val('0.00');
} }
if(amountOfMoney != 0){ if (amountOfMoney != 0) {
$("#taxLastMoney" + rowNum).val((amountOfMoney + taxMoney).toFixed(2)); $("#taxLastMoney" + thisRowKey).val((amountOfMoney + taxMoney).toFixed(2));
} else { } else {
$("#taxLastMoney" + rowNum).val('0.00'); $("#taxLastMoney" + thisRowKey).val('0.00');
} }
} else { } else {
$("#taxUnitPrice" + rowNum).val('0.00'); $("#taxUnitPrice" + thisRowKey).val('0.00');
$("#taxLastMoney" + rowNum).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()); var taxUnitPrice = parseFloat(isNull($("#taxUnitPrice" + thisRowKey).val()) ? 0 : $("#taxUnitPrice" + thisRowKey).val());
if(taxUnitPrice == 0){ if (taxUnitPrice == 0) {
$("#taxLastMoney" + rowNum).val('0.00'); $("#taxLastMoney" + thisRowKey).val('0.00');
$("#unitPrice" + rowNum).val('0.00'); $("#unitPrice" + thisRowKey).val('0.00');
$("#amountOfMoney" + rowNum).val('0.00'); $("#amountOfMoney" + thisRowKey).val('0.00');
$("#taxMoney" + rowNum).val('0.00'); $("#taxMoney" + thisRowKey).val('0.00');
$("#taxRate" + rowNum).val('0.00'); $("#taxRate" + thisRowKey).val('0.00');
return; return;
} }
//输出合计价税,税额,税率 //输出合计价税,税额,税率
if(unitPrice != 0){ if (unitPrice != 0) {
if(rkNum != 0 ){ if (rkNum != 0) {
$("#taxLastMoney" + rowNum).val((taxUnitPrice * rkNum).toFixed(2)); $("#taxLastMoney" + thisRowKey).val((taxUnitPrice * rkNum).toFixed(2));
$("#amountOfMoney" + rowNum).val((unitPrice * rowNum).toFixed(2)); $("#amountOfMoney" + thisRowKey).val((unitPrice * thisRowKey).toFixed(2));
} else { } else {
$("#taxLastMoney" + rowNum).val('0.00'); $("#taxLastMoney" + thisRowKey).val('0.00');
$("#amountOfMoney" + rowNum).val('0.00'); $("#amountOfMoney" + thisRowKey).val('0.00');
} }
$("#taxMoney" + rowNum).val((taxUnitPrice - unitPrice).toFixed(2)); $("#taxMoney" + thisRowKey).val((taxUnitPrice - unitPrice).toFixed(2));
$("#taxRate" + rowNum).val(((taxUnitPrice / unitPrice - 1) * 100).toFixed(2)); $("#taxRate" + thisRowKey).val(((taxUnitPrice / unitPrice - 1) * 100).toFixed(2));
} else { } else {
$("#taxLastMoney" + rowNum).val('0.00'); $("#taxLastMoney" + thisRowKey).val('0.00');
$("#unitPrice" + rowNum).val('0.00'); $("#unitPrice" + thisRowKey).val('0.00');
$("#amountOfMoney" + rowNum).val('0.00'); $("#amountOfMoney" + thisRowKey).val('0.00');
$("#taxMoney" + rowNum).val('0.00'); $("#taxMoney" + thisRowKey).val('0.00');
$("#taxRate" + rowNum).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()); var taxLastMoney = parseFloat(isNull($("#taxLastMoney" + thisRowKey).val()) ? 0 : $("#taxLastMoney" + thisRowKey).val());
if(taxLastMoney == 0){ if (taxLastMoney == 0) {
$("#taxUnitPrice" + rowNum).val('0.00'); $("#taxUnitPrice" + thisRowKey).val('0.00');
$("#unitPrice" + rowNum).val('0.00'); $("#unitPrice" + thisRowKey).val('0.00');
$("#amountOfMoney" + rowNum).val('0.00'); $("#amountOfMoney" + thisRowKey).val('0.00');
$("#taxMoney" + rowNum).val('0.00'); $("#taxMoney" + thisRowKey).val('0.00');
$("#taxRate" + rowNum).val('0.00'); $("#taxRate" + thisRowKey).val('0.00');
return; return;
} }
//输出含税单价,税额,税率 //输出含税单价,税额,税率
if(rkNum != 0 ){ if (rkNum != 0) {
if(unitPrice != 0){ if (unitPrice != 0) {
$("#taxUnitPrice" + rowNum).val((taxLastMoney / rkNum).toFixed(2)); $("#taxUnitPrice" + thisRowKey).val((taxLastMoney / rkNum).toFixed(2));
$("#taxMoney" + rowNum).val((taxLastMoney / rkNum - unitPrice).toFixed(2)); $("#taxMoney" + thisRowKey).val((taxLastMoney / rkNum - unitPrice).toFixed(2));
$("#taxRate" + rowNum).val(((taxLastMoney / rkNum / unitPrice - 1 ) * 100).toFixed(2)); $("#taxRate" + thisRowKey).val(((taxLastMoney / rkNum / unitPrice - 1) * 100).toFixed(2));
$("#amountOfMoney" + rowNum).val((unitPrice * rkNum).toFixed(2)); $("#amountOfMoney" + thisRowKey).val((unitPrice * rkNum).toFixed(2));
} else { } else {
$("#amountOfMoney" + rowNum).val('0.00'); $("#amountOfMoney" + thisRowKey).val('0.00');
$("#taxMoney" + rowNum).val('0.00'); $("#taxMoney" + thisRowKey).val('0.00');
$("#taxUnitPrice" + rowNum).val('0.00'); $("#taxUnitPrice" + thisRowKey).val('0.00');
$("#unitPrice" + rowNum).val('0.00'); $("#unitPrice" + thisRowKey).val('0.00');
} }
} else { } else {
$("#taxUnitPrice" + rowNum).val('0.00'); $("#taxUnitPrice" + thisRowKey).val('0.00');
$("#unitPrice" + rowNum).val('0.00'); $("#unitPrice" + thisRowKey).val('0.00');
$("#amountOfMoney" + rowNum).val('0.00'); $("#amountOfMoney" + thisRowKey).val('0.00');
$("#taxMoney" + rowNum).val('0.00'); $("#taxMoney" + thisRowKey).val('0.00');
$("#taxRate" + rowNum).val('0.00'); $("#taxRate" + thisRowKey).val('0.00');
} }
} }
allPrice += parseFloat($("#amountOfMoney" + rowNum).val()); allPrice += parseFloat($("#amountOfMoney" + thisRowKey).val());
taxLastMoneyPrice += parseFloat($("#taxLastMoney" + rowNum).val()); taxLastMoneyPrice += parseFloat($("#taxLastMoney" + thisRowKey).val());
}); });
$("#allPrice").html(allPrice.toFixed(2)); $("#allPrice").html(allPrice.toFixed(2));
$("#taxLastMoneyPrice").html(taxLastMoneyPrice.toFixed(2)); $("#taxLastMoneyPrice").html(taxLastMoneyPrice.toFixed(2));
//优惠率计算 //优惠率计算
var discount = parseFloat(isNull($("#discount").val()) ? 0 : $("#discount").val()); var discount = parseFloat(isNull($("#discount").val()) ? 0 : $("#discount").val());
//输出优惠金额 //输出优惠金额
......
/** /**
* 根据规格加载库存 * 根据规格加载库存
*
* @param rowNum 表格行坐标 * @param rowNum 表格行坐标
* @param depotId 仓库id * @param depotId 仓库id
*/ */
function loadTockByDepotAndMUnit(rowNum, depotId){ function loadTockByDepotAndMUnit(rowNum, depotId) {
//获取当前选中的规格 // 获取当前选中的规格
var chooseUnitId = $("#unitId" + rowNum).val(); var chooseUnitId = $("#mUnitId" + rowNum).val();
//当规格不为空时 // 当规格不为空时
if(!isNull(chooseUnitId)){ if (!isNull(chooseUnitId)) {
// 获取库存 // 获取库存
getStockAjaxByDepotAndNormsId(chooseUnitId, depotId, function (json) { getStockAjaxByDepotAndNormsId(chooseUnitId, depotId, function (json) {
var currentTock = 0; var currentTock = 0;
if(!isNull(json.bean)){ if (!isNull(json.bean)) {
currentTock = json.bean.currentTock; currentTock = json.bean.currentTock;
} }
$("#currentTock" + rowNum).html(currentTock); $("#currentTock" + rowNum).html(currentTock);
}); });
} else { } else {
//否则重置库存为空 // 否则重置库存为空
$("#currentTock" + rowNum).html(""); $("#currentTock" + rowNum).html("");
} }
} }
/** /**
* 根据仓库id加载表格中已经选择的商品规格的库存 * 根据仓库id加载表格中已经选择的商品规格的库存
*
* @param depotId 仓库id * @param depotId 仓库id
*/ */
function loadMaterialDepotStockByDepotId(depotId){ function loadMaterialDepotStockByDepotId(depotId) {
var rowTr = $("#useTable tr"); var rowTr = $("#useTable tr");
var normsIds = new Array(); var normsIds = new Array();
var normsIdsNum = new Array(); var normsIdsNum = new Array();
$.each(rowTr, function(i, item) { $.each(rowTr, function (i, item) {
// 获取行坐标 // 获取行坐标
var rowNum = $(item).attr("trcusid").replace("tr", ""); var rowNum = $(item).attr("trcusid").replace("tr", "");
var unitId = $("#unitId" + rowNum).val(); var unitId = $("#unitId" + rowNum).val();
if(!isNull(unitId)){ if (!isNull(unitId)) {
normsIds.push(unitId); normsIds.push(unitId);
normsIdsNum.push(rowNum); normsIdsNum.push(rowNum);
} }
}); });
if(normsIds.length == 0){ if (normsIds.length == 0) {
return; return;
} }
// 获取库存 // 获取库存
getStockAjaxByDepotAndNormsId(normsIds.join(','), depotId, function (json) { getStockAjaxByDepotAndNormsId(normsIds.join(','), depotId, function (json) {
if(normsIds.length == 1){ if (normsIds.length == 1) {
$("#currentTock" + normsIdsNum[0]).html(json.bean.currentTock); $("#currentTock" + normsIdsNum[0]).html(json.bean.currentTock);
} else { } else {
$.each(normsIdsNum, function(i, item) { $.each(normsIdsNum, function (i, item) {
$("#currentTock" + normsIdsNum[i]).html(json.rows[i].currentTock); $("#currentTock" + normsIdsNum[i]).html(json.rows[i].currentTock);
}); });
} }
...@@ -60,8 +62,12 @@ function loadMaterialDepotStockByDepotId(depotId){ ...@@ -60,8 +62,12 @@ function loadMaterialDepotStockByDepotId(depotId){
* @param depotId 仓库id,可为空 * @param depotId 仓库id,可为空
* @param callBack 回调函数 * @param callBack 回调函数
*/ */
function getStockAjaxByDepotAndNormsId(normsIds, depotId, callBack){ function getStockAjaxByDepotAndNormsId(normsIds, depotId, callBack) {
AjaxPostUtil.request({url: flowableBasePath + "material011", params: {depotId: depotId, normsIds: normsIds}, type: 'json', method: "POST", callback: function(json) { var params = {
depotId: depotId,
normsIds: normsIds
};
AjaxPostUtil.request({url: flowableBasePath + "material011", params: params, type: 'json', method: "POST", callback: function(json) {
if(typeof(callBack) == "function") { if(typeof(callBack) == "function") {
callBack(json); callBack(json);
} }
......
...@@ -4,8 +4,6 @@ var productionMation = {}; ...@@ -4,8 +4,6 @@ var productionMation = {};
// 根据那一列的值进行变化,默认根据数量 // 根据那一列的值进行变化,默认根据数量
var showTdByEdit = 'rkNum'; var showTdByEdit = 'rkNum';
// 表格的序号
var rowNum = 1;
// 兼容动态表单 // 兼容动态表单
var layedit, form; var layedit, form;
...@@ -61,12 +59,12 @@ layui.config({ ...@@ -61,12 +59,12 @@ layui.config({
{id: 'taxLastMoney', title: '合计价税', formType: 'input', width: '80', className: 'change-input taxLastMoney', verify: 'required|money'}, {id: 'taxLastMoney', title: '合计价税', formType: 'input', width: '80', className: 'change-input taxLastMoney', verify: 'required|money'},
{id: 'remark', title: '备注', formType: 'input', width: '100'} {id: 'remark', title: '备注', formType: 'input', width: '100'}
], ],
deleteRowCallback: function (trId) { deleteRowCallback: function (trcusid) {
allChooseProduct[trId] = undefined; delete allChooseProduct[trcusid];
// 计算价格 // 计算价格
calculatedTotalPrice(); calculatedTotalPrice();
}, },
addRowCallback: function (rowIndexStr) { addRowCallback: function (trcusid) {
// 设置根据某列变化的颜色 // 设置根据某列变化的颜色
$("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'});
}, },
...@@ -80,26 +78,27 @@ layui.config({ ...@@ -80,26 +78,27 @@ layui.config({
// 商品规格加载变化事件 // 商品规格加载变化事件
form.on('select(selectUnitProperty)', function(data) { form.on('select(selectUnitProperty)', function(data) {
var thisRowValue = data.value; var thisRowValue = data.value;
var thisRowNum = data.elem.id.replace("unitId", "");//获取当前行 var thisRowKey = data.elem.id.replace("mUnitId", "").toString();
// 当前当前行选中的商品信息 // 当前当前行选中的商品信息
if(!isNull(thisRowValue) && thisRowValue != '请选择') { if (!isNull(thisRowValue)) {
var product = allChooseProduct["tr" + thisRowNum.toString()]; var product = allChooseProduct["tr" + thisRowKey];
$.each(product.unitList, function(j, bean) { $.each(product.unitList, function (j, bean) {
if(thisRowValue == bean.id){//获取规格 if (thisRowValue == bean.id) {
//获取当前行数量 var rkNum = parseInt($("#rkNum" + thisRowKey).val());
var rkNum = parseInt($("#rkNum" + thisRowNum).val()); // 设置单价和金额
$("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 $("#unitPrice" + thisRowKey).val(bean.estimatePurchasePrice.toFixed(2));
$("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 $("#amountOfMoney" + thisRowKey).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));
return false; return false;
} }
}); });
} else { } 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(); calculatedTotalPrice();
}); });
...@@ -130,48 +129,31 @@ layui.config({ ...@@ -130,48 +129,31 @@ layui.config({
return false; return false;
}); });
function saveData(subType, approvalId){ function saveData(subType, approvalId) {
//获取已选商品数据 var dataList = initTableChooseUtil.getDataList('productList');
var rowTr = $("#useTable tr"); var noError = false;
if(rowTr.length == 0) { var tableData = [];
winui.window.msg('请选择商品.', {icon: 2, time: 2000}); $.each(dataList, function(i, item) {
return false;
}
var tableData = new Array();
var noError = false; //循环遍历表格数据时,是否有其他错误信息
$.each(rowTr, 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;
materialId: product.productId, 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;
} }
...@@ -200,69 +182,63 @@ layui.config({ ...@@ -200,69 +182,63 @@ layui.config({
// 供应商选择 // 供应商选择
$("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) { $("body").on("click", ".chooseProductBtn", function (e) {
var trId = $(this).parent().parent().attr("trcusid"); var trId = $(this).parent().parent().attr("trcusid");
erpOrderUtil.openMaterialChooseChoosePage(function (chooseProductMation) { erpOrderUtil.openMaterialChooseChoosePage(function (chooseProductMation) {
//获取表格行号 // 获取表格行号
var thisRowNum = trId.replace("tr", ""); var thisRowKey = trId.replace("tr", "");
//商品赋值 // 商品赋值
allChooseProduct[trId] = chooseProductMation; allChooseProduct[trId] = chooseProductMation;
//表格商品名称赋值 // 表格商品名称赋值
$("#materialId" + thisRowNum.toString()).val(allChooseProduct[trId].productName + "(" + allChooseProduct[trId].productModel + ")"); $("#materialId" + thisRowKey.toString()).val(chooseProductMation.productName + "(" + chooseProductMation.productModel + ")");
//表格单位赋值 // 表格单位赋值
$("#unitId" + thisRowNum.toString()).html(getDataUseHandlebars(selOption, {rows: allChooseProduct[trId].unitList})); $("#mUnitId" + thisRowKey.toString()).html(getDataUseHandlebars(selOption, {rows: chooseProductMation.unitList}));
form.render('select'); form.render('select');
//计算价格 //计算价格
calculatedTotalPrice(); calculatedTotalPrice();
}); });
}); });
//生产计划单选择 // 生产计划单选择
$("body").on("click", "#productionOrderSel", function (e) { $("body").on("click", "#productionOrderSel", function (e) {
_openNewWindows({ _openNewWindows({
url: "../../tpl/erpProduction/erpProductionNoSuccessChoose.html", url: "../../tpl/erpProduction/erpProductionNoSuccessChoose.html",
title: "选择生产计划单", title: "选择生产计划单",
pageId: "erpProductionNoSuccessChoose", pageId: "erpProductionNoSuccessChoose",
area: ['90vw', '90vh'], area: ['90vw', '90vh'],
callBack: function(refreshCode){ callBack: function(refreshCode) {
$("#productionOrder").val(productionMation.defaultNumber); $("#productionOrder").val(productionMation.defaultNumber);
//移除之前填写的所有行 initTableChooseUtil.deleteAllRow('productList');
var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']"); $.each(productionMation.norms, function(i, item) {
$.each(checkRow, function(i, item) { var params = {
//删除allChooseProduct已选择的商品信息 "materialId": item.product.productName + "(" + item.product.productModel + ")",
var trId = $(item).parent().parent().attr("trcusid"); "mUnitId": {
allChooseProduct[trId] = undefined; "html": getDataUseHandlebars(selOption, {rows: item.product.unitList}),
//移除界面上的信息 "value": item.normsId
$(item).parent().parent().remove(); },
}); "currentTock": item.currentTock,
$.each(productionMation.norms, function(i, item){ "rkNum": item.needNum,
addRow(); "unitPrice": item.unitPrice.toFixed(2),
//将规格所属的商品信息加入到对象中存储 "amountOfMoney": item.allPrice.toFixed(2),
allChooseProduct["tr" + (rowNum - 1)] = item.product; "taxRate": item.taxRate.toFixed(2),
//单位回显 "taxMoney": item.taxMoney.toFixed(2),
$("#unitId" + (rowNum - 1)).html(getDataUseHandlebars(selOption, {rows: item.product.unitList})); "taxUnitPrice": item.taxUnitPrice.toFixed(2),
$("#unitId" + (rowNum - 1)).val(item.normsId); "taxLastMoney": item.taxLastMoney.toFixed(2)
//商品回显 };
$("#materialId" + (rowNum - 1)).val(item.product.productName + "(" + item.product.productModel + ")"); var trcusid = initTableChooseUtil.resetData('productList', params);
$("#currentTock" + (rowNum - 1)).html(item.currentTock);//库存回显 // 将规格所属的商品信息加入到对象中存储
$("#rkNum" + (rowNum - 1)).val(item.needNum); allChooseProduct[trcusid] = item.product;
$("#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));
}); });
//渲染 // 渲染
form.render(); form.render();
//计算价格 // 计算价格
calculatedTotalPrice(); calculatedTotalPrice();
}}); }});
}); });
......
...@@ -42,32 +42,7 @@ ...@@ -42,32 +42,7 @@
<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" id="productList"> <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-xs4"> <div class="layui-form-item layui-col-xs4">
...@@ -148,27 +123,6 @@ ...@@ -148,27 +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>
<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>
......
...@@ -17,8 +17,8 @@ var initTableChooseUtil = { ...@@ -17,8 +17,8 @@ var initTableChooseUtil = {
// value: '默认值', // value: '默认值',
// valueKey: '回显时要展示数据里面的那个key', // valueKey: '回显时要展示数据里面的那个key',
// layFilter: '可以方便指定监听事件'} // layFilter: '可以方便指定监听事件'}
deleteRowCallback: function () {trId}, // 删除行之后的回调函数 deleteRowCallback: function () {trcusid}, // 删除行之后的回调函数
addRowCallback: function (rowIndexStr) {}, // 新增行之后的回调函数 addRowCallback: function (trcusid) {}, // 新增行之后的回调函数
form: null, // form表单对象 form: null, // form表单对象
}, // 表格参数数据 }, // 表格参数数据
...@@ -67,32 +67,33 @@ var initTableChooseUtil = { ...@@ -67,32 +67,33 @@ var initTableChooseUtil = {
/** /**
* 初始化点击事件 * 初始化点击事件
* *
* @param id * @param tableDivId 表格外层div的id
*/ */
initEvent: function (id) { initEvent: function (tableDivId) {
// 新增行 // 新增行
$("body").on("click", "#addRow" + id, function() { $("body").on("click", "#addRow" + tableDivId, function() {
var pointBtnBoxId = $(this).attr("id").replace("addRow", ""); var tableDivId = $(this).attr("id").replace("addRow", "");
initTableChooseUtil.addRow(pointBtnBoxId); initTableChooseUtil.addRow(tableDivId);
}); });
// 删除行 // 删除行
$("body").on("click", "#deleteRow" + id, function() { $("body").on("click", "#deleteRow" + tableDivId, function() {
var pointBtnBoxId = $(this).attr("id").replace("addRow", ""); var tableDivId = $(this).attr("id").replace("deleteRow", "");
initTableChooseUtil.deleteRow(pointBtnBoxId); initTableChooseUtil.deleteRow(tableDivId);
}); });
}, },
/** /**
* 新增行 * 新增行
* *
* @param id * @param tableDivId 表格外层div的id
*/ */
addRow: function (id) { addRow: function (tableDivId) {
// 获取配置 // 获取配置
var options = initTableChooseUtil.setting[id]; var options = initTableChooseUtil.setting[tableDivId];
var rowIndexStr = id + options.indexRow.toString(); var rowIndexStr = tableDivId + options.indexRow.toString();
var tbodyStr = '<tr trcusid="tr' + rowIndexStr + '"><td><input type="checkbox" rowId="row' + rowIndexStr + '" name="tableCheckRow"/></td>'; var trcusid = 'tr' + rowIndexStr;
var tbodyStr = '<tr trcusid="' + trcusid + '"><td><input type="checkbox" rowId="row' + rowIndexStr + '" name="tableCheckRow"/></td>';
$.each(options.cols, function (i, item) { $.each(options.cols, function (i, item) {
var tdId = item.id + rowIndexStr; var tdId = item.id + rowIndexStr;
var value = isNull(item.value) ? "" : item.value; var value = isNull(item.value) ? "" : item.value;
...@@ -110,27 +111,29 @@ var initTableChooseUtil = { ...@@ -110,27 +111,29 @@ var initTableChooseUtil = {
} }
}); });
tbodyStr += '</tr>'; tbodyStr += '</tr>';
$("#table" + id).append(tbodyStr); $("#table" + tableDivId).append(tbodyStr);
options.form.render(); options.form.render();
options.indexRow = options.indexRow + 1; options.indexRow = options.indexRow + 1;
initTableChooseUtil.setting[id] = options; initTableChooseUtil.setting[tableDivId] = options;
if(typeof(initTableChooseUtil.addRowCallback) == "function") { if(typeof(options.addRowCallback) == "function") {
initTableChooseUtil.addRowCallback(rowIndexStr); options.addRowCallback(trcusid);
} }
return trcusid;
}, },
/** /**
* 删除行 * 删除行
* *
* @param id * @param tableDivId 表格外层div的id
*/ */
deleteRow: function (id) { deleteRow: function (tableDivId) {
var checkRow = $("#table" + id + " input[type='checkbox'][name='tableCheckRow']:checked"); var checkRow = $("#table" + tableDivId + " input[type='checkbox'][name='tableCheckRow']:checked");
if (checkRow.length > 0) { if (checkRow.length > 0) {
var options = initTableChooseUtil.setting[tableDivId];
$.each(checkRow, function (i, item) { $.each(checkRow, function (i, item) {
var trId = $(item).parent().parent().attr("trcusid"); var trcusid = $(item).parent().parent().attr("trcusid");
if (typeof (initTableChooseUtil.deleteRowCallback) == "function") { if (typeof (options.deleteRowCallback) == "function") {
initTableChooseUtil.deleteRowCallback(trId); options.deleteRowCallback(trcusid);
} }
// 移除界面上的信息 // 移除界面上的信息
$(item).parent().parent().remove(); $(item).parent().parent().remove();
...@@ -140,20 +143,40 @@ var initTableChooseUtil = { ...@@ -140,20 +143,40 @@ var initTableChooseUtil = {
} }
}, },
/**
* 删除所有行
*
* @param tableDivId 表格外层div的id
*/
deleteAllRow: function (tableDivId) {
var trRow = $("#table" + tableDivId + " tr");
var options = initTableChooseUtil.setting[tableDivId];
$.each(trRow, function (i, item) {
var trId = $(item).attr("trcusid");
if (typeof (options.deleteRowCallback) == "function") {
options.deleteRowCallback(trId);
}
// 移除界面上的信息
$(item).remove();
});
},
/** /**
* 获取数据 * 获取数据
* *
* @param id * @param tableDivId 表格外层div的id
*/ */
getDataList: function (id) { getDataList: function (tableDivId) {
// 获取配置 // 获取配置
var options = initTableChooseUtil.setting[id]; var options = initTableChooseUtil.setting[tableDivId];
var result = []; var result = [];
var rowTr = $("#table" + id + " tr"); var rowTr = $("#table" + tableDivId + " tr");
$.each(rowTr, function (i, item) { $.each(rowTr, function (i, item) {
var trId = $(item).attr("trcusid"); var trcusid = $(item).attr("trcusid");
var rowIndexStr = trId.replace("tr", ""); var rowIndexStr = trcusid.replace("tr", "");
var row = {}; var row = {
"trcusid": trcusid
};
$.each(options.cols, function (j, bean) { $.each(options.cols, function (j, bean) {
var tdId = bean.id + rowIndexStr; var tdId = bean.id + rowIndexStr;
var value = ""; var value = "";
...@@ -174,18 +197,75 @@ var initTableChooseUtil = { ...@@ -174,18 +197,75 @@ var initTableChooseUtil = {
/** /**
* 获取指定表格每一行的rowIndex * 获取指定表格每一行的rowIndex
* *
* @param id * @param tableDivId 表格外层div的id
*/ */
getDataRowIndex: function (id) { getDataRowIndex: function (tableDivId) {
// 获取配置 // 获取配置
var result = []; var result = [];
var rowTr = $("#table" + id + " tr"); var rowTr = $("#table" + tableDivId + " tr");
$.each(rowTr, function (i, item) { $.each(rowTr, function (i, item) {
var trId = $(item).attr("trcusid"); var trcusid = $(item).attr("trcusid");
var rowIndexStr = trId.replace("tr", ""); var thisRowKey = trcusid.replace("tr", "");
result.push(rowIndexStr); result.push(thisRowKey);
}); });
return result; return result;
}, },
/**
* 重置数据
*
* @param tableDivId 表格外层div的id
* @param data 数据集合[]
*/
resetDataList: function (tableDivId, data) {
// 清空数据
initTableChooseUtil.deleteAllRow(tableDivId);
// 获取配置
var options = initTableChooseUtil.setting[tableDivId];
$.each(data, function (i, item) {
var trcusid = initTableChooseUtil.addRow(tableDivId);
initTableChooseUtil.setCols(options.cols, item, trcusid);
});
},
/**
* 重置单条数据
*
* @param tableDivId 表格外层div的id
* @param data 数据对象{}
*/
resetData: function (tableDivId, data) {
// 获取配置
var options = initTableChooseUtil.setting[tableDivId];
var trcusid = initTableChooseUtil.addRow(tableDivId);
initTableChooseUtil.setCols(options.cols, data, trcusid);
return trcusid;
},
/**
* 设置每一列的值
*
* @param cols 列集合
* @param data 数据对象{}
* @param trcusid 行id
*/
setCols: function (cols, data, trcusid) {
var rowIndexStr = trcusid.replace("tr", "");
$.each(cols, function (j, bean) {
var value = data[bean.id];
var tdId = bean.id + rowIndexStr;
var formType = bean.formType;
if (formType == 'input') {
$("#" + tdId).val(value);
} else if (formType == 'chooseInput') {
$("#" + tdId).val(value);
} else if (formType == 'select') {
$("#" + tdId).html(value["html"]);
$("#" + tdId).val(value["value"]);
} else if (formType == 'detail') {
$("#" + tdId).html(value);
}
});
}
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册