var pageCurr; layui.config({ base: baseUrl + "/static/layui/lay/modules/" }).use(['table','laydate', 'form', 'util', 'admin', 'tableMerge'], function(){ var table = layui.table; var $ = layui.jquery; var layer = layui.layer; var layDate = layui.laydate; var form = layui.form; var admin = layui.admin; var tableMerge = layui.tableMerge; var util = layui.util; /****************************************** 左边表 *************************************************/ /* 渲染表格 */ var insTb = table.render({ elem: '#docTypeTable', url: baseUrl + '/docType/list/auth', height: 'full-100', headers: {token: localStorage.getItem('token')}, request: { pageName: 'curr', pageSize: 'limit' }, where: { doc_class: 2,//出库单 }, parseData: function (res) { return { 'code': res.code, 'msg': res.msg, 'count': res.data.total, 'data': res.data.records } }, response: { statusCode: 200 }, toolbar: ['
', ' ', ' ', '', '
'].join(''), defaultToolbar: [], cols: [[ {field: 'docId', title: '编号', width: 70, align: 'center'}, {field: 'docName', title: '单据类型'} ,{field: 'docClass', title: '单据类别', hide:true} ]], done: function (res, curr, count) { $('#dictTable+.layui-table-view .layui-table-body tbody>tr:first').trigger('click'); } }); /* 表格搜索 */ form.on('submit(docTypeTableSearch)', function (data) { insTb.reload({where: {doc_name: data.field.docName,doc_class:2}}); return false; }); /* 表格头工具栏点击事件 */ table.on('toolbar(docTypeTable)', function (obj) { if (obj.event === 'add') { // 添加 showEditModel(); } else if (obj.event === 'edit') { // 修改 if (selObj == null) { return; } showEditModel(selObj.data); } else if (obj.event === 'del') { // 删除 if (selObj == null) { return; } doDel(selObj); } }); /* 监听行单击事件 */ var selObj; table.on('row(docTypeTable)', function (obj) { selObj = obj; obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click'); insTb2.reload({where: {doc_type: obj.data.docId}, page: {curr: 1}}); }); /* 显示表单弹窗 */ function showEditModel(mData) { admin.open({ type: 1, title: (mData ? '修改' : '添加') + '单据类型', content: $('#docTypeEditDialog').html(), success: function (layero, dIndex) { // 回显表单数据 form.val('docTypeEditForm', mData); if(mData){ // $('#docId').addClass("layui-input").attr("disabled",true); $('input[name="docId"]').addClass("layui-input").attr("disabled",true); } // 表单提交事件 form.on('submit(docTypeEditSubmit)', function (data) { var loadIndex = layer.load(2); $.ajax({ url: baseUrl+"/docType/"+(mData?'update':'add')+"/auth", headers: {'token': localStorage.getItem('token')}, data: data.field, method: 'POST', success: function (res) { layer.close(loadIndex); selObj = null; if (res.code === 200){ layer.close(dIndex); layer.msg(res.msg, {icon: 1}); insTb.reload(); } else if (res.code === 403){ top.location.href = baseUrl+"/"; } else { layer.msg(res.msg, {icon: 2}); } } }) return false; }); } }); } /* 删除 */ function doDel(obj) { layer.confirm('确定要删除此单据类型吗?', { skin: 'layui-layer-admin', shade: .1 }, function (i) { layer.close(i); var loadIndex = layer.load(2); $.ajax({ url: baseUrl+"/docType/delete/one/auth", headers: {'token': localStorage.getItem('token')}, data: {param: JSON.stringify(obj.data)}, method: 'POST', success: function (res) { selObj = null; layer.close(loadIndex); if (res.code === 200){ layer.closeAll(); insTb.reload(); $('#dictTable+.layui-table-view .layui-table-body tbody>tr:first').trigger('click'); } else if (res.code === 403){ top.location.href = baseUrl+"/"; } else { layer.msg(res.msg, {icon: 2}); } } }) }); } /****************************************** 右边表 *************************************************/ /* 渲染表格2 */ var insTb2 = table.render({ elem: '#orderTable', headers: {token: localStorage.getItem('token')}, url: baseUrl+'/order/list/auth', page: true, // size: 'lg', limit: 15, limits: [15, 30, 50, 100, 200, 500], toolbar: '#orderToolbar', height: 'full-100', cols: [[ {type: 'checkbox'} // ,{field: 'uuid', align: 'center',title: '编号'} ,{field: 'docType$', align: 'center',title: '类别', templet: '#docTypeTpl', width: 100} ,{field: 'orderNo', align: 'center',title: '单据编号', minWidth: 200} ,{field: 'orderTime', align: 'center',title: '单据日期', width: 120} ,{field: 'itemName', align: 'center',title: '项目'} ,{field: 'allotItemId$', align: 'center',title: '调拨项目编号', hide: true} ,{field: 'defNumber', align: 'center',title: '初始票据号', hide: true} ,{field: 'number', align: 'center',title: '票据号', hide: true} ,{field: 'cstmrName', align: 'center',title: '客户'} ,{field: 'waveNo', align: 'center', title: '波次编号'} ,{align: 'center', title: '明细', toolbar: '#tbLook', minWidth: 140, width: 140} ,{field: 'tel', align: 'center',title: '联系方式', hide: true} ,{field: 'operMemb', align: 'center',title: '操作人员', hide: true} ,{field: 'totalFee', align: 'center',title: '合计金额', hide: true} ,{field: 'discount', align: 'center',title: '优惠率', hide: true} ,{field: 'discountFee', align: 'center',title: '优惠金额', hide: true} ,{field: 'otherFee', align: 'center',title: '销售或采购费用合计', hide: true} ,{field: 'actFee', align: 'center',title: '实付金额', hide: true} ,{field: 'payType$', align: 'center',title: '付款类型', hide: true} ,{field: 'salesman', align: 'center',title: '业务员', hide: true} ,{field: 'accountDay', align: 'center',title: '结算天数', hide: true} ,{field: 'postFeeType$', align: 'center',title: '邮费支付类型', hide: true} ,{field: 'postFee', align: 'center',title: '邮费', hide: true} ,{field: 'payTime$', align: 'center',title: '付款时间', hide: true} ,{field: 'sendTime$', align: 'center',title: '发货时间', hide: true} ,{field: 'shipName', align: 'center',title: '物流名称', hide: true} ,{field: 'shipCode', align: 'center',title: '物流单号', hide: true} ,{field: 'settle$', align: 'center',title: '订单状态', templet: '#settleTpl', width: 105} ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width: 120} ]], request: { pageName: 'curr', pageSize: 'limit' }, parseData: function (res) { return { 'code': res.code, 'msg': res.msg, 'count': res.data.total, 'data': res.data.records } }, response: { statusCode: 200 }, done: function(res, curr, count) { if (res.code === 403) { top.location.href = baseUrl+"/"; } pageCurr=curr; limit(); } }); /* 表格2搜索 */ form.on('submit(orderTbSearch)', function (data) { insTb2.reload({where: data.field, page: {curr: 1}}); return false; }); /* 表格2重置 */ form.on('submit(orderTbReset)', function (data) { insTb2.reload({where: null,page: {curr: 1}}); return false; }); /* 表格2头工具栏点击事件 */ table.on('toolbar(orderTable)', function (obj) { if (obj.event === 'add') { // 添加 right(); } else if (obj.event === 'del') { // 删除 var checkRows = table.checkStatus('orderTable'); if (checkRows.data.length === 0) { layer.msg('请选择要删除的数据', {icon: 2}); return; } var ids = checkRows.data.map(function (d) { return d.id; }); doDelOrder({ids: ids}); }else if (obj.event === 'wave'){ var checkRows = table.checkStatus('orderTable'); if (checkRows.data.length === 0) { layer.msg('请选择要生成波次的数据', {icon: 2}); return; } doWaveOrder(checkRows); } }); /* 表格2工具条点击事件 */ table.on('tool(orderTable)', function (obj) { var data = obj.data; switch (obj.event) { // 拣货 case 'stockOut': var loadIndex = layer.load(2); $.ajax({ url: baseUrl + "/work/stock/out/preview", headers: {'token': localStorage.getItem('token')}, contentType: 'application/json;charset=UTF-8', data: JSON.stringify({ orderNo: data.orderNo }), method: 'POST', success: function (res) { layer.close(loadIndex); if (res.code === 200){ layer.open({ type: 1 ,title: false ,closeBtn: false ,offset: '100px' ,area: '1000px' ,shade: 0.5 ,shadeClose: true ,btn: ['立即生成', '稍后处理'] ,btnAlign: 'c' ,moveType: 1 //拖拽模式,0或者1 ,content: $('#stoukOutPreview') ,success: function(layero, index){ table.render({ elem: '#stoPreTab', data: res.data, page: true, cellMinWidth: 100, height: 432, cols: [[ {field: 'title', title: '商品', merge: true, align: 'center'}, {field: 'anfme', title: '总数量', merge: ['title'], align: 'center', style: 'font-weight: bold', width: 90}, {field: 'type', title: '仓库', merge: true, align: 'center', templet: '#typeTpl', width: 90}, {field: 'locNo', title: '货位', align: 'center'}, {field: 'prior$', title: '推荐货位', align: 'center', width: 100}, {field: 'reduce', title: '数量', align: 'center', width: 90, style: 'font-weight: bold'}, // {field: 'remQty', title: '余量', align: 'center', width: 80}, {field: 'total', title: '总量', align: 'center', width: 90}, ]], done: function () { tableMerge.render(this); $('.layui-table-body.layui-table-main').css("overflow", "auto") } }); } ,yes: function(index, layero){ //按钮【马上拣货】的回调 stockOut(data.orderNo); } ,btn2: function(index, layero){ //按钮【稍后处理】的回调 //return false 开启该代码可禁止点击该按钮关闭 } }); } else if (res.code === 403){ top.location.href = baseUrl+"/"; } else { layer.msg(res.msg, {icon: 2}) } } }) break; // 打印 case 'print': layer.confirm('开始打印' +data.orderNo + ' 拣货单?', {shadeClose: true}, function(){ layer.closeAll(); printPakouts(data.orderNo); }) break; // 删除 case 'del': var ids = [obj.id]; doDelOrder({ids: ids}); break; // 明细 case 'look': var $a = $(obj.tr).find('a[lay-event="look"]'); var offset = $a.offset(); layer.open({ type: 1, title: false, area: '700px', offset: [offset.top + 'px', (offset.left - 530 + $a.outerWidth()) + 'px'], shade: .01, shadeClose: true, fixed: false, content: '