| | |
| | | <script type="text/html" id="toolbarDemo"> |
| | | <div class="layui-btn-container"> |
| | | <!--<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-normal">普通条码</button>--> |
| | | <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-box">内外箱条码</button> |
| | | <!--<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-box">内外箱条码</button>--> |
| | | |
| | | </div> |
| | | </script> |
| | |
| | | var time = date.getFullYear() + "-" + month + "-" + day |
| | | return time; |
| | | } |
| | | function DateDiff(sDate1, sDate2) { //sDate1和sDate2是2002-12-18格式 |
| | | var aDate, oDate1, oDate2, iDays |
| | | aDate = sDate1.split("-") |
| | | oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式 |
| | | aDate = sDate2.split("-") |
| | | oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) |
| | | iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24) //把相差的毫秒数转换为天数 |
| | | return iDays |
| | | } |
| | | function getUrlVars() { |
| | | var vars = [], hash; |
| | | var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); |
| | |
| | | var linterid = params[params[0]]; |
| | | var lentryid = params[params[1]]; |
| | | var type = params[params[2]]; |
| | | var mainUrl = "GetHBarCodeShowBillMain"; |
| | | var subUrl = "GetHBarCodeShowBillSub"; |
| | | //原生成条码方法(送货单默认) |
| | | var mainUrl = "GetHBarCodeShowBillMain"; //表头数据加载ajax |
| | | var subUrl = "GetHBarCodeShowBillSub";//表体数据加载ajax h_v_SRM_POInStockBillSub_ForWeb2 |
| | | var saveBarCode = "GetBarcodeSaveBillBox";//条码生成保存方法ajax |
| | | var openTmpListType = "HBarCodePrint"; //条码打印按钮 弹出界面 |
| | | //采购订单条码生成规则 |
| | | if (type == 'SRM_POOrderBillList') { |
| | | mainUrl = 'GetHBarCodeShowBillMainBycg'; |
| | | subUrl = "GetHBarCodeShowBillSubBycg"; |
| | | subUrl = "GetHBarCodeShowBillSubBycg"; //h_v_Cg_POOrderBillSub_ForWeb2 |
| | | saveBarCode = "GetBarcodeSaveBillBoxBycg"; |
| | | openTmpListType = 'SRM_POOrderBillList'; |
| | | |
| | | } |
| | | //委外订单 |
| | | else if (type == 'SRM_EntrustOrderBill') { |
| | | mainUrl = 'GetHBarCodeShowBillMainBywy'; |
| | | subUrl = "GetHBarCodeShowBillSubBywy"; //h_v_srm_EntrustOrderBillSub_ForWeb2 |
| | | saveBarCode = "GetBarcodeSaveBillBoxBycg";//调用采购数据 |
| | | openTmpListType = 'SRM_POOrderBillList'; |
| | | } |
| | | // debugger; |
| | | $.ajax({ |
| | | url: GetWEBURL() + mainUrl, |
| | | type: "GET", |
| | | data: { "sMsg": linterid }, |
| | | success: function (d) { |
| | | console.log(d.data); |
| | | //$("#HDate").val(d.) |
| | | $("#HInterID").val(d.data[0].HInterID); |
| | | $("#HBillNo").val(d.data[0].HBillNo); |
| | | $("#HRemark").val(d.data[0].HRemark); |
| | | $("#HDate").val(d.data[0].HDateForWeb); |
| | | //$("#HMaker").val(d.data[0].HMaker); |
| | | $("#HMakerDate").val(d.data[0].HMakerDate) |
| | | $("#HChecker").val(d.data[0].HChecker); |
| | | $("#HCheckDate").val(d.data[0].HCheckDate); |
| | | $("#HSupID").val(d.data[0].HSupID); |
| | | $("#HSupName").val(d.data[0].HSupName); |
| | | $("#HEmpID").val(d.data[0].HEmpID); |
| | | $("#HEmpName").val(d.data[0].HEmpName); |
| | | $("#HManagerID").val(d.data[0].HManagerID); |
| | | $("#HManagerName").val(d.data[0].HManagerName); |
| | | $("#HMaker").val(sessionStorage["HUserName"]); |
| | | } |
| | | }); |
| | | |
| | | $.ajax({ |
| | | url: GetWEBURL() + mainUrl, |
| | | type: "GET", |
| | | data: { "sMsg": linterid }, |
| | | success: function (d) { |
| | | console.log(d.data); |
| | | //$("#HDate").val(d.) |
| | | $("#HInterID").val(d.data[0].HInterID); |
| | | $("#HBillNo").val(d.data[0].HBillNo); |
| | | $("#HRemark").val(d.data[0].HRemark); |
| | | $("#HDate").val(d.data[0].HDateForWeb); |
| | | //$("#HMaker").val(d.data[0].HMaker); |
| | | $("#HMakerDate").val(d.data[0].HMakerDate) |
| | | $("#HChecker").val(d.data[0].HChecker); |
| | | $("#HCheckDate").val(d.data[0].HCheckDate); |
| | | $("#HSupID").val(d.data[0].HSupID); |
| | | $("#HSupName").val(d.data[0].HSupName); |
| | | $("#HEmpID").val(d.data[0].HEmpID); |
| | | $("#HEmpName").val(d.data[0].HEmpName); |
| | | $("#HManagerID").val(d.data[0].HManagerID); |
| | | $("#HManagerName").val(d.data[0].HManagerName); |
| | | $("#HMaker").val(sessionStorage["HUserName"]); |
| | | } |
| | | }); |
| | | |
| | | layui.config({ |
| | | base: '../../layuiadmin/' //静态资源所在路径 |
| | | }).extend({ |
| | |
| | | $.ajax( |
| | | { |
| | | type: "POST", |
| | | url: GetWEBURL() + "GetBarcodeSaveBillBox", //方法所在页面和方法名 |
| | | url: GetWEBURL() + saveBarCode, //方法所在页面和方法名 |
| | | async: true, |
| | | data: { "msg": sMainSub }, |
| | | dataType: "json", |
| | |
| | | }); |
| | | table.render({ |
| | | elem: '#subTable' |
| | | , url: GetWEBURL() + 'GetHBarCodeShowBillSub3' |
| | | , url: GetWEBURL() + 'GetHBarCodeShowBillSub3' //h_v_Web_BarCodeBill_ForWeb1 |
| | | , toolbar: '#toolbarDemo1' |
| | | , defaultToolbar: ['filter', 'exports'] |
| | | , where: { sMsg: linterid } |
| | |
| | | , data2 = layui.table.cache["subTable2"]; |
| | | var rows = ''; |
| | | var rows2 = ''; |
| | | if (data1 == undefined || data2 == undefined) { |
| | | layer.msg("请先生成内外箱条码!") |
| | | return; |
| | | } |
| | | for (var i = 0; i < data1.length; i++) { |
| | | rows += data1[i].HItemID.toString() + ','; |
| | | rows2 += data1[i].HBarCode.toString() + ','; |
| | |
| | | rows2 = rows2.substring(rows2.length - 1, 0); |
| | | if (rows == "") { |
| | | layer.msg("至少选择一行记录!") |
| | | return; |
| | | } |
| | | else { |
| | | layer.open({ |
| | |
| | | , shade: 0.6 //遮罩透明度 |
| | | , maxmin: false //允许全屏最小化 |
| | | , anim: 0 //0-6的动画形式,-1不开启 |
| | | , content: ['../../views/BaseSet/SRM_OpenTmpList.html?linterid=' + rows.toString() + '&HBarcode=' + rows2.toString() + '&Type=HBarCodePrint', 'yes'] |
| | | , content: ['../../views/BaseSet/SRM_OpenTmpList.html?linterid=' + rows.toString() + '&HBarcode=&Type=' + openTmpListType, 'yes'] |
| | | , resize: false |
| | | //, cancel: function () { |
| | | // $(".layui-btn").removeClass("layui-btn-disabled"); |
| | |
| | | } |
| | | }); |
| | | layer.load(3) |
| | | |
| | | |
| | | table.render({ |
| | | elem: '#mainTable' |
| | | , url: GetWEBURL() + subUrl |
| | |
| | | , where: { sMsg: linterid, sMsg2: lentryid } |
| | | , cols: [[ |
| | | , { field: 'HMaterID', title: '物料ID', width: 100, hide: true } |
| | | , { field: 'HMaterNumber', title: '物料代码', width: 100 } |
| | | , { field: 'HMaterName', title: '物料名称', width: 200 } |
| | | , { field: 'HMaterModel', title: '规格型号', width: 200 } |
| | | , { field: 'HMaterNumber', title: '物料编码', width: 120 } |
| | | , { field: 'HMaterShortNumber', title: '物料代码', width: 120 } |
| | | , { field: 'HMaterName', title: '物料名称', width: 120 } |
| | | , { field: 'HMaterModel', title: '规格型号', width: 120 } |
| | | , { field: 'HUnitName', title: '计量单位', width: 100 } |
| | | , { field: 'HUnitNumber', title: '计量单位代码', width: 100, hide: true } |
| | | , { field: 'HUnitID', title: '计量单位ID', width: 100, hide: true } |
| | |
| | | , { field: 'HMoney', title: '金额', width: 100, hide: true } |
| | | , { field: 'HMTONO', title: '计划跟踪单号', width: 100 } |
| | | , { field: 'HBatchNo', title: '批次', width: 100, edit: 'text' } |
| | | , { field: 'HKFDate', title: '生产日期', align: 'center', width: 150 }//, data_field: 'HKFDate', event: "chooseHKFDate" |
| | | , { field: 'HKFPeriod', title: '保质期', width: 100 }//, edit: 'text', event: "inputHKFPeriod" |
| | | , { field: 'HKFDQDate', title: '到期日期', align: 'center', width: 150 }//, data_field: 'HKFDQDate', event: "chooseHKFDQDate" |
| | | //, { field: 'HBeginDate', title: '生产日期', width: 120, data_field: 'HBeginDate', event: "chooseHBeginDate" } |
| | | //, { field: 'HEndDate', title: '失效日期', width: 120, data_field: 'HEndDate', event: "chooseHEndDate" } |
| | | , { field: 'HKFDate', title: '生产日期', align: 'center', width: 150, data_field: 'HKFDate', event: "chooseHKFDate" }// |
| | | , { field: 'HKFPeriod', title: '保质期', width: 100, edit: 'text', event: "inputHKFPeriod" }// |
| | | , { field: 'HKFDQDate', title: '到期日期', align: 'center', width: 150, data_field: 'HKFDQDate', event: "chooseHKFDQDate" }// |
| | | //, { field: 'HDate', title: '要求交货日期', width: 150 } |
| | | , { field: 'HPOOrderInterID', title: '采购订单主内码', width: 150, hide: true } |
| | | , { field: 'HPOOrderEntryID', title: '采购订单子内码', width: 150, hide: true } |
| | |
| | | , { field: 'HSourceEntryID', title: '源单子内码', width: 150, hide: true } |
| | | , { field: 'HSourceInterID', title: '源单主内码', width: 150, hide: true } |
| | | , { field: 'HSupID', title: '供应商ID', width: 150, hide: true } |
| | | , { field: 'HSupName', title: '供应商名称', width: 150, hide: true } |
| | | |
| | | ]] |
| | | // , data: [linterid] |
| | | // , page: true |
| | | //, height: 500 |
| | | |
| | | , done: function (res, curr, count) { |
| | | //日期控件 |
| | | //$(".layui-input-date").each(function (i) { |
| | | // layui.laydate.render({ |
| | | // elem: this |
| | | // ,format: "yyyy-MM-dd" |
| | | // , value: this.value |
| | | // ,trigger:'click'//采用click弹出 |
| | | // , done: function (value, date, endDate) { |
| | | // table.cache.mainTable. |
| | | // //if (res && res.data[i]) { |
| | | // // $.extend(res.data[i], { 'HKFDate': value }) |
| | | // //} |
| | | // } |
| | | // }); |
| | | //}); |
| | | |
| | | console.log(res); |
| | | layer.closeAll("loading"); |
| | | } |
| | |
| | | , { field: 'HMoney', title: '金额', width: 100, hide: true } |
| | | , { field: 'HMTONO', title: '计划跟踪单号', width: 100 } |
| | | , { field: 'HBatchNo', title: '批次', width: 100, edit: 'text' } |
| | | //, { field: 'HBeginDate', title: '生产日期', width: 120, data_field: 'HBeginDate', event: "chooseHBeginDate" } |
| | | //, { field: 'HEndDate', title: '失效日期', width: 120, data_field: 'HEndDate', event: "chooseHEndDate" } |
| | | , { field: 'HKFDate', title: '生产日期', align: 'center', width: 150, data_field: 'HKFDate', event: "chooseHKFDate" } |
| | | , { field: 'HKFPeriod', title: '保质期', width: 100, edit: 'text', event: "inputHKFPeriod" } |
| | | , { field: 'HKFDQDate', title: '到期日期', align: 'center', width: 150, data_field: 'HKFDQDate', event: "chooseHKFDQDate" } |
| | |
| | | , done: function (value, date) { |
| | | data[field] = value; |
| | | obj.update(data); |
| | | if (obj.data.HKFDQDate != "" && obj.data.HKFDate != "") { |
| | | var days = DateDiff(obj.data.HKFDQDate, obj.data.HKFDate); |
| | | obj.update({ |
| | | HKFPeriod: days, |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | else if (obj.event == 'chooseHBeginDate') { |
| | | var field = $(this).data('field'); |
| | | laydate.render({ |
| | | elem: this.firstChild |
| | | , show: true //直接显示 |
| | | , closeStop: this |
| | | , done: function (value, date) { |
| | | data[field] = value; |
| | | obj.update(data); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | else if (obj.event == 'chooseHEndDate') { |
| | | var field = $(this).data('field'); |
| | | laydate.render({ |
| | | elem: this.firstChild |
| | | , show: true //直接显示 |
| | | , closeStop: this |
| | | , done: function (value, date) { |
| | | data[field] = value; |
| | | obj.update(data); |
| | | |
| | | } |
| | | }); |
| | |
| | | }); |
| | | } |
| | | }); |
| | | //table.on('tool(mainTable)', function (d) { |
| | | // switch (d.event) { |
| | | // case "inputHKFPeriod": |
| | | // $(d.tr).find(".layui-table-edit").keyup(function () { |
| | | // var $input = $(this), val = $input.val(); |
| | | // if (!val) val = "1"; |
| | | // $input.val(val.replace(/[^\d]/g, '')); |
| | | // }); |
| | | // break; |
| | | // } |
| | | //}); |
| | | table.on('edit(mainTable)', function (obj) { //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值" |
| | | var value = obj.value //得到修改后的值 |
| | | , data = obj.data //得到所在行所有键值 |
| | | , field = obj.field; //得到字段 |
| | | |
| | | var HMinQty = 0; |
| | | var HWXQty = 0; |
| | | var HKFPeriod = 0; |
| | | var HWBQty = 0; |
| | | var HBQty = 0; |
| | | if (obj.data.HMinQty != undefined) { |
| | | HMinQty = parseFloat(obj.data.HMinQty); |
| | | } |
| | |
| | | if (obj.data.HKFPeriod != undefined) { |
| | | HKFPeriod = parseFloat(obj.data.HKFPeriod); |
| | | } |
| | | HKFPeriod |
| | | if (obj.data.HWBQty != undefined) { |
| | | HWBQty = parseFloat(obj.data.HWBQty); |
| | | } |
| | | if (obj.data.HBQty != undefined) { |
| | | HBQty = parseFloat(obj.data.HBQty); |
| | | } |
| | | //HMinQty 内箱包装数 |
| | | //HBQty 内箱数 |
| | | //HWXQty 外箱包装数 |
| | | //HWBQty 外箱数 HWBQty |
| | | switch (field) { |
| | | case "HMinQty": |
| | | if (HMinQty > 0) { |
| | | if (HWXQty >= 0) { |
| | | if (isPositiveIntegerTimes(parseFloat(obj.value), HWXQty)) //外箱包装数能被内箱包装数整除 |
| | | { |
| | | obj.update({ |
| | | HBQty: Math.ceil(parseFloat(obj.data.HQty) / parseFloat(obj.value)), |
| | | }); |
| | | } |
| | | else { |
| | | //obj.update({ |
| | | // HMinQty: 0, |
| | | //}); |
| | | f_alert("外箱包装数必须是内箱包装数的整数倍!"); |
| | | } |
| | | } |
| | | } |
| | | else { |
| | | //obj.update({ |
| | | // HMinQty: 0, |
| | | //}); |
| | | case "HQty": |
| | | obj.update({ |
| | | HMinQty: 0, |
| | | HBQty: 0, |
| | | HWXQty: 0, |
| | | HWBQty: 0, |
| | | }); |
| | | break; |
| | | case "HMinQty": //内箱包装数 |
| | | if (HMinQty < 0) { |
| | | f_alert("内箱包装数不能为负数!"); |
| | | } |
| | | else if (HWXQty > 0 && HMinQty > HWXQty) { |
| | | f_alert("内箱包装数量不能超出外箱包装数量") |
| | | obj.update({ |
| | | HBQty: Math.ceil(parseFloat(obj.data.HQty) / parseFloat(obj.value)), |
| | | HWXQty: 0, |
| | | HWBQty: 0, |
| | | }); |
| | | return; |
| | | } |
| | | else (HWXQty > 0)//外箱包装数大于0时候 |
| | | { |
| | | obj.update({ |
| | | //外箱包装总数 = 内箱数量/外箱数量 * 内箱包装数量 |
| | | HBQty: Math.ceil(parseFloat(obj.data.HQty) / parseFloat(obj.value)), |
| | | |
| | | }); |
| | | if (parseFloat(obj.data.HWBQty) > 0) |
| | | obj.update({ |
| | | HWXQty: Math.ceil(parseFloat(obj.data.HBQty) / parseFloat(obj.data.HWBQty)) * parseFloat(obj.data.HMinQty), |
| | | }); |
| | | } |
| | | break; |
| | | case "HWXQty": |
| | | if (HWXQty > 0) { |