提交 | 用户 | 时间
|
1ac2bc
|
1 |
layui.use(['upload', '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 upload = layui.upload; |
|
8 |
|
|
9 |
/** |
|
10 |
* 生产订单管理 |
|
11 |
*/ |
|
12 |
var SalesOrder = { |
|
13 |
tableId: "salesOrderTable" |
|
14 |
}; |
|
15 |
|
|
16 |
/** |
|
17 |
* 初始化表格的列 |
|
18 |
*/ |
|
19 |
SalesOrder.initColumn = function () { |
|
20 |
return [[ |
|
21 |
{type: 'checkbox'}, |
|
22 |
{field: 'id', hide: true, title: '主键id'}, |
|
23 |
{field: 'salesOrderCode', sort: true, title: '订单编号',width: 160}, |
|
24 |
{field: 'customerNo', sort: true, title: '客户编号',width: 120}, |
|
25 |
{field: 'cargoNo', sort: true, title: '货号',width: 120}, |
|
26 |
{field: 'productCode', sort: true, title: '产品编号',width: 160}, |
|
27 |
{field: 'productName', sort: true, title: '产品名称',width: 160}, |
|
28 |
{field: 'planNumber', sort: true, title: '计划数量',width: 120}, |
|
29 |
{ |
|
30 |
field: 'state', align: "center", title: '状态', templet: function (d) { |
|
31 |
switch(d.state){ |
|
32 |
case "1" : |
|
33 |
return "<span style=\"color: #130c0e;\">未开始</span>"; |
|
34 |
break; |
|
35 |
case "2" : |
|
36 |
return "<span style=\"color: #00cc33;\">已拆分</span>"; |
|
37 |
break; |
|
38 |
case "3" : |
|
39 |
return "<span style=\"color: #ff9933;\">已下发</span>"; |
|
40 |
break; |
|
41 |
case "4" : |
|
42 |
return "<span style=\"color: #cc0000;\">已关闭</span>"; |
|
43 |
break; |
|
44 |
default : |
|
45 |
} |
|
46 |
} |
|
47 |
}, |
|
48 |
{field: 'planStartTime', sort: true, title: '计划开始时间',width: 160}, |
|
49 |
{field: 'planEndTime', sort: true, title: '计划结束时间',width: 160}, |
|
50 |
{field: 'workshopCode', sort: true, title: '车间编码',width: 120}, |
|
51 |
{field: 'lineCode', sort: true, title: '产线编码',width: 120}, |
|
52 |
{field: 'deliveryTime', sort: true, title: '交货时间',width: 160}, |
|
53 |
{field: 'orderSource', sort: true, title: '订单来源',width: 120}, |
|
54 |
{field: 'createUser', sort: true, title: '创建用户',width: 120}, |
|
55 |
{field: 'createTime', sort: true, title: '创建时间',width: 160}, |
|
56 |
{field: 'updateUser', sort: true, title: '更改用户',width: 120}, |
|
57 |
{field: 'updateTime', sort: true, title: '更改时间',width: 160}, |
|
58 |
{field: 'remark', sort: true, title: '备注'}, |
|
59 |
{fixed: 'right',width: 125, minWidth: 125, align: 'center', toolbar: '#tableBar', title: '操作'} |
|
60 |
]]; |
|
61 |
}; |
|
62 |
|
|
63 |
/** |
|
64 |
* 点击查询按钮 |
|
65 |
*/ |
|
66 |
SalesOrder.search = function () { |
|
67 |
var queryData = {}; |
|
68 |
queryData['salesOrderCode'] = $('#salesOrderCode').val(); |
|
69 |
queryData['customerNo'] = $('#customerNo').val(); |
|
70 |
queryData['cargoNo'] = $('#cargoNo').val(); |
|
71 |
queryData['productCode'] = $('#productCode').val(); |
|
72 |
queryData['productName'] = $('#productName').val(); |
|
73 |
queryData['workshopCode'] = $('#workshopCode').val(); |
|
74 |
queryData['lineCode'] = $('#lineCode').val(); |
|
75 |
queryData['state'] = $('#state').val(); |
|
76 |
table.reload(SalesOrder.tableId, { |
|
77 |
where: queryData, page: {curr: 1} |
|
78 |
}); |
|
79 |
}; |
|
80 |
|
|
81 |
//下载模板 |
|
82 |
$("#btnTemp").click(function () { |
|
83 |
window.location.href = Feng.ctxPath + "/salesOrder/exportOut" |
|
84 |
}); |
|
85 |
|
|
86 |
// 导入excel |
|
87 |
var uploadInst = upload.render({ |
|
88 |
elem: '#import' |
|
89 |
,url: Feng.ctxPath + '/salesOrder/importIn' |
|
90 |
,accept: 'file' |
|
91 |
,done: function (res) { |
|
92 |
table.reload(SalesOrder.tableId, {url: Feng.ctxPath + "/salesOrder/list"}); |
|
93 |
Feng.success("上传成功") |
|
94 |
} |
|
95 |
,error: function () { |
|
96 |
Feng.error("上传失败") |
|
97 |
} |
|
98 |
}); |
|
99 |
|
|
100 |
$('#split').click(function (){ |
|
101 |
var checkRows = table.checkStatus(SalesOrder.tableId); |
|
102 |
if (checkRows.data.length !== 1) { |
|
103 |
Feng.error("请选择一条要拆分的订单"); |
|
104 |
} |
|
105 |
window.location.href = Feng.ctxPath + '/salesOrder/split?id=' + checkRows.data[0].id |
|
106 |
|
|
107 |
}); |
|
108 |
|
|
109 |
/** |
|
110 |
* 跳转到添加页面 |
|
111 |
*/ |
|
112 |
SalesOrder.jumpAddPage = function () { |
|
113 |
window.location.href = Feng.ctxPath + '/salesOrder/add' |
|
114 |
}; |
|
115 |
|
|
116 |
/** |
|
117 |
* 跳转到编辑页面 |
|
118 |
* |
|
119 |
* @param data 点击按钮时候的行数据 |
|
120 |
*/ |
|
121 |
SalesOrder.jumpEditPage = function (data) { |
|
122 |
window.location.href = Feng.ctxPath + '/salesOrder/edit?id=' + data.id |
|
123 |
}; |
|
124 |
|
|
125 |
/** |
|
126 |
* 导出excel按钮 |
|
127 |
*/ |
|
128 |
SalesOrder.exportExcel = function () { |
|
129 |
var checkRows = table.checkStatus(SalesOrder.tableId); |
|
130 |
if (checkRows.data.length === 0) { |
|
131 |
Feng.error("请选择要导出的数据"); |
|
132 |
} else { |
|
133 |
table.exportFile(tableResult.config.id, checkRows.data, 'xls'); |
|
134 |
} |
|
135 |
}; |
|
136 |
|
|
137 |
/** |
|
138 |
* 下发订单 |
|
139 |
*/ |
|
140 |
SalesOrder.distribute = function (data) { |
|
141 |
layer.alert(data); |
|
142 |
|
|
143 |
}; |
|
144 |
|
|
145 |
/** |
|
146 |
* 点击删除 |
|
147 |
* |
|
148 |
* @param data 点击按钮时候的行数据 |
|
149 |
*/ |
|
150 |
SalesOrder.onDeleteItem = function (data) { |
|
151 |
var operation = function () { |
|
152 |
var ajax = new $ax(Feng.ctxPath + "/salesOrder/delete", function (data) { |
|
153 |
Feng.success("删除成功!"); |
|
154 |
table.reload(SalesOrder.tableId); |
|
155 |
}, function (data) { |
|
156 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
157 |
}); |
|
158 |
ajax.set("id", data.id); |
|
159 |
ajax.start(); |
|
160 |
}; |
|
161 |
Feng.confirm("是否删除?", operation); |
|
162 |
}; |
|
163 |
|
|
164 |
// 渲染表格 |
|
165 |
var tableResult = table.render({ |
|
166 |
elem: '#' + SalesOrder.tableId, |
|
167 |
url: Feng.ctxPath + '/salesOrder/list', |
|
168 |
page: true, |
|
169 |
height: "full-158", |
|
170 |
cellMinWidth: 100, |
|
171 |
cols: SalesOrder.initColumn() |
|
172 |
}); |
|
173 |
|
|
174 |
// 搜索按钮点击事件 |
|
175 |
$('#btnSearch').click(function () { |
|
176 |
SalesOrder.search(); |
|
177 |
}); |
|
178 |
|
|
179 |
// 添加按钮点击事件 |
|
180 |
$('#btnAdd').click(function () { |
|
181 |
|
|
182 |
SalesOrder.jumpAddPage(); |
|
183 |
|
|
184 |
}); |
|
185 |
|
|
186 |
// 导出excel |
|
187 |
$('#btnExp').click(function () { |
|
188 |
SalesOrder.exportExcel(); |
|
189 |
}); |
|
190 |
|
|
191 |
let salesId = []; |
|
192 |
|
|
193 |
// 绑定下发 |
|
194 |
$('#distribute').click(function () { |
|
195 |
var checkRows = table.checkStatus(SalesOrder.tableId); |
|
196 |
if(checkRows.data[0].state === "3"){ |
|
197 |
Feng.error("该工单已下发完毕!"); |
|
198 |
return; |
|
199 |
} |
|
200 |
if (checkRows.data.length !== 1) { |
|
201 |
Feng.error("请选择一条要下发的订单"); |
|
202 |
return; |
|
203 |
} |
|
204 |
var checkRows = table.checkStatus(SalesOrder.tableId); |
|
205 |
console.log(checkRows.data); |
|
206 |
window.location.href = Feng.ctxPath + '/salesOrder/bindParam?id=' + checkRows.data[0].id |
|
207 |
// layer.open({ |
|
208 |
// type: 2, |
|
209 |
// area: ['1000px', '600px'], |
|
210 |
// title: '下发订单', |
|
211 |
// content: Feng.ctxPath + '/salesOrder/bindParam', |
|
212 |
// success: function (layero, index) { |
|
213 |
// // let body = layer.getChildFrame('body', index); |
|
214 |
// // body.find('form').find('#salesOrderList').val(checkRows.data); |
|
215 |
// // 获取子页面的iframe |
|
216 |
// var iframe = window['layui-layer-iframe'+index]; |
|
217 |
// // 向子页面的全局函数child传参 |
|
218 |
// iframe.child(checkRows.data); |
|
219 |
// }, |
|
220 |
// end: function () { |
|
221 |
// table.reload(SalesOrder.tableId, { |
|
222 |
// where: null, page: {curr: 1} |
|
223 |
// }); |
|
224 |
// } |
|
225 |
// }); |
|
226 |
}); |
|
227 |
|
|
228 |
// 工具条点击事件 |
|
229 |
table.on('tool(' + SalesOrder.tableId + ')', function (obj) { |
|
230 |
var data = obj.data; |
|
231 |
var layEvent = obj.event; |
|
232 |
if (layEvent === 'edit') { |
|
233 |
SalesOrder.jumpEditPage(data); |
|
234 |
} else if (layEvent === 'delete') { |
|
235 |
SalesOrder.onDeleteItem(data); |
|
236 |
} |
|
237 |
}); |
|
238 |
}); |