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

解决采购订单转采购入库单失败的问题

上级 2d86d3fb
...@@ -9,432 +9,466 @@ var showTdByEdit = 'rkNum'; ...@@ -9,432 +9,466 @@ var showTdByEdit = 'rkNum';
//表格的序号 //表格的序号
var rowNum = 1; var rowNum = 1;
// 兼容动态表单
var layedit, form;
layui.config({ layui.config({
base: basePath, base: basePath,
version: skyeyeVersion version: skyeyeVersion
}).extend({ }).extend({
window: 'js/winui.window' window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'laydate', 'textool'], function(exports) { }).define(['window', 'jquery', 'winui', 'laydate', 'textool'].concat(dsFormUtil.mastHaveImport), function(exports) {
winui.renderColor(); winui.renderColor();
layui.use(['form'], function(form) { var index = parent.layer.getFrameIndex(window.name);
var index = parent.layer.getFrameIndex(window.name); var $ = layui.$,
var $ = layui.$, laydate = layui.laydate,
laydate = layui.laydate, textool = layui.textool;
textool = layui.textool; layedit = layui.layedit,
var inoutitemHtml = "";//支出项目 form = layui.form;
var cgddOrderNum = "";//采购订单编号
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 inoutitemHtml = "";//支出项目
systemCommonUtil.getSysInoutitemListByType(2, function(json){
// 加载支出项目
inoutitemHtml = getDataUseHandlebars(selOption, json);
});
// 初始化仓库 var cgddOrderNum = "";//采购订单编号
erpOrderUtil.getDepotList(function (json){
// 加载仓库数据 var usetableTemplate = $("#usetableTemplate").html(),
$("#depotId").html(getDataUseHandlebars(selOption, json)); otherTemplate = $("#otherTemplate").html();
// 初始化回显数据 var selOption = getFileContent('tpl/template/select-option.tpl');
initDataShow(); //已经选择的商品集合key:表格的行trId,value:商品信息
}); var allChooseProduct = {};
// 获取单据提交类型
var submitType = erpOrderUtil.getSubmitTypeByOrderType(systemOrderType["putIsPurchase"]["orderType"]);
//单据时间
laydate.render({
elem: '#operTime',
type: 'datetime',
value: getFormatDate(),
trigger: 'click'
});
// 加载动态表单
dsFormUtil.loadPageByCode("dsFormShow", sysDsFormWithCodeType["putIsPurchase"]["code"]);
// 初始化账户
systemCommonUtil.getSysAccountListByType(function(json){
// 加载账户数据
$("#accountId").html(getDataUseHandlebars(selOption, json));
});
// 初始化支出项目
systemCommonUtil.getSysInoutitemListByType(2, function(json){
// 加载支出项目
inoutitemHtml = getDataUseHandlebars(selOption, json);
});
//初始化回显数据 // 初始化仓库
function initDataShow(){ erpOrderUtil.getDepotList(function (json){
AjaxPostUtil.request({url: reqBasePath + "purchaseorder008", params: {rowId: parent.rowId}, type: 'json', method: "GET", callback: function(json) { // 加载仓库数据
if(json.returnCode == 0) { $("#depotId").html(getDataUseHandlebars(selOption, json));
if(isNull(json.bean)){ // 初始化回显数据
$("#showForm").html(""); initDataShow();
winui.window.msg('数据不存在~', {icon: 2, time: 2000}); });
return;
} // 初始化回显数据
function initDataShow(){
//供应商信息赋值 AjaxPostUtil.request({url: reqBasePath + "purchaseorder008", params: {rowId: parent.rowId}, type: 'json', method: "GET", callback: function(json) {
supplierMation = { if(json.returnCode == 0) {
id: json.bean.organId, if(isNull(json.bean)){
supplierName: json.bean.supplierName $("#showForm").html("");
} winui.window.msg('数据不存在~', {icon: 2, time: 2000});
return;
cgddOrderNum = json.bean.defaultNumber;
$("#supplierName").val(json.bean.supplierName);//供应商
$("#cgddOrderNum").html(cgddOrderNum);
$("#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));
});
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';
});
} }
}});
} //供应商信息赋值
supplierMation = {
//商品规格加载变化事件 id: json.bean.organId,
form.on('select(selectUnitProperty)', function(data) { supplierName: json.bean.supplierName
var thisRowValue = data.value; }
var thisRowNum = data.elem.id.replace("unitId", "");//获取当前行
//当前当前行选中的商品信息 cgddOrderNum = json.bean.defaultNumber;
if(!isNull(thisRowValue) && thisRowValue != '请选择') {
var product = allChooseProduct["tr" + thisRowNum.toString()]; $("#supplierName").val(json.bean.supplierName);//供应商
$.each(product.unitList, function(j, bean) { $("#cgddOrderNum").html(cgddOrderNum);
if(thisRowValue == bean.id){//获取规格 $("#accountId").val(json.bean.accountId);
//获取当前行数量 $("#payType").val(json.bean.payType);
var rkNum = parseInt($("#rkNum" + thisRowNum).val()); $("#allPrice").html(json.bean.totalPrice.toFixed(2));
$("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 $("#taxLastMoneyPrice").html(json.bean.taxLastMoneyPrice.toFixed(2));
return false; $("#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));
});
textool.init({
eleId: 'remark',
maxlength: 200,
tools: ['count', 'copy', 'reset', 'clear']
}); });
matchingLanguage();
form.render();
} else { } else {
$("#unitPrice" + thisRowNum).val("0.00");//重置单价为空 winui.window.msg(json.returnMessage, {icon: 2, time: 2000}, function(){
} parent.layer.close(index);
parent.refreshCode = '-9999';
//加载库存
loadTockByDepotAndMUnit(thisRowNum, $("#depotId").val());
//计算价格
calculatedTotalPrice();
});
form.on('submit(formEditBean)', function(data) {
if(winui.verifyForm(data.elem)) {
if(isNull(supplierMation.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);
}); });
if(noError) { }
}});
}
//商品规格加载变化事件
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; return false;
} }
//获取其他费用 });
var rowPriceTr = $("#otherPriceTable tr"); } else {
var tablePriceData = new Array(); $("#unitPrice" + thisRowNum).val("0.00");//重置单价为空
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);
});
var params = { //加载库存
supplierId: supplierMation.id, loadTockByDepotAndMUnit(thisRowNum, $("#depotId").val());
operTime: $("#operTime").val(), //计算价格
accountId: $("#accountId").val(), calculatedTotalPrice();
payType: $("#payType").val(), });
remark: $("#remark").val(),
discount: isNull($("#discount").val()) ? "0.00" : $("#discount").val(), // 保存为草稿
discountMoney: isNull($("#discountMoney").val()) ? "0.00" : $("#discountMoney").val(), form.on('submit(formAddBean)', function(data) {
changeAmount: isNull($("#changeAmount").val()) ? "0.00" : $("#changeAmount").val(), if(winui.verifyForm(data.elem)) {
depotheadStr: JSON.stringify(tableData), saveData("1", "");
otherMoney: otherMoney.toFixed(2), }
otherMoneyList: JSON.stringify(tablePriceData), return false;
cgddOrderNum: cgddOrderNum, });
rowId: parent.rowId
}; // 走工作流的提交审批
if(isStandard){ form.on('submit(formSubOneBean)', function(data) {
layer.confirm('该入库单已超出采购单数量,是否继续?', { icon: 3, title: '超标提示' }, function (i) { if(winui.verifyForm(data.elem)) {
AjaxPostUtil.request({url: reqBasePath + "purchaseorder009", params: params, type: 'json', callback: function(json) { activitiUtil.startProcess(sysActivitiModel["putIsPurchase"]["key"], function (approvalId) {
if(json.returnCode == 0) { saveData("2", approvalId);
parent.layer.close(index); });
parent.refreshCode = '0'; }
} else { return false;
winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); });
}
}}); // 不走工作流的提交
}); form.on('submit(formSubTwoBean)', function(data) {
}else{ if(winui.verifyForm(data.elem)) {
AjaxPostUtil.request({url: reqBasePath + "purchaseorder009", params: params, type: 'json', callback: function(json) { saveData("2", "");
if(json.returnCode == 0) { }
parent.layer.close(index); return false;
parent.refreshCode = '0'; });
} else {
winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); function saveData(subType, approvalId){
} if(isNull(supplierMation.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; 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);
}); });
if(noError) {
/*********************** 商品表格操作 start ****************************/ return false;
//删除行 }
$("body").on("click", "#deleteRow", function() { //获取其他费用
deleteRow(); var rowPriceTr = $("#otherPriceTable tr");
//计算价格 var tablePriceData = new Array();
calculatedTotalPrice(); 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);
}); });
//新增行 var params = {
function addRow() { supplierId: supplierMation.id,
var par = { operTime: $("#operTime").val(),
id: "row" + rowNum.toString(), //checkbox的id accountId: $("#accountId").val(),
trId: "tr" + rowNum.toString(), //行的id payType: $("#payType").val(),
materialId: "materialId" + rowNum.toString(), //商品id remark: $("#remark").val(),
unitId: "unitId" + rowNum.toString(), //规格id discount: isNull($("#discount").val()) ? "0.00" : $("#discount").val(),
currentTock: "currentTock" + rowNum.toString(), //库存id discountMoney: isNull($("#discountMoney").val()) ? "0.00" : $("#discountMoney").val(),
nowNum: "nowNum" + rowNum.toString(), //剩余数量id changeAmount: isNull($("#changeAmount").val()) ? "0.00" : $("#changeAmount").val(),
rkNum: "rkNum" + rowNum.toString(), //数量id depotheadStr: JSON.stringify(tableData),
unitPrice: "unitPrice" + rowNum.toString(), //单价id otherMoney: otherMoney.toFixed(2),
amountOfMoney: "amountOfMoney" + rowNum.toString(), //金额id otherMoneyList: JSON.stringify(tablePriceData),
taxRate: "taxRate" + rowNum.toString(), //税率id cgddOrderNum: cgddOrderNum,
taxMoney: "taxMoney" + rowNum.toString(), //税额id rowId: parent.rowId,
taxUnitPrice: "taxUnitPrice" + rowNum.toString(), //含税单价id submitType: submitType,
taxLastMoney: "taxLastMoney" + rowNum.toString(), //含税合计id subType: subType,
remark: "remark" + rowNum.toString() //备注id approvalId: approvalId
}; };
$("#useTable").append(getDataUseHandlebars(usetableTemplate, par)); if(isStandard){
form.render('checkbox'); layer.confirm('该入库单已超出采购单数量,是否继续?', { icon: 3, title: '超标提示' }, function (i) {
rowNum++; sendRequest(params);
//设置根据某列变化的颜色 });
$("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); }else{
sendRequest(params);
} }
}
//删除行 function sendRequest(params){
function deleteRow() { AjaxPostUtil.request({url: reqBasePath + "purchaseorder009", params: params, type: 'json', method: "POST", callback: function(json) {
var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']:checked"); if(json.returnCode == 0) {
if(checkRow.length > 0) { dsFormUtil.savePageData("dsFormShow", json.bean.id);
$.each(checkRow, function(i, item) { parent.layer.close(index);
//删除allChooseProduct已选择的商品信息 parent.refreshCode = '0';
var trId = $(item).parent().parent().attr("trcusid");
allChooseProduct[trId] = undefined;
//移除界面上的信息
$(item).parent().parent().remove();
});
} else { } else {
winui.window.msg('请选择要删除的行', {icon: 2, time: 2000}); winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
} }
}});
}
/*********************** 商品表格操作 start ****************************/
//删除行
$("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('checkbox');
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){ //供应商选择
_openNewWindows({ $("body").on("click", "#supplierNameSel", function(e){
url: "../../tpl/supplier/supplierChoose.html", _openNewWindows({
title: "选择供应商", url: "../../tpl/supplier/supplierChoose.html",
pageId: "supplierChoose", title: "选择供应商",
area: ['90vw', '90vh'], pageId: "supplierChoose",
callBack: function(refreshCode){ area: ['90vw', '90vh'],
if (refreshCode == '0') { callBack: function(refreshCode){
$("#supplierName").val(supplierMation.supplierName); if (refreshCode == '0') {
} else if (refreshCode == '-9999') { $("#supplierName").val(supplierMation.supplierName);
winui.window.msg(systemLanguage["com.skyeye.operationFailed"][languageType], {icon: 2,time: 2000}); } 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"); $("body").on("click", ".chooseProductBtn", function(e){
_openNewWindows({ var trId = $(this).parent().parent().attr("trcusid");
url: "../../tpl/material/materialChoose.html", _openNewWindows({
title: "选择商品", url: "../../tpl/material/materialChoose.html",
pageId: "productlist", title: "选择商品",
area: ['90vw', '90vh'], pageId: "productlist",
callBack: function(refreshCode){ area: ['90vw', '90vh'],
if (refreshCode == '0') { callBack: function(refreshCode){
//获取表格行号 if (refreshCode == '0') {
var thisRowNum = trId.replace("tr", ""); //获取表格行号
//商品赋值 var thisRowNum = trId.replace("tr", "");
allChooseProduct[trId] = productMation; //商品赋值
//表格商品名称赋值 allChooseProduct[trId] = productMation;
$("#materialId" + thisRowNum.toString()).val(allChooseProduct[trId].productName + "(" + allChooseProduct[trId].productModel + ")"); //表格商品名称赋值
//表格单位赋值 $("#materialId" + thisRowNum.toString()).val(allChooseProduct[trId].productName + "(" + allChooseProduct[trId].productModel + ")");
$("#unitId" + thisRowNum.toString()).html(getDataUseHandlebars(selOption, {rows: allChooseProduct[trId].unitList})); //表格单位赋值
form.render('select'); $("#unitId" + thisRowNum.toString()).html(getDataUseHandlebars(selOption, {rows: allChooseProduct[trId].unitList}));
//计算价格 form.render('select');
calculatedTotalPrice(); //计算价格
} else if (refreshCode == '-9999') { calculatedTotalPrice();
winui.window.msg(systemLanguage["com.skyeye.operationFailed"][languageType], {icon: 2,time: 2000}); } else if (refreshCode == '-9999') {
} winui.window.msg(systemLanguage["com.skyeye.operationFailed"][languageType], {icon: 2,time: 2000});
}}); }
}); }});
});
/*********************** 商品表格操作 end ****************************/ /*********************** 商品表格操作 end ****************************/
/*********************** 其他费用表格操作 start ****************************/ /*********************** 其他费用表格操作 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));
}
var priceNum = 1;
//新增行
$("body").on("click", "#addPriceRow", function() {
addPriceRow();
});
//删除行 //其他费用变化
$("body").on("click", "#deletePriceRow", function() { $("body").on("input", ".otherPrice", function() {
deletePriceRow(); //计算价格
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));
}
//新增行 var priceNum = 1;
function addPriceRow() { //新增行
var par = { $("body").on("click", "#addPriceRow", function() {
id: "row" + priceNum.toString(), //checkbox的id addPriceRow();
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() { $("body").on("click", "#deletePriceRow", function() {
var checkRow = $("#otherPriceTable input[type='checkbox'][name='tableCheckRow']:checked"); deletePriceRow();
if(checkRow.length > 0) { });
$.each(checkRow, function(i, item) {
$(item).parent().parent().remove(); //新增行
}); function addPriceRow() {
} else { var par = {
winui.window.msg('请选择要删除的行', {icon: 2, time: 2000}); id: "row" + priceNum.toString(), //checkbox的id
} trId: "tr" + priceNum.toString(), //行的id
//计算价格 inoutitemId: "inoutitemId" + priceNum.toString(), //支出项目id
calculationPrice(); 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 ****************************/ /*********************** 其他费用表格操作 end ****************************/
$("body").on("click", "#cancle", function() { $("body").on("click", "#cancle", function() {
parent.layer.close(index); parent.layer.close(index);
});
}); });
}); });
\ No newline at end of file
...@@ -153,10 +153,15 @@ ...@@ -153,10 +153,15 @@
</table> </table>
</div> </div>
</div> </div>
<div id="dsFormShow">
</div>
<div class="layui-form-item layui-col-xs12"> <div class="layui-form-item layui-col-xs12">
<div class="layui-input-block"> <div class="layui-input-block">
<button class="winui-btn" id="cancle"><language showName="com.skyeye.cancel"></language></button> <button class="winui-btn" id="cancle"><language showName="com.skyeye.cancel"></language></button>
<button class="winui-btn" lay-submit lay-filter="formEditBean"><language showName="com.skyeye.save"></language></button> <button class="winui-btn" lay-submit lay-filter="formAddBean">保存为草稿</button>
<button class="winui-btn submitTypeIsOne" lay-submit lay-filter="formSubOneBean">提交审批</button>
<button class="winui-btn submitTypeIsTwo" lay-submit lay-filter="formSubTwoBean">提交</button>
</div> </div>
</div> </div>
</form> </form>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册