提交 | 用户 | 时间
|
71e81e
|
1 |
/** |
懒 |
2 |
* 添加或者修改页面 |
|
3 |
*/ |
|
4 |
var BomInfoInfoDlg = { |
|
5 |
data: { |
|
6 |
id: "", |
|
7 |
materialCode: "", |
|
8 |
materialName: "", |
|
9 |
productCode: "", |
|
10 |
productName: "", |
|
11 |
locationCode: "", |
|
12 |
locationName: "", |
|
13 |
loadingCode: "", |
|
14 |
loadingName: "", |
|
15 |
traceabilityType: "", |
|
16 |
quantity: "", |
|
17 |
remarks: "" |
|
18 |
} |
|
19 |
}; |
|
20 |
|
|
21 |
layui.use(['form', 'admin', 'ax','laydate','upload','formSelects'], function () { |
|
22 |
var $ = layui.jquery; |
|
23 |
var $ax = layui.ax; |
|
24 |
var form = layui.form; |
|
25 |
var admin = layui.admin; |
|
26 |
|
|
27 |
$(document).ready(function () { |
|
28 |
$.ajax({ |
|
29 |
type: "POST", |
|
30 |
contentType: "application/json;charset=UTF-8", |
|
31 |
url: Feng.ctxPath + '/locationInfo/selectList', |
|
32 |
success: function (result) { |
|
33 |
$.each(result.data, function (index, value) { |
|
34 |
$('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素 |
|
35 |
$('#loadingCode').append(new Option(value.locationCode));// 下拉菜单里添加元素 |
|
36 |
|
|
37 |
}); |
|
38 |
layui.form.render("select");//重新渲染 固定写法 |
|
39 |
}, |
|
40 |
}); |
|
41 |
}); |
|
42 |
|
|
43 |
form.on("select", function (data) { |
|
44 |
if (data.value !== "") { |
|
45 |
if (data.elem.id === "locationCode") { |
|
46 |
console.log(data.value); |
|
47 |
$('#locationName').val(getLocationName(data.value)); |
|
48 |
} |
|
49 |
if (data.elem.id === "loadingCode") { |
|
50 |
$('#loadingName').val(getLocationName(data.value)); |
|
51 |
} |
|
52 |
} |
|
53 |
}); |
|
54 |
|
|
55 |
function getLocationName(data){ |
|
56 |
var ajax1 = new $ax(Feng.ctxPath + "/locationInfo/list?locationCode=" +data); |
|
57 |
var result1 = ajax1.start(); |
|
58 |
return result1.data[0].locationName; |
|
59 |
} |
|
60 |
|
|
61 |
$('#materialCode').click(function () { |
|
62 |
layer.open({ |
|
63 |
type: 2, |
|
64 |
area: ['1000px', '600px'], |
|
65 |
title: '物料信息', |
|
66 |
content: Feng.ctxPath + '/productionOrdeInfo/materialLists', |
|
67 |
end: function () { |
|
68 |
let msg = JSON.parse(window.localStorage.getItem('message')); |
|
69 |
console.log(msg) |
|
70 |
if(msg !== null){ |
|
71 |
$('#materialCode').val(msg.materialCode); |
|
72 |
$('#materialName').val(msg.materialName); |
|
73 |
} |
|
74 |
} |
|
75 |
}); |
|
76 |
}); |
|
77 |
|
|
78 |
$('#productCode').click(function () { |
|
79 |
layer.open({ |
|
80 |
type: 2, |
|
81 |
area: ['1000px', '600px'], |
|
82 |
title: '物料信息', |
|
83 |
content: Feng.ctxPath + '/productionOrdeInfo/materialList', |
|
84 |
success: function (layero, index) { |
|
85 |
window.materialType = '成品'; |
|
86 |
}, |
|
87 |
end: function () { |
|
88 |
let msg = JSON.parse(window.localStorage.getItem('message')); |
|
89 |
console.log(msg) |
|
90 |
if(msg !== null){ |
|
91 |
$('#productCode').val(msg.materialCode); |
|
92 |
$('#productName').val(msg.materialName); |
|
93 |
} |
|
94 |
} |
|
95 |
}); |
|
96 |
}); |
|
97 |
|
|
98 |
//表单提交事件 |
|
99 |
form.on('submit(btnSubmit)', function (data) { |
|
100 |
var ajax = new $ax(Feng.ctxPath + "/bomInfo/addItem", function (data) { |
|
101 |
Feng.success("添加成功!"); |
|
102 |
window.location.href = Feng.ctxPath + '/bomInfo' |
|
103 |
}, function (data) { |
|
104 |
Feng.error("添加失败!" + data.responseJSON.message) |
|
105 |
}); |
|
106 |
ajax.set(data.field); |
|
107 |
ajax.start(); |
|
108 |
|
|
109 |
return false; |
|
110 |
}); |
|
111 |
|
|
112 |
$('#cancel').click(function(){ |
|
113 |
window.location.href = Feng.ctxPath + '/bomInfo' |
|
114 |
}); |
|
115 |
|
|
116 |
}); |