Receipt.js
8.87 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
let action = null;
layui.config({
base: "/js/",
version: 2
}).use(['system'], function () {
var form = layui.form,
$ = layui.jquery,
element = layui.element,
table = layui.table,
system = layui.system,
sysU = new system.u(),
sendData = null,
areaName = "wo",
controllerName = "WorkOrder",
tableEdit = layui.tableEdit,
app = null,
aopTable = null;
action = {
addOptions: function () {
var options = {
fromId: "#modifyForm form",
url: `/${areaName}/${controllerName}/Ins`,
submit: "submit(fromAdd)"
}
return options;
},
editOptions: function () {
var options = {
fromId: "#modifyForm form",
url: `/${areaName}/${controllerName}/UpdReceipt`,
submit: "submit(fromUpdate)"
}
return options;
},
deleteOptions: function () {
var options = {
url: `/${areaName}/${controllerName}/DelByIds`,
keyId: "id"
}
return options;
},
exportOptions: function () {
var options = {
fromId: "listForm",
url: `/${areaName}/${controllerName}/ExportReceipt`,
isDefault: false,
excelCols: {
head: app.data.cols,
body: app.data.colsDesc
}
}
return options;
},
queryOptions: function () {
var options = {
resetFrom: "form[lay-filter=listForm]",
fromId: "listForm",
urlExport: `/${areaName}/${controllerName}/ExportReceipt`,
urlQuery: `/${areaName}/${controllerName}/LoadReceipt`,
mainTable: app.data.tableIns
}
return options;
},
uploadOptions: function () {
var options = {
url: `/${areaName}/${controllerName}/Import`,
fromFile: "#excelfile",
content: $("#ImportData")
}
return options;
},
editBefore: function (data, callBack) {
data.enable = data.enable.toString();
form.val("modifyForm", data);
if (callBack != null) callBack();
},
btnSaveReceipt: function (sU, toolbarId, obj) {
var allData = sysU.getTableAllData(toolbarId),
allCos = obj.config.cols[0],
validCosName = [],
setData = [];
for (var j = 0; j < allCos.length; j++) {
if (typeof allCos[j].verifyConfig == "undefined") continue;
validCosName.push({
field: allCos[j]["field"],
verifyConfig: allCos[j].verifyConfig
});
}
for (var i = 0; i < allData.length; i++) {
//isEdit 是修改源码table.js新增的标记
if (typeof allData[i].isEdit == "undefined") continue;
var tempVal = {};
for (var k = 0; k < validCosName.length; k++) {
let field = validCosName[k].field;
var vaCos = allData[i][field];
if (validCosName[k].verifyConfig.empty == "req" && validCosName[k].verifyConfig.type == "number") {
let isVal = "".isNumber(vaCos);
if (!isVal) {
layer.alert(validCosName[k].verifyConfig.msg + allData[i].id, { icon: sysU.config.iconoError, shade: 0.4 });
return;
}
}
tempVal[field] = vaCos;
tempVal["id"] = allData[i]["id"];
tempVal["quantityRequired"] = allData[i]["quantityRequired"];
tempVal["qty"] = allData[i]["qty"];
tempVal["consumedQuantity"] = allData[i]["consumedQuantity"];
}
setData.push(tempVal);
}
if (setData.length == 0) {
layer.alert("请编辑修改[收货数量]后在提交保存!", { icon: sysU.config.iconoError, shadeClose: true });
return;
}
var ajaxConfig = {
data: {
model: setData
},
url: `/${areaName}/${controllerName}/UpdReceipt`,
success: function (result) {
if (sysU.successBefore(result)) return;
layer.msg(result.Message, { icon: sysU.config.iconoOk, shade: 0.4, time: sysU.config.msgOpenTimeLong });
table.reload(toolbarId);
}
};
sysU.ajax(ajaxConfig);
},
//所有动作成功之后
actionSuccess: (falg) => {
sysU.refreshTable(app, sysU, sendData, falg);
}
}
app = {
data: {
cols: [[
{ checkbox: true, fixed: true, hide: true, },
{ field: "id", width: 80, title: "Id" },
{ field: "workOrderCode", width: 150, title: "工单编码", totalRowText: '合计:' },
{ field: "oprSequenceCode", width: 150, title: "工序编码" },
{ field: "materialCode", width: 150, title: "物料编码" },
{ field: "materialName", width: 150, title: "物料名称" },
{ field: "quantityRequired", width: 80, title: "需求数量", totalRow: true, templet: '<span>{{ d.quantityRequired }}</span>' },
{
field: "quantityReceived", width: 80, title: "收货数量", edit: "text", totalRow: true, templet: '<span>{{ d.quantityReceived }}</span>',
verifyConfig: {
empty: "req", msg: "列【收货数量】不能为空且只能是数字!,ID:", type: "number",
}
},
{ field: "consumedQuantity", width: 80, title: "消耗数量", totalRow: true, templet: '<span>{{ d.consumedQuantity }}</span>' },
{ field: "qty", width: 80, title: "库存数量", totalRow: true, templet: '<span>{{ d.qty }}</span>' },
{ field: "whCode", width: 60, title: "单位" },
//{ field: "createTime", width: 150, title: "创建时间" },
//{ field: "createBy", width: 150, title: "创建用户" },
//{ field: "updateTime", width: 150, title: "更新时间" },
//{ field: "updateBy", width: 150, title: "更新用户" },
]],
tableIns: null,
tableElem: "mainList",
//下拉框配置
selectOption: {
//station: {
// SelType: "FromUrl",
// SelFrom: `/${areaName}/${controllerName}/StationLineSelect`,
// SelLabel: "workStationName",
// SelValue: "workStationCode",
// OptGroup: true,
// Dom: [$("[name='stationCode']")]
//},
//返回的数据 用于后续操作
selectData: {
}
}
},
methods: {
initTable: function () {
let options = {
elem: "#" + app.data.tableElem,
url: `/${areaName}/${controllerName}/LoadReceipt`,
cols: sysU.columnRecord(app.data.tableElem, app.data.cols),
toolbar: '#toolbarTable',
totalRow: true,
doneExtend: function () {
setTimeout(function () {
app.methods.initAopTable();
}, 1000);
}
}
app.data.tableIns = sysU.initTable(options);
},
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);
});
},
initSelectTable: function () {
},
initFrom() {
sysU.initSelect(app.data.selectOption);
}
},
registerEvent: function () {
},
init: function () {
app.methods.initTable();
app.methods.initFrom();
app.registerEvent();
}
};
app.init();
});