提交 | 用户 | 时间
|
71e81e
|
1 |
layui.use(['table', 'admin', 'ax','laydate', 'func', 'form', 'element','upload'], 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 element = layui.element; |
|
8 |
var laydate = layui.laydate; |
|
9 |
var form = layui.form; |
|
10 |
var upload = layui.upload; |
|
11 |
/** |
|
12 |
* 生产工单管理 |
|
13 |
*/ |
|
14 |
var ProductionOrdeInfo = { |
|
15 |
tableId: "productionOrdeInfoTable" |
|
16 |
}; |
|
17 |
|
|
18 |
//下载excel导入模板 |
|
19 |
$("#btnDownloadExc").click(function () { |
|
20 |
window.location.href = Feng.ctxPath + "/productionOrdeInfo/downloadExcelTemplate" |
|
21 |
}); |
|
22 |
|
|
23 |
//执行实例,导入excel |
|
24 |
var uploadInst = upload.render({ |
|
25 |
elem: '#btnUploadExc' |
|
26 |
, url: '/productionOrdeInfo/uploadExcel' |
|
27 |
,accept: 'file' |
|
28 |
, done: function (res) { |
|
29 |
Feng.success("导入成功!"); |
|
30 |
table.reload(ProductionOrdeInfo.tableId, {url: Feng.ctxPath + "/productionOrdeInfo/list"}); |
|
31 |
} |
|
32 |
, error: function () { |
|
33 |
//请求异常回调 |
|
34 |
Feng.success("导入失败!"); |
|
35 |
} |
|
36 |
}); |
|
37 |
/** |
|
38 |
* 初始化表格的列 |
|
39 |
*/ |
|
40 |
ProductionOrdeInfo.initColumn = function () { |
|
41 |
return [[ |
|
42 |
{type: 'radio'}, |
|
43 |
{align: 'center', toolbar: '#tableBar', title: '操作',minWidth:330}, |
|
44 |
{field: 'id', hide: true, title: 'ID'}, |
|
45 |
/*{field: 'salesOrderNo', sort: true, title: '销售工单号'},*/ |
|
46 |
|
|
47 |
{field: 'workOrderNo', sort: true, title: '生产工单号',minWidth:150}, |
|
48 |
|
|
49 |
/*{field: 'drawingNo', sort: true, title: '图号'},*/ |
|
50 |
/*{field: 'productionLine', sort: true, title: '生产线',minWidth:100},*/ |
|
51 |
{field: 'materialCode', sort: true, title: '产品编号',minWidth:160}, |
|
52 |
// {field: 'materialCode', sort: true, title: '产品编号',minWidth:120, |
|
53 |
// event: 'materialCodeClick', |
|
54 |
// style: 'cursor: pointer;color: blue;font-style: italic;text-decoration: underline;'}, |
|
55 |
{field: 'materialName', sort: true, title: '产品名称',minWidth:280}, |
|
56 |
/* {field: 'custom', sort: true, title: '客户编号',minWidth:120},*/ |
|
57 |
|
|
58 |
{field: 'orderStatus', sort: true, title: '状态',align:'center',width:80,templet: '#orderStatusTpl'}, |
|
59 |
|
|
60 |
{field: 'planQty', sort: true, title: '计划数量',align:'center',minWidth:120}, |
|
61 |
{field: 'actualQty', sort: true, title: '完成数量',align:'center',minWidth:120}, |
|
62 |
// {field: 'actualOnlineQty', sort: true, title: '实际上线数量',minWidth:120}, |
|
63 |
/*{field: 'scrapQty', sort: true, title: '报废数量'}, |
|
64 |
{field: 'repairQty', sort: true, title: '返修数量'}, |
|
65 |
{field: 'actualOnlineQty', sort: true, title: '实际上线数量'}, |
|
66 |
{field: 'onlineCompletionMark', sort: true, title: '上线完工标记'}, |
|
67 |
{field: 'demandDate', sort: true, title: '需求日期'},*/ |
|
68 |
{field: 'planStartTimeString', sort: true, title: '计划开始时间',minWidth:160}, |
|
69 |
{field: 'planEndTimeString', sort: true, title: '计划结束时间',minWidth:160}, |
|
70 |
|
|
71 |
/* {field: 'serialNumber', sort: true, title: '顺序号'},*/ |
|
72 |
|
|
73 |
{field: 'actualStartTime', sort: true, title: '实际开始时间',minWidth:160}, |
|
74 |
{field: 'actualEndTime', sort: true, title: '实际结束时间',minWidth:160}, |
|
75 |
/* {field: 'marketAreaCode', sort: true, title: '市场区域编码',minWidth:120},*/ |
|
76 |
{field: 'softwareVersionCode', sort: true, title: '产品型号',minWidth:120}, |
|
77 |
{field: 'productCompanyCode', sort: true, title: '班次',minWidth:120}, |
|
78 |
|
|
79 |
/* {field: 'spareField1', sort: true, title: '预留字段1'}, |
|
80 |
{field: 'spareField2', sort: true, title: '预留字段2'}, |
|
81 |
{field: 'spareField3', sort: true, title: '预留字段3'}, |
|
82 |
{field: 'spareField4', sort: true, title: '预留字段4'}, |
|
83 |
{field: 'createTime', sort: true, title: '创建时间'}, |
|
84 |
{field: 'updateTime', sort: true, title: '更新时间'}, |
|
85 |
{field: 'createUser', sort: true, title: '创建人'}, |
|
86 |
{field: 'updateUser', sort: true, title: '修改人'},*/ |
|
87 |
{field: 'remarks', sort: true, title: '备注'} |
|
88 |
|
|
89 |
]]; |
|
90 |
}; |
|
91 |
|
|
92 |
/** |
|
93 |
* 点击查询按钮 |
|
94 |
*/ |
|
95 |
ProductionOrdeInfo.search = function () { |
|
96 |
var queryData = {}; |
|
97 |
queryData['workOrderNo'] = $("#workOrderNo").val(); |
|
98 |
queryData['materialCode'] = $("#materialCode").val(); |
|
99 |
queryData['orderStatus'] = $("#orderStatus").val(); |
|
100 |
|
|
101 |
table.reload(ProductionOrdeInfo.tableId, { |
|
102 |
where: queryData, page: {curr: 1} |
|
103 |
}); |
|
104 |
}; |
|
105 |
|
|
106 |
/** |
|
107 |
* 跳转到添加页面 |
|
108 |
*/ |
|
109 |
ProductionOrdeInfo.jumpAddPage = function () { |
|
110 |
window.location.href = Feng.ctxPath + '/productionOrdeInfo/add' |
|
111 |
}; |
|
112 |
|
|
113 |
/** |
|
114 |
* 跳转到编辑页面 |
|
115 |
* |
|
116 |
* @param data 点击按钮时候的行数据 |
|
117 |
*/ |
|
118 |
ProductionOrdeInfo.jumpEditPage = function (data) { |
|
119 |
window.location.href = Feng.ctxPath + '/productionOrdeInfo/edit?id=' + data.id |
|
120 |
}; |
|
121 |
|
|
122 |
/** |
|
123 |
* 导出excel按钮 |
|
124 |
*/ |
|
125 |
ProductionOrdeInfo.exportExcel = function () { |
|
126 |
var checkRows = table.checkStatus(ProductionOrdeInfo.tableId); |
|
127 |
if (checkRows.data.length === 0) { |
|
128 |
Feng.error("请选择要导出的数据"); |
|
129 |
} else { |
|
130 |
table.exportFile(tableResult.config.id, checkRows.data, 'xls'); |
|
131 |
} |
|
132 |
}; |
|
133 |
|
|
134 |
|
|
135 |
/** |
|
136 |
* 点击开始工单 |
|
137 |
*/ |
|
138 |
ProductionOrdeInfo.startOrder = function (data) { |
|
139 |
var ajax1 = new $ax(Feng.ctxPath + "/productionOrdeInfo/orderCount?orderStatus=3"); |
|
140 |
var result1 = ajax1.start(); |
|
141 |
if(result1.data===0) { |
|
142 |
var operation = function () { |
|
143 |
var ajax = new $ax(Feng.ctxPath + "/productionOrdeInfo/editItem", function (data) { |
|
144 |
Feng.success("开始工单成功!"); |
|
145 |
table.reload(ProductionOrdeInfo.tableId); |
|
146 |
}, function (data) { |
|
147 |
Feng.error("开始工单失败!" + data.responseJSON.message + "!"); |
|
148 |
}); |
|
149 |
ajax.set(data); |
|
150 |
ajax.set("flag","true"); |
|
151 |
ajax.start(); |
|
152 |
}; |
|
153 |
Feng.confirm("是否开始生产?", operation); |
|
154 |
}else { |
|
155 |
layer.open({ |
|
156 |
title: "操作提示", |
|
157 |
icon: 0, |
|
158 |
closeBtn: 2, |
|
159 |
area: ['450px', '200px'], |
|
160 |
time: 5000, |
|
161 |
content: '<span style="font-size: 30px;color: red">开始失败,只能有一条生产中的工单进行生产!</span>' |
|
162 |
}); |
|
163 |
} |
|
164 |
}; |
|
165 |
|
|
166 |
/** |
|
167 |
* 点击冻结工单 |
|
168 |
*/ |
|
169 |
ProductionOrdeInfo.freezeOrder = function (data) { |
|
170 |
// var ajax1 = new $ax(Feng.ctxPath + "/productionOrdeInfo/orderCount?orderStatus=3"); |
|
171 |
// var result1 = ajax1.start(); |
|
172 |
// if(result1.data>1) { |
|
173 |
var operation = function () { |
|
174 |
var ajax = new $ax(Feng.ctxPath + "/productionOrdeInfo/editItem", function (data) { |
|
175 |
Feng.success("冻结工单成功!"); |
|
176 |
table.reload(ProductionOrdeInfo.tableId); |
|
177 |
}, function (data) { |
|
178 |
Feng.error("冻结工单失败!" + data.responseJSON.message + "!"); |
|
179 |
}); |
|
180 |
ajax.set(data); |
|
181 |
ajax.start(); |
|
182 |
}; |
|
183 |
Feng.confirm("是否冻结工单?", operation); |
|
184 |
// }else { |
|
185 |
// layer.open({ |
|
186 |
// title: "操作提示", |
|
187 |
// icon: 0, |
|
188 |
// closeBtn: 2, |
|
189 |
// area: ['450px', '200px'], |
|
190 |
// time: 5000, |
|
191 |
// content: '<span style="font-size: 30px;color: red">解冻失败,只能有一条生产中的工单进行生产!</span>' |
|
192 |
// }); |
|
193 |
// } |
|
194 |
|
|
195 |
}; |
|
196 |
|
|
197 |
/** |
|
198 |
* 点击解冻工单 |
|
199 |
*/ |
|
200 |
ProductionOrdeInfo.thawOrder = function (data) { |
|
201 |
var ajax1 = new $ax(Feng.ctxPath + "/productionOrdeInfo/orderCount?orderStatus=3"); |
|
202 |
var result1 = ajax1.start(); |
|
203 |
if(result1.data === 0) { |
|
204 |
var operation = function () { |
|
205 |
var ajax = new $ax(Feng.ctxPath + "/productionOrdeInfo/editItem", function (data) { |
|
206 |
Feng.success("解冻工单成功!"); |
|
207 |
table.reload(ProductionOrdeInfo.tableId); |
|
208 |
}, function (data) { |
|
209 |
Feng.error("解冻工单失败!" + data.responseJSON.message + "!"); |
|
210 |
}); |
|
211 |
ajax.set(data); |
|
212 |
ajax.start(); |
|
213 |
}; |
|
214 |
Feng.confirm("是否解冻工单?", operation); |
|
215 |
}else { |
|
216 |
layer.open({ |
|
217 |
title: "操作提示", |
|
218 |
icon: 0, |
|
219 |
closeBtn: 2, |
|
220 |
area: ['450px', '200px'], |
|
221 |
time: 5000, |
|
222 |
content: '<span style="font-size: 30px;color: red">解冻失败,只能有一条生产中的工单进行生产!</span>' |
|
223 |
}); |
|
224 |
} |
|
225 |
}; |
|
226 |
|
|
227 |
/** |
|
228 |
* 点击启用工单 |
|
229 |
*/ |
|
230 |
ProductionOrdeInfo.enableOrder = function (data) { |
|
231 |
var operation = function () { |
|
232 |
var ajax = new $ax(Feng.ctxPath + "/productionOrdeInfo/editItem", function (data) { |
|
233 |
Feng.success("启用工单成功!"); |
|
234 |
table.reload(ProductionOrdeInfo.tableId); |
|
235 |
}, function (data) { |
|
236 |
Feng.error("启用工单失败!" + data.responseJSON.message + "!"); |
|
237 |
}); |
|
238 |
ajax.set(data); |
|
239 |
ajax.start(); |
|
240 |
}; |
|
241 |
Feng.confirm("是否启用工单?", operation); |
|
242 |
}; |
|
243 |
/** |
|
244 |
* 点击关闭工单 |
|
245 |
*/ |
|
246 |
ProductionOrdeInfo.closeOrder = function (data) { |
|
247 |
var operation = function () { |
|
248 |
var ajax = new $ax(Feng.ctxPath + "/productionOrdeInfo/editItem", function (data) { |
|
249 |
Feng.success("关闭工单成功!"); |
|
250 |
table.reload(ProductionOrdeInfo.tableId); |
|
251 |
}, function (data) { |
|
252 |
Feng.error("关闭工单失败!" + data.responseJSON.message + "!"); |
|
253 |
}); |
|
254 |
ajax.set(data); |
|
255 |
ajax.start(); |
|
256 |
}; |
|
257 |
Feng.confirm("是否关闭工单?", operation); |
|
258 |
}; |
|
259 |
|
|
260 |
ProductionOrdeInfo.materialCodeClick = function (data){ |
|
261 |
layer.open({ |
|
262 |
type: 2, |
|
263 |
area: ['1000px', '600px'], |
|
264 |
title: '物料信息列表', |
|
265 |
content: Feng.ctxPath + '/productionOrdeInfo/materialList', |
|
266 |
success: function (layero, index) { |
|
267 |
window.materialType = '成品'; |
|
268 |
}, |
|
269 |
}); |
|
270 |
} |
|
271 |
|
|
272 |
|
|
273 |
/** |
|
274 |
* 点击删除 |
|
275 |
* |
|
276 |
* @param data 点击按钮时候的行数据 |
|
277 |
*/ |
|
278 |
ProductionOrdeInfo.onDeleteItem = function (data) { |
|
279 |
var operation = function () { |
|
280 |
var ajax = new $ax(Feng.ctxPath + "/productionOrdeInfo/delete", function (data) { |
|
281 |
Feng.success("删除成功!"); |
|
282 |
table.reload(ProductionOrdeInfo.tableId); |
|
283 |
}, function (data) { |
|
284 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
285 |
}); |
|
286 |
ajax.set("id", data.id); |
|
287 |
ajax.start(); |
|
288 |
}; |
|
289 |
Feng.confirm("是否删除?", operation); |
|
290 |
}; |
|
291 |
var now = new Date(); |
|
292 |
|
|
293 |
/** |
|
294 |
* 点击完成 |
|
295 |
* |
|
296 |
* @param data 点击按钮时候的行数据 |
|
297 |
*/ |
|
298 |
ProductionOrdeInfo.finish = function (data) { |
|
299 |
var operation = function () { |
|
300 |
var ajax = new $ax(Feng.ctxPath + "/productionOrdeInfo/editItem", function (data) { |
|
301 |
Feng.success("已完成!"); |
|
302 |
table.reload(ProductionOrdeInfo.tableId); |
|
303 |
}, function (data) { |
|
304 |
Feng.error("删除失败!" + data.responseJSON.message + "!"); |
|
305 |
}); |
|
306 |
ajax.set(data); |
|
307 |
ajax.start(); |
|
308 |
}; |
|
309 |
Feng.confirm("是否完成?", operation); |
|
310 |
}; |
|
311 |
|
|
312 |
// 渲染表格 |
|
313 |
var tableResult = table.render({ |
|
314 |
elem: '#' + ProductionOrdeInfo.tableId, |
|
315 |
url: Feng.ctxPath + '/productionOrdeInfo/list', |
|
316 |
toolbar: '#toolbarDemo', |
|
317 |
page: true, |
|
318 |
height: "full-158", |
|
319 |
cellMinWidth: 100, |
|
320 |
cols: ProductionOrdeInfo.initColumn() |
|
321 |
}); |
|
322 |
|
|
323 |
// 搜索按钮点击事件 |
|
324 |
$('#btnSearch').click(function () { |
|
325 |
ProductionOrdeInfo.search(); |
|
326 |
}); |
|
327 |
|
|
328 |
// 添加按钮点击事件 |
|
329 |
/* $('body').on('click', '#btnAdd', function() {*/ |
|
330 |
$('#btnAdd').click(function () { |
|
331 |
ProductionOrdeInfo.jumpAddPage(); |
|
332 |
}); |
|
333 |
|
|
334 |
// 导出excel |
|
335 |
$('#btnExp').click(function () { |
|
336 |
ProductionOrdeInfo.exportExcel(); |
|
337 |
}); |
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
var data_tr; |
|
342 |
table.on('radio(' + ProductionOrdeInfo.tableId + ')', function (obj) { |
|
343 |
data_tr = $(this); |
|
344 |
}); |
|
345 |
|
|
346 |
// 上移按钮点击事件 |
|
347 |
$('body').on('click', '#btnUpTr', function() { |
|
348 |
var checkRows = table.checkStatus(ProductionOrdeInfo.tableId); |
|
349 |
if (checkRows.data.length != 1) { |
|
350 |
layer.msg("请选择一行数据!"); |
|
351 |
return; |
|
352 |
} |
|
353 |
var tr=$(data_tr).parent().parent().parent(); |
|
354 |
if($(tr).prev().html()==null){ |
|
355 |
layer.msg("已经是最顶部了!"); |
|
356 |
return; |
|
357 |
}else { |
|
358 |
var tbData = table.cache.productionOrdeInfoTable; |
|
359 |
//未上移前,记录本行和上一行数据 |
|
360 |
var tem = tbData[tr.index()]; |
|
361 |
var tem2 = tbData[tr.prev().index()]; |
|
362 |
|
|
363 |
//将本身插入到目标tr之前 |
|
364 |
$(tr).insertBefore($(tr).prev()); |
|
365 |
|
|
366 |
var num1 = tem.serialNumber; |
|
367 |
var num2 = tem2.serialNumber; |
|
368 |
|
|
369 |
tem.serialNumber = num2; |
|
370 |
tem2.serialNumber = num1; |
|
371 |
//上移之后,数据交换 |
|
372 |
tbData[tr.index()]=tem; |
|
373 |
tbData[tr.next().index()]=tem2; |
|
374 |
} |
|
375 |
}); |
|
376 |
|
|
377 |
// 下移按钮点击事件 |
|
378 |
$('body').on('click', '#btnDownTr', function() { |
|
379 |
var checkRows = table.checkStatus(ProductionOrdeInfo.tableId); |
|
380 |
if (checkRows.data.length != 1) { |
|
381 |
layer.msg("请选择一行数据!"); |
|
382 |
return; |
|
383 |
} |
|
384 |
var tr=$(data_tr).parent().parent().parent(); |
|
385 |
if($(tr).next().html()==null){ |
|
386 |
layer.msg("已经是最低部了!"); |
|
387 |
return; |
|
388 |
}else { |
|
389 |
var tbData = table.cache.productionOrdeInfoTable; |
|
390 |
//未上移前,记录本行和下一行数据 |
|
391 |
var tem = tbData[tr.index()]; |
|
392 |
var tem2 = tbData[tr.next().index()]; |
|
393 |
|
|
394 |
// 将本身插入到目标tr的后面 |
|
395 |
$(tr).insertAfter($(tr).next()); |
|
396 |
|
|
397 |
var num1 = tem.serialNumber; |
|
398 |
var num2 = tem2.serialNumber; |
|
399 |
|
|
400 |
tem.serialNumber = num2; |
|
401 |
tem2.serialNumber = num1; |
|
402 |
//上移之后,数据交换 |
|
403 |
tbData[tr.index()]=tem; |
|
404 |
tbData[tr.prev().index()]=tem2; |
|
405 |
} |
|
406 |
}); |
|
407 |
|
|
408 |
// 保存顺序 |
|
409 |
$('body').on('click', '#btnSaveSort', function() { |
|
410 |
var tbData = table.cache.productionOrdeInfoTable; |
|
411 |
$.ajax({ |
|
412 |
url: "/productionOrdeInfo/editItemAll", |
|
413 |
data: JSON.stringify(tbData), |
|
414 |
type: "post", |
|
415 |
contentType: "application/json", |
|
416 |
dataType: "json", |
|
417 |
success: function(data) { |
|
418 |
Feng.success("更新成功!"); |
|
419 |
table.reload(ProductionOrdeInfo.tableId); |
|
420 |
}, |
|
421 |
error: function (data) { |
|
422 |
if (me.error !== undefined) { |
|
423 |
me.error(data); |
|
424 |
} |
|
425 |
} |
|
426 |
}); |
|
427 |
|
|
428 |
}); |
|
429 |
|
|
430 |
//获取当前日期 |
|
431 |
function getDateTime(){ |
|
432 |
let date = new Date(); |
|
433 |
let year = date.getFullYear(); |
|
434 |
let month = date.getMonth() + 1; |
|
435 |
let day = date.getDate(); |
|
436 |
let time = date.toLocaleTimeString(); |
|
437 |
// 对月份进行处理,1-9月在前面添加一个“0” |
|
438 |
if (month >= 1 && month <= 9) { |
|
439 |
month = "0" + month; |
|
440 |
} |
|
441 |
//对日期进行处理,1-9日在前面添加一个“0” |
|
442 |
if (day >= 0 && day <= 9) { |
|
443 |
day = "0" + day; |
|
444 |
} |
|
445 |
let separator = "-"; //添加分隔符“-” |
|
446 |
this.dateTime = year + separator + month + separator + day + " " + time; |
|
447 |
return this.dateTime; |
|
448 |
} |
|
449 |
|
|
450 |
|
|
451 |
// 工具条点击事件 |
|
452 |
table.on('tool(' + ProductionOrdeInfo.tableId + ')', function (obj) { |
|
453 |
var data = obj.data; |
|
454 |
var layEvent = obj.event; |
|
455 |
|
|
456 |
if (layEvent === 'edit') {//编辑 |
|
457 |
ProductionOrdeInfo.jumpEditPage(data); |
|
458 |
} |
|
459 |
else if (layEvent === 'start') {//开始 |
|
460 |
data.orderStatus = '3'; |
|
461 |
//data.actualStartTime = getDateTime(); |
|
462 |
ProductionOrdeInfo.startOrder(data); |
|
463 |
}else if (layEvent === 'freeze') {//冻结 |
|
464 |
data.orderStatus = '4'; |
|
465 |
ProductionOrdeInfo.freezeOrder(data); |
|
466 |
}else if (layEvent === 'thaw') {//解冻 |
|
467 |
data.orderStatus = '3'; |
|
468 |
ProductionOrdeInfo.thawOrder(data); |
|
469 |
}else if (layEvent === 'close') {//关闭 |
|
470 |
data.orderStatus = '6'; |
|
471 |
ProductionOrdeInfo.closeOrder(data); |
|
472 |
}else if (layEvent === 'enable') {//启用 |
|
473 |
data.orderStatus = '1'; |
|
474 |
ProductionOrdeInfo.enableOrder(data); |
|
475 |
}else if (layEvent === 'delete') { |
|
476 |
ProductionOrdeInfo.onDeleteItem(data); |
|
477 |
}else if (layEvent === 'materialCodeClick') { |
|
478 |
ProductionOrdeInfo.materialCodeClick(data); |
|
479 |
}else if (layEvent === 'finish') {//完成 |
|
480 |
data.orderStatus = '5'; |
|
481 |
data.actualEndTime = getDateTime(); |
|
482 |
ProductionOrdeInfo.finish(data); |
|
483 |
} |
|
484 |
}); |
|
485 |
|
|
486 |
}); |