HuXiYu
authored
about a year ago
1
2
3
4
5
6
7
8
9
10
11
12
13
let action = null ;
layui . config ({
base : "/js/" ,
version : 1
}). use ([ 'system' ], function () {
var form = layui . form ,
$ = layui . jquery ,
element = layui . element ,
table = layui . table ,
system = layui . system ,
sysU = new system . u (),
areaName = "equipment" ,
controllerName = "BaseEquipment" ,
14
15
16
17
18
19
20
21
22
23
24
25
26
27
app = null ,
selectMaintainRuleOpt = {
selectMaintainRule : {
SelType : "FromUrl" ,
SelFrom : ` / $ { areaName } /BusEquipmentMaintainRuleHead/ Load ` ,
SelLabel : "equipmentRuleName" ,
SelValue : "equipmentRuleCode" ,
Where : {},
Dom : [ $ ( "#modifyForm [name='equipmentMaintainRuleCode']" )],
},
selectData : {
},
},
28
29
30
31
32
33
34
35
36
37
38
39
40
41
selectFactoryOpt = {
factoryCode : {
SelType : "FromUrl" ,
SelFrom : ` / configure / Factory / Load ` ,
SelLabel : "factoryName" ,
SelValue : "factoryCode" ,
Where : {},
Dom : [ $ ( "[name='factoryCode']" )],
/* isFirstSelected: false*/
},
selectData : {
},
},
42
sendData = {
43
44
editMaintainRuleWhere : null ,
selectFactorySelectWhere : null
45
46
};
HuXiYu
authored
about a year ago
47
48
action = {
HuXiYu
authored
about a year ago
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
addOptions : function () {
var options = {
fromId : "#modifyForm form" ,
url : ` / $ { areaName } /${controllerName}/ Ins ` ,
//sendDataWhere: null,
//isAddWhereExtend: "arbitrarily",
//mainTable: app.data.tableIns,
submit : "submit(fromAdd)"
}
return options ;
},
editOptions : function () {
var options = {
fromId : "#modifyForm form" ,
url : ` / $ { areaName } /${controllerName}/ Upd ` ,
submit : "submit(fromUpdate)"
}
return options ;
},
deleteOptions : function () {
var options = {
url : ` / $ { areaName } /${controllerName}/ DelByIds ` ,
keyId : "id"
}
return options ;
},
HuXiYu
authored
about a year ago
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
exportOptions : function () {
var options = {
fromId : "listForm" ,
url : ` / $ { areaName } /${controllerName}/ Export ` ,
isDefault : false ,
sendDataWhere : {},
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}/ Export ` ,
urlQuery : ` / $ { areaName } /${controllerName}/ Load ` ,
sendDataWhere : {},
mainTable : app . data . tableIns
}
return options ;
},
/*rowClickOptions: function () {
var options = {
/ / 是否主子表
isDefault : true ,
targetTableId : app . data . tableElem ,
tabfilter : "tableTabBody" ,
tabId : 2 ,
customFn : app . methods . initTableDesc
}
return options ;
}, * /
uploadOptions: function () {
var options = {
url: `/ $ { areaName } /${controllerName}/ Import ` ,
fromFile : "#excelfile" ,
content : $ ( "#ImportData" )
}
return options ;
},
HuXiYu
authored
about a year ago
123
addBefore : function ( callBack ) {
124
sendData . editMaintainRuleWhere = null ;
125
126
127
128
selectMaintainRuleOpt . selectMaintainRule . Dom [ 0 ]. empty ();
selectFactoryOpt . factoryCode . Dom [ 0 ]. empty ();
form . render ( "select" );
HuXiYu
authored
about a year ago
129
130
131
132
133
134
135
136
//callBack是回调函数,如果editBefore有ajax 放在成功之后
if ( callBack != null ) callBack ();
},
addSaveBefore : function ( data , callBack ) {
if ( callBack != null ) callBack ();
},
editBefore : function ( data , callBack ) {
137
138
139
140
141
142
143
sendData . editMaintainRuleWhere = data ;
selectMaintainRuleOpt . selectMaintainRule . Where [ "equipmentTypeCode" ] = data . equipmentTypeCode ;
var fn = () => {
callBack ();
form . val ( "modifyForm" , data );
}
sysU . initSelect ( selectMaintainRuleOpt , fn );
144
145
146
147
148
selectFactoryOpt . factoryCode . Where [ "factorySelectWhere" ] = data . projectKeys ;
sysU . initSelect ( selectFactoryOpt , () => {
form . val ( "modifyForm" , data );
});
HuXiYu
authored
about a year ago
149
150
},
editSaveBefore : function ( data , callBack ) {
151
if ( typeof data . field . isEnable == "undefined" ) data . field [ "isEnable" ] = 0 ;
HuXiYu
authored
about a year ago
152
153
if ( callBack != null ) callBack ();
},
HuXiYu
authored
about a year ago
154
155
156
checkboxMethod : function ( obj ) {
var page = "" . GetUrlParam ( "page" ),
HuXiYu
authored
about a year ago
157
158
simNumber = "" . GetUrlParam ( "simNumber" );
if ( page == "BaseSim" ) {
HuXiYu
authored
about a year ago
159
var sendData = {
HuXiYu
authored
about a year ago
160
161
162
163
simNumber : simNumber ,
checkeds : obj . checked ,
equipmentCode : obj . data . equipmentCode ,
factoryCode : obj . data . factoryCode
HuXiYu
authored
about a year ago
164
165
166
};
var ajaxConfig = {
data : sendData ,
HuXiYu
authored
about a year ago
167
url : "/base/BaseSim/BindEquipment" ,
HuXiYu
authored
about a year ago
168
169
170
success : function ( result ) {
if ( sysU . successBefore ( result )) return false ;
layer . msg ( result . Message );
HuXiYu
authored
about a year ago
171
sysU . refreshTable ( app , sysU , null , "main" );
HuXiYu
authored
about a year ago
172
173
174
175
176
}
};
sysU . ajax ( ajaxConfig );
}
},
HuXiYu
authored
about a year ago
177
178
179
180
181
182
183
184
185
186
187
//所有动作成功之后
actionSuccess : ( flag ) => {
sysU . refreshTable ( app , sysU , null , flag );
},
closeAfter : function ( callBack ) {
if ( callBack != null ) callBack ();
},
//设备类型加载保养规则
equipmentTypeCodeFromEvent : function ( data ) {
188
189
190
191
192
193
if ( data . value == "" ) {
selectMaintainRuleOpt . selectMaintainRule . Dom [ 0 ]. empty ();
form . render ( "select" );
return false ;
}
//对应到实体(筛选条件)中字段属性
赖素文
authored
12 months ago
194
selectMaintainRuleOpt . selectMaintainRule . Where [ "equipmentTypeCode" ] = data . value ;
195
sysU . initSelect ( selectMaintainRuleOpt );
196
197
},
198
199
200
//所属项目加载项目厂房
projectKeysFromEvent : function ( data ) {
if ( data . value == "" ) {
201
selectFactoryOpt . factoryCode . Dom [ 0 ]. empty ();
202
203
204
205
form . render ( "select" );
return false ;
}
//对应到实体(筛选条件)中字段属性
206
207
selectFactoryOpt . factoryCode . Where [ "factorySelectWhere" ] = data . value ;
sysU . initSelect ( selectFactoryOpt );
HuXiYu
authored
about a year ago
208
},
赖素文
authored
12 months ago
209
EqDescTableRowEvent : function ( sU , toolbarId , obj ) {
赖素文
authored
12 months ago
210
211
window . open ( "/equipment/BaseEquipment/ProjectMapEqDescIndex" , "_self" );
},
赖素文
authored
12 months ago
212
213
214
215
216
217
218
EqeqmaintainTableRowEvent : function ( sU , toolbarId , obj ) {
window . open ( "/equipment/BaseEquipment/ProjectMapEqDescIndex" , "_self" );
},
//关联设备链接
btnBindEquipment : function ( sU , toolbarId , obj ) {
sU . getParentElemId ( "BaseSim" ). click ();
},
HuXiYu
authored
about a year ago
219
220
221
222
223
224
}
app = {
data : {
cols : [[
{ field : "id" , width : 80 , hide : true , title : "Id" },
225
{ field : "projectKeys" , width : 150 , title : "项目keys" , hide : true , },
226
227
{ field : "projectName" , width : 150 , title : "项目" },
/*{ field: "factoryCode", width: 150, title: "厂房编码" },*/
HuXiYu
authored
about a year ago
228
赖素文
authored
12 months ago
229
{ field : "equipmentCode" , width : 120 , title : "设备编码" },
230
{ field : "equipmentName" , width : 150 , title : "设备名称" },
231
{ field : "equipmentTypeCode" , width : 150 , title : "设备类型编码" , hide : true },
赖素文
authored
12 months ago
232
{ field : "name" , width : 120 , title : "设备类型" },
233
{ field : "equipmentMaintainRuleCode" , width : 150 , title : "维护规则" },
赖素文
authored
12 months ago
234
赖素文
authored
12 months ago
235
{ field : "equipmentStatus" , width : 150 , title : "状态" },
236
{ field : "simNumber" , width : 150 , title : "SIM卡号" },
237
{ field : "startTime" , width : 150 , title : "出厂时间" },
HuXiYu
authored
about a year ago
238
239
{ field : "imgSrc" , width : 150 , title : "图片" },
赖素文
authored
12 months ago
240
241
242
243
{ field : "ip" , width : 150 , title : "IP" , hide : true , },
{ field : "destinationArea" , width : 150 , title : "区域" , hide : true ,},
{ field : "remark" , width : 150 , title : "描述" , hide : true , },
{ field : "isEnable" , width : 100 , title : "启用" , templet : '#isSysEnableTemplet' },
HuXiYu
authored
about a year ago
244
245
246
{ field : "createTime" , width : 150 , title : "createTime" },
{ field : "createBy" , width : 150 , title : "createBy" },
赖素文
authored
12 months ago
247
248
249
{ field : "updateTime" , width : 150 , title : "updateTime" , hide : true , },
{ field : "updateBy" , width : 150 , title : "updateBy" , hide : true , },
HuXiYu
authored
about a year ago
250
251
252
253
254
255
256
257
258
]],
colsDesc : null ,
tableIns : null ,
tableElem : "mainList" ,
tableInsDesc : null ,
tableElemDesc : "mainListDesc" ,
//下拉框配置
selectOption : {
HuXiYu
authored
about a year ago
259
260
261
262
263
264
selectEquipmentTypeCode : {
SelType : "FromUrl" ,
SelFrom : ` / $ { areaName } /BaseEquipmentType/ Load ` ,
//SelModel:"EquipmentTypeName",
SelLabel : "name" ,
SelValue : "code" ,
265
266
Dom : [ $ ( "[name='equipmentTypeCode']" )],
isFirstSelected : false
HuXiYu
authored
about a year ago
267
},
268
269
270
271
projectKeys : {
SelType : "FromUrl" ,
SelFrom : ` / configure / BaseProject / Load ` ,
SelLabel : "projectName" ,
272
273
274
SelValue : "keys" ,
Dom : [ $ ( "[name='projectKeys']" )],
isFirstSelected : false
275
},
HuXiYu
authored
about a year ago
276
277
278
279
280
281
282
283
284
285
//返回的数据 用于后续操作
selectData : {
}
},
},
methods : {
initTable : function ( opt ) {
var config = {};
if ( opt != undefined ) $ . extend ( config , opt );
赖素文
authored
12 months ago
286
287
288
289
290
291
292
293
//项目地图跳转过来的
var flag = $ ( ".layui-breadcrumb" );
if ( flag . length > 0 ) {
config [ "projectKeys" ] = localStorage . getItem ( "projectMapKeys" );
app . data . cols [ 0 ]. push ({ fixed : 'right' , title : '操作' , width : 150 , toolbar : '#barDemo' });
} else {
app . data . cols [ 0 ]. unshift ({ checkbox : true , fixed : true });
}
HuXiYu
authored
about a year ago
294
295
296
297
298
299
300
301
302
303
304
let options = {
elem : "#" + app . data . tableElem ,
url : ` / $ { areaName } /${controllerName}/ Load ` ,
cols : sysU . columnRecord ( app . data . tableElem , app . data . cols ),
toolbar : '#toolbarTable' ,
where : config ,
//height: "full-56",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
doneExtend : function ( res , obj ) {
}
}
赖素文
authored
12 months ago
305
赖素文
authored
12 months ago
306
307
308
if ( flag . length > 0 ) {
options [ "height" ] = "full-25"
}
HuXiYu
authored
about a year ago
309
310
311
312
313
app . data . tableIns = sysU . initTable ( options );
},
initFrom () {
HuXiYu
authored
about a year ago
314
sysU . initSelect ( app . data . selectOption );
HuXiYu
authored
about a year ago
315
316
317
318
319
320
321
322
//sysU.initSelecteByEnum(app.data.selectOptionEnum);
}
},
registerEvent : function () {
},
init : function () {
赖素文
authored
12 months ago
323
debugger
HuXiYu
authored
about a year ago
324
325
326
327
328
329
330
331
//var sendDataWhere = form.val("listForm")
app . methods . initTable ();
app . methods . initFrom ();
app . registerEvent ();
}
};
app . init ();
});