提交 | 用户 | 时间
|
71e81e
|
1 |
|
懒 |
2 |
layui.use(['table', 'admin', 'ax', 'func'], function () { |
|
3 |
var $ = layui.$; |
|
4 |
var table = layui.table; |
|
5 |
var $ax = layui.ax; |
|
6 |
var admin = layui.admin; |
|
7 |
var func = layui.func; |
|
8 |
|
|
9 |
|
|
10 |
/** |
|
11 |
* 看板配置管理 |
|
12 |
*/ |
|
13 |
var KanbanConf = { |
|
14 |
tableId: "kanbanConfTable" |
|
15 |
}; |
|
16 |
|
|
17 |
/** |
|
18 |
* bom信息管理 |
|
19 |
*/ |
|
20 |
var BomInfo = { |
|
21 |
tableId: "bomInfoTable" |
|
22 |
}; |
|
23 |
|
|
24 |
/** |
|
25 |
* bom信息管理 |
|
26 |
*/ |
|
27 |
var MaterialShortage = { |
|
28 |
tableId: "materialShortageTable" |
|
29 |
}; |
|
30 |
|
|
31 |
initPageInfo(); |
|
32 |
async function initPageInfo() { |
|
33 |
await initKanBanConfInfo();//初始化配置信息 |
|
34 |
await initOrderInfo(); |
|
35 |
initBomTable(); |
|
36 |
initMaterialShortage(); |
|
37 |
/* xR(); |
|
38 |
xa();*/ |
|
39 |
} |
|
40 |
|
|
41 |
$('#revert').click(function () { |
|
42 |
window.location.href = Feng.ctxPath + '/badBoard/boardHome' |
|
43 |
}); |
|
44 |
|
|
45 |
function initKanBanConfInfo() { |
|
46 |
// 根据ip查询配置信息 |
|
47 |
var ajax = new $ax(Feng.ctxPath + "/lineFeedingView/qryKBConflist?pageCode=" + 'KB_WLDJ_007'); |
|
48 |
var result = ajax.start(); |
|
49 |
if (result.data.length > 0) { |
|
50 |
let msg = result.data[0]; |
|
51 |
$('#id').val(msg.id); |
|
52 |
$('#ipAddress').val(msg.ipAddress); |
|
53 |
$('#pageCode').val(msg.pageCode); |
|
54 |
$('#workshopCode').val(msg.workshopCode); |
|
55 |
$('#lineCode').val(msg.lineCode); |
|
56 |
$('#locationCode').val(msg.locationCode); |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
function initOrderInfo() { |
|
61 |
// 根据ip查询配置信息 |
|
62 |
var ajax = new $ax(Feng.ctxPath + "/productionOrdeInfo/list?orderStatus=" + '3'); |
|
63 |
var result = ajax.start(); |
|
64 |
if (result.data.length > 0) { |
|
65 |
let msg = result.data[0]; |
|
66 |
$('#orderId').val(msg.id); |
|
67 |
$('#workOrderNo').val(msg.workOrderNo); |
|
68 |
$('#materialCode').val(msg.materialCode); |
|
69 |
$('#materialName').val(msg.materialName); |
|
70 |
$('#planQty').val(msg.planQty); |
|
71 |
|
|
72 |
$('#custom').val(msg.custom); |
|
73 |
$('#createTime').val(msg.createTime); |
|
74 |
$('#actualQty').val(msg.actualQty); |
|
75 |
$('#planStartTime').val(msg.planStartTime); |
|
76 |
$('#planEndTime').val(msg.planEndTime); |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 |
function initBomTable(){ |
|
81 |
checkTable(); |
|
82 |
var queryData = {}; |
|
83 |
console.log($("#locationCode").val()); |
|
84 |
console.log($("#materialCode").val()); |
|
85 |
|
|
86 |
queryData['locationCode'] = $("#locationCode").val(); |
|
87 |
queryData['productCode'] = $("#materialCode").val(); |
|
88 |
queryData['stepSortFlag'] = "1"; |
|
89 |
|
|
90 |
// 渲染表格 |
|
91 |
var tableResult = table.render({ |
|
92 |
elem: '#' + BomInfo.tableId, |
|
93 |
url: Feng.ctxPath + '/recipeManage/list', |
|
94 |
// page: true, |
|
95 |
// height: 475, |
|
96 |
height: 530, |
|
97 |
cellMinWidth: 100, |
|
98 |
where:queryData, |
|
99 |
cols: BomInfo.initColumn() |
|
100 |
}); |
|
101 |
} |
|
102 |
|
|
103 |
function checkTable(){ |
|
104 |
setTimeout(function() { |
|
105 |
if($('#locationCode').val().length===null||$('#locationCode').val() === ""){ |
|
106 |
Feng.error("请选择工位!") |
|
107 |
return; |
|
108 |
} |
|
109 |
if($('#materialCode').val().length===null||$('#materialCode').val() === ""){ |
|
110 |
Feng.error("请选择生产工单!") |
|
111 |
return; |
|
112 |
} |
|
113 |
}, 2000); |
|
114 |
} |
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
/** |
|
119 |
* 物料Bom初始化表格的列 |
|
120 |
*/ |
|
121 |
BomInfo.initColumn = function () { |
|
122 |
return [[ |
|
123 |
{type:"numbers" ,title:'工步',width:40,fixed:'left'}, |
|
124 |
{field: 'id', hide: true, title: 'id'}, |
|
125 |
{field: 'operationSteps', sort: true, title: '操作内容', width: 210}, |
|
126 |
{field: 'spareField1', sort: true, title: '物料条码'}, |
|
127 |
{field: 'spareField2', sort: true, title: '数据', width: 200}, |
|
128 |
{field: 'spareField3', sort: true, title: '结果', width: 100}, |
|
129 |
{fixed: 'right', title:'操作', toolbar: '#barDemo', width: 70} |
|
130 |
|
|
131 |
]]; |
|
132 |
}; |
|
133 |
|
|
134 |
/** |
|
135 |
* 缺料报警初始化表格的列 |
|
136 |
*/ |
|
137 |
MaterialShortage.initColumn = function () { |
|
138 |
return [[ |
|
139 |
{type: 'checkbox'}, |
|
140 |
{field: 'id', hide: true, title: 'ID'}, |
|
141 |
{field: 'workOrderNo', sort: true, title: '工单号', width: 165}, |
|
142 |
{field: 'productCode', sort: true, title: '产品编码'}, |
|
143 |
{field: 'materialCode', sort: true, title: '物料编号'}, |
|
144 |
{field: 'locationCode', sort: true, title: '工位编号', width: 105}, |
|
145 |
{field: 'lineCode', sort: true, title: '产线编号', width: 105}, |
|
146 |
]]; |
|
147 |
}; |
|
148 |
|
|
149 |
function initMaterialShortage(){ |
|
150 |
var queryData = {}; |
|
151 |
queryData['workOrderNo'] = $("#workOrderNo").val(); |
|
152 |
// 渲染表格 |
|
153 |
var tableResult = table.render({ |
|
154 |
elem: '#' + MaterialShortage.tableId, |
|
155 |
url: Feng.ctxPath + '/materialTraceability/viewList', |
|
156 |
page: true, |
|
157 |
height: 257, |
|
158 |
cellMinWidth: 80, |
|
159 |
where:queryData, |
|
160 |
cols: MaterialShortage.initColumn() |
|
161 |
}); |
|
162 |
} |
|
163 |
|
|
164 |
|
|
165 |
// 生产工单设置按钮点击事件 |
|
166 |
$('#orderBtnSet').click(function () { |
|
167 |
KanbanConf.openOrderEditPage(); |
|
168 |
}); |
|
169 |
|
|
170 |
// 设置按钮点击事件 |
|
171 |
$('#btnSet').click(function () { |
|
172 |
var id = $("#id").val(); |
|
173 |
if(id == "" || id == undefined){ |
|
174 |
KanbanConf.openAddDlg(); |
|
175 |
}else{ |
|
176 |
KanbanConf.openEditPage(id); |
|
177 |
} |
|
178 |
|
|
179 |
}); |
|
180 |
|
|
181 |
/** |
|
182 |
* 弹出添加页面设置对话框 |
|
183 |
*/ |
|
184 |
KanbanConf.openAddDlg = function () { |
|
185 |
layer.open({ |
|
186 |
type: 2, |
|
187 |
area: ['1000px', '600px'], |
|
188 |
title: '添加看板配置', |
|
189 |
content: Feng.ctxPath + '/lineFeedingView/add', |
|
190 |
success: function (layero, index) { |
|
191 |
let body = layer.getChildFrame('body', index); |
|
192 |
body.find('form').find('#testlineCode').val($('#lineCode').val()); |
|
193 |
body.find('form').find('#testlocationCode').val($('#locationCode').val()); |
|
194 |
body.find('form').find('#pageCode').val("KB_WLDJ_007"); |
|
195 |
}, |
|
196 |
end: function () { |
|
197 |
console.log("end") |
|
198 |
let lineCode = JSON.parse(window.localStorage.getItem('lineCode')); |
|
199 |
let locationCode = JSON.parse(window.localStorage.getItem('locationCode')); |
|
200 |
$('#lineCode').val(lineCode); |
|
201 |
$('#locationCode').val(locationCode); |
|
202 |
initKanBanConfInfo() |
|
203 |
} |
|
204 |
}); |
|
205 |
}; |
|
206 |
|
|
207 |
/** |
|
208 |
* 弹出编辑页面设置对话框 |
|
209 |
* |
|
210 |
* @param data 点击按钮时候的行数据 |
|
211 |
*/ |
|
212 |
KanbanConf.openEditPage = function (data) { |
|
213 |
func.open({ |
|
214 |
title: '添加看板配置', |
|
215 |
content: Feng.ctxPath + '/lineFeedingView/edit?id=' + data, |
|
216 |
//tableId: KanbanConf.tableId |
|
217 |
}); |
|
218 |
|
|
219 |
}; |
|
220 |
|
|
221 |
KanbanConf.openOrderEditPage = function (data) { |
|
222 |
layer.open({ |
|
223 |
type: 2, |
|
224 |
area: ['1000px', '600px'], |
|
225 |
title: '工单配置', |
|
226 |
content: Feng.ctxPath + '/lineFeedingView/orderEdit', |
|
227 |
success: function () { |
|
228 |
console.log($('#lineCode').val()); |
|
229 |
window.lineCode = $('#lineCode').val(); |
|
230 |
}, |
|
231 |
end: function () { |
|
232 |
let msg = JSON.parse(window.localStorage.getItem('message')); |
|
233 |
console.log("选择工单_id", msg.id) |
|
234 |
$('#orderId').val(msg.id); |
|
235 |
$('#workOrderNo').val(msg.workOrderNo); |
|
236 |
$('#materialCode').val(msg.materialCode); |
|
237 |
$('#materialName').val(msg.materialName); |
|
238 |
$('#planQty').val(msg.planQty); |
|
239 |
$('#createTime').val(msg.createTime); |
|
240 |
$('#actualQty').val(msg.actualQty); |
|
241 |
initMaterialShortage(); |
|
242 |
} |
|
243 |
}); |
|
244 |
}; |
|
245 |
|
|
246 |
$('#btnClean').click(function (){ |
|
247 |
$('#barCode').val(""); |
|
248 |
}); |
|
249 |
|
|
250 |
$('#finish').click(function (){ |
|
251 |
var ajax = new $ax(Feng.ctxPath + "/recipeManage/finish?locationCode=" + $('#locationCode').val()+"&productCode="+$('#materialCode').val()); |
|
252 |
ajax.set("workOrderNo",$('#workOrderNo').val()); |
|
253 |
ajax.set("lineCode",$('#lineCode').val()); |
|
254 |
var result = ajax.start(); |
|
255 |
console.log("---------------"+result.data) |
|
256 |
if(result.data === 0){ |
|
257 |
initBomTable(); |
|
258 |
Feng.success("已完成!"); |
|
259 |
}else if(result.data === 980){ |
|
260 |
Feng.error("未加载配方列表!"); |
|
261 |
|
|
262 |
}else { |
|
263 |
Feng.error("请录入完整数据!"); |
|
264 |
} |
|
265 |
|
|
266 |
}); |
|
267 |
|
|
268 |
$('#heavyLoad').click(function (){ |
|
269 |
checkTable(); |
|
270 |
var ajax = new $ax(Feng.ctxPath + "/recipeManage/heavyLoad?locationCode=" + $('#locationCode').val()+"&productCode="+$('#materialCode').val()); |
|
271 |
var result = ajax.start(); |
|
272 |
Feng.success("重载完成!"); |
|
273 |
initBomTable(); |
|
274 |
}); |
|
275 |
|
|
276 |
var ip = ""; |
|
277 |
$(document).ready(function () { |
|
278 |
console.log($('#locationCode').val()); |
|
279 |
var ajax = new $ax(Feng.ctxPath + "/scannerConfig/getOneByLocationCode?locationCode=" + $('#locationCode').val()); |
|
280 |
var result = ajax.start(); |
|
281 |
console.log(result.data); |
|
282 |
ip = result.data.ipAddress; |
|
283 |
}); |
|
284 |
|
|
285 |
var websocket = null; |
|
286 |
//判断当前浏览器是否支持WebSocket |
|
287 |
if('WebSocket' in window) { |
|
288 |
//改成你的地址 |
|
289 |
// websocket = new WebSocket('ws://'+ip+':8083/websocket/lineFeedingView'); |
|
290 |
websocket = new WebSocket('ws://127.0.0.1:8083/websocket/recipeManageView'); |
|
291 |
} else { |
|
292 |
alert('当前浏览器 Not support websocket') |
|
293 |
} |
|
294 |
//接收到消息的回调方法 |
|
295 |
websocket.onmessage = function(event) { |
|
296 |
console.log(event); |
|
297 |
console.log(event.data) |
|
298 |
$('#barCode').val(event.data); |
|
299 |
var ajax = new $ax(Feng.ctxPath + "/recipeManage/editItemView?locationCode=" + $('#locationCode').val()+"&productCode="+$('#materialCode').val()+"&soketData="+event.data); |
|
300 |
var result = ajax.start(); |
|
301 |
console.log(result.data); |
|
302 |
if(result.data!==null&&result.data!==""){ |
|
303 |
Feng.info(result.data); |
|
304 |
} |
|
305 |
initBomTable(); |
|
306 |
|
|
307 |
} |
|
308 |
|
|
309 |
//连接成功建立的回调方法 |
|
310 |
websocket.onopen = function() { |
|
311 |
Feng.info("扫码枪连接建立成功") |
|
312 |
} |
|
313 |
|
|
314 |
//连接关闭的回调方法 |
|
315 |
websocket.onclose = function() { |
|
316 |
Feng.info("扫码枪连接已关闭") |
|
317 |
} |
|
318 |
|
|
319 |
window.onunload = function(){ |
|
320 |
websocket.close(); |
|
321 |
} |
|
322 |
|
|
323 |
table.on('tool(bomInfoTable)', function(obj){ // 双击 toolDouble |
|
324 |
var data = obj.data; |
|
325 |
if(obj.event === 'del'){ |
|
326 |
layer.confirm('真的删除行么', function(index){ |
|
327 |
obj.del(); |
|
328 |
layer.close(index); |
|
329 |
console.log(data); |
|
330 |
singleRowDelete(data); |
|
331 |
}); |
|
332 |
} |
|
333 |
}); |
|
334 |
|
|
335 |
function singleRowDelete(data){ |
|
336 |
console.log("id"+data.id); |
|
337 |
var ajax = new $ax(Feng.ctxPath + "/recipeManage/singleRowDelete?id=" + data.id); |
|
338 |
var result = ajax.start(); |
|
339 |
initBomTable(); |
|
340 |
} |
|
341 |
|
|
342 |
}); |