n20-common-lib 1.3.49 → 1.3.50

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "1.3.49",
3
+ "version": "1.3.50",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -510,7 +510,7 @@ $--input-max: 304px;
510
510
  }
511
511
  }
512
512
 
513
- .el-select .el-input__inner{
513
+ .el-select .el-input__inner {
514
514
  text-overflow: ellipsis;
515
515
  }
516
516
 
@@ -694,9 +694,25 @@ $--input-max: 304px;
694
694
  margin-left: 10px;
695
695
  }
696
696
  }
697
-
698
- .el-select .el-input__suffix {
699
- display: none;
697
+ &[clearable] {
698
+ .el-select {
699
+ .el-input__inner {
700
+ padding-right: 48px;
701
+ }
702
+ .el-input__suffix {
703
+ right: 26px;
704
+ .el-icon-arrow-up {
705
+ display: none;
706
+ }
707
+ }
708
+ }
709
+ }
710
+ &:not([clearable]) {
711
+ .el-select {
712
+ .el-input__suffix {
713
+ display: none;
714
+ }
715
+ }
700
716
  }
701
717
  }
702
718
 
@@ -62,9 +62,11 @@ export default {
62
62
  },
63
63
  methods: {
64
64
  visibleChangeFn(val) {
65
- if (val && !this.$refs['input-search']['multiple']) {
66
- this.$refs['input-search']['selectedLabel'] =
67
- this.$refs['input-search']['currentPlaceholder']
65
+ if (val && !this.multiple) {
66
+ if (this.value || this.value === 0) {
67
+ this.$refs['input-search']['selectedLabel'] =
68
+ this.$refs['input-search']['currentPlaceholder']
69
+ }
68
70
  }
69
71
  },
70
72
  changeFn(val) {
@@ -80,21 +80,20 @@
80
80
  <el-dropdown-item command="changePassword" divided>{{
81
81
  '修改密码' | $l(i18n)
82
82
  }}</el-dropdown-item>
83
+ <el-dropdown-item v-if="customOpt.mydeal" command="myDeal" divided>{{
84
+ '我的交易' | $l(i18n)
85
+ }}</el-dropdown-item>
83
86
  <el-dropdown-item
84
- v-if="customOpt.mydeal !== false"
85
- command="myDeal"
86
- divided
87
- >{{ '我的交易' | $l(i18n) }}</el-dropdown-item
88
- >
89
- <el-dropdown-item
90
- v-if="customOpt.agency && customOpt.agency.show"
91
- command="myAgency"
87
+ v-if="customOpt.switchuser"
88
+ command="switchUser"
92
89
  divided
90
+ >{{ '切换用户' | $l(i18n) }}</el-dropdown-item
93
91
  >
92
+ <el-dropdown-item v-if="customOpt.agency" command="myAgency" divided>
94
93
  <div class="flex-box flex-v">
95
94
  <span>{{ '工作代理' | $l(i18n) }}</span>
96
95
  <el-badge
97
- v-if="customOpt.agency.underway"
96
+ v-if="underway"
98
97
  class="m-l-auto font-size-small color-primary"
99
98
  is-dot
100
99
  type="primary"
@@ -169,6 +168,14 @@
169
168
  >
170
169
  <noticePop ref="noticeContent" :num.sync="noticeNum" />
171
170
  </el-popover>
171
+ <el-dialog
172
+ :visible.sync="scV"
173
+ :title="'切换用户' | $l(i18n)"
174
+ append-to-body
175
+ width="600px"
176
+ >
177
+ <switchUser :visible.sync="scV" :user-no="userNo" />
178
+ </el-dialog>
172
179
  </div>
173
180
  </template>
174
181
 
@@ -179,8 +186,9 @@ import { themeList } from '../../../utils/theme.config.js'
179
186
  import dialogWrap from '../../Dialog/index.vue'
180
187
  import changePwd from './changePwd.vue'
181
188
  import noticePop from './noticePop.vue'
182
- import axios from '../../../utils/axios'
189
+ import switchUser from './switchUser.vue'
183
190
 
191
+ import axios from '../../../utils/axios'
184
192
  import getJsonc from '../../../assets/getJsonc'
185
193
  import realUrl from '../../../assets/realUrl'
186
194
  import auth from '../../../utils/auth'
@@ -208,6 +216,9 @@ const i18n = {
208
216
  我的交易: {
209
217
  en: 'My deal'
210
218
  },
219
+ 切换用户: {
220
+ en: 'Switch User'
221
+ },
211
222
  工作代理: {
212
223
  en: 'My agency'
213
224
  },
@@ -247,7 +258,8 @@ export default {
247
258
  components: {
248
259
  dialogWrap,
249
260
  changePwd,
250
- noticePop
261
+ noticePop,
262
+ switchUser
251
263
  },
252
264
  inject: {
253
265
  customOpt: {
@@ -264,6 +276,7 @@ export default {
264
276
  headerTitle: undefined,
265
277
  headerUserUrl: undefined,
266
278
  userInfo: {},
279
+ userNo: window.sessionStorage.getItem('userNo'),
267
280
  durationTime: '00小时00分00秒',
268
281
  cpwdV: false,
269
282
  langV: false,
@@ -273,6 +286,8 @@ export default {
273
286
  themeVal: window.localStorage.getItem('pageTheme') || 'default',
274
287
  noticeNum: 0,
275
288
  rolesList: [],
289
+ scV: false,
290
+ underway: false,
276
291
  i18n
277
292
  }
278
293
  },
@@ -295,12 +310,16 @@ export default {
295
310
  setUserVisible(v) {
296
311
  if (v) {
297
312
  let userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}')
313
+
314
+ this.userNo = userInfo.uno
298
315
  this.userInfo = {
299
316
  userName: userInfo.uname,
300
317
  companyName: userInfo.cltName
301
318
  }
302
319
  this.rolesList = userInfo.roles || []
303
320
 
321
+ this.customOpt.agency && this.getProxyAuthIing()
322
+
304
323
  let loginTime = sessionStorage.getItem('loginTime')
305
324
  if (loginTime) {
306
325
  this.setDurationTime(loginTime)
@@ -356,6 +375,15 @@ export default {
356
375
  case 'logOut':
357
376
  this.logOut()
358
377
  break
378
+ case 'myDeal':
379
+ this.$router.push('/activiti/alreadyToExamine')
380
+ break
381
+ case 'myAgency':
382
+ this.$router.push('/user-web/agency')
383
+ break
384
+ case 'switchUser':
385
+ this.switchUser()
386
+ break
359
387
  default:
360
388
  this.$emit('custom-event', { type: c })
361
389
  break
@@ -393,6 +421,9 @@ export default {
393
421
  // alert('修改密码')
394
422
  this.cpwdV = true
395
423
  },
424
+ switchUser() {
425
+ this.scV = true
426
+ },
396
427
  logOut() {
397
428
  // alert('退出登录')
398
429
  this.$confirm(
@@ -406,6 +437,16 @@ export default {
406
437
  ).then(() => {
407
438
  auth.removeToken()
408
439
  })
440
+ },
441
+ // 检查是否代理中
442
+ async getProxyAuthIing() {
443
+ let res = await axios.get(
444
+ `/bems/prod_1.0/user/wfUserProxyAuth/check/ongoing/${this.userNo}`,
445
+ null,
446
+ { loading: false, noMsg: true }
447
+ )
448
+
449
+ this.underway = !!res.data
409
450
  }
410
451
  }
411
452
  }
@@ -0,0 +1,67 @@
1
+ <template>
2
+ <el-table :data="userListBanck" style="width: 100%">
3
+ <el-table-column type="index" label="序号" />
4
+ <el-table-column prop="uno" label="账号" width="180" />
5
+ <el-table-column prop="cltName" label="单位" />
6
+ <el-table-column width="100" label="操作">
7
+ <template slot-scope="{ row }">
8
+ <el-button v-if="userNo === row.uno" type="text" disabled
9
+ >当前用户</el-button
10
+ >
11
+ <el-button v-else type="text" @click="handleChange(row.uno)"
12
+ >切换</el-button
13
+ >
14
+ </template>
15
+ </el-table-column>
16
+ </el-table>
17
+ </template>
18
+
19
+ <script>
20
+ import axios from '../../../utils/axios'
21
+ import auth from '../../../utils/auth'
22
+
23
+ export default {
24
+ props: {
25
+ visible: {
26
+ type: Boolean,
27
+ default: false
28
+ },
29
+ userNo: {
30
+ type: String,
31
+ default: undefined
32
+ }
33
+ },
34
+ data() {
35
+ return {
36
+ userListBanck: [{}]
37
+ }
38
+ },
39
+ created() {
40
+ axios
41
+ .get(
42
+ `/bems/prod_1.0/user/api/userController/queryUserListByUserNo/${this.userNo}`
43
+ )
44
+ .then(({ data }) => {
45
+ this.userListBanck = data
46
+ })
47
+ },
48
+ methods: {
49
+ handleChange(uno) {
50
+ axios
51
+ .get(`/bems/prod_1.0/uas/api/authorization/switchUser/${uno}`)
52
+ .then(({ data }) => {
53
+ this.$emit('update:visible', false)
54
+
55
+ window.sessionStorage.setItem('_auto_login_ing_', true)
56
+ window.sessionStorage.setItem(
57
+ '_auto_login_data_',
58
+ JSON.stringify(data)
59
+ )
60
+ auth.toLogin()
61
+ })
62
+ }
63
+ }
64
+ }
65
+ </script>
66
+
67
+ <style></style>
@@ -1,5 +1,15 @@
1
1
  <template>
2
+ <div v-if="alV" v-loading="alV" class="login-wrap">
3
+ <loginForm
4
+ ref="login-form"
5
+ :login-types="LOGIN_MODE || loginTypes"
6
+ :login-then="loginThen"
7
+ class="login-form"
8
+ style="display: none"
9
+ />
10
+ </div>
2
11
  <div
12
+ v-else
3
13
  class="login-wrap"
4
14
  :style="{
5
15
  backgroundImage: BgImage ? `url(${BgImage})` : `url(${loginBg})`
@@ -66,6 +76,14 @@ export default {
66
76
  loginThen: {
67
77
  type: Function,
68
78
  default: undefined
79
+ },
80
+ autoLogin: {
81
+ type: Boolean,
82
+ default: false
83
+ },
84
+ autoLoginDate: {
85
+ type: Object,
86
+ default: undefined
69
87
  }
70
88
  },
71
89
  data() {
@@ -82,10 +100,20 @@ export default {
82
100
  loginLogoHeight: 'auto',
83
101
  loginLogoText: '',
84
102
  sloganHtml: '',
85
- operateType: 'login'
103
+ operateType: 'login',
104
+ alV: false
86
105
  }
87
106
  },
88
107
  created() {
108
+ if (this.autoLogin) {
109
+ this.autoLoginSC()
110
+ return
111
+ }
112
+ if (window.sessionStorage.getItem('_auto_login_ing_')) {
113
+ this.autoLoginSS()
114
+ return
115
+ }
116
+
89
117
  this.removeStorage()
90
118
  this.init()
91
119
  },
@@ -159,6 +187,37 @@ export default {
159
187
  },
160
188
  getChangetype(val) {
161
189
  this.operateType = val
190
+ },
191
+ autoLoginSC() {
192
+ this.alV = true
193
+ let alData = this.autoLoginDate
194
+ this.removeStorage()
195
+ if (alData && alData.accessToken) {
196
+ this.autoLoginFn(alData)
197
+ } else {
198
+ this.$watch('autoLoginDate', (alData) => {
199
+ if (alData && alData.accessToken) {
200
+ this.removeStorage()
201
+ this.autoLoginFn(alData)
202
+ }
203
+ })
204
+ }
205
+ },
206
+ autoLoginSS() {
207
+ this.alV = true
208
+ let alDataStr = window.sessionStorage.getItem('_auto_login_data_')
209
+ this.removeStorage()
210
+ if (alDataStr) {
211
+ let alData = JSON.parse(alDataStr)
212
+ if (alData && alData.accessToken) {
213
+ this.autoLoginFn(alData)
214
+ }
215
+ }
216
+ },
217
+ autoLoginFn(alData) {
218
+ this.$nextTick(() => {
219
+ this.$refs['login-form']?.loginAfter(alData)
220
+ })
162
221
  }
163
222
  }
164
223
  }
package/src/utils/auth.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import Cookies from 'js-cookie'
3
3
 
4
4
  const STORAGE = window.sessionStorage
5
+ let ownLoginPath = '/login'
5
6
 
6
7
  const auth = {
7
8
  stokenKey: 'token',
@@ -18,6 +19,7 @@ const auth = {
18
19
  return Cookies.get(this.cokenKey)
19
20
  },
20
21
  setToken(val) {
22
+ this.tokenVal = val
21
23
  Cookies.set(this.cokenKey, val, { expires: 1 })
22
24
  STORAGE.setItem(this.stokenKey, val)
23
25
  },
@@ -25,7 +27,7 @@ const auth = {
25
27
  this.tokenVal = ''
26
28
  Cookies.remove(this.cokenKey)
27
29
  STORAGE.removeItem(this.stokenKey)
28
- toLogin()
30
+ auth.toLogin()
29
31
  },
30
32
  setLoginPath(router) {
31
33
  let { base = '/', mode = 'history' } = router.options
@@ -36,21 +38,19 @@ const auth = {
36
38
  ownLoginPath = window.location.origin + base + 'login'
37
39
  }
38
40
  // 判断有没有token,没有直接跳到登录页
39
- auth.getToken() || toLogin()
41
+ auth.getToken() || auth.toLogin()
42
+ },
43
+ toLogin() {
44
+ let hrefOld = window.location.href
45
+ let loginHref = window.__POWERED_BY_QIANKUN__
46
+ ? window.location.origin + '/login'
47
+ : ownLoginPath
48
+ if (hrefOld !== loginHref) {
49
+ window.location.href = loginHref
50
+ }
40
51
  }
41
52
  }
42
- auth.cokenKey = 'Admin-Token'
43
53
 
44
- let ownLoginPath = '/login'
45
- function toLogin() {
46
- let hrefOld = window.location.href
47
- let loginHref = window.__POWERED_BY_QIANKUN__
48
- ? window.location.origin + '/login'
49
- : ownLoginPath
50
- if (hrefOld !== loginHref) {
51
- history.pushState(null, null, loginHref)
52
- window.location.reload()
53
- }
54
- }
54
+ auth.cokenKey = 'Admin-Token'
55
55
 
56
56
  export default auth