n20-common-lib 1.2.27 → 1.2.30

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.
Files changed (191) hide show
  1. package/README.md +2 -2
  2. package/package.json +88 -88
  3. package/src/_qiankun/index.js +113 -113
  4. package/src/_qiankun/postMessage.js +48 -48
  5. package/src/assets/css/_coreLib.scss +35 -35
  6. package/src/assets/css/cl-anchor.scss +23 -23
  7. package/src/assets/css/cl-approve-card.scss +58 -58
  8. package/src/assets/css/cl-dialog.scss +99 -99
  9. package/src/assets/css/cl-drag-list.scss +22 -22
  10. package/src/assets/css/cl-empty.scss +10 -10
  11. package/src/assets/css/cl-expandable-pane.scss +26 -26
  12. package/src/assets/css/cl-expandable.scss +24 -24
  13. package/src/assets/css/cl-file-upload-table.scss +11 -11
  14. package/src/assets/css/cl-filter.scss +4 -4
  15. package/src/assets/css/cl-flow-step.scss +185 -185
  16. package/src/assets/css/cl-footer-box.scss +10 -10
  17. package/src/assets/css/cl-form-item.scss +612 -612
  18. package/src/assets/css/cl-general-card.scss +11 -11
  19. package/src/assets/css/cl-layout-aside.scss +92 -92
  20. package/src/assets/css/cl-layout-content.scss +16 -16
  21. package/src/assets/css/cl-layout-header.scss +73 -73
  22. package/src/assets/css/cl-layout-tabs.scss +87 -87
  23. package/src/assets/css/cl-layout.scss +97 -97
  24. package/src/assets/css/cl-login-temporary.scss +37 -37
  25. package/src/assets/css/cl-message.scss +75 -75
  26. package/src/assets/css/cl-more-tab.scss +98 -98
  27. package/src/assets/css/cl-nav-menu.scss +5 -5
  28. package/src/assets/css/cl-pagination.scss +128 -128
  29. package/src/assets/css/cl-secondary-tab.scss +53 -53
  30. package/src/assets/css/cl-showcolumn.scss +23 -23
  31. package/src/assets/css/cl-sifting.scss +51 -51
  32. package/src/assets/css/cl-statis.scss +42 -42
  33. package/src/assets/css/cl-step.scss +73 -73
  34. package/src/assets/css/cl-suspend.scss +19 -19
  35. package/src/assets/css/cl-tertiary-tab.scss +54 -54
  36. package/src/assets/css/cl-upload.scss +41 -41
  37. package/src/assets/css/cl-worn-pagination.scss +50 -50
  38. package/src/assets/css/el-button.scss +173 -173
  39. package/src/assets/css/el-table.scss +79 -79
  40. package/src/assets/css/element-variables.scss +1061 -1061
  41. package/src/assets/css/element.dev.scss +21 -21
  42. package/src/assets/css/font-icon.scss +27 -27
  43. package/src/assets/css/index.dev.scss +4 -4
  44. package/src/assets/css/index.scss +11 -11
  45. package/src/assets/css/normalize.scss +726 -726
  46. package/src/assets/css/rootvar.scss +139 -139
  47. package/src/assets/css/select.scss +25 -25
  48. package/src/assets/css/title-pop.scss +4 -4
  49. package/src/assets/getJsonc.js +50 -50
  50. package/src/assets/realUrl.js +12 -12
  51. package/src/components/Anchor/AnchorItem.vue +29 -29
  52. package/src/components/Anchor/index.vue +185 -185
  53. package/src/components/ApprovalButtons/index.vue +233 -233
  54. package/src/components/ApprovalCard/index.vue +128 -128
  55. package/src/components/ApprovalRecord/approvalImg.vue +39 -39
  56. package/src/components/ApprovalRecord/index.vue +59 -59
  57. package/src/components/Button/button-group.vue +150 -150
  58. package/src/components/Button/icon-group-button.vue +61 -61
  59. package/src/components/Button/index.vue +56 -56
  60. package/src/components/CascaderArea/index.vue +103 -103
  61. package/src/components/ContentLoading/index.vue +41 -41
  62. package/src/components/ContentNull/index.vue +19 -19
  63. package/src/components/DatePicker/index.vue +27 -27
  64. package/src/components/DatePicker/por.vue +169 -169
  65. package/src/components/Dialog/index.vue +26 -26
  66. package/src/components/Dialog/indexO.vue +116 -116
  67. package/src/components/DragList/index.vue +75 -75
  68. package/src/components/Empty/img/abnormal.svg +108 -108
  69. package/src/components/Empty/img/dispose.svg +71 -71
  70. package/src/components/Empty/img/empty.svg +57 -57
  71. package/src/components/Empty/img/general.svg +58 -58
  72. package/src/components/Empty/img/lock.svg +57 -57
  73. package/src/components/Empty/img/network.svg +59 -59
  74. package/src/components/Empty/img/relevant.svg +68 -68
  75. package/src/components/Empty/img/search.svg +72 -72
  76. package/src/components/Empty/index.vue +92 -92
  77. package/src/components/Expandable/index.vue +49 -49
  78. package/src/components/Expandable/main.vue +52 -52
  79. package/src/components/FileExportAsync/index.vue +178 -178
  80. package/src/components/FileUploadTable/index.vue +484 -484
  81. package/src/components/Filters/index.vue +371 -371
  82. package/src/components/Filters/indexO.vue +104 -104
  83. package/src/components/FlowStep/index.vue +68 -68
  84. package/src/components/FooterBox/index.vue +21 -21
  85. package/src/components/GeneralCard/index.vue +15 -15
  86. package/src/components/InputNumber/index.vue +169 -169
  87. package/src/components/InputNumber/numberRange.vue +47 -47
  88. package/src/components/InputSearch/index.vue +75 -75
  89. package/src/components/Layout/AsideNav/index.vue +119 -119
  90. package/src/components/Layout/AsideNav/menuItem.vue +34 -34
  91. package/src/components/Layout/AsideNav/submenuTitle.vue +26 -26
  92. package/src/components/Layout/HeaderWrap/changePwd.vue +215 -215
  93. package/src/components/Layout/HeaderWrap/index.vue +373 -373
  94. package/src/components/Layout/HeaderWrap/noticePop.vue +300 -300
  95. package/src/components/Layout/SubContent/index.vue +131 -131
  96. package/src/components/Layout/TabsNav/index.vue +170 -170
  97. package/src/components/Layout/index.vue +529 -529
  98. package/src/components/Layout/utils.js +12 -12
  99. package/src/components/LoginTemporary/form.vue +561 -563
  100. package/src/components/LoginTemporary/index.vue +139 -146
  101. package/src/components/LoginTemporary/qrcode.vue +90 -90
  102. package/src/components/LoginTemporary/retrievePw.vue +372 -374
  103. package/src/components/LoginTemporary/utils.js +73 -73
  104. package/src/components/MicroApp/index.js +67 -67
  105. package/src/components/MicroFrame/index.vue +95 -95
  106. package/src/components/MoreTab/index.vue +232 -232
  107. package/src/components/NavMenu/index.vue +60 -60
  108. package/src/components/NstcG6Components/NstcDialog/NstcDialog.vue +184 -184
  109. package/src/components/PageLayout/page.vue +15 -15
  110. package/src/components/Pagination/index.vue +165 -165
  111. package/src/components/SecondaryTab/index.vue +58 -58
  112. package/src/components/SelectLazy/index.vue +75 -75
  113. package/src/components/SelectTree/SelectTreeLazy.vue +241 -241
  114. package/src/components/SelectTree/index.vue +205 -205
  115. package/src/components/ShowColumn/index.vue +213 -208
  116. package/src/components/Sifting/index.vue +99 -99
  117. package/src/components/Statis/index.vue +97 -97
  118. package/src/components/Statis/statisItem.vue +54 -54
  119. package/src/components/Statis/statisPopover.vue +55 -55
  120. package/src/components/Step/index.vue +38 -38
  121. package/src/components/Suspend/index.vue +72 -72
  122. package/src/components/Table/index.vue +209 -209
  123. package/src/components/Table/indexO.vue +149 -149
  124. package/src/components/Task/index.vue +26 -26
  125. package/src/components/TertiaryTab/index.vue +63 -63
  126. package/src/components/TimePicker/index.vue +28 -28
  127. package/src/components/Upload/index.vue +242 -242
  128. package/src/components/WornPagination/index.vue +73 -73
  129. package/src/directives/VClickOutside/index.js +19 -19
  130. package/src/directives/VHas/index.js +58 -58
  131. package/src/directives/VMove/index.js +42 -42
  132. package/src/directives/VTitle/index.js +69 -69
  133. package/src/directives/VTitle/tooltip.vue +21 -21
  134. package/src/index.js +229 -229
  135. package/src/plugins/CompatibleOld/index.js +57 -57
  136. package/src/plugins/Print/index.js +4 -4
  137. package/src/plugins/Print/print-js/.babelrc +12 -12
  138. package/src/plugins/Print/print-js/LICENSE +21 -21
  139. package/src/plugins/Print/print-js/README.md +98 -98
  140. package/src/plugins/Print/print-js/dist/print.css +96 -96
  141. package/src/plugins/Print/print-js/dist/print.js +990 -990
  142. package/src/plugins/Print/print-js/package.json +60 -60
  143. package/src/plugins/Print/print-js/src/index.d.ts +45 -45
  144. package/src/plugins/Print/print-js/src/index.js +10 -10
  145. package/src/plugins/Print/print-js/src/js/browser.js +33 -33
  146. package/src/plugins/Print/print-js/src/js/functions.js +103 -103
  147. package/src/plugins/Print/print-js/src/js/html.js +70 -70
  148. package/src/plugins/Print/print-js/src/js/image.js +48 -48
  149. package/src/plugins/Print/print-js/src/js/init.js +168 -168
  150. package/src/plugins/Print/print-js/src/js/json.js +109 -109
  151. package/src/plugins/Print/print-js/src/js/modal.js +62 -62
  152. package/src/plugins/Print/print-js/src/js/pdf.js +62 -62
  153. package/src/plugins/Print/print-js/src/js/print.js +102 -102
  154. package/src/plugins/Print/print-js/src/js/raw-html.js +15 -15
  155. package/src/plugins/Print/print-js/src/sass/index.scss +13 -13
  156. package/src/plugins/Print/print-js/src/sass/modules/_colors.scss +9 -9
  157. package/src/plugins/Print/print-js/src/sass/partials/_modal.scss +40 -40
  158. package/src/plugins/Print/print-js/src/sass/partials/_spinner.scss +45 -45
  159. package/src/plugins/Print/print.js +2 -2
  160. package/src/plugins/Print/print.scss +1 -1
  161. package/src/plugins/SetMenuTree/index.vue +41 -41
  162. package/src/plugins/SetMenuTree/logoIcon.vue +37 -37
  163. package/src/plugins/SetMenuTree/setmenutree.vue +427 -427
  164. package/src/plugins/SetMenuTree/utils.js +74 -74
  165. package/src/plugins/Sign/InfosecNetSignCNGAgent.min.js +2000 -2000
  166. package/src/plugins/Sign/index.js +65 -65
  167. package/src/plugins/Sign/sign.js +1 -1
  168. package/src/plugins/setTabsForSub.js +2 -2
  169. package/src/utils/auth.js +53 -53
  170. package/src/utils/axios.js +203 -203
  171. package/src/utils/downloadBlob.js +19 -19
  172. package/src/utils/forEachs.js +16 -16
  173. package/src/utils/getScrollContainer.js +43 -43
  174. package/src/utils/i18n/cn2hk.json +1270 -1270
  175. package/src/utils/i18n/index.js +50 -50
  176. package/src/utils/list2tree.js +36 -36
  177. package/src/utils/msgboxPor.js +26 -26
  178. package/src/utils/print.js +161 -161
  179. package/src/utils/relaNo.js +76 -76
  180. package/src/utils/repairElementUI.js +66 -66
  181. package/src/utils/urlToGo.js +82 -82
  182. package/style/css/normalize.scss +726 -726
  183. package/style/index.css +3 -3
  184. package/style/pageDemo/demo-1.vue +131 -131
  185. package/style/pageDemo/demo-2.vue +35 -35
  186. package/style/pageDemo/demo-3.vue +22 -22
  187. package/style/pageDemo/seeCode.js +20 -20
  188. package/style/server-config.jsonc +606 -606
  189. package/src/components/.DS_Store +0 -0
  190. package/src/components/Layout/.DS_Store +0 -0
  191. package/src/components/NstcG6Components/.DS_Store +0 -0
@@ -1,563 +1,561 @@
1
- <template>
2
- <!-- eslint-disable no-irregular-whitespace -->
3
- <div v-loading="loadingV" class="login-form-wrap p-a">
4
- <slot name="header"></slot>
5
- <svg class="cut-qrcode-h">
6
- <image
7
- v-if="theType === 'qrcode'"
8
- width="52"
9
- height="52"
10
- xlink:href="./qrt.png"
11
- />
12
- <image v-else width="52" height="52" xlink:href="./qr.png" />
13
- <path d="M0,0L52,0L52,52Z" @click="cutQrcode" />
14
- </svg>
15
- <!-- 账号/密码登录 -->
16
- <div v-if="theType === 'account'">
17
- <el-form
18
- ref="login-form"
19
- :model="form"
20
- :rules="rules"
21
- :hide-required-asterisk="true"
22
- @submit.native.prevent="submitLogin"
23
- >
24
- <el-form-item class="m-b" label="账号" prop="username">
25
- <el-input v-model="form.username" placeholder="请输入账号" />
26
- </el-form-item>
27
- <el-form-item class="m-b" label="密码" prop="password">
28
- <el-input
29
- v-model="form.password"
30
- placeholder="请输入密码"
31
- show-password
32
- />
33
- <!-- 不自动填充密码
34
- <input
35
- v-model="fakePwd"
36
- type="password"
37
- name="password"
38
- hidden="hidden"
39
- @change="fakePwd = 'a1b2c3d4'"
40
- />
41
- <el-input
42
- v-model="form.password"
43
- placeholder="请输入密码"
44
- :class="{ 'login-password': !showPwd }"
45
- >
46
- <i
47
- slot="suffix"
48
- class="el-input__icon el-icon-view"
49
- style="pointer-events: all"
50
- @click.stop="showPwd = !showPwd"
51
- ></i>
52
- </el-input>
53
- 不自动填充密码End -->
54
- </el-form-item>
55
- <el-button
56
- class="m-t"
57
- type="primary"
58
- native-type="submit"
59
- style="width: 100%"
60
- >登 录</el-button
61
- >
62
- </el-form>
63
- </div>
64
- <!-- 二维码扫码登录 -->
65
- <qrCode v-else-if="theType === 'qrcode'" @qrcode-login="QrcodeLogin" />
66
- <!-- 手机验证码登录 -->
67
- <div v-if="theType === 'pthon'">
68
- <el-form
69
- ref="login-form"
70
- :model="form"
71
- :rules="rules"
72
- :hide-required-asterisk="true"
73
- @submit.native.prevent="submitLogin"
74
- >
75
- <el-form-item class="m-b" label="手机号" prop="phone">
76
- <el-input v-model="form.phone" placeholder="请输入手机号" />
77
- </el-form-item>
78
- <el-form-item class="m-b" label="验证码" prop="code">
79
- <br />
80
- <div class="flex-box">
81
- <el-input
82
- v-model="form.code"
83
- class="flex-item m-r-s"
84
- placeholder="请输入验证码"
85
- />
86
- <el-button
87
- plain
88
- style="4em"
89
- :disabled="!form.phone || codeNum !== '验证码'"
90
- @click="sendMsg('phone', '手机号')"
91
- >{{ codeNum }}</el-button
92
- >
93
- </div>
94
- </el-form-item>
95
- <el-button
96
- class="m-t"
97
- type="primary"
98
- native-type="submit"
99
- style="width: 100%"
100
- >登 录</el-button
101
- >
102
- </el-form>
103
- </div>
104
- <!-- 账户密码验证码登录 -->
105
- <div v-if="theType === 'accountPthon'">
106
- <el-form
107
- ref="login-form"
108
- :model="form"
109
- :rules="rules"
110
- :hide-required-asterisk="true"
111
- @submit.native.prevent="submitLogin"
112
- >
113
- <el-form-item class="m-b" label="账号" prop="username">
114
- <el-input v-model="form.username" placeholder="请输入账号" />
115
- </el-form-item>
116
- <el-form-item class="m-b" label="密码" prop="password">
117
- <el-input
118
- v-model="form.password"
119
- placeholder="请输入密码"
120
- show-password
121
- />
122
- </el-form-item>
123
- <el-form-item class="m-b" label="验证码" prop="code">
124
- <br />
125
- <div class="flex-box">
126
- <el-input
127
- v-model="form.code"
128
- class="flex-item m-r-s"
129
- placeholder="请输入验证码"
130
- />
131
- <el-button
132
- plain
133
- style="4em"
134
- :disabled="!form.username || codeNum !== '验证码'"
135
- @click="sendMsg('username', '账户')"
136
- >{{ codeNum }}</el-button
137
- >
138
- </div>
139
- </el-form-item>
140
- <el-button
141
- class="m-t"
142
- type="primary"
143
- native-type="submit"
144
- style="width: 100%"
145
- >登 录</el-button
146
- >
147
- </el-form>
148
- </div>
149
- <!-- -->
150
- <div v-if="theType !== 'qrcode'" class="flex-box flex-lr m-t-s m-b-s">
151
- <el-dropdown
152
- size="mini"
153
- placement="bottom-start"
154
- @command="changeLoginType"
155
- >
156
- <span>其他登录方式</span>
157
- <el-dropdown-menu slot="dropdown">
158
- <template v-for="item in loginTypes">
159
- <el-dropdown-item
160
- v-if="item !== theType"
161
- :key="item"
162
- :command="item"
163
- >{{ loginTypeMap[item] }}</el-dropdown-item
164
- >
165
- </template>
166
- </el-dropdown-menu>
167
- </el-dropdown>
168
-
169
- <el-link :underline="false" @click="forgetPw">忘记密码</el-link>
170
- </div>
171
- <slot name="footer"></slot>
172
- </div>
173
- </template>
174
-
175
- <script>
176
- import decode from 'jsonwebtoken/decode'
177
- import axios from '../../utils/axios'
178
- import auth from '../../utils/auth'
179
- import qrCode from './qrcode.vue'
180
- import { siteTree2menus, siteTree2RelaNos } from './utils'
181
- import retrievePw from './retrievePw.vue'
182
-
183
- function encode(pwd = '', key = 0) {
184
- if (pwd === '') return ''
185
-
186
- let pwdArr = pwd.trim().split('')
187
- let resultArr = pwdArr.map((oPwd) =>
188
- String.fromCharCode(oPwd.charCodeAt() ^ key)
189
- )
190
- let result = resultArr.join('')
191
-
192
- return window.btoa(window.unescape(window.encodeURIComponent(result)))
193
- }
194
-
195
- export default {
196
- name: 'LoginForm',
197
- components: {
198
- qrCode,
199
- retrievePw
200
- },
201
- props: {
202
- loginTypes: {
203
- type: Array,
204
- default: () => ['account']
205
- },
206
- loginThen: {
207
- type: Function,
208
- default: undefined
209
- }
210
- },
211
- data() {
212
- return {
213
- showPwd: false,
214
- fakePwd: 'a1b2c3d4',
215
- loadingV: false,
216
- loginTypeMap: {
217
- account: '账号密码登录',
218
- pthon: '手机验证码登录',
219
- qrcode: '二维码扫码登录',
220
- accountPthon: '账户密码验证码登录'
221
- },
222
- theType: this.loginTypes[0],
223
- userNo: undefined,
224
- form: {
225
- username: '',
226
- password: '',
227
- code: ''
228
- },
229
- pwd: '',
230
- rules: {
231
- username: [{ required: true, message: '请输入账号!', trigger: 'blur' }],
232
- password: [{ required: true, message: '请输入密码!', trigger: 'blur' }],
233
- code: [{ required: true, message: '请输入验证码!', trigger: 'blur' }],
234
- phone: [
235
- { required: true, message: '请输入手机号!', trigger: 'blur' },
236
- {
237
- pattern: /^1\d{10}$/,
238
- message: '请输入正确手机号!',
239
- trigger: 'blur'
240
- }
241
- ]
242
- },
243
- fPwV: false,
244
- codeNum: '验证码',
245
- getAzCount: 0
246
- }
247
- },
248
- methods: {
249
- // 忘记密码
250
- forgetPw() {
251
- this.$emit('changType', false)
252
- },
253
- // 切换登录方式
254
- changeLoginType(val) {
255
- this.theType = val
256
- },
257
- // 切换二维码小图标
258
- cutQrcode() {
259
- if (this.theType !== 'qrcode') {
260
- this.theType = 'qrcode'
261
- } else {
262
- this.theType = this.loginTypes[0]
263
- }
264
- },
265
- // 发送短信
266
- outTime(num) {
267
- clearTimeout(this.setTimeNum)
268
- if (num > 0) {
269
- num--
270
- this.codeNum = num + 'S'
271
-
272
- this.setTimeNum = setTimeout(() => {
273
- this.outTime(num)
274
- }, 1000)
275
- num--
276
- } else {
277
- clearTimeout(this.setTimeNum)
278
- this.codeNum = '验证码'
279
- }
280
- },
281
- sendMsg(type = 'phone', typeName = '手机号') {
282
- this.$refs['login-form'].validateField(type, (valid) => {
283
- if (!valid) {
284
- this.outTime(60)
285
-
286
- axios
287
- .get(
288
- `/bems/prod_1.0/uas/api/authorization/captcha/${this.form[type]}/1`,
289
- null,
290
- { loading: false, noMsg: true }
291
- )
292
- .then(() => {
293
- this.$message.success(
294
- `${typeName}: ${this.form[type]} 验证码发送成功`
295
- )
296
- })
297
- .catch(() => {
298
- clearTimeout(this.setTimeNum)
299
- this.codeNum = '验证码'
300
- this.$message.warning(
301
- `${typeName}: ${this.form[type]} 验证码发送失败`
302
- )
303
- })
304
- }
305
- })
306
- },
307
- loadingFn() {
308
- this.loadingV = false
309
- },
310
- // 登录
311
- submitLogin() {
312
- this.$refs['login-form'].validate((valid) => {
313
- if (!valid) return false
314
-
315
- auth.removeToken()
316
- this.theType === 'account' && this.passwordLogin().catch(this.loadingFn)
317
- this.theType === 'pthon' && this.phoneLogin().catch(this.loadingFn)
318
- this.theType === 'accountPthon' &&
319
- this.accountPthonLogin().catch(this.loadingFn)
320
- })
321
- },
322
- // 获取加密参数
323
- authorizationCode(username, password, code) {
324
- this.getAzCount = this.getAzCount + 1
325
-
326
- let pwdArr = code ? [username, password, code] : [username, password]
327
- let pwd = pwdArr.join('@@')
328
-
329
- return new Promise((resolve, reject) => {
330
- if (this.getAzCount <= 3) {
331
- axios
332
- .get(
333
- '/bems/prod_1.0/uas/api/authorization/authorizationCode',
334
- {},
335
- { loading: false }
336
- )
337
- .then(({ data = {} }) => {
338
- try {
339
- pwd = encode(pwd, data.authorizationValue)
340
- this.pwd = pwd + '@@' + data.authorizationKey
341
-
342
- this.getAzCount = 0
343
- resolve()
344
- } catch (error) {
345
- console.error('密码加密错误:' + JSON.stringify(data))
346
- this.authorizationCode(username, password, code) // 再次请求
347
- .then(resolve)
348
- .catch(reject)
349
- }
350
- })
351
- } else {
352
- // 当重新请求大于3次,抛出错误
353
- this.$message.warning(`登录失败,请重新登录!`)
354
- this.getAzCount = 0
355
- reject()
356
- }
357
- })
358
- },
359
- // 账号/密码登录
360
- async passwordLogin() {
361
- this.loadingV = true
362
-
363
- let { username, password, code } = this.form
364
- await this.authorizationCode(username, password, code)
365
- // 请求该账号要不要强制验证码登录
366
- let cL = await axios.post(
367
- '/bems/prod_1.0/uas/api/authorization/checkLogin',
368
- { grantType: 'password', username, password: this.pwd, code },
369
- {
370
- loading: false
371
- }
372
- )
373
-
374
- // 输入验证码
375
- if (cL.data === true) {
376
- this.loadingV = false
377
- this.theType = 'accountPthon'
378
-
379
- this.sendMsg('username', '账户')
380
- this.outTime(60)
381
- return
382
- }
383
- // 签名验签
384
- else if (cL.data === false) {
385
- // 获取线上签名uDn
386
- let uDn = await axios.get(
387
- `/bems/prod_1.0/dssc/sign/getUserDn/${username}/password`,
388
- null,
389
- { loading: false }
390
- )
391
- let { checkCert, userDn } = uDn.data
392
- // 走本地签名
393
- let sign = undefined
394
- let certDn = undefined
395
- if (checkCert) {
396
- let { getSign } = await import('../../plugins/Sign/index')
397
- sign = getSign(username, userDn)
398
- certDn = userDn
399
- }
400
-
401
- await this.authorizationCode(username, password, code) // authorizationValue 使用一次后就失效了
402
- axios
403
- .post(
404
- '/bems/prod_1.0/uas/api/authorization/login',
405
- {
406
- grantType: 'password',
407
- username,
408
- password: this.pwd,
409
- code,
410
- sign,
411
- certDn
412
- },
413
- {
414
- loading: this.loadingFn
415
- }
416
- )
417
- .then((res) => {
418
- this.loginAfter(res.data)
419
- })
420
- return
421
- }
422
-
423
- // 正常登录
424
- await this.authorizationCode(username, password, code) // authorizationValue 使用一次后就失效了
425
- axios
426
- .post(
427
- '/bems/prod_1.0/uas/api/authorization/login',
428
- { grantType: 'password', username, password: this.pwd, code },
429
- { loading: this.loadingFn }
430
- )
431
- .then((res) => {
432
- this.loginAfter(res.data)
433
- })
434
- },
435
- // 二维码扫码登录
436
- QrcodeLogin(userNo, qrcode) {
437
- axios
438
- .post(
439
- '/bems/prod_1.0/uas/api/authorization/login',
440
- {
441
- grantType: 'qr_code',
442
- type: 'qr_code',
443
- username: userNo,
444
- password: qrcode
445
- },
446
- { loading: false }
447
- )
448
- .then((res) => {
449
- this.loginAfter(res.data)
450
- })
451
- },
452
- // 手机号/验证码登录
453
- async phoneLogin() {
454
- this.loadingV = true
455
- let { phone, code } = this.form
456
- await this.authorizationCode(phone, code)
457
- let pwd = this.pwd
458
-
459
- axios
460
- .post(
461
- '/bems/prod_1.0/uas/api/authorization/login',
462
- { grantType: 'mobile', username: phone, password: pwd },
463
- { loading: this.loadingFn }
464
- )
465
- .then((res) => {
466
- this.loginAfter(res.data)
467
- })
468
- },
469
- async accountPthonLogin() {
470
- this.loadingV = true
471
- let { username, password, code } = this.form
472
- await this.authorizationCode(username, password, code)
473
- let pwd = this.pwd
474
-
475
- axios
476
- .post(
477
- '/bems/prod_1.0/uas/api/authorization/login',
478
- { grantType: 'user_password_code', username, password: pwd, code },
479
- { loading: this.loadingFn }
480
- )
481
- .then((res) => {
482
- this.loginAfter(res.data)
483
- })
484
- },
485
- // 登录成功后
486
- loginAfter(data) {
487
- auth.setToken(data.accessToken)
488
- try {
489
- let tokenObj = decode(data.accessToken)
490
- let userInfo = JSON.parse(tokenObj.user_name)
491
- this.userNo = userInfo.userNo
492
- } catch (error) {
493
- console.error('accessToken解析错误:' + data.accessToken)
494
- }
495
-
496
- Promise.all([
497
- this.getUserInfo(),
498
- this.getMicroAppsInfo(),
499
- this.getCltRelaNos()
500
- ]).then(() => {
501
- if (this.loginThen) {
502
- this.loginThen().then(() => {
503
- this.$router.replace('/')
504
- })
505
- } else {
506
- this.$router.replace('/')
507
- }
508
- })
509
- },
510
- // 获取用户基本信息
511
- async getUserInfo() {
512
- let username = this.userNo
513
- let { data } = await axios.get(
514
- // '/bems/prod_1.0/user/api/userController/userCltAdDep/' + username
515
- '/bems/prod_1.0/user/api/userController/userCltAdRole/' + username
516
- )
517
- let userInfo = data || { uname: username }
518
-
519
- sessionStorage.setItem('userNo', username)
520
- sessionStorage.setItem('userInfo', JSON.stringify(userInfo))
521
- sessionStorage.setItem('loginTime', Date.now())
522
- },
523
- // 获取子应用相关列表
524
- async getMicroAppsInfo() {
525
- this.loadingV = true
526
- let { data } = await axios.get('/bems/1.0/menuTree/tree', null, {
527
- loading: this.loadingFn
528
- })
529
- data || (data = [])
530
-
531
- let layoutMenus = siteTree2menus(data)
532
- sessionStorage.setItem('menuTree', JSON.stringify(layoutMenus))
533
-
534
- let relaNos = siteTree2RelaNos(data)
535
- sessionStorage.setItem('relaNos', JSON.stringify(relaNos))
536
-
537
- // XXX: 兼容旧版resources
538
- sessionStorage.setItem('resources', JSON.stringify(data))
539
- },
540
- // 新增不同单位对应不同角色,具有不同权限
541
- getCltRelaNos() {
542
- let pro = new Promise((resolve) => {
543
- axios
544
- .post(
545
- '/bems/prod_1.0/user/api/userController/qryBusyInfoNo',
546
- { uno: this.userNo },
547
- { loading: false, noMsg: true }
548
- )
549
- .then(({ data: cltrelaMap = [] }) => {
550
- let cltrelaNos = {}
551
- cltrelaMap.forEach((item) => {
552
- cltrelaNos[item.cltNo] = item.relaNos
553
- })
554
- sessionStorage.setItem('cltrelaNos', JSON.stringify(cltrelaNos))
555
- })
556
- .finally(resolve)
557
- })
558
-
559
- return pro
560
- }
561
- }
562
- }
563
- </script>
1
+ <template>
2
+ <!-- eslint-disable no-irregular-whitespace -->
3
+ <div v-loading="loadingV" class="login-form-wrap flex-column p-a">
4
+ <slot name="header"></slot>
5
+ <svg class="cut-qrcode-h">
6
+ <image
7
+ v-if="theType === 'qrcode'"
8
+ width="52"
9
+ height="52"
10
+ xlink:href="./qrt.png"
11
+ />
12
+ <image v-else width="52" height="52" xlink:href="./qr.png" />
13
+ <path d="M0,0L52,0L52,52Z" @click="cutQrcode" />
14
+ </svg>
15
+ <!-- 账号/密码登录 -->
16
+ <div v-if="theType === 'account'" class="flex-item">
17
+ <el-form
18
+ ref="login-form"
19
+ :model="form"
20
+ :rules="rules"
21
+ :hide-required-asterisk="true"
22
+ @submit.native.prevent="submitLogin"
23
+ >
24
+ <el-form-item class="m-b" label="账号" prop="username">
25
+ <el-input v-model="form.username" placeholder="请输入账号" />
26
+ </el-form-item>
27
+ <el-form-item class="m-b" label="密码" prop="password">
28
+ <el-input
29
+ v-model="form.password"
30
+ placeholder="请输入密码"
31
+ show-password
32
+ />
33
+ <!-- 不自动填充密码
34
+ <input
35
+ v-model="fakePwd"
36
+ type="password"
37
+ name="password"
38
+ hidden="hidden"
39
+ @change="fakePwd = 'a1b2c3d4'"
40
+ />
41
+ <el-input
42
+ v-model="form.password"
43
+ placeholder="请输入密码"
44
+ :class="{ 'login-password': !showPwd }"
45
+ >
46
+ <i
47
+ slot="suffix"
48
+ class="el-input__icon el-icon-view"
49
+ style="pointer-events: all"
50
+ @click.stop="showPwd = !showPwd"
51
+ ></i>
52
+ </el-input>
53
+ 不自动填充密码End -->
54
+ </el-form-item>
55
+ <el-button
56
+ class="m-t"
57
+ type="primary"
58
+ native-type="submit"
59
+ style="width: 100%"
60
+ >登 录</el-button
61
+ >
62
+ </el-form>
63
+ </div>
64
+ <!-- 二维码扫码登录 -->
65
+ <qrCode v-else-if="theType === 'qrcode'" @qrcode-login="QrcodeLogin" />
66
+ <!-- 手机验证码登录 -->
67
+ <div v-if="theType === 'pthon'" class="flex-item">
68
+ <el-form
69
+ ref="login-form"
70
+ :model="form"
71
+ :rules="rules"
72
+ :hide-required-asterisk="true"
73
+ @submit.native.prevent="submitLogin"
74
+ >
75
+ <el-form-item class="m-b" label="手机号" prop="phone">
76
+ <el-input v-model="form.phone" placeholder="请输入手机号" />
77
+ </el-form-item>
78
+ <el-form-item class="m-b" label="验证码" prop="code">
79
+ <br />
80
+ <div class="flex-box">
81
+ <el-input
82
+ v-model="form.code"
83
+ class="flex-item m-r-s"
84
+ placeholder="请输入验证码"
85
+ />
86
+ <el-button
87
+ plain
88
+ style="4em"
89
+ :disabled="!form.phone || codeNum !== '验证码'"
90
+ @click="sendMsg('phone', '手机号')"
91
+ >{{ codeNum }}</el-button
92
+ >
93
+ </div>
94
+ </el-form-item>
95
+ <el-button
96
+ class="m-t"
97
+ type="primary"
98
+ native-type="submit"
99
+ style="width: 100%"
100
+ >登 录</el-button
101
+ >
102
+ </el-form>
103
+ </div>
104
+ <!-- 账户密码验证码登录 -->
105
+ <div v-if="theType === 'accountPthon'" class="flex-item">
106
+ <el-form
107
+ ref="login-form"
108
+ :model="form"
109
+ :rules="rules"
110
+ :hide-required-asterisk="true"
111
+ @submit.native.prevent="submitLogin"
112
+ >
113
+ <el-form-item class="m-b" label="账号" prop="username">
114
+ <el-input v-model="form.username" placeholder="请输入账号" />
115
+ </el-form-item>
116
+ <el-form-item class="m-b" label="密码" prop="password">
117
+ <el-input
118
+ v-model="form.password"
119
+ placeholder="请输入密码"
120
+ show-password
121
+ />
122
+ </el-form-item>
123
+ <el-form-item class="m-b" label="验证码" prop="code">
124
+ <br />
125
+ <div class="flex-box">
126
+ <el-input
127
+ v-model="form.code"
128
+ class="flex-item m-r-s"
129
+ placeholder="请输入验证码"
130
+ />
131
+ <el-button
132
+ plain
133
+ style="4em"
134
+ :disabled="!form.username || codeNum !== '验证码'"
135
+ @click="sendMsg('username', '账户')"
136
+ >{{ codeNum }}</el-button
137
+ >
138
+ </div>
139
+ </el-form-item>
140
+ <el-button
141
+ class="m-t"
142
+ type="primary"
143
+ native-type="submit"
144
+ style="width: 100%"
145
+ >登 录</el-button
146
+ >
147
+ </el-form>
148
+ </div>
149
+ <!-- -->
150
+ <div v-if="theType !== 'qrcode'" class="flex-box flex-lr m-t-s m-b-s">
151
+ <el-dropdown
152
+ size="mini"
153
+ placement="bottom-start"
154
+ @command="changeLoginType"
155
+ >
156
+ <span>其他登录方式</span>
157
+ <el-dropdown-menu slot="dropdown">
158
+ <template v-for="item in loginTypes">
159
+ <el-dropdown-item
160
+ v-if="item !== theType"
161
+ :key="item"
162
+ :command="item"
163
+ >{{ loginTypeMap[item] }}</el-dropdown-item
164
+ >
165
+ </template>
166
+ </el-dropdown-menu>
167
+ </el-dropdown>
168
+
169
+ <el-link :underline="false" @click="forgetPw">忘记密码</el-link>
170
+ </div>
171
+ <slot name="footer"></slot>
172
+ </div>
173
+ </template>
174
+
175
+ <script>
176
+ import decode from 'jsonwebtoken/decode'
177
+ import axios from '../../utils/axios'
178
+ import auth from '../../utils/auth'
179
+ import qrCode from './qrcode.vue'
180
+ import { siteTree2menus, siteTree2RelaNos } from './utils'
181
+
182
+ function encode(pwd = '', key = 0) {
183
+ if (pwd === '') return ''
184
+
185
+ let pwdArr = pwd.trim().split('')
186
+ let resultArr = pwdArr.map((oPwd) =>
187
+ String.fromCharCode(oPwd.charCodeAt() ^ key)
188
+ )
189
+ let result = resultArr.join('')
190
+
191
+ return window.btoa(window.unescape(window.encodeURIComponent(result)))
192
+ }
193
+
194
+ export default {
195
+ name: 'LoginForm',
196
+ components: {
197
+ qrCode
198
+ },
199
+ props: {
200
+ loginTypes: {
201
+ type: Array,
202
+ default: () => ['account']
203
+ },
204
+ loginThen: {
205
+ type: Function,
206
+ default: undefined
207
+ }
208
+ },
209
+ data() {
210
+ return {
211
+ showPwd: false,
212
+ fakePwd: 'a1b2c3d4',
213
+ loadingV: false,
214
+ loginTypeMap: {
215
+ account: '账号密码登录',
216
+ pthon: '手机验证码登录',
217
+ qrcode: '二维码扫码登录',
218
+ accountPthon: '账户密码验证码登录'
219
+ },
220
+ theType: this.loginTypes[0],
221
+ userNo: undefined,
222
+ form: {
223
+ username: '',
224
+ password: '',
225
+ code: ''
226
+ },
227
+ pwd: '',
228
+ rules: {
229
+ username: [{ required: true, message: '请输入账号!', trigger: 'blur' }],
230
+ password: [{ required: true, message: '请输入密码!', trigger: 'blur' }],
231
+ code: [{ required: true, message: '请输入验证码!', trigger: 'blur' }],
232
+ phone: [
233
+ { required: true, message: '请输入手机号!', trigger: 'blur' },
234
+ {
235
+ pattern: /^1\d{10}$/,
236
+ message: '请输入正确手机号!',
237
+ trigger: 'blur'
238
+ }
239
+ ]
240
+ },
241
+ codeNum: '验证码',
242
+ getAzCount: 0
243
+ }
244
+ },
245
+ methods: {
246
+ // 忘记密码
247
+ forgetPw() {
248
+ this.$emit('changType', 'retrievePw')
249
+ },
250
+ // 切换登录方式
251
+ changeLoginType(val) {
252
+ this.theType = val
253
+ },
254
+ // 切换二维码小图标
255
+ cutQrcode() {
256
+ if (this.theType !== 'qrcode') {
257
+ this.theType = 'qrcode'
258
+ } else {
259
+ this.theType = this.loginTypes[0]
260
+ }
261
+ },
262
+ // 发送短信
263
+ outTime(num) {
264
+ clearTimeout(this.setTimeNum)
265
+ if (num > 0) {
266
+ num--
267
+ this.codeNum = num + 'S'
268
+
269
+ this.setTimeNum = setTimeout(() => {
270
+ this.outTime(num)
271
+ }, 1000)
272
+ num--
273
+ } else {
274
+ clearTimeout(this.setTimeNum)
275
+ this.codeNum = '验证码'
276
+ }
277
+ },
278
+ sendMsg(type = 'phone', typeName = '手机号') {
279
+ this.$refs['login-form'].validateField(type, (valid) => {
280
+ if (!valid) {
281
+ this.outTime(60)
282
+
283
+ axios
284
+ .get(
285
+ `/bems/prod_1.0/uas/api/authorization/captcha/${this.form[type]}/1`,
286
+ null,
287
+ { loading: false, noMsg: true }
288
+ )
289
+ .then(() => {
290
+ this.$message.success(
291
+ `${typeName}: ${this.form[type]} 验证码发送成功`
292
+ )
293
+ })
294
+ .catch(() => {
295
+ clearTimeout(this.setTimeNum)
296
+ this.codeNum = '验证码'
297
+ this.$message.warning(
298
+ `${typeName}: ${this.form[type]} 验证码发送失败`
299
+ )
300
+ })
301
+ }
302
+ })
303
+ },
304
+ loadingFn() {
305
+ this.loadingV = false
306
+ },
307
+ // 登录
308
+ submitLogin() {
309
+ this.$refs['login-form'].validate((valid) => {
310
+ if (!valid) return false
311
+
312
+ auth.removeToken()
313
+ this.theType === 'account' && this.passwordLogin().catch(this.loadingFn)
314
+ this.theType === 'pthon' && this.phoneLogin().catch(this.loadingFn)
315
+ this.theType === 'accountPthon' &&
316
+ this.accountPthonLogin().catch(this.loadingFn)
317
+ })
318
+ },
319
+ // 获取加密参数
320
+ authorizationCode(username, password, code) {
321
+ this.getAzCount = this.getAzCount + 1
322
+
323
+ let pwdArr = code ? [username, password, code] : [username, password]
324
+ let pwd = pwdArr.join('@@')
325
+
326
+ return new Promise((resolve, reject) => {
327
+ if (this.getAzCount <= 3) {
328
+ axios
329
+ .get(
330
+ '/bems/prod_1.0/uas/api/authorization/authorizationCode',
331
+ {},
332
+ { loading: false }
333
+ )
334
+ .then(({ data = {} }) => {
335
+ try {
336
+ pwd = encode(pwd, data.authorizationValue)
337
+ this.pwd = pwd + '@@' + data.authorizationKey
338
+
339
+ this.getAzCount = 0
340
+ resolve()
341
+ } catch (error) {
342
+ console.error('密码加密错误:' + JSON.stringify(data))
343
+ this.authorizationCode(username, password, code) // 再次请求
344
+ .then(resolve)
345
+ .catch(reject)
346
+ }
347
+ })
348
+ } else {
349
+ // 当重新请求大于3次,抛出错误
350
+ this.$message.warning(`登录失败,请重新登录!`)
351
+ this.getAzCount = 0
352
+ reject()
353
+ }
354
+ })
355
+ },
356
+ // 账号/密码登录
357
+ async passwordLogin() {
358
+ this.loadingV = true
359
+
360
+ let { username, password, code } = this.form
361
+ await this.authorizationCode(username, password, code)
362
+ // 请求该账号要不要强制验证码登录
363
+ let cL = await axios.post(
364
+ '/bems/prod_1.0/uas/api/authorization/checkLogin',
365
+ { grantType: 'password', username, password: this.pwd, code },
366
+ {
367
+ loading: false
368
+ }
369
+ )
370
+
371
+ // 输入验证码
372
+ if (cL.data === true) {
373
+ this.loadingV = false
374
+ this.theType = 'accountPthon'
375
+
376
+ this.sendMsg('username', '账户')
377
+ this.outTime(60)
378
+ return
379
+ }
380
+ // 签名验签
381
+ else if (cL.data === false) {
382
+ // 获取线上签名uDn
383
+ let uDn = await axios.get(
384
+ `/bems/prod_1.0/dssc/sign/getUserDn/${username}/password`,
385
+ null,
386
+ { loading: false }
387
+ )
388
+ let { checkCert, userDn } = uDn.data
389
+ // 走本地签名
390
+ let sign = undefined
391
+ let certDn = undefined
392
+ if (checkCert) {
393
+ let { getSign } = await import('../../plugins/Sign/index')
394
+ sign = getSign(username, userDn)
395
+ certDn = userDn
396
+ }
397
+
398
+ await this.authorizationCode(username, password, code) // authorizationValue 使用一次后就失效了
399
+ axios
400
+ .post(
401
+ '/bems/prod_1.0/uas/api/authorization/login',
402
+ {
403
+ grantType: 'password',
404
+ username,
405
+ password: this.pwd,
406
+ code,
407
+ sign,
408
+ certDn
409
+ },
410
+ {
411
+ loading: this.loadingFn
412
+ }
413
+ )
414
+ .then((res) => {
415
+ this.loginAfter(res.data)
416
+ })
417
+ return
418
+ }
419
+
420
+ // 正常登录
421
+ await this.authorizationCode(username, password, code) // authorizationValue 使用一次后就失效了
422
+ axios
423
+ .post(
424
+ '/bems/prod_1.0/uas/api/authorization/login',
425
+ { grantType: 'password', username, password: this.pwd, code },
426
+ { loading: this.loadingFn }
427
+ )
428
+ .then((res) => {
429
+ this.loginAfter(res.data)
430
+ })
431
+ },
432
+ // 二维码扫码登录
433
+ QrcodeLogin(userNo, qrcode) {
434
+ axios
435
+ .post(
436
+ '/bems/prod_1.0/uas/api/authorization/login',
437
+ {
438
+ grantType: 'qr_code',
439
+ type: 'qr_code',
440
+ username: userNo,
441
+ password: qrcode
442
+ },
443
+ { loading: false }
444
+ )
445
+ .then((res) => {
446
+ this.loginAfter(res.data)
447
+ })
448
+ },
449
+ // 手机号/验证码登录
450
+ async phoneLogin() {
451
+ this.loadingV = true
452
+ let { phone, code } = this.form
453
+ await this.authorizationCode(phone, code)
454
+ let pwd = this.pwd
455
+
456
+ axios
457
+ .post(
458
+ '/bems/prod_1.0/uas/api/authorization/login',
459
+ { grantType: 'mobile', username: phone, password: pwd },
460
+ { loading: this.loadingFn }
461
+ )
462
+ .then((res) => {
463
+ this.loginAfter(res.data)
464
+ })
465
+ },
466
+ async accountPthonLogin() {
467
+ this.loadingV = true
468
+ let { username, password, code } = this.form
469
+ await this.authorizationCode(username, password, code)
470
+ let pwd = this.pwd
471
+
472
+ axios
473
+ .post(
474
+ '/bems/prod_1.0/uas/api/authorization/login',
475
+ { grantType: 'user_password_code', username, password: pwd, code },
476
+ { loading: this.loadingFn }
477
+ )
478
+ .then((res) => {
479
+ this.loginAfter(res.data)
480
+ })
481
+ },
482
+ // 登录成功后
483
+ loginAfter(data) {
484
+ auth.setToken(data.accessToken)
485
+ try {
486
+ let tokenObj = decode(data.accessToken)
487
+ let userInfo = JSON.parse(tokenObj.user_name)
488
+ this.userNo = userInfo.userNo
489
+ sessionStorage.setItem('User_Info', tokenObj.user_name)
490
+ } catch (error) {
491
+ console.error('accessToken解析错误:' + data.accessToken)
492
+ }
493
+
494
+ Promise.all([
495
+ this.getUserInfo(),
496
+ this.getMicroAppsInfo(),
497
+ this.getCltRelaNos()
498
+ ]).then(() => {
499
+ if (this.loginThen) {
500
+ this.loginThen().then(() => {
501
+ this.$router.replace('/')
502
+ })
503
+ } else {
504
+ this.$router.replace('/')
505
+ }
506
+ })
507
+ },
508
+ // 获取用户基本信息
509
+ async getUserInfo() {
510
+ let username = this.userNo
511
+ let { data } = await axios.get(
512
+ // '/bems/prod_1.0/user/api/userController/userCltAdDep/' + username
513
+ '/bems/prod_1.0/user/api/userController/userCltAdRole/' + username
514
+ )
515
+ let userInfo = data || { uname: username }
516
+
517
+ sessionStorage.setItem('userNo', username)
518
+ sessionStorage.setItem('userInfo', JSON.stringify(userInfo))
519
+ sessionStorage.setItem('loginTime', Date.now())
520
+ },
521
+ // 获取子应用相关列表
522
+ async getMicroAppsInfo() {
523
+ this.loadingV = true
524
+ let { data } = await axios.get('/bems/1.0/menuTree/tree', null, {
525
+ loading: this.loadingFn
526
+ })
527
+ data || (data = [])
528
+
529
+ let layoutMenus = siteTree2menus(data)
530
+ sessionStorage.setItem('menuTree', JSON.stringify(layoutMenus))
531
+
532
+ let relaNos = siteTree2RelaNos(data)
533
+ sessionStorage.setItem('relaNos', JSON.stringify(relaNos))
534
+
535
+ // XXX: 兼容旧版resources
536
+ sessionStorage.setItem('resources', JSON.stringify(data))
537
+ },
538
+ // 新增不同单位对应不同角色,具有不同权限
539
+ getCltRelaNos() {
540
+ let pro = new Promise((resolve) => {
541
+ axios
542
+ .post(
543
+ '/bems/prod_1.0/user/api/userController/qryBusyInfoNo',
544
+ { uno: this.userNo },
545
+ { loading: false, noMsg: true }
546
+ )
547
+ .then(({ data: cltrelaMap = [] }) => {
548
+ let cltrelaNos = {}
549
+ cltrelaMap.forEach((item) => {
550
+ cltrelaNos[item.cltNo] = item.relaNos
551
+ })
552
+ sessionStorage.setItem('cltrelaNos', JSON.stringify(cltrelaNos))
553
+ })
554
+ .finally(resolve)
555
+ })
556
+
557
+ return pro
558
+ }
559
+ }
560
+ }
561
+ </script>