Inventory.js
9.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
let action = null,
aopTable = null,
app = null;
layui.config({
base: "/js/",
version: 128
}).use(['system', "jqprint"], function () {
var form = layui.form,
$ = layui.jquery,
table = layui.table,
layer = layui.layer,
system = layui.system,
u = new system.u(),
sendData = null,
tableEdit = layui.tableEdit,
isFirstQuery = false,
areaName = 'warehous',
tableName = 'Inventory';
action = {
addOptions: function () {
var options = {
fromId: "#modifyForm form",
url: `/${areaName}/${tableName}/Ins`,
submit: "submit(fromAdd)"
}
return options;
},
editOptions: function () {
var options = {
fromId: "#modifyForm form",
url: `/${areaName}/${tableName}/Upd`,
submit: "submit(fromUpdate)"
}
return options;
},
deleteOptions: function () {
var options = {
url: `/${areaName}/${tableName}/DelByIds`,
keyId: "id"
}
return options;
},
exportOptions: function () {
var options = {
fromId: "listForm",
url: `/${areaName}/${tableName}/Export`,
isDefault: false,
excelCols: {
head: app.data.cols
}
}
return options;
},
queryOptions: function () {
var options = {
resetFrom: "form[lay-filter=listForm]",
fromId: "listForm",
urlExport: `/${areaName}/${tableName}/Export`,
urlQuery: `/${areaName}/${tableName}/Load`,
mainTable: app.data.tableIns
}
return options;
},
uploadOptions: function () {
var options = {
url: `/${areaName}/${tableName}/Import`,
fromFile: "#excelfile",
content: $("#ImportData")
}
return options;
},
addBefore: function (callBack) {
//callBack是回调函数,如果editBefore有ajax 放在成功之后
if (callBack != null) callBack();
},
editBefore: function (data, callBack) {
debugger
form.val("modifyForm", data);
if (callBack != null) callBack();
},
editAfter: function (callBack) {
if (callBack != null) callBack();
},
addSaveBefore: function (data, callBack) {
if (callBack != null) callBack();
},
//所有动作成功之后
actionSuccess: (falg) => {
u.refreshTable(app, u, null, falg);
}
}
app = {
data: {
cols: [[
{ checkbox: true, fixed: true },
{
field: "id", width: 60, sort: true, fixed: true, hide: true, title: "ID",
verifyConfig: {
empty: "req", msg: "盘点数据【ID】不能为空!,ID:", type: "number"
}
},
{ field: "lineCode", width: 150, sort: true, fixed: false, title: "产线" },
{ field: "materialCode", width: 150, sort: true, fixed: false, title: "物料编码" },
{
field: "pipeLength", width: 100, sort: true, fixed: false, title: "管材长度", edit: "text",
verifyConfig: {
empty: "req", msg: "盘点数据【管材长度】不能为空!,ID:", type: "number"
}
},
{
field: "qty", width: 80, sort: true, fixed: false, title: "数量", edit: "text",
verifyConfig: {
empty: "req", msg: "盘点数据【数量】不能为空!,ID:", type: "number"
}
},
{ field: "materialName", width: 200, sort: true, fixed: false, title: "物料名称" },
{ field: "diameter", width: 150, sort: true, fixed: false, title: "管径" },
{ field: "thickness", width: 150, sort: true, fixed: false, title: "壁厚" },
{ field: "useState", width: 150, sort: true, fixed: false, title: "物料状态", templet: (d) => { return "".GetState(window.top.InventoryUseState, d.useState) } },
{
field: "pipeSN", width: 150, sort: true, fixed: false, title: "管材SN",
edit: "text",
verifyConfig: {
empty: "req", msg: "盘点数据【管材SN】不能为空!,ID:", type: "string"
}
},
{ field: "createTime", width: 150, sort: true, fixed: false, title: "入库日期" },
]],
tableIns: null,
tableElem: "mainList",
//下拉框配置
selectOption: {
lineCode: {
SelType: "FromUrl",
SelFrom: "/HomeRedis/GetBaseInfoByKey?key=base_line",
SelLabel: "LineName",
SelValue: "LineCode",
Dom: [$("[name='lineCode']")]
},
locationCode: {
SelType: "FromUrl",
SelFrom: "/HomeRedis/GetBaseInfoByKey?key=base_location",
SelLabel: "locationName",
SelValue: "locationCode",
Dom: [$("[name='locationCode']")]
},
inventoryStatus: {
SelType: "FromDict",
SelFrom: "inventoryStatus",
SelLabel: "DictLabel",
SelValue: "DictValue",
},
zoneCode: {
SelType: "FromDict",
SelFrom: "zoneCode",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='zoneCode']")]
},
warehouseCode: {
SelType: "FromUrl",
SelFrom: "/warehous/Warehouse/Load",
SelLabel: "name",
SelValue: "code",
Dom: [$("[name='warehouseCode']")]
},
//返回的数据 用于后续操作
selectData: {
}
}
},
methods: {
initTable: function (opts) {
var config = {};
if (opts != undefined) $.extend(config, opts);
let options = {
elem: "#" + app.data.tableElem,
url: `/${areaName}/${tableName}/Load`,
cols: u.columnRecord(app.data.tableElem, app.data.cols),
toolbar: '#toolbarTable',
where: config,
doneExtend: function () {
setTimeout(function () {
app.methods.setColsEditConfig();
app.methods.initAopTable();
}, 2000);
}
}
if ("".GetUrlParam("menuFlag") === -2) options["height"] = 'full-55';
app.data.tableIns = u.initTable(options);
},
setColsEditConfig: function () {
for (var i = 0; i < app.data.cols[0].length; i++) {
if (typeof app.data.cols[0][i].field == "undefined") continue;
if (app.data.cols[0][i].field == "locationCode") {
var locationCodeConfigData = [];
app.data.selectOption.selectData["locationCode"].forEach(x => {
locationCodeConfigData.push({ name: x.id, value: x.locationCode });
});
app.data.cols[0][i]["config"] = { type: 'select', data: locationCodeConfigData }
}
}
},
initAopTable: function () {
aopTable = tableEdit.aopObj(app.data.cols);
aopTable.on(`tool(${app.data.tableElem})`, function (obj) {
debugger
var field = obj.field; //单元格字段
var value = obj.value; //修改后的值
var data = obj.data; //当前行旧数据
var event = obj.event; //当前单元格事件属性值
var update = {};
update[field] = value;
obj.update(update);
});
},
initFrom() {
u.initSelect(app.data.selectOption);
var opt1 = {
elem: "#materialCode",
checkedKey: "MaterialCode",
doneKey: {
key: "MaterialCode",
lableValue: "MaterialName"
},
searchKey: "MaterialCode",
searchName: "物料编码",
doneExtend: function (elem, data, $nowElem) {
debugger
var rootFrom = $("#modifyForm");
rootFrom.find("[name=materialCode]").val(data.data[0].materialCode);
rootFrom.find("[name=materialName]").val(data.data[0].materialName);
}
};
u.initSelectMaterialFeed1(opt1);
}
},
registerEvent: function () {
},
init: function () {
var inventoryId = "".GetUrlParam("InventoryId");
sendData = { id: inventoryId == null ? 0 : inventoryId }
app.methods.initFrom();
app.methods.initTable(sendData);
app.registerEvent();
}
};
app.init();
});