Line.js
9.12 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
let action = null;
layui.config({
base: "/js/",
version: 55
}).use(['ztree', 'system'], function () {
var form = layui.form,
$ = layui.jquery,
table = layui.table,
system = layui.system,
u = new system.u(),
sendData = {
isok: null,
workshopCode: null,
workshopKey: null
},
areaName = "configure",
tableName = "Line";
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`,
sendDataWhere: {
workshopCode: sendData.workshopCode == null ? 0 : sendData.workshopCode
},
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;
},
editBefore: function (data, callBack) {
form.val("modifyForm", data);
//callBack是回调函数,如果editBefore有ajax 放在成功之后
if (callBack != null) callBack();
},
addBefore: function (callBack) {
if (sendData.isok !== "true") {
layer.alert("请选择车间节点新增线体", { icon: u.config.iconoError, shade: 0.4, time: u.config.errorTime });
return;
}
//callBack是回调函数,如果editBefore有ajax 放在成功之后
if (callBack != null) callBack();
},
addSaveBefore: function (data, callBack) {
debugger
if (sendData.isok !=="true") {
layer.alert("请选择车间节点新增线体", { icon: u.config.iconoError, shade: 0.4, time: u.config.errorTime });
return;
}
if (sendData.workshopKey == "" || sendData.workshopKey == null) {
layer.alert("线体新增:车间key不能为空!", { icon: u.config.iconoError, shade: 0.4, time: u.config.errorTime });
return;
}
if (sendData.workshopCode == "") {
layer.alert("线体新增:车间编码不能为空!", { icon: u.config.iconoError, shade: 0.4, time: u.config.errorTime });
return;
}
data.field.workshopCode = sendData.workshopCode;
data.field.workshopKey = sendData.workshopKey;
if (callBack != null) callBack();
},
qcCodePrintOptions: () => {
var options = {
qrCodeValueKey: "lineCode",
//【qrcodeElem】 是要修改的内容其他的不要变 id 的变量值不需要变
customFn: (sysU, parameter, selectData) => {
for (var i = 0; i < selectData.length; i++) {
var qcCodeValue = selectData[i][parameter.qrCodeValueKey],
qrcodeId = "qrcode" + i,
qrcodeHeadId = "qrcodeHead" + i,
qrcodeElem = `<div id="${qrcodeHeadId}" class="qcCode" >
<div id="${qrcodeId}" ></div>
<div class="qcCode_lable">
<label>线体编码:</label><label>${qcCodeValue}</label>
</div>
<div class="qcCode_lable">
<label>线体名称:</label><label>${selectData[i].lineName}</label>
</div>
<div class="qcCode_lable">
<label>车间名称:</label><label>${selectData[i].workshopName}</label>
</div>
</div>`;
sysU.qRCodeWirtDom(parameter, qrcodeElem, qrcodeId, qcCodeValue);
}
return true;
}
}
return options;
},
//所有动作成功之后
actionSuccess: (falg) => {
debugger
u.refreshTable(app, u, null, falg, function () {
app.methods.initTable({ workshopCode: sendData.workshopCode });
});
}
}
var app = {
data: {
cols: [[
{ checkbox: true, fixed: true },
{ field: "id", width: 80, hide: true, title: "id" },
{ field: "workshopName", width: 160, sort: false, fixed: false, title: "车间名称", noExel: true },
{ field: "lineCode", width: 100, title: "线体代号" },
{ field: "lineName", width: 200, title: "线体名称" },
{ field: 'otherCode', width: 120, title: '外部编码' },
{ field: "workshopId", width: 150, hide: true, title: "车间id" },
{ field: "workshopKey", width: 150, hide: true, title: "车间key" },
{ field: "lineKey", width: 150, hide: true, title: "线体key" },
{ field: "createTime", width: 150, title: "建立时间" },
{ field: "createBy", width: 150, title: "建立者" },
{ field: "updateTime", width: 150, title: "更新时间" },
{ field: "updateBy", width: 150, title: "更新者" }
]],
urlTable: `/${areaName}/${tableName}/Load`,
tableIns: null,
tableElem: "mainList",
tree: $("#tree"),
treeObj: null,
setting: {
view: { selectedMulti: false },
async: {
enable: true,
url: `/${areaName}/${tableName}/GetTreeList`,
type: "get"
},
data: {
simpleData: {
enable: true,
idKey: "keys",
pIdKey: "parentId",
rootPId: ""
}
},
callback: {
onClick: function (event, treeId, treeNode) {
debugger
sendData.isok = treeNode.isok;
sendData.workshopCode = treeNode.workShopCode;
sendData.workshopKey = treeNode.keys;
if (sendData.isok === "true") {
app.methods.initTable({ workshopCode: sendData.workshopCode });
}
},
onAsyncSuccess: function (event, treeId, treeNode, msg) {
app.data.treeObj.expandAll(true);
}
}
}
},
methods: {
initTable: function (options) {
var config = {};
if (options != undefined) $.extend(config, options);
let opt = {
cols: u.columnRecord(app.data.tableElem, app.data.cols),
elem: "#" + app.data.tableElem,
url: `/${areaName}/${tableName}/Load`,
toolbar: '#toolbarTable',
where: config
}
app.data.tableIns = u.initTable(opt);
},
initTree: function () {
setTimeout(()=> {
app.data.treeObj = $.fn.zTree.init(app.data.tree, app.data.setting);
app.data.tree.height($("div.layui-table-view").height() - 20);
}, 50);
}
},
registerEvent: function () {
},
init: function () {
app.methods.initTable();
app.methods.initTree();
app.registerEvent();
}
};
app.init();
})