提交 | 用户 | 时间
|
71e81e
|
1 |
|
懒 |
2 |
layui.use(['form','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 |
var form = layui.form; |
|
9 |
|
|
10 |
|
|
11 |
/** |
|
12 |
* 看板配置管理 |
|
13 |
*/ |
|
14 |
var KanbanConf = { |
|
15 |
tableId: "kanbanConfTable" |
|
16 |
}; |
|
17 |
|
|
18 |
/** |
|
19 |
* bom信息管理 |
|
20 |
*/ |
|
21 |
var BomInfo = { |
|
22 |
tableId: "bomInfoTable" |
|
23 |
}; |
|
24 |
|
|
25 |
/** |
|
26 |
* bom信息管理 |
|
27 |
*/ |
|
28 |
var MaterialShortage = { |
|
29 |
tableId: "materialShortageTable" |
|
30 |
}; |
|
31 |
|
|
32 |
$(document).ready(function() { |
|
33 |
console.log("111111111111111111111"); |
|
34 |
$.ajax({ |
|
35 |
type: "POST", |
|
36 |
contentType: "application/json;charset=UTF-8", |
|
37 |
url: Feng.ctxPath + '/lineInfo/list', |
|
38 |
success: function (result) { |
|
39 |
$('#lineCode').empty(); |
|
40 |
$('#lineCode').append(new Option("请选择产线", ""));// 下拉菜单里添加元素 |
|
41 |
|
|
42 |
$.each(result.data, function (index, value) { |
|
43 |
$('#lineCode').append(new Option(value.lineCode, value.lineCode));// 下拉菜单里添加元素 |
|
44 |
}); |
|
45 |
layui.form.render("select");//重新渲染 固定写法 |
|
46 |
}, |
|
47 |
}); |
|
48 |
}); |
|
49 |
|
|
50 |
form.on("select", function (data) { |
|
51 |
if (data.value !== "") { |
|
52 |
if (data.elem.id === "lineCode") { |
|
53 |
$.ajax({ |
|
54 |
type: "POST", |
|
55 |
contentType: "application/json;charset=UTF-8", |
|
56 |
url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+ $('#lineCode').val(), |
|
57 |
success: function (result) { |
|
58 |
$('#locationCode').empty(); |
|
59 |
$('#locationCode').append(new Option("请选择工位", ""));// 下拉菜单里添加元素 |
|
60 |
|
|
61 |
$.each(result.data, function (index, value) { |
|
62 |
$('#locationCode').append(new Option(value.locationCode, value.locationCode));// 下拉菜单里添加元素 |
|
63 |
}); |
|
64 |
layui.form.render("select");//重新渲染 固定写法 |
|
65 |
}, |
|
66 |
}); |
|
67 |
} |
|
68 |
if (data.elem.id === "locationCode") { |
|
69 |
$.ajax({ |
|
70 |
type: "POST", |
|
71 |
contentType: "application/json;charset=UTF-8", |
|
72 |
url: Feng.ctxPath + '/scrapCategoryConf/list?locationCode='+ $('#locationCode').val(), |
|
73 |
success: function (result) { |
|
74 |
$('#scrapReason').empty(); |
|
75 |
$('#scrapCategory').empty(); |
|
76 |
$.each(result.data, function (index, value) { |
|
77 |
$('#scrapCategory').append(new Option(value.scrapCategory, value.scrapCategory));// 下拉菜单里添加元素 |
|
78 |
$('#scrapReason').append(new Option(value.scrapReason, value.scrapReason));// 下拉菜单里添加元素 |
|
79 |
}); |
|
80 |
if($('#scrapCategory option').length === 0){ |
|
81 |
Feng.error("该工位没有报废类目配置"); |
|
82 |
} |
|
83 |
layui.form.render("select");//重新渲染 固定写法 |
|
84 |
}, |
|
85 |
}); |
|
86 |
} |
|
87 |
} |
|
88 |
}); |
|
89 |
|
|
90 |
initPageInfo(); |
|
91 |
async function initPageInfo() { |
|
92 |
await initKanBanConfInfo();//初始化配置信息 |
|
93 |
await initOrderInfo(); |
|
94 |
initBomTable(); |
|
95 |
initMaterialShortage(); |
|
96 |
/* xR(); |
|
97 |
xa();*/ |
|
98 |
} |
|
99 |
|
|
100 |
function initKanBanConfInfo() { |
|
101 |
// 根据ip查询配置信息 |
|
102 |
var ajax = new $ax(Feng.ctxPath + "/scrapBoard/qryKBConflist?pageCode=" + 'KB_WLDJ_004'); |
|
103 |
var result = ajax.start(); |
|
104 |
if (result.data.length > 0) { |
|
105 |
let msg = result.data[0]; |
|
106 |
$('#id').val(msg.id); |
|
107 |
$('#ipAddress').val(msg.ipAddress); |
|
108 |
$('#pageCode').val(msg.pageCode); |
|
109 |
$('#workshopCode').val(msg.workshopCode); |
|
110 |
$('#lineCode').val(msg.lineCode); |
|
111 |
$('#locationCode').val(msg.locationCode); |
|
112 |
|
|
113 |
$('#scrapCategory').val(msg.warehouseCode); |
|
114 |
$('#scrapReason').val(msg.warehouseName); |
|
115 |
console.log(msg) |
|
116 |
|
|
117 |
} |
|
118 |
} |
|
119 |
|
|
120 |
function initOrderInfo() { |
|
121 |
// 根据ip查询配置信息 |
|
122 |
var ajax = new $ax(Feng.ctxPath + "/productionOrdeInfo/list?orderStatus=" + '3'); |
|
123 |
var result = ajax.start(); |
|
124 |
if (result.data.length > 0) { |
|
125 |
let msg = result.data[0]; |
|
126 |
$('#orderId').val(msg.id); |
|
127 |
$('#workOrderNo').val(msg.workOrderNo); |
|
128 |
$('#materialCode').val(msg.materialCode); |
|
129 |
$('#materialName').val(msg.materialName); |
|
130 |
$('#planQty').val(msg.planQty); |
|
131 |
|
|
132 |
$('#custom').val(msg.custom); |
|
133 |
$('#createTime').val(msg.createTime); |
|
134 |
$('#actualQty').val(msg.actualQty); |
|
135 |
$('#planStartTime').val(msg.planStartTime); |
|
136 |
$('#planEndTime').val(msg.planEndTime); |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
function initBomTable(){ |
|
141 |
var queryData = {}; |
|
142 |
queryData['loadingCode'] = $("#locationCode").val(); |
|
143 |
// queryData['workOrderNo'] = $("#workOrderNo").val(); |
|
144 |
|
|
145 |
// 渲染表格 |
|
146 |
var tableResult = table.render({ |
|
147 |
elem: '#' + BomInfo.tableId, |
|
148 |
url: Feng.ctxPath + '/bomInfo/kbListTable', |
|
149 |
// page: true, |
|
150 |
// height: 475, |
|
151 |
height: 435, |
|
152 |
cellMinWidth: 100, |
|
153 |
where:queryData, |
|
154 |
cols: BomInfo.initColumn() |
|
155 |
}); |
|
156 |
} |
|
157 |
/** |
|
158 |
* 物料Bom初始化表格的列 |
|
159 |
*/ |
|
160 |
BomInfo.initColumn = function () { |
|
161 |
return [[ |
|
162 |
// {type: 'checkbox'}, |
|
163 |
/* {type:"numbers" ,title:'序号',width:40,fixed:'left'},*/ |
|
164 |
{field: 'id', hide: true, title: 'ID'}, |
|
165 |
{field: 'materialCode', sort: true, title: '物料编号'}, |
|
166 |
{field: 'materialName', sort: true, title: '物料名称'}, |
|
167 |
// {field: 'workorderNo', sort: true, title: '工单编号'}, |
|
168 |
// {field: 'productCode', sort: true, title: '产品编号'}, |
|
169 |
{field: 'locationCode', sort: true, title: '工位编号'}, |
|
170 |
{field: 'loadingCode', sort: true, title: '上料工位编号'}, |
|
171 |
// {field: 'state', sort: true, title: '是否扫码'}, |
|
172 |
// {field: 'batchCode', sort: true, title: '批次码'}, |
|
173 |
]]; |
|
174 |
}; |
|
175 |
|
|
176 |
/** |
|
177 |
* 缺料报警初始化表格的列 |
|
178 |
*/ |
|
179 |
MaterialShortage.initColumn = function () { |
|
180 |
return [[ |
|
181 |
{field: 'id', hide: true, title: '主键id'}, |
|
182 |
{field: 'workOrderNo', sort: true, title: '生产工单号',minWidth:160}, |
|
183 |
// {field: 'sfcCode', sort: true, title: '总成序列号',minWidth:160}, |
|
184 |
{field: 'lineCode', sort: true, title: '产线编号',minWidth:125}, |
|
185 |
// {field: 'lineName', sort: true, title: '产线名称',minWidth:160}, |
|
186 |
{field: 'locationCode', sort: true, title: '工位编号',minWidth:125}, |
|
187 |
// {field: 'locationName', sort: true, title: '工位名称',minWidth:160}, |
|
188 |
{field: 'scrapCategory', sort: true, title: '报废类目',minWidth:125}, |
|
189 |
{field: 'scrapQuantity', sort: true, title: '报废数量',minWidth:125}, |
|
190 |
{field: 'scrapReason', sort: true, title: '报废原因',minWidth:160}, |
|
191 |
{field: 'operateUser', sort: true, title: '操作用户',minWidth:125}, |
|
192 |
{field: 'createTime', sort: true, title: '报废时间',minWidth:160}, |
|
193 |
]]; |
|
194 |
}; |
|
195 |
|
|
196 |
function initMaterialShortage(){ |
|
197 |
var queryData = {}; |
|
198 |
// queryData['workOrderNo'] = $("#workOrderNo").val(); |
|
199 |
// queryData['loadingCode'] = $("#locationCode").val(); |
|
200 |
|
|
201 |
// 渲染表格 |
|
202 |
var tableResult = table.render({ |
|
203 |
elem: '#' + MaterialShortage.tableId, |
|
204 |
url: Feng.ctxPath + '/scrapCategoryRecord/list', |
|
205 |
// page: true, |
|
206 |
height: 350, |
|
207 |
cellMinWidth: 80, |
|
208 |
where:queryData, |
|
209 |
cols: MaterialShortage.initColumn() |
|
210 |
}); |
|
211 |
} |
|
212 |
|
|
213 |
|
|
214 |
// 生产工单设置按钮点击事件 |
|
215 |
$('#orderBtnSet').click(function () { |
|
216 |
KanbanConf.openOrderEditPage(); |
|
217 |
}); |
|
218 |
|
|
219 |
// 设置按钮点击事件 |
|
220 |
$('#btnSet').click(function () { |
|
221 |
var id = $("#id").val(); |
|
222 |
if(id == "" || id == undefined){ |
|
223 |
KanbanConf.openAddDlg(); |
|
224 |
}else{ |
|
225 |
KanbanConf.openEditPage(id); |
|
226 |
} |
|
227 |
|
|
228 |
}); |
|
229 |
|
|
230 |
$('#enter').click(function (enterNum){ |
|
231 |
if($('#lineCode').val() === null){ |
|
232 |
Feng.error("请选择产线!") |
|
233 |
return; |
|
234 |
} |
|
235 |
if($('#locationCode').val() === null){ |
|
236 |
Feng.error("请选择工位!") |
|
237 |
return; |
|
238 |
} |
|
239 |
if($('#scrapCategory').val() === null){ |
|
240 |
Feng.error("请选择报废类目!") |
|
241 |
return; |
|
242 |
} |
|
243 |
if($('#scrapReason').val() === null){ |
|
244 |
Feng.error("请选择报废原因!") |
|
245 |
return; |
|
246 |
} |
|
247 |
if($('#scrapNumber').val() < 1){ |
|
248 |
Feng.error("请输入数量!") |
|
249 |
return; |
|
250 |
} |
|
251 |
let ajaxEnter = new $ax(Feng.ctxPath + "/scrapCategoryRecord/addItem", function (data) { |
|
252 |
}, function (data) { |
|
253 |
Feng.error("添加失败!" + data.responseJSON.message) |
|
254 |
}); |
|
255 |
ajaxEnter.set("lineCode", $('#lineCode').val()); |
|
256 |
ajaxEnter.set("locationCode", $('#locationCode').val()); |
|
257 |
ajaxEnter.set("scrapCategory", $('#scrapCategory').val()); |
|
258 |
ajaxEnter.set("scrapReason", $('#scrapReason').val()); |
|
259 |
ajaxEnter.set("scrapQuantity", $('#scrapNumber').val()); |
|
260 |
ajaxEnter.set("workOrderNo", $('#workOrderNo').val()); |
|
261 |
ajaxEnter.start(); |
|
262 |
initMaterialShortage(); |
|
263 |
}); |
|
264 |
|
|
265 |
/** |
|
266 |
* 弹出添加页面设置对话框 |
|
267 |
*/ |
|
268 |
KanbanConf.openAddDlg = function () { |
|
269 |
console.log("弹出添加页面设置对话框"); |
|
270 |
layer.open({ |
|
271 |
type: 2, |
|
272 |
area: ['1000px', '600px'], |
|
273 |
title: '添加看板配置', |
|
274 |
content: Feng.ctxPath + '/scrapBoard/add', |
|
275 |
success: function (layero, index) { |
|
276 |
let body = layer.getChildFrame('body', index); |
|
277 |
body.find('form').find('#testlineCode').val($('#lineCode').val()); |
|
278 |
body.find('form').find('#testlocationCode').val($('#locationCode').val()); |
|
279 |
body.find('form').find('#testscrapCategory').val($('#scrapCategory').val()); |
|
280 |
body.find('form').find('#testscrapReason').val($('#scrapReason').val()); |
|
281 |
}, |
|
282 |
end: function () { |
|
283 |
console.log("end") |
|
284 |
let lineCode = JSON.parse(window.localStorage.getItem('lineCode')); |
|
285 |
let locationCode = JSON.parse(window.localStorage.getItem('locationCode')); |
|
286 |
$('#lineCode').val(lineCode); |
|
287 |
$('#locationCode').val(locationCode); |
|
288 |
initKanBanConfInfo() |
|
289 |
} |
|
290 |
}); |
|
291 |
}; |
|
292 |
|
|
293 |
/** |
|
294 |
* 弹出编辑页面设置对话框 |
|
295 |
* |
|
296 |
* @param data 点击按钮时候的行数据 |
|
297 |
*/ |
|
298 |
KanbanConf.openEditPage = function (data) { |
|
299 |
func.open({ |
|
300 |
title: '添加看板配置', |
|
301 |
content: Feng.ctxPath + '/materialRegistration/edit?id=' + data, |
|
302 |
//tableId: KanbanConf.tableId |
|
303 |
}); |
|
304 |
|
|
305 |
}; |
|
306 |
|
|
307 |
$('#revert').click(function () { |
|
308 |
window.location.href = Feng.ctxPath + '/badBoard/boardHome' |
|
309 |
}); |
|
310 |
|
|
311 |
KanbanConf.openOrderEditPage = function (data) { |
|
312 |
layer.open({ |
|
313 |
type: 2, |
|
314 |
area: ['1000px', '600px'], |
|
315 |
title: '工单配置', |
|
316 |
content: Feng.ctxPath + '/materialRegistration/orderEdit', |
|
317 |
success: function () { |
|
318 |
console.log($('#lineCode').val()); |
|
319 |
window.lineCode = $('#lineCode').val(); |
|
320 |
}, |
|
321 |
end: function () { |
|
322 |
let msg = JSON.parse(window.localStorage.getItem('message')); |
|
323 |
console.log("选择工单_id", msg.id) |
|
324 |
$('#orderId').val(msg.id); |
|
325 |
$('#workOrderNo').val(msg.workOrderNo); |
|
326 |
$('#materialCode').val(msg.materialCode); |
|
327 |
$('#materialName').val(msg.materialName); |
|
328 |
$('#planQty').val(msg.planQty); |
|
329 |
$('#createTime').val(msg.createTime); |
|
330 |
$('#actualQty').val(msg.actualQty); |
|
331 |
initMaterialShortage(); |
|
332 |
} |
|
333 |
}); |
|
334 |
}; |
|
335 |
}); |