提交 | 用户 | 时间
|
1ac2bc
|
1 |
layui.use(['form', 'table', 'admin', 'ax', 'func'], function () { |
懒 |
2 |
var $ = layui.$; |
|
3 |
var table = layui.table; |
|
4 |
var $ax = layui.ax; |
|
5 |
var admin = layui.admin; |
|
6 |
var func = layui.func; |
|
7 |
var form = layui.form; |
|
8 |
|
|
9 |
|
|
10 |
/** |
|
11 |
* 物料信息管理 |
|
12 |
*/ |
|
13 |
var MaterialInfo = { |
|
14 |
tableId: "materialInfoTable" |
|
15 |
}; |
|
16 |
|
|
17 |
/** |
|
18 |
* 订单信息 |
|
19 |
*/ |
|
20 |
var salesOrderChild = { |
|
21 |
tableId: "salesOrderChildTable" |
|
22 |
}; |
|
23 |
|
|
24 |
/** |
|
25 |
* 初始化表格的列 |
|
26 |
*/ |
|
27 |
MaterialInfo.initColumn = function () { |
|
28 |
return [[ |
|
29 |
{field: 'id', hide: true, title: '主键id'}, |
|
30 |
{field: 'salesOrderCode', sort: true, title: '订单编号',width: 160}, |
|
31 |
{field: 'customerNo', sort: true, title: '客户编号',width: 120}, |
|
32 |
{field: 'cargoNo', sort: true, title: '货号',width: 120}, |
|
33 |
{field: 'productCode', sort: true, title: '产品编号',width: 160}, |
|
34 |
{field: 'productName', sort: true, title: '产品名称',width: 160}, |
|
35 |
{field: 'planNumber', sort: true, title: '计划数量',width: 120}, |
|
36 |
{field: 'planStartTime', sort: true, title: '计划开始时间',width: 160}, |
|
37 |
{field: 'planEndTime', sort: true, title: '计划结束时间',width: 160}, |
|
38 |
{field: 'workshopCode', sort: true, title: '车间编码',width: 120}, |
|
39 |
{field: 'lineCode', sort: true, title: '产线编码',width: 120}, |
|
40 |
{field: 'deliveryTime', sort: true, title: '交货时间',width: 160}, |
|
41 |
{field: 'state', sort: true, title: '状态'}, |
|
42 |
{field: 'orderSource', sort: true, title: '订单来源',width: 120}, |
|
43 |
{field: 'createUser', sort: true, title: '创建用户',width: 120}, |
|
44 |
{field: 'createTime', sort: true, title: '创建时间',width: 160}, |
|
45 |
{field: 'updateUser', sort: true, title: '更改用户',width: 120}, |
|
46 |
{field: 'updateTime', sort: true, title: '更改时间',width: 160}, |
|
47 |
]]; |
|
48 |
}; |
|
49 |
|
|
50 |
//获取信息 |
|
51 |
var ajax = new $ax(Feng.ctxPath + "/salesOrder/list?id=" + Feng.getUrlParam("id")); |
|
52 |
var result = ajax.start(); |
|
53 |
var orderRes = result.data; |
|
54 |
let salesOrderCode = result.data[0].salesOrderCode; |
|
55 |
let planNumber = result.data[0].planNumber; |
|
56 |
$('#salesOrderCode').val(salesOrderCode); |
|
57 |
$('#cargoNo').val(result.data[0].cargoNo); |
|
58 |
$('#productCode').val(result.data[0].productCode); |
|
59 |
$('#planNumber').val(result.data[0].planNumber); |
|
60 |
let state = result.data[0].state; |
|
61 |
if(result.data[0].state === "2"){ |
|
62 |
$('#residueNumber').val(0); |
|
63 |
}else { |
|
64 |
$('#residueNumber').val(result.data[0].planNumber); |
|
65 |
} |
|
66 |
|
|
67 |
// 拆分按钮点击事件 |
|
68 |
$('#splitbtn').click(function () { |
|
69 |
let splitNumber = $('#splitNumber').val(); |
|
70 |
var ajax1 = new $ax(Feng.ctxPath + "/salesOrderChild/getPlanNumberTotal?salesOrderCode=" +salesOrderCode); |
|
71 |
var result1 = ajax1.start(); |
|
72 |
let test = parseInt(splitNumber); |
|
73 |
if(result1.data+test>planNumber){ |
|
74 |
Feng.error("超出订单计划总数无法拆分!") |
|
75 |
return |
|
76 |
} |
|
77 |
$('#residueNumber').val($('#residueNumber').val()-splitNumber); |
|
78 |
var ajax = new $ax(Feng.ctxPath + "/salesOrderChild/addItem?salesOrderCode=" +salesOrderCode+"&splitNumber="+splitNumber); |
|
79 |
var result = ajax.start(); |
|
80 |
salesOrderChildTableResult.reload(); |
|
81 |
|
|
82 |
}); |
|
83 |
|
|
84 |
// 渲染表格 |
|
85 |
var salesOrderChildTableResult = table.render({ |
|
86 |
elem: '#' + salesOrderChild.tableId, |
|
87 |
url: Feng.ctxPath + '/salesOrderChild/list?salesOrderCode='+ salesOrderCode, |
|
88 |
page: true, |
|
89 |
cellMinWidth: 100, |
|
90 |
cols: MaterialInfo.initColumn() |
|
91 |
}); |
|
92 |
|
|
93 |
$('#cancel').click(function(){ |
|
94 |
if(state === "1"){ |
|
95 |
var ajax = new $ax(Feng.ctxPath + "/salesOrderChild/deleteBySalesOrderCode?salesOrderCode=" +salesOrderCode); |
|
96 |
var result = ajax.start(); |
|
97 |
} |
|
98 |
window.location.href = Feng.ctxPath + '/salesOrder' |
|
99 |
}); |
|
100 |
|
|
101 |
$('#btnSubmit').click(function(){ |
|
102 |
if(state === "2"){ |
|
103 |
Feng.error("订单已拆分完成,请勿提交!") |
|
104 |
return |
|
105 |
} |
|
106 |
console.log($('#residueNumber').val()); |
|
107 |
let residuePas = parseInt($('#residueNumber').val()); |
|
108 |
if(residuePas !== 0){ |
|
109 |
Feng.error("未拆分完毕禁止提交订单!") |
|
110 |
return |
|
111 |
} |
|
112 |
var ajax = new $ax(Feng.ctxPath + "/salesOrder/updateBySalesOrderId", function (data) { |
|
113 |
}, function (data) { |
|
114 |
Feng.error("更新失败!" + data.responseJSON.message) |
|
115 |
}); |
|
116 |
ajax.set('id',Feng.getUrlParam("id")); |
|
117 |
ajax.start(); |
|
118 |
window.location.href = Feng.ctxPath + '/salesOrder' |
|
119 |
}); |
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
}); |