HuXiYu
authored
about a year ago
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 (),
sendDataWhere = null ,
sendDataDescWhere = null ,
areaName = "configure" ,
controllerName = "BaseProject" ,
app = null ;
action = {
addOptions : function () {
var options = {
fromId : "#modifyForm form" ,
url : ` / $ { areaName } /${controllerName}/ Ins ` ,
赖素文
authored
12 months ago
23
area :[ "750px" , "550px" ] ,
HuXiYu
authored
about a year ago
24
25
26
27
28
29
30
31
32
33
34
35
//sendDataWhere: null,
//isAddWhereExtend: "arbitrarily",
//mainTable: app.data.tableIns,
submit : "submit(fromAdd)"
}
return options ;
},
editOptions : function () {
var options = {
fromId : "#modifyForm form" ,
url : ` / $ { areaName } /${controllerName}/ Upd ` ,
赖素文
authored
12 months ago
36
area : [ "750px" , "550px" ],
HuXiYu
authored
about a year ago
37
38
39
40
41
42
43
44
submit : "submit(fromUpdate)"
}
return options ;
},
deleteOptions : function () {
var options = {
url : ` / $ { areaName } /${controllerName}/ DelByIds ` ,
赖素文
authored
about a year ago
45
titleConfirmDelete : "确定要删除所选信息吗?项目已绑定客户,项目不能直接删除需要先解绑客户和设备再删除项目。删除项目会直接删除厂房!" ,
HuXiYu
authored
about a year ago
46
keyId : "keys"
HuXiYu
authored
about a year ago
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
}
return options ;
},
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 ;
},
赖素文
authored
11 months ago
96
addBefore : function ( callBack , flagKey ) {
HuXiYu
authored
about a year ago
97
98
99
100
//callBack是回调函数,如果editBefore有ajax 放在成功之后
if ( callBack != null ) callBack ();
},
赖素文
authored
11 months ago
101
102
103
104
addSaveBefore : function ( data , callBack , flagKey ) {
if ( flagKey == "btnCopyAdd" ) {
data . field . eqCount = "0"
}
赖素文
authored
11 months ago
105
106
107
108
if ( new Date ( data . field . projectStartTime ) > new Date ( data . field . projectEndTime )) {
layer . alert ( "开始时间不能大于结束时间" , { icon : sysU . config . iconoError , shadeClose : true , title : sysU . config . titleOpen });
return
}
HuXiYu
authored
about a year ago
109
110
111
112
113
114
115
if ( callBack != null ) callBack ();
},
editBefore : function ( data , callBack ) {
form . val ( "modifyForm" , data );
if ( callBack != null ) callBack ();
},
editSaveBefore : function ( data , callBack ) {
赖素文
authored
11 months ago
116
117
118
119
if ( new Date ( data . field . projectStartTime ) > new Date ( data . field . projectEndTime )) {
layer . alert ( "开始时间不能大于结束时间" , { icon : sysU . config . iconoError , shadeClose : true , title : sysU . config . titleOpen });
return
}
HuXiYu
authored
about a year ago
120
121
122
123
if ( callBack != null ) callBack ();
},
checkboxMethod : function ( obj ) {
赖素文
authored
12 months ago
124
//用户绑定项目
HuXiYu
authored
about a year ago
125
var page = "" . GetUrlParam ( "page" ),
赖素文
authored
12 months ago
126
127
128
userAccount = "" . GetUrlParam ( "userAccount" );
if ( page == "sysuser" ) {
debugger
HuXiYu
authored
about a year ago
129
var sendData = {
赖素文
authored
12 months ago
130
userAccount : userAccount ,
HuXiYu
authored
about a year ago
131
132
checkeds : obj . checked ,
projectKeys : obj . data . keys ,
HuXiYu
authored
about a year ago
133
};
赖素文
authored
12 months ago
134
135
136
137
138
139
140
141
142
if ( obj . type == "all" ) {
sendData . projectKeys = sysU . getTableAllData ( app . data . tableElem ). GetArrValue ( "keys" );
} else {
sendData . projectKeys = obj . data . keys ;
}
if ( sendData . projectKeys == null || sendData . projectKeys == "" ) {
layer . alert ( "checkboxMethod:工位标识【projectKeys】为空,请重新关闭后再操作,反复出现请联系管理员" , { icon : 2 , shadeClose : true , title : "提示" });
return false ;
}
HuXiYu
authored
about a year ago
143
144
var ajaxConfig = {
data : sendData ,
赖素文
authored
12 months ago
145
url : "/base/SysUser/UserBindProjectRel" ,
HuXiYu
authored
about a year ago
146
147
148
success : function ( result ) {
if ( sysU . successBefore ( result )) return false ;
layer . msg ( result . Message );
赖素文
authored
12 months ago
149
sysU . refreshTable ( app , sysU , null , "main" );
HuXiYu
authored
about a year ago
150
151
152
153
154
}
};
sysU . ajax ( ajaxConfig );
}
},
赖素文
authored
about a year ago
155
//项目客户信息链接
赖素文
authored
12 months ago
156
157
btnUserProjectLink : function ( sU , toolbarId , obj ) {
sU . getParentElemId ( "SysUser" ). click ();
赖素文
authored
about a year ago
158
},
赖素文
authored
12 months ago
159
160
161
162
163
164
165
//地图默认定位(本地)
btnMapPosition : function ( sU , toolbarId , obj ) {
var dataCheckObj = table . checkStatus ( toolbarId );
if ( dataCheckObj . data . length != 1 ) {
layer . alert ( sU . config . titleSelectOneRowData , { icon : sU . config . iconoError , shadeClose : true , title : sU . config . titleSelectOneRowData });
return ;
}
赖素文
authored
12 months ago
166
localStorage . setItem ( "defaultSelectProjectId" , dataCheckObj . data [ 0 ]. id );
赖素文
authored
12 months ago
167
layer . msg ( sU . config . titleActionSuccess , { icon : sU . config . iconoOk , shade : 0.4 , time : 2000 });
赖素文
authored
12 months ago
168
169
},
HuXiYu
authored
about a year ago
170
171
//所有动作成功之后
actionSuccess : ( flag ) => {
HuXiYu
authored
about a year ago
172
sysU . refreshTable ( app , sysU , null , flag );
HuXiYu
authored
about a year ago
173
174
175
176
177
178
179
180
181
182
183
184
},
closeAfter : function ( callBack ) {
if ( callBack != null ) callBack ();
}
}
app = {
data : {
cols : [[
{ checkbox : true , fixed : true },
{ field : "id" , width : 80 , hide : true , title : "Id" },
{ field : "keys" , width : 80 , hide : true , title : "Keys" },
赖素文
authored
about a year ago
185
{ field : "projectName" , width : 200 , title : "项目名称" },
赖素文
authored
about a year ago
186
187
{ field : "eqCount" , width : 100 , title : "设备总数" },
赖素文
authored
12 months ago
188
189
{ field : "projectUsers" , width : 200 , title : "用户账号登入" },
{ field : "projectManager" , width : 150 , title : "项目负责人" },
赖素文
authored
about a year ago
190
{ field : "telephone" , width : 150 , title : "负责人电话" },
赖素文
authored
12 months ago
191
192
{ field : "projectClientName" , width : 150 , title : "工商信息" },
{ field : "projectAddress" , width : 300 , title : "项目地址" },
赖素文
authored
11 months ago
193
194
195
196
197
198
199
200
201
202
{
field : "projectStatus" , width : 120 , title : "状态" , templet : function ( obj ) {
var state = "" . GetState ( window . top . EnumProjectStatus , obj . projectStatus )
var nowTime = new Date ();
if ( nowTime > new Date ( obj . projectEndTime ) && state != window . top . EnumProjectStatus [ "已完成" ]) {
return ` < span style = 'color:red;' > $ { state } < /span>`;
}
return state;
}
},
赖素文
authored
about a year ago
203
204
205
206
207
208
209
210
211
212
{
field: "projectStartTime", width: 150, title: "开始日期", templet: function ( obj ) {
return new Date ( obj.projectStartTime ) .format ( "yyyy-MM-dd" )
}
},
{
field: "projectEndTime", width: 150, title: "结束日期", templet: function ( obj ) {
return new Date ( obj.projectEndTime ) .format ( "yyyy-MM-dd" )
}
},
赖素文
authored
12 months ago
213
214
{ field: "longitude", width: 100, title: "经度" },
{ field: "latitude", width: 100, title: "纬度" },
HuXiYu
authored
about a year ago
215
{ field: "picture", width: 150, title: "图片" },
赖素文
authored
about a year ago
216
217
{ field: "projectDescribe", width: 150, title: "描述" },
赖素文
authored
about a year ago
218
219
{ field: "createBy", width: 150, title: "创建人" },
{ field: "createTime", width: 150, title: "创建时间" },
HuXiYu
authored
about a year ago
220
221
222
]],
tableIns: null,
tableElem: "mainList",
赖素文
authored
about a year ago
223
224
225
btnGetPoint: $ ( "#btnGetPoint" ) ,
txtProjectAddress: $ ( "#modifyForm form input [ name=projectAddress ] " ) ,
赖素文
authored
about a year ago
226
227
btnCopyLonLat: document.querySelector ( "#btnCopyLonLat" ) ,
HuXiYu
authored
about a year ago
228
229
/ / 下拉框配置
赖素文
authored
about a year ago
230
selectOptionEnum : {
赖素文
authored
about a year ago
231
232
type : {
SelFrom : "dataSource" ,
赖素文
authored
about a year ago
233
SelValue : "value" ,
赖素文
authored
about a year ago
234
235
236
Dom : [ $ ( "select[name='projectStatus']" )],
dataSource : window . top . EnumProjectStatus ,
},
HuXiYu
authored
about a year ago
237
238
239
//返回的数据 用于后续操作
selectData : {
}
赖素文
authored
about a year ago
240
241
242
243
244
245
246
247
248
249
250
},
//下拉框配置
selectOption : {
projectType : {
SelType : "FromDict" ,
SelFrom : "projectType" ,
SelLabel : "DictLabel" ,
SelValue : "DictValue" ,
Dom : [ $ ( "[name='projectType']" )]
},
赖素文
authored
12 months ago
251
252
253
254
255
256
257
lineCode : {
SelType : "FromUrl" ,
SelFrom : "/configure/BaseClientInfo/Load" ,
SelLabel : "clientName" ,
SelValue : "keys" ,
Dom : [ $ ( "[name='projectClientInfoKeys']" )]
},
赖素文
authored
about a year ago
258
259
260
261
262
//返回的数据 用于后续操作
selectData : {
}
},
HuXiYu
authored
about a year ago
263
264
265
266
267
268
269
270
271
272
273
274
275
},
methods : {
initTable : function ( opt ) {
var config = {};
if ( opt != undefined ) $ . extend ( config , opt );
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 ) {
HuXiYu
authored
about a year ago
276
var pageFlag = "" . GetUrlParam ( "page" ),
赖素文
authored
12 months ago
277
278
279
userAccount = "" . GetUrlParam ( "userAccount" );
//加载用户绑定的项目
if ( pageFlag == "sysuser" ) {
HuXiYu
authored
about a year ago
280
let ajaxConfig = {
赖素文
authored
12 months ago
281
282
data : { userAccount : userAccount },
url : ` / base / SysUser / GetUserBindClient ` ,
HuXiYu
authored
about a year ago
283
284
success : function ( result ) {
if ( sysU . successBefore ( result )) return false ;
赖素文
authored
12 months ago
285
var targetArrValue = result . Result . map ( function ( e ) { return e . clientKeys ; });
HuXiYu
authored
about a year ago
286
287
288
289
290
291
var selectColKey = "" . GetUrlParam ( "selectColKeyCustom" );
sysU . SetTableCheck ( targetArrValue , res , selectColKey , app . data . tableElem );
}
};
sysU . ajax ( ajaxConfig );
}
HuXiYu
authored
about a year ago
292
293
294
295
296
}
}
app . data . tableIns = sysU . initTable ( options );
},
赖素文
authored
about a year ago
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
//根据地址解析经度纬度
setLngAndlat () {
let address = app . data . txtProjectAddress . val ();
if ( ! address ) {
app . data . txtProjectAddress . focus ();
return ;
}
mapApp . fn . getPointByAddress ( address , ( point ) => {
var val = { longitude : "" , latitude : "" , }
if ( point ) {
val . longitude = point . lng ;
val . latitude = point . lat ;
}
form . val ( "modifyForm" , val );
});
HuXiYu
authored
about a year ago
312
313
314
},
initFrom () {
赖素文
authored
about a year ago
315
316
sysU . initSelecteByEnum ( app . data . selectOptionEnum );
sysU . initSelect ( app . data . selectOption );
赖素文
authored
about a year ago
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
},
initCopy () {
app . data . btnCopyLonLat . addEventListener ( "click" , function ( event ) {
$ ( "#modifyForm form input[name=longitude]" ). focus ();
// 获取剪贴板中的文本数据
navigator . clipboard . readText ()
. then ( text => {
const pattern = /^ \d + (\.\d + )? , \d + (\.\d + )? $/ ;
if ( ! pattern . test ( text )) {
layer . alert ( '经纬度复制的值错误,正确的是格式【x,x】x是数字!' , { icon : sysU . config . iconoError , shadeClose : true , title : sysU . config . titleOpen });
return ;
}
var tempValue = text . split ( "," );
form . val ( "modifyForm" , { longitude : tempValue [ 0 ], latitude : tempValue [ 1 ] });
})
. catch ( err => {
layer . alert ( '无法读取剪贴板数据:' + err , { icon : sysU . config . iconoError , shadeClose : true , title : sysU . config . titleError });
});
});
HuXiYu
authored
about a year ago
336
337
338
}
},
registerEvent : function () {
赖素文
authored
about a year ago
339
340
341
app . data . btnGetPoint . click ( function () {
app . methods . setLngAndlat ();
})
HuXiYu
authored
about a year ago
342
343
344
345
},
init : function () {
app . methods . initTable ();
app . methods . initFrom ();
赖素文
authored
about a year ago
346
app . methods . initCopy ();
HuXiYu
authored
about a year ago
347
348
349
350
351
app . registerEvent ();
}
};
app . init ();
});