system-clients 3.2.62 → 3.2.63-jingwei

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,533 +1,533 @@
1
- import Vue from 'vue'
2
- import {HttpResetClass} from 'vue-client'
3
- import cryptJS from './EncryptUtil'
4
-
5
- let loginGen = async function (name, password, cue) {
6
- let data = {name: name, password: password}
7
- data = '$' + cryptJS.RSAEncrypt(JSON.stringify(data))
8
- const getLogin = await Vue.resetpost('/rs/logic/getLogin', data, {resolveMsg: null, rejectMsg: null})
9
- if (getLogin.data.states === '登录成功') {
10
- //获取jwt
11
- Vue.$login.jwt = getLogin.data.jwt
12
- Vue.$login.jwtNew = getLogin.data.jwtNew
13
- // 调用远程登录服务,获取所有有权访问的功能
14
- data = {username: name, password: password}
15
- data = cryptJS.RSAEncrypt(JSON.stringify(data))
16
- const resource = await Vue.resetpost(`/rs/user/userLogin/客服系统`, data, {
17
- resolveMsg: null,
18
- rejectMsg: null
19
- })
20
- // 兼容旧版ldao
21
- if ((JSON.stringify(resource.data).startsWith("{") || JSON.stringify(resource.data).startsWith("[")) && resource.data.code && resource.data.msg && resource.data.code !== 200) {
22
- throw {status: 555, data: resource.data.msg}
23
- }
24
- console.log('登陆获取Util', JSON.stringify(resource.data))
25
-
26
- // 兼容旧版ldao,旧版不返回code
27
- if ((JSON.stringify(resource.data).startsWith("{") || JSON.stringify(resource.data).startsWith("[")) && resource.data.code && resource.data.msg) {
28
- Vue.$login.f = resource.data.data
29
- } else {
30
- Vue.$login.f = resource.data
31
- }
32
- // 把登录用户添加到cookie里
33
- Vue.cookie.set('loginId', Vue.$login.f.id)
34
- try {
35
- //获取有权限的功能树
36
- let hasRight = await Vue.resetpost(`/rs/search`, {
37
- source: "tool.getFullTree(this.getRights().where(row.getType() == $function$))",
38
- userid: Vue.$login.f.id
39
- }, { resolveMsg: null, rejectMsg: null })
40
- console.log('有权限功能返回数据', JSON.stringify(hasRight.data))
41
- //准备替换功能树
42
- var fun = []
43
- hasRight.data[0].children[0].children.forEach((item) => {
44
- if (item.name === '客服系统') {
45
- item.children.forEach((item1) => {
46
- fun.push(item1)
47
- })
48
- }
49
- })
50
- // console.log('替换前', JSON.stringify(Vue.$login.f.functions))
51
- // console.log('替换后', JSON.stringify(fun))
52
- Vue.$login.f.functions = fun
53
- } catch (error) {
54
- }
55
- if (Vue.$login.f.id !== '11') {
56
- try {
57
- let getAllArea = await Vue.resetpost('/rs/search', {
58
- source: 'this.getParentByType($organization$).getChildByName($片区$).getChildren()',
59
- userid: Vue.$login.f.id
60
- }, {resolveMsg: null, rejectMsg: null})
61
-
62
- let areaTemp = []
63
- for (let i = 0; i < getAllArea.data.length; i++) {
64
- areaTemp.push({label: getAllArea.data[i].name, value: getAllArea.data[i]})
65
- }
66
- Vue.$login.f.f_allArea = areaTemp
67
- } catch (error) {
68
- Vue.$login.f.f_allArea = []
69
- console.log('获取区县', error)
70
- }
71
- // 获取抄表员
72
- try {
73
- let getGasman = await Vue.resetpost('/rs/search', {
74
- source: 'this.getParentByType($organization$).getChildByName($抄表员$).getUsers()',
75
- userid: Vue.$login.f.id
76
- }, {resolveMsg: null, rejectMsg: null})
77
- let gasman = []
78
- for (let i = 0; i < getGasman.data.length; i++) {
79
- gasman.push(getGasman.data[i])
80
- }
81
- Vue.$login.f.f_gasman = gasman
82
- } catch (error) {
83
- Vue.$login.f.f_gasman = []
84
- console.log('抄表员模块', error)
85
- }
86
- // 获取安装人
87
- try {
88
- let getInstallman = await Vue.resetpost('/rs/search', {
89
- source: 'this.getParentByType($organization$).getChildByName($安装员$).getUsers()',
90
- userid: Vue.$login.f.id
91
- }, {resolveMsg: null, rejectMsg: null})
92
- console.log('获取安装员', getInstallman)
93
- let installman = []
94
- for (let i = 0; i < getInstallman.data.length; i++) {
95
- installman.push(getInstallman.data[i])
96
- }
97
- Vue.$login.f.f_installman = installman
98
- } catch (error) {
99
- Vue.$login.f.f_installman = []
100
- console.log('安装人模块', error)
101
- }
102
- // 获取换表员
103
- // try {
104
- // let getChangeMeterman = await Vue.resetpost('/rs/search', {
105
- // source: 'this.getParentByType($organization$).getChildByName($换表员$).getUsers()',
106
- // userid: Vue.$login.f.id
107
- // }, {resolveMsg: null, rejectMsg: null})
108
- // let changemeterman = []
109
- // for (let i = 0; i < getChangeMeterman.data.length; i++) {
110
- // changemeterman.push(getChangeMeterman.data[i])
111
- // }
112
- // Vue.$login.f.f_changemeterman = changemeterman
113
- // }catch (error) {
114
- // Vue.$login.f.f_changemeterman = []
115
- // console.log('换表员模块',error)
116
- // }
117
- // 获取资源服务权限
118
- try {
119
- let getLic = await Vue.resetpost('/rs/search', {
120
- data: {
121
- source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($资源操作$) != -1)',
122
- userid: Vue.$login.f.id
123
- }
124
- }, {resolveMsg: null, rejectMsg: null})
125
- let arry = []
126
- getLic.data.forEach((item) => {
127
- arry.push(item.name)
128
- })
129
- Vue.$login.f.lics = arry
130
- } catch (error) {
131
- Vue.$login.f.f_gasman = []
132
- console.log('资源服务权限', error)
133
- }
134
- // // 票据使用人
135
- // try {
136
- // let getPaperUseman = await Vue.resetpost('/rs/search', {
137
- // source: 'this.getParentByType($organization$).getChildByName($票据使用人$).getUsers()',
138
- // userid: Vue.$login.f.id
139
- // }, {resolveMsg: null, rejectMsg: null})
140
- // let perperuseman = []
141
- // for (let i = 0; i < getPaperUseman.data.length; i++) {
142
- // perperuseman.push(getPaperUseman.data[i])
143
- // }
144
- // Vue.$login.f.f_paperUseman = perperuseman
145
- // }catch (error) {
146
- // Vue.$login.f.f_paperUseman = []
147
- // console.log('票据使用人模块',error)
148
- //
149
- // }
150
- // // 票据分配人
151
- // try {
152
- // let getPaperAllotman = await Vue.resetpost('/rs/search', {
153
- // source: 'this.getParentByType($organization$).getChildByName($票据分配人$).getUsers()',
154
- // userid: Vue.$login.f.id
155
- // }, {resolveMsg: null, rejectMsg: null})
156
- // let paperallotman = []
157
- // for (let i = 0; i < getPaperAllotman.data.length; i++) {
158
- // paperallotman.push(getPaperAllotman.data[i])
159
- // }
160
- // Vue.$login.f.f_paperAllotman = paperallotman
161
- // }catch (error) {
162
- // Vue.$login.f.f_paperAllotman = []
163
- // console.log('票据分配人模块',error)
164
- // }
165
- // TODO 处理界面细节
166
- try {
167
- let viewDetails = await Vue.resetpost('rs/search', {
168
- source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($功能权限$) != -1)',
169
- userid: Vue.$login.f.id
170
- }, {resolveMsg: null, rejectMsg: null})
171
- let r = viewDetails.data
172
- Vue.$login.r = []
173
- r.forEach(x => Vue.$login.r.push(x.name))
174
- } catch (error) {
175
- Vue.$login.r = []
176
- console.log('加载模块失败', error)
177
- }
178
- // 调用登录后处理
179
- for (let proc of Vue.$login.afterLogin) {
180
- await proc(Vue.$login.f)
181
- }
182
- // 定时发送心跳
183
- if (cue) {
184
- setInterval(() => {
185
- let http = new HttpResetClass()
186
- //暂时不出现不出现异地登录校验
187
- http.load('POST', `rs/user/access/${Vue.$login.f.id}`, {}, {
188
- resolveMsg: null,
189
- rejectMsg: null
190
- }).then((req) => {
191
- if (req.data.forcestate && req.data.forcestate == 1) {
192
- Vue.showMessage("您被强制下线!", ['confirm']).then((res) => {
193
- location.reload()
194
- })
195
- } else if (req.data.status == 710) {
196
- Vue.showMessage(req.data.msg + ",您将被强制退出系统", ['confirm']).then((res) => {
197
- if (res === 'confirm') {
198
- location.reload()
199
- }
200
- })
201
- }
202
- })
203
- }, 2 * 60 * 1000)
204
- }
205
- }
206
-
207
- } else {
208
- let error = {status: 401, data: getLogin.data.states}
209
- // 抛出错误
210
- throw error
211
- }
212
- }
213
-
214
- let GetLoginInfoService = {
215
- // 登录后要处理的异步对象
216
- afterLogin: [],
217
- //验证码开关
218
- Verification: true,
219
- //构建时间开关
220
- versionTime: true,
221
- //登录信息展示开关
222
- depPrompt: true,
223
- install(Vue, options) {
224
- // 给vue增添对话框显示方法
225
- Vue.$login = Vue.prototype.$login = GetLoginInfoService
226
- },
227
-
228
- f: {},
229
-
230
- /**
231
- * 登录
232
- * @param name
233
- * @param password
234
- * @param cue true/false 是/否显示异地登录
235
- */
236
- login(name, password, cue) {
237
- if (cue === undefined || cue === null || cue === '') {
238
- cue = true
239
- }
240
- return loginGen(name, password, cue)
241
- },
242
-
243
- convertToIn(val) {
244
- let temp = ''
245
- if (val instanceof Array) {
246
- if (val.length >= 1) {
247
- temp = '('
248
- val.forEach((res) => {
249
- temp += `'${res}',`
250
- })
251
- temp = temp.substr(0, temp.length - 1) + ')'
252
- }
253
- }
254
- return temp
255
- },
256
-
257
- toStandardYearMonth() {
258
- let dt = new Date()
259
- let month = dt.getMonth() + 1
260
- return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month)
261
- },
262
-
263
- toStandardYearMonth1() {
264
- let dt = new Date()
265
- let month = dt.getMonth() + 1
266
- return dt.getFullYear() + (month < 10 ? '0' + month : month)
267
- },
268
-
269
- toStandardDateString() {
270
- let dt = new Date()
271
- let month = dt.getMonth() + 1
272
- let date = dt.getDate()
273
- return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date)
274
- },
275
-
276
- toStartAndEndDateString() {
277
- let dt = new Date()
278
- let month = dt.getMonth() + 1
279
- // let date = dt.getDate()
280
- return [dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-01',
281
- dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (new Date(dt.getFullYear(), month, 0).getDate())]
282
- // return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date)
283
- },
284
-
285
- toStandardTimeString() {
286
- let dt = new Date()
287
- let month = dt.getMonth() + 1
288
- let date = dt.getDate()
289
- let hour = dt.getHours()
290
- let min = dt.getMinutes()
291
- let sec = dt.getSeconds()
292
- return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date) +
293
- ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec)
294
- },
295
-
296
- guid() {
297
- let buf = new Uint16Array(8)
298
- window.crypto.getRandomValues(buf)
299
- let S4 = function (num) {
300
- let ret = num.toString(16)
301
- while (ret.length < 4) {
302
- ret = '0' + ret
303
- }
304
- return ret
305
- }
306
- return (S4(buf[0]) + S4(buf[1]) + S4(buf[2]) + S4(buf[3]) + S4(buf[4]) + S4(buf[5]) + S4(buf[6]) + S4(buf[7]))
307
- },
308
-
309
- choices(role, param, hasBlank = false, blankHint = '请选择') {
310
- if (role == 'view') {
311
- Vue.getParams(param, [null])
312
- } else {
313
- let result = []
314
- if (hasBlank)
315
- result.push({label: blankHint, value: null})
316
- if (!Vue.param || !Vue.param[param])
317
- result.push({label: '请在系统设置里更新参数', value: '请在系统设置里更新参数'})
318
- else {
319
- let p = Vue.param[param]
320
- p.forEach(function (item) {
321
- result.push({label: item.name, value: item.name})
322
- })
323
- }
324
- return result
325
- }
326
- },
327
-
328
- required(param) {
329
- if (typeof param === 'number' && param == 0)
330
- return false
331
- if (!param)
332
- return true
333
- param = param + ''
334
- param = param.trim()
335
- if (!param)
336
- return true
337
- return false
338
- },
339
-
340
- isInt(n) {
341
- return !window.isNaN(n) && n % 1 === 0
342
- },
343
-
344
- isFloat(n) {
345
- return !window.isNaN(n)
346
- },
347
-
348
- // this will convert all true/false to boolean
349
- booleanFilter(paper) {
350
- for (let key in paper) {
351
- if (!paper.hasOwnProperty(key))
352
- continue
353
- if (typeof paper[key] == 'object' && paper[key] != null) {
354
- booleanFilter(paper[key])
355
- } else {
356
- if (paper[key] === 'true' || paper[key] == 'false')
357
- paper[key] = (paper[key] === 'true')
358
- }
359
- }
360
- },
361
- // recursively traverse through each path
362
- ratifyPics(paper) {
363
- for (let key in paper) {
364
- if (key.endsWith('_path')) {
365
- if (!paper[key]) {
366
- paper[key] = 'rs/db/file/nopic.png'
367
- } else {
368
- paper[key] = 'rs/db/file/' + paper[key]
369
- }
370
- } else if (paper[key] !== null && typeof (paper[key]) == 'object') {
371
- ratifyPics(paper[key])
372
- }
373
- }
374
- },
375
-
376
- // load script and other stuff
377
- loadscript(type, fileName) {
378
- return new Promise((resolve, reject) => {
379
- let element
380
- if (type == 'css') {
381
- element = document.createElement('link')
382
- element.setAttribute('rel', 'stylesheet')
383
- element.setAttribute('type', 'text/css')
384
- element.setAttribute('href', fileName)
385
- } else if (type == 'js') {
386
- element = document.createElement('script')
387
- element.setAttribute('type', 'text/javascript')
388
- element.setAttribute('src', fileName)
389
- }
390
- if (element) {
391
- element.setAttribute('async', '')
392
- element.setAttribute('defer', '')
393
- element.addEventListener('load', function () {
394
- resolve(element)
395
- }, false)
396
- element.addEventListener('error', function () {
397
- reject(element)
398
- }, false)
399
- document.body.appendChild(element)
400
- }
401
- })
402
- },
403
- // 不能选择器中截取掉多余的字符
404
- orgName(name) {
405
- return name.substring(10)
406
- },
407
-
408
- getNowDate(name) {
409
- // 求取当前时间的工具
410
- let myweekday = ''
411
- let year = ''
412
- let mydate = new Date()
413
- myweekday = mydate.getDay()
414
- let mymonth = mydate.getMonth() + 1
415
- let myday = mydate.getDate()
416
- let myyear = mydate.getYear()
417
- year = (myyear > 200) ? myyear : 1900 + myyear
418
- let week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期日', '星期六']
419
- // document.write("<font color=#ffffff>今天是 "+year+"年"+mymonth+"月"+myday+"日 "+weekday+"</font>");
420
- return year + '年' + mymonth + '月' + myday + '日 ' + week[myweekday]
421
- },
422
-
423
- addDate(date, days) {
424
- // 求取当前时间的工具
425
- let endDate = new Date(date)
426
- endDate = endDate.valueOf()
427
- endDate = endDate + days * 24 * 60 * 60 * 1000
428
- endDate = new Date(endDate)
429
- let month = endDate.getMonth() + 1
430
- let day = endDate.getDate()
431
- let hour = endDate.getHours()
432
- let min = endDate.getMinutes()
433
- let sec = endDate.getSeconds()
434
- return endDate.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day) +
435
- ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec)
436
- // return a
437
- },
438
-
439
- // 通过地址栏的参数获取参数内容
440
- getUrlParames(param) {
441
- var query = window.location.search
442
- var iLen = param.length
443
- var iStart = query.indexOf(param)
444
- if (iStart === -1) {
445
- return ''
446
- }
447
- iStart += iLen + 1
448
- var iEnd = query.indexOf('&', iStart)
449
- if (iEnd === -1) {
450
- return query.substring(iStart)
451
- }
452
- return query.substring(iStart, iEnd)
453
- },
454
-
455
- // 从地址栏获取加密的参数
456
- getUrlCompileParames(param) {
457
- let code = unescape(window.location.search.slice(1, window.location.search.length))
458
- let query = String.fromCharCode(code.charCodeAt(0) - code.length)
459
- for (var i = 1; i < code.length; i++) {
460
- query += String.fromCharCode(code.charCodeAt(i) - query.charCodeAt(i - 1))
461
- }
462
- let iLen = param.length
463
- let iStart = query.indexOf(param)
464
- if (iStart === -1) {
465
- return ''
466
- }
467
- iStart += iLen + 1
468
- let iEnd = query.indexOf('&', iStart)
469
- if (iEnd === -1) {
470
- return query.substring(iStart)
471
- }
472
- return query.substring(iStart, iEnd)
473
- },
474
-
475
- // 对字符串进行加密
476
- compileStr(code) {
477
- let c = String.fromCharCode(code.charCodeAt(0) + code.length)
478
- for (let i = 1; i < code.length; i++) {
479
- c += String.fromCharCode(code.charCodeAt(i) + code.charCodeAt(i - 1))
480
- }
481
- return escape(c)
482
- },
483
- // 字符串进行解密
484
- uncompileStr(code) {
485
- code = unescape(code)
486
- let c = String.fromCharCode(code.charCodeAt(0) - code.length)
487
- for (var i = 1; i < code.length; i++) {
488
- c += String.fromCharCode(code.charCodeAt(i) - c.charCodeAt(i - 1))
489
- }
490
- return c
491
- },
492
-
493
- dateDescripte(date) {
494
- let nowTime = new Date().getTime()
495
- let oldTime = new Date(date).getTime()
496
- let timeDiff = nowTime - oldTime
497
- // 规则说明
498
- // 小于等于2分钟为刚刚
499
- // 大于2分钟小于等于1小时为取整的分钟前(例如:35分钟前)
500
- // 大于1小时小于等于24小时为取整的小时前(例如:15小时前)
501
- // 大于24小时小于等于30天为取整的天前(例如:12天前)
502
- // 大于30天小于等于12月为取整的月前,月份统一为30天一月,不做额外处理(例如:3个月前)
503
- // 大于365取整的年前,(例如:2年前)
504
- let minute = 1000 * 60
505
- let hour = minute * 60
506
- let day = hour * 24
507
- let month = day * 30
508
- let year = month * 12
509
- let des = ''
510
- if (timeDiff <= minute * 2) {
511
- des = '刚刚'
512
- } else if (minute * 2 < timeDiff && timeDiff < hour) {
513
- des = `${Math.floor(timeDiff / minute)}分钟前`
514
- } else if (hour < timeDiff && timeDiff <= day) {
515
- des = `${Math.floor(timeDiff / hour)}小时前`
516
- } else if (day < timeDiff && timeDiff <= month) {
517
- des = `${Math.floor(timeDiff / day)}天前`
518
- } else if (month < timeDiff && timeDiff <= year) {
519
- des = `${Math.floor(timeDiff / month)}个月前`
520
- } else if (year < timeDiff) {
521
- des = `${Math.floor(timeDiff / year)}年前`
522
- }
523
- return des
524
- },
525
-
526
- nextMonth20(date) {
527
- let ds = date.split('-')
528
- let nextMonth = ds[1] - 0 + 1
529
- return ds[0] + '-' + (nextMonth < 10 ? '0' + nextMonth : nextMonth) + '-20 00:00:00'
530
- }
531
- }
532
-
533
- export default GetLoginInfoService
1
+ import Vue from 'vue'
2
+ import {HttpResetClass} from 'vue-client'
3
+ import cryptJS from './EncryptUtil'
4
+
5
+ let loginGen = async function (name, password, cue) {
6
+ let data = {name: name, password: password}
7
+ data = '$' + cryptJS.RSAEncrypt(JSON.stringify(data))
8
+ const getLogin = await Vue.resetpost('/rs/logic/getLogin', data, {resolveMsg: null, rejectMsg: null})
9
+ if (getLogin.data.states === '登录成功') {
10
+ //获取jwt
11
+ Vue.$login.jwt = getLogin.data.jwt
12
+ Vue.$login.jwtNew = getLogin.data.jwtNew
13
+ // 调用远程登录服务,获取所有有权访问的功能
14
+ data = {username: name, password: password}
15
+ data = cryptJS.RSAEncrypt(JSON.stringify(data))
16
+ const resource = await Vue.resetpost(`/rs/user/userLogin/客服系统`, data, {
17
+ resolveMsg: null,
18
+ rejectMsg: null
19
+ })
20
+ // 兼容旧版ldao
21
+ if ((JSON.stringify(resource.data).startsWith("{") || JSON.stringify(resource.data).startsWith("[")) && resource.data.code && resource.data.msg && resource.data.code !== 200) {
22
+ throw {status: 555, data: resource.data.msg}
23
+ }
24
+ console.log('登陆获取Util', JSON.stringify(resource.data))
25
+
26
+ // 兼容旧版ldao,旧版不返回code
27
+ if ((JSON.stringify(resource.data).startsWith("{") || JSON.stringify(resource.data).startsWith("[")) && resource.data.code && resource.data.msg) {
28
+ Vue.$login.f = resource.data.data
29
+ } else {
30
+ Vue.$login.f = resource.data
31
+ }
32
+ // 把登录用户添加到cookie里
33
+ Vue.cookie.set('loginId', Vue.$login.f.id)
34
+ try {
35
+ //获取有权限的功能树
36
+ let hasRight = await Vue.resetpost(`/rs/search`, {
37
+ source: "tool.getFullTree(this.getRights().where(row.getType() == $function$))",
38
+ userid: Vue.$login.f.id
39
+ }, { resolveMsg: null, rejectMsg: null })
40
+ console.log('有权限功能返回数据', JSON.stringify(hasRight.data))
41
+ //准备替换功能树
42
+ var fun = []
43
+ hasRight.data[0].children[0].children.forEach((item) => {
44
+ if (item.name === '客服系统') {
45
+ item.children.forEach((item1) => {
46
+ fun.push(item1)
47
+ })
48
+ }
49
+ })
50
+ // console.log('替换前', JSON.stringify(Vue.$login.f.functions))
51
+ // console.log('替换后', JSON.stringify(fun))
52
+ Vue.$login.f.functions = fun
53
+ } catch (error) {
54
+ }
55
+ if (Vue.$login.f.id !== '11') {
56
+ try {
57
+ let getAllArea = await Vue.resetpost('/rs/search', {
58
+ source: 'this.getParentByType($organization$).getChildByName($片区$).getChildren()',
59
+ userid: Vue.$login.f.id
60
+ }, {resolveMsg: null, rejectMsg: null})
61
+
62
+ let areaTemp = []
63
+ for (let i = 0; i < getAllArea.data.length; i++) {
64
+ areaTemp.push({label: getAllArea.data[i].name, value: getAllArea.data[i]})
65
+ }
66
+ Vue.$login.f.f_allArea = areaTemp
67
+ } catch (error) {
68
+ Vue.$login.f.f_allArea = []
69
+ console.log('获取区县', error)
70
+ }
71
+ // 获取抄表员
72
+ try {
73
+ let getGasman = await Vue.resetpost('/rs/search', {
74
+ source: 'this.getParentByType($organization$).getChildByName($抄表员$).getUsers()',
75
+ userid: Vue.$login.f.id
76
+ }, {resolveMsg: null, rejectMsg: null})
77
+ let gasman = []
78
+ for (let i = 0; i < getGasman.data.length; i++) {
79
+ gasman.push(getGasman.data[i])
80
+ }
81
+ Vue.$login.f.f_gasman = gasman
82
+ } catch (error) {
83
+ Vue.$login.f.f_gasman = []
84
+ console.log('抄表员模块', error)
85
+ }
86
+ // 获取安装人
87
+ try {
88
+ let getInstallman = await Vue.resetpost('/rs/search', {
89
+ source: 'this.getParentByType($organization$).getChildByName($安装员$).getUsers()',
90
+ userid: Vue.$login.f.id
91
+ }, {resolveMsg: null, rejectMsg: null})
92
+ console.log('获取安装员', getInstallman)
93
+ let installman = []
94
+ for (let i = 0; i < getInstallman.data.length; i++) {
95
+ installman.push(getInstallman.data[i])
96
+ }
97
+ Vue.$login.f.f_installman = installman
98
+ } catch (error) {
99
+ Vue.$login.f.f_installman = []
100
+ console.log('安装人模块', error)
101
+ }
102
+ // 获取换表员
103
+ // try {
104
+ // let getChangeMeterman = await Vue.resetpost('/rs/search', {
105
+ // source: 'this.getParentByType($organization$).getChildByName($换表员$).getUsers()',
106
+ // userid: Vue.$login.f.id
107
+ // }, {resolveMsg: null, rejectMsg: null})
108
+ // let changemeterman = []
109
+ // for (let i = 0; i < getChangeMeterman.data.length; i++) {
110
+ // changemeterman.push(getChangeMeterman.data[i])
111
+ // }
112
+ // Vue.$login.f.f_changemeterman = changemeterman
113
+ // }catch (error) {
114
+ // Vue.$login.f.f_changemeterman = []
115
+ // console.log('换表员模块',error)
116
+ // }
117
+ // 获取资源服务权限
118
+ try {
119
+ let getLic = await Vue.resetpost('/rs/search', {
120
+ data: {
121
+ source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($资源操作$) != -1)',
122
+ userid: Vue.$login.f.id
123
+ }
124
+ }, {resolveMsg: null, rejectMsg: null})
125
+ let arry = []
126
+ getLic.data.forEach((item) => {
127
+ arry.push(item.name)
128
+ })
129
+ Vue.$login.f.lics = arry
130
+ } catch (error) {
131
+ Vue.$login.f.f_gasman = []
132
+ console.log('资源服务权限', error)
133
+ }
134
+ // // 票据使用人
135
+ // try {
136
+ // let getPaperUseman = await Vue.resetpost('/rs/search', {
137
+ // source: 'this.getParentByType($organization$).getChildByName($票据使用人$).getUsers()',
138
+ // userid: Vue.$login.f.id
139
+ // }, {resolveMsg: null, rejectMsg: null})
140
+ // let perperuseman = []
141
+ // for (let i = 0; i < getPaperUseman.data.length; i++) {
142
+ // perperuseman.push(getPaperUseman.data[i])
143
+ // }
144
+ // Vue.$login.f.f_paperUseman = perperuseman
145
+ // }catch (error) {
146
+ // Vue.$login.f.f_paperUseman = []
147
+ // console.log('票据使用人模块',error)
148
+ //
149
+ // }
150
+ // // 票据分配人
151
+ // try {
152
+ // let getPaperAllotman = await Vue.resetpost('/rs/search', {
153
+ // source: 'this.getParentByType($organization$).getChildByName($票据分配人$).getUsers()',
154
+ // userid: Vue.$login.f.id
155
+ // }, {resolveMsg: null, rejectMsg: null})
156
+ // let paperallotman = []
157
+ // for (let i = 0; i < getPaperAllotman.data.length; i++) {
158
+ // paperallotman.push(getPaperAllotman.data[i])
159
+ // }
160
+ // Vue.$login.f.f_paperAllotman = paperallotman
161
+ // }catch (error) {
162
+ // Vue.$login.f.f_paperAllotman = []
163
+ // console.log('票据分配人模块',error)
164
+ // }
165
+ // TODO 处理界面细节
166
+ try {
167
+ let viewDetails = await Vue.resetpost('rs/search', {
168
+ source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($功能权限$) != -1)',
169
+ userid: Vue.$login.f.id
170
+ }, {resolveMsg: null, rejectMsg: null})
171
+ let r = viewDetails.data
172
+ Vue.$login.r = []
173
+ r.forEach(x => Vue.$login.r.push(x.name))
174
+ } catch (error) {
175
+ Vue.$login.r = []
176
+ console.log('加载模块失败', error)
177
+ }
178
+ // 调用登录后处理
179
+ for (let proc of Vue.$login.afterLogin) {
180
+ await proc(Vue.$login.f)
181
+ }
182
+ // 定时发送心跳
183
+ if (cue) {
184
+ setInterval(() => {
185
+ let http = new HttpResetClass()
186
+ //暂时不出现不出现异地登录校验
187
+ http.load('POST', `rs/user/access/${Vue.$login.f.id}`, {}, {
188
+ resolveMsg: null,
189
+ rejectMsg: null
190
+ }).then((req) => {
191
+ if (req.data.forcestate && req.data.forcestate == 1) {
192
+ Vue.showMessage("您被强制下线!", ['confirm']).then((res) => {
193
+ location.reload()
194
+ })
195
+ } else if (req.data.status == 710) {
196
+ Vue.showMessage(req.data.msg + ",您将被强制退出系统", ['confirm']).then((res) => {
197
+ if (res === 'confirm') {
198
+ location.reload()
199
+ }
200
+ })
201
+ }
202
+ })
203
+ }, 2 * 60 * 1000)
204
+ }
205
+ }
206
+
207
+ } else {
208
+ let error = {status: 401, data: getLogin.data.states}
209
+ // 抛出错误
210
+ throw error
211
+ }
212
+ }
213
+
214
+ let GetLoginInfoService = {
215
+ // 登录后要处理的异步对象
216
+ afterLogin: [],
217
+ //验证码开关
218
+ Verification: true,
219
+ //构建时间开关
220
+ versionTime: true,
221
+ //登录信息展示开关
222
+ depPrompt: true,
223
+ install(Vue, options) {
224
+ // 给vue增添对话框显示方法
225
+ Vue.$login = Vue.prototype.$login = GetLoginInfoService
226
+ },
227
+
228
+ f: {},
229
+
230
+ /**
231
+ * 登录
232
+ * @param name
233
+ * @param password
234
+ * @param cue true/false 是/否显示异地登录
235
+ */
236
+ login(name, password, cue) {
237
+ if (cue === undefined || cue === null || cue === '') {
238
+ cue = true
239
+ }
240
+ return loginGen(name, password, cue)
241
+ },
242
+
243
+ convertToIn(val) {
244
+ let temp = ''
245
+ if (val instanceof Array) {
246
+ if (val.length >= 1) {
247
+ temp = '('
248
+ val.forEach((res) => {
249
+ temp += `'${res}',`
250
+ })
251
+ temp = temp.substr(0, temp.length - 1) + ')'
252
+ }
253
+ }
254
+ return temp
255
+ },
256
+
257
+ toStandardYearMonth() {
258
+ let dt = new Date()
259
+ let month = dt.getMonth() + 1
260
+ return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month)
261
+ },
262
+
263
+ toStandardYearMonth1() {
264
+ let dt = new Date()
265
+ let month = dt.getMonth() + 1
266
+ return dt.getFullYear() + (month < 10 ? '0' + month : month)
267
+ },
268
+
269
+ toStandardDateString() {
270
+ let dt = new Date()
271
+ let month = dt.getMonth() + 1
272
+ let date = dt.getDate()
273
+ return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date)
274
+ },
275
+
276
+ toStartAndEndDateString() {
277
+ let dt = new Date()
278
+ let month = dt.getMonth() + 1
279
+ // let date = dt.getDate()
280
+ return [dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-01',
281
+ dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (new Date(dt.getFullYear(), month, 0).getDate())]
282
+ // return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date)
283
+ },
284
+
285
+ toStandardTimeString() {
286
+ let dt = new Date()
287
+ let month = dt.getMonth() + 1
288
+ let date = dt.getDate()
289
+ let hour = dt.getHours()
290
+ let min = dt.getMinutes()
291
+ let sec = dt.getSeconds()
292
+ return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date) +
293
+ ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec)
294
+ },
295
+
296
+ guid() {
297
+ let buf = new Uint16Array(8)
298
+ window.crypto.getRandomValues(buf)
299
+ let S4 = function (num) {
300
+ let ret = num.toString(16)
301
+ while (ret.length < 4) {
302
+ ret = '0' + ret
303
+ }
304
+ return ret
305
+ }
306
+ return (S4(buf[0]) + S4(buf[1]) + S4(buf[2]) + S4(buf[3]) + S4(buf[4]) + S4(buf[5]) + S4(buf[6]) + S4(buf[7]))
307
+ },
308
+
309
+ choices(role, param, hasBlank = false, blankHint = '请选择') {
310
+ if (role == 'view') {
311
+ Vue.getParams(param, [null])
312
+ } else {
313
+ let result = []
314
+ if (hasBlank)
315
+ result.push({label: blankHint, value: null})
316
+ if (!Vue.param || !Vue.param[param])
317
+ result.push({label: '请在系统设置里更新参数', value: '请在系统设置里更新参数'})
318
+ else {
319
+ let p = Vue.param[param]
320
+ p.forEach(function (item) {
321
+ result.push({label: item.name, value: item.name})
322
+ })
323
+ }
324
+ return result
325
+ }
326
+ },
327
+
328
+ required(param) {
329
+ if (typeof param === 'number' && param == 0)
330
+ return false
331
+ if (!param)
332
+ return true
333
+ param = param + ''
334
+ param = param.trim()
335
+ if (!param)
336
+ return true
337
+ return false
338
+ },
339
+
340
+ isInt(n) {
341
+ return !window.isNaN(n) && n % 1 === 0
342
+ },
343
+
344
+ isFloat(n) {
345
+ return !window.isNaN(n)
346
+ },
347
+
348
+ // this will convert all true/false to boolean
349
+ booleanFilter(paper) {
350
+ for (let key in paper) {
351
+ if (!paper.hasOwnProperty(key))
352
+ continue
353
+ if (typeof paper[key] == 'object' && paper[key] != null) {
354
+ booleanFilter(paper[key])
355
+ } else {
356
+ if (paper[key] === 'true' || paper[key] == 'false')
357
+ paper[key] = (paper[key] === 'true')
358
+ }
359
+ }
360
+ },
361
+ // recursively traverse through each path
362
+ ratifyPics(paper) {
363
+ for (let key in paper) {
364
+ if (key.endsWith('_path')) {
365
+ if (!paper[key]) {
366
+ paper[key] = 'rs/db/file/nopic.png'
367
+ } else {
368
+ paper[key] = 'rs/db/file/' + paper[key]
369
+ }
370
+ } else if (paper[key] !== null && typeof (paper[key]) == 'object') {
371
+ ratifyPics(paper[key])
372
+ }
373
+ }
374
+ },
375
+
376
+ // load script and other stuff
377
+ loadscript(type, fileName) {
378
+ return new Promise((resolve, reject) => {
379
+ let element
380
+ if (type == 'css') {
381
+ element = document.createElement('link')
382
+ element.setAttribute('rel', 'stylesheet')
383
+ element.setAttribute('type', 'text/css')
384
+ element.setAttribute('href', fileName)
385
+ } else if (type == 'js') {
386
+ element = document.createElement('script')
387
+ element.setAttribute('type', 'text/javascript')
388
+ element.setAttribute('src', fileName)
389
+ }
390
+ if (element) {
391
+ element.setAttribute('async', '')
392
+ element.setAttribute('defer', '')
393
+ element.addEventListener('load', function () {
394
+ resolve(element)
395
+ }, false)
396
+ element.addEventListener('error', function () {
397
+ reject(element)
398
+ }, false)
399
+ document.body.appendChild(element)
400
+ }
401
+ })
402
+ },
403
+ // 不能选择器中截取掉多余的字符
404
+ orgName(name) {
405
+ return name.substring(10)
406
+ },
407
+
408
+ getNowDate(name) {
409
+ // 求取当前时间的工具
410
+ let myweekday = ''
411
+ let year = ''
412
+ let mydate = new Date()
413
+ myweekday = mydate.getDay()
414
+ let mymonth = mydate.getMonth() + 1
415
+ let myday = mydate.getDate()
416
+ let myyear = mydate.getYear()
417
+ year = (myyear > 200) ? myyear : 1900 + myyear
418
+ let week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期日', '星期六']
419
+ // document.write("<font color=#ffffff>今天是 "+year+"年"+mymonth+"月"+myday+"日 "+weekday+"</font>");
420
+ return year + '年' + mymonth + '月' + myday + '日 ' + week[myweekday]
421
+ },
422
+
423
+ addDate(date, days) {
424
+ // 求取当前时间的工具
425
+ let endDate = new Date(date)
426
+ endDate = endDate.valueOf()
427
+ endDate = endDate + days * 24 * 60 * 60 * 1000
428
+ endDate = new Date(endDate)
429
+ let month = endDate.getMonth() + 1
430
+ let day = endDate.getDate()
431
+ let hour = endDate.getHours()
432
+ let min = endDate.getMinutes()
433
+ let sec = endDate.getSeconds()
434
+ return endDate.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day) +
435
+ ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec)
436
+ // return a
437
+ },
438
+
439
+ // 通过地址栏的参数获取参数内容
440
+ getUrlParames(param) {
441
+ var query = window.location.search
442
+ var iLen = param.length
443
+ var iStart = query.indexOf(param)
444
+ if (iStart === -1) {
445
+ return ''
446
+ }
447
+ iStart += iLen + 1
448
+ var iEnd = query.indexOf('&', iStart)
449
+ if (iEnd === -1) {
450
+ return query.substring(iStart)
451
+ }
452
+ return query.substring(iStart, iEnd)
453
+ },
454
+
455
+ // 从地址栏获取加密的参数
456
+ getUrlCompileParames(param) {
457
+ let code = unescape(window.location.search.slice(1, window.location.search.length))
458
+ let query = String.fromCharCode(code.charCodeAt(0) - code.length)
459
+ for (var i = 1; i < code.length; i++) {
460
+ query += String.fromCharCode(code.charCodeAt(i) - query.charCodeAt(i - 1))
461
+ }
462
+ let iLen = param.length
463
+ let iStart = query.indexOf(param)
464
+ if (iStart === -1) {
465
+ return ''
466
+ }
467
+ iStart += iLen + 1
468
+ let iEnd = query.indexOf('&', iStart)
469
+ if (iEnd === -1) {
470
+ return query.substring(iStart)
471
+ }
472
+ return query.substring(iStart, iEnd)
473
+ },
474
+
475
+ // 对字符串进行加密
476
+ compileStr(code) {
477
+ let c = String.fromCharCode(code.charCodeAt(0) + code.length)
478
+ for (let i = 1; i < code.length; i++) {
479
+ c += String.fromCharCode(code.charCodeAt(i) + code.charCodeAt(i - 1))
480
+ }
481
+ return escape(c)
482
+ },
483
+ // 字符串进行解密
484
+ uncompileStr(code) {
485
+ code = unescape(code)
486
+ let c = String.fromCharCode(code.charCodeAt(0) - code.length)
487
+ for (var i = 1; i < code.length; i++) {
488
+ c += String.fromCharCode(code.charCodeAt(i) - c.charCodeAt(i - 1))
489
+ }
490
+ return c
491
+ },
492
+
493
+ dateDescripte(date) {
494
+ let nowTime = new Date().getTime()
495
+ let oldTime = new Date(date).getTime()
496
+ let timeDiff = nowTime - oldTime
497
+ // 规则说明
498
+ // 小于等于2分钟为刚刚
499
+ // 大于2分钟小于等于1小时为取整的分钟前(例如:35分钟前)
500
+ // 大于1小时小于等于24小时为取整的小时前(例如:15小时前)
501
+ // 大于24小时小于等于30天为取整的天前(例如:12天前)
502
+ // 大于30天小于等于12月为取整的月前,月份统一为30天一月,不做额外处理(例如:3个月前)
503
+ // 大于365取整的年前,(例如:2年前)
504
+ let minute = 1000 * 60
505
+ let hour = minute * 60
506
+ let day = hour * 24
507
+ let month = day * 30
508
+ let year = month * 12
509
+ let des = ''
510
+ if (timeDiff <= minute * 2) {
511
+ des = '刚刚'
512
+ } else if (minute * 2 < timeDiff && timeDiff < hour) {
513
+ des = `${Math.floor(timeDiff / minute)}分钟前`
514
+ } else if (hour < timeDiff && timeDiff <= day) {
515
+ des = `${Math.floor(timeDiff / hour)}小时前`
516
+ } else if (day < timeDiff && timeDiff <= month) {
517
+ des = `${Math.floor(timeDiff / day)}天前`
518
+ } else if (month < timeDiff && timeDiff <= year) {
519
+ des = `${Math.floor(timeDiff / month)}个月前`
520
+ } else if (year < timeDiff) {
521
+ des = `${Math.floor(timeDiff / year)}年前`
522
+ }
523
+ return des
524
+ },
525
+
526
+ nextMonth20(date) {
527
+ let ds = date.split('-')
528
+ let nextMonth = ds[1] - 0 + 1
529
+ return ds[0] + '-' + (nextMonth < 10 ? '0' + nextMonth : nextMonth) + '-20 00:00:00'
530
+ }
531
+ }
532
+
533
+ export default GetLoginInfoService