| | |
| | | cols.push({fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:65}) |
| | | return cols; |
| | | } |
| | | |
| | | layui.use(['table','laydate', 'form'], function() { |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).extend({ |
| | | notice: 'notice/notice', |
| | | }).use(['table','laydate', 'form', 'admin', 'notice'], function() { |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var form = layui.form; |
| | | var notice = layui.notice; |
| | | var layDate = layui.laydate; |
| | | var admin = layui.admin; |
| | | |
| | | tableIns = table.render({ |
| | | elem: '#chooseData', |
| | |
| | | switch (obj.event) { |
| | | case 'createDoc': |
| | | if (data.length === 0){ |
| | | layer.msg('请添加物料'); |
| | | notice.error({ |
| | | title: '消息通知', |
| | | message: '请添加物料' |
| | | }); |
| | | } else { |
| | | var success = true; |
| | | for (var i=0;i<matData.length;i++) { |
| | | if (matData[i].count <= 0) { |
| | | layer.msg(matData[i].matnr + '物料数量必须大于零!', {icon: 2}) |
| | | notice.error({ |
| | | title: '消息通知', |
| | | message: matData[i].matnr + '物料数量必须大于零!' |
| | | }); |
| | | success = false; |
| | | return false; |
| | | } |
| | | } |
| | | var index = layer.load(1, {shade: [0.1,'#000']}); |
| | | // 单据类型 |
| | | var docTypeData; |
| | | $.ajax({ |
| | | url: baseUrl+"/work/docType/all/get", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'POST', |
| | | async: false, |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | docTypeData = res; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }); |
| | | var tpl1 = $('#docTypeSelectTpl').html(); |
| | | var template1 = Handlebars.compile(tpl1); |
| | | var html1 = template1(docTypeData); |
| | | $("#docType").html(html1); |
| | | |
| | | // 客户 |
| | | var cstmrData; |
| | | $.ajax({ |
| | | url: baseUrl+"/work/cstmr/all/get", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'POST', |
| | | async: false, |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | cstmrData = res; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }); |
| | | var tpl2 = $('#cstmrSelectTpl').html(); |
| | | var template2 = Handlebars.compile(tpl2); |
| | | var html2 = template2(cstmrData); |
| | | $("#cstmr").html(html2); |
| | | |
| | | // 项目 |
| | | var itemData; |
| | | $.ajax({ |
| | | url: baseUrl+"/work/item/all/get", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'POST', |
| | | async: false, |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | itemData = res; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }); |
| | | var tpl3 = $('#itemSelectTpl').html(); |
| | | var template3 = Handlebars.compile(tpl3); |
| | | var html3 = template3(itemData); |
| | | $("#item").html(html3); |
| | | |
| | | layer.close(index); |
| | | if (success) { |
| | | layer.open({ |
| | | admin.open({ |
| | | type: 1, |
| | | title: '定义销售单编号', |
| | | title: '单据填充', |
| | | offset: '100px', |
| | | area: ['360px'], |
| | | shade: 0.1, |
| | | shade: 0.3, |
| | | content: $('#getOrderNo'), |
| | | success: function(layero, index){ |
| | | layer.iframeAuto(index) |
| | | layer.iframeAuto(index); |
| | | $(layero).children('.layui-layer-content').css('overflow', 'visible'); |
| | | layui.form.render('select'); |
| | | }, |
| | | cancel: function () { |
| | | $('#orderNo').val(''); |
| | |
| | | |
| | | }); |
| | | }); |
| | | var number = data.field.orderNo; // 单号 |
| | | if (number.substring(0, 3) !== 'PR-') { |
| | | notice.error({ |
| | | title: '消息通知', |
| | | message: '单号不符合规则,请以 PR- 开头' |
| | | }); |
| | | return false; |
| | | } |
| | | var req = JSON.stringify({ |
| | | number: data.field.orderNo |
| | | , customerTypeId: '1' |
| | | number: number |
| | | , customerTypeId: data.field.customerTypeId |
| | | , list: matDetls |
| | | }) |
| | | $.ajax({ |
| | |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | layer.msg(res.msg, {icon: 1}); |
| | | notice.success({ |
| | | title: '消息通知', |
| | | message: res.msg |
| | | }); |
| | | top.layui.layer.close(top.popupRight); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}) |
| | | notice.error({ |
| | | title: '消息通知', |
| | | message: res.msg |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | |
| | | |
| | | function updateMatData(locNo, matnr, count) { |
| | | if (isNaN(count)) { |
| | | layer.msg("请输入数字"); |
| | | notice.error({ |
| | | title: '消息通知', |
| | | message: '请输入数字' |
| | | }); |
| | | } else { |
| | | if (count > 0) { |
| | | for (var i=0;i<matData.length;i++){ |
| | | if (matData[i]["matnr"] === matnr){ |
| | | // if (count > locDetlData[i]["anfme"]) { |
| | | // layer.msg("不能超过原数量"); |
| | | // } else { |
| | | matData[i]["count"] = count; |
| | | // } |
| | | matData[i]["count"] = count; |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | layer.msg("数量必须大于零"); |
| | | notice.error({ |
| | | title: '消息通知', |
| | | message: '数量必须大于零' |
| | | }); |
| | | } |
| | | } |
| | | tableIns.reload({data: matData,done:function (res) { |
| | | limit(); |
| | | }}); |
| | | } |
| | | |
| | | layDate.render({ |
| | | elem: '#orderTime', |
| | | trigger: 'click', |
| | | type: 'date' |
| | | }); |
| | | |
| | | }) |
| | | |
| | |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}) |
| | | notice.error({ |
| | | title: '消息通知', |
| | | message: res.msg |
| | | }); |
| | | } |
| | | } |
| | | }); |