system-clients 3.2.54 → 3.2.55-1

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