diff --git a/erp_web/js/pages/materials/in_out.js b/erp_web/js/pages/materials/in_out.js index 313e72ac..e863700b 100644 --- a/erp_web/js/pages/materials/in_out.js +++ b/erp_web/js/pages/materials/in_out.js @@ -392,8 +392,9 @@ //初始化表格数据 function initTableData(){ if(pageType === "skip") { - var oldRowInfo = sessionStorage.getItem("rowInfo"); - editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据 + var res = sessionStorage.getItem("rowInfo"); + res = JSON.parse(res); + editDepotHead(0, res); //自动弹出编辑框,带缓存数据 } var hideType = undefined; var isHiddenStatus = true; @@ -492,26 +493,14 @@ columns:[[ { field: 'id',width:35,align:"center",checkbox:true}, { title: '操作',field: 'op',align:"center",width:opWidth, - formatter:function(value,rec) { + formatter:function(value,rec,index) { var str = ''; - var rowInfo = rec.id + 'AaBb' + rec.projectid+ 'AaBb' + rec.number+ 'AaBb' + rec.operpersonname - + 'AaBb' + rec.opertimeStr+ 'AaBb' + rec.organid+ 'AaBb' + rec.handspersonid - + 'AaBb' + rec.accountid+ 'AaBb' + rec.changeamount+ 'AaBb' + rec.remark - + 'AaBb' + rec.projectName+ 'AaBb' + rec.organName+ 'AaBb' + rec.handsPersonName - + 'AaBb' + rec.accountName + 'AaBb' + rec.totalprice + 'AaBb' + rec.allocationprojectid - + 'AaBb' + rec.allocationProjectName + 'AaBb' + rec.paytype + 'AaBb' + rec.salesman - + 'AaBb' + rec.discount + 'AaBb' + rec.discountmoney + 'AaBb' + rec.discountlastmoney - + 'AaBb' + rec.accountidlist + 'AaBb' + rec.accountmoneylist - + 'AaBb' + rec.othermoney + 'AaBb' + rec.othermoneylist + 'AaBb' + rec.othermoneyitem - + 'AaBb' + rec.accountday + 'AaBb' + rec.linknumber; - rowInfo = rowInfo.replace(/\"/g, ""); - rowInfo = rowInfo.replace(/\[|]/g,""); var orgId = rec.organid? rec.organid:0; - str += '   '; - str += '   '; + str += '   '; + str += '   '; str += ''; if(isShowSkip) { - str += '   '; + str += '   '; } return str; } @@ -1294,11 +1283,12 @@ } //订单转采购或销售 - function skipDepotHead(rowInfo, status){ + function skipDepotHead(index){ + var res = $("#tableData").datagrid("getRows")[index]; if(status == "0" || status == "2") { $.messager.alert('提示','未审核和已转的单据禁止操作!','warning'); } else { - sessionStorage.setItem("rowInfo", rowInfo); //将单据信息存入缓存中 + sessionStorage.setItem("rowInfo", JSON.stringify(res)); //将单据信息存入缓存中 if(listTitle == "采购订单列表") { js.addTabPage(null, "订单转采购", "/pages/materials/purchase_in_list.html?t=skip"); } else if(listTitle == "销售订单列表") { @@ -1539,44 +1529,49 @@ } //编辑信息 - function editDepotHead(depotHeadTotalInfo, status){ - if(status == "1" || status == "2") { - $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning'); - return; - } - var depotHeadInfo = depotHeadTotalInfo.split("AaBb"); - var TotalPrice = depotHeadInfo[14]; //合计金额 + function editDepotHead(index, res){ + if(!res) { + res = $("#tableData").datagrid("getRows")[index]; + } + if(pageType!="skip") { + if (res.status == "1" || res.status == "2") { + $.messager.alert('编辑提示', '已审核和已转的单据不能编辑!', 'warning'); + return; + } + } + var TotalPrice = res.totalprice; //合计金额 if(pageType === "skip") { //从订单跳转过来 buildNumber(); //生成单据编号 var thisDateTime = getNowFormatDateTime(); //当前时间 $("#OperTime").val(thisDateTime); - $("#LinkNumber").val(depotHeadInfo[2]); //关联订单号 + $("#LinkNumber").val(res.number); //关联订单号 $("#AccountId").val(defaultAccountId); //初始化默认的账户Id $("#DiscountLastMoney").val(TotalPrice); //优惠后金额 $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice); } else { - $("#Number").val(depotHeadInfo[2]).attr("data-defaultNumber",depotHeadInfo[2]); - $("#OperTime").val(depotHeadInfo[4]); - $("#LinkNumber").val(depotHeadInfo[28].replace("undefined","")); //关联订单号 - $("#AccountId").val(depotHeadInfo[7]); //账户Id - $("#DiscountLastMoney").val(depotHeadInfo[21].replace("undefined","0.00")); //优惠后金额 - $("#ChangeAmount").val(depotHeadInfo[8]).attr("data-changeamount", depotHeadInfo[8]); + $("#Number").val(res.number).attr("data-defaultNumber",res.number); + $("#OperTime").val(res.opertimeStr); + $("#LinkNumber").val(res.linknumber); //关联订单号 + $("#AccountId").val(res.accountid); //账户Id + $("#DiscountLastMoney").val(res.discountlastmoney); //优惠后金额 + $("#ChangeAmount").val(res.changeamount).attr("data-changeamount", res.changeamount); } - $('#OrganId').combobox('setValue', depotHeadInfo[5]=='undefined'?'':depotHeadInfo[5]); - $("#HandsPersonId").val(depotHeadInfo[6]); - $("#Remark").val(depotHeadInfo[9]); - $("#Discount").val(depotHeadInfo[19].replace("undefined","0")); - $("#DiscountMoney").val(depotHeadInfo[20].replace("undefined","0.00")); - $("#Debt").val((depotHeadInfo[21].replace("undefined","0.00")-depotHeadInfo[8]).toFixed(2)); - $("#AccountDay").val(depotHeadInfo[27].replace("undefined","")); //结算天数 - preTotalPrice = depotHeadInfo[14]; //记录前一次合计金额,用于扣预付款 - $("#AllocationProjectId").val(depotHeadInfo[15]); - oldNumber = depotHeadInfo[2]; //记录编辑前的单据编号 - oldId = depotHeadInfo[0]; //记录单据Id + $('#OrganId').combobox('setValue', res.organid); + $("#HandsPersonId").val(res.handspersonid); + $("#Remark").val(res.remark); + $("#Discount").val(res.discount?res.discount:0); + $("#DiscountMoney").val(res.discountmoney?res.discountmoney:0); + var discountlastmoney = res.discountlastmoney?res.discountlastmoney:0; + $("#Debt").val(discountlastmoney-res.changeamount); + $("#AccountDay").val(res.accountday); //结算天数 + preTotalPrice = res.totalprice; //记录前一次合计金额,用于扣预付款 + $("#AllocationProjectId").val(res.allocationprojectid); + oldNumber = res.number; //记录编辑前的单据编号 + oldId = res.id; //记录单据Id var editTitle = listTitle.replace("列表","信息"); $('#depotHeadDlg').dialog('open').dialog('setTitle',' 编辑' + editTitle); $(".window-mask").css({ width: webW ,height: webH}); - depotHeadID = depotHeadInfo[0]; + depotHeadID = res.id; if(listSubType == "零售"){ var option = ""; @@ -1591,8 +1586,8 @@ } if(listSubType === "销售" || listSubType === "销售退货" || listSubType === "销售订单"){ - if(depotHeadInfo[18]){ - var arr = depotHeadInfo[18].split(","); + if(res.salesman){ + var arr = res.salesman.split(","); var salesmanArray = []; for(var i=0;i 查看' + showTitle); $(".window-mask").css({ width: webW ,height: webH}); - depotHeadID = depotHeadInfo[0]; + depotHeadID = res.id; initTableData_material_show(TotalPrice); //商品列表-查看状态 //零售单据展示数据 @@ -1732,8 +1740,8 @@ } } if(listSubType === "销售" || listSubType === "销售退货" || listSubType === "销售订单"){ - if(depotHeadInfo[18]){ - var arr = depotHeadInfo[18].split(","); + if(res.salesman){ + var arr = res.salesman.split(","); var salesmanStr = ""; for(var i=0;i-1){ $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning'); @@ -2370,17 +2381,22 @@ }); //给弹窗赋值-采购费用、销售费用数据 - var itemArr = $("#OtherMoney").attr("data-itemArr"); - itemArr = JSON.parse(itemArr); - var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr"); - itemMoneyArr = JSON.parse(itemMoneyArr); - $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){ - var index = $(this).attr("data-index"); - $(this).find(".money-id-dlg").val(itemArr[index]); - if(itemMoneyArr[index]!="undefined"){ - $(this).find(".other-money-dlg").val(itemMoneyArr[index]); - } - }); + var itemArr = $("#OtherMoney").attr("data-itemArr"); + itemArr = JSON.parse(itemArr); + var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr"); + itemMoneyArr = JSON.parse(itemMoneyArr); + $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){ + var index = $(this).attr("data-index"); + $(this).find(".money-id-dlg").val(itemArr[index]); + if(itemMoneyArr[index]!="undefined"){ + for(var k =0;k