n20-common-lib 1.2.8 → 1.2.9

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