肖超群
authored
10 months ago
1
2
3
4
5
6
7
<template>
<div id="userLayout" :class="['user-layout-wrapper']">
<div class="left-div">
<div id="logo">
<div id="logoImg">
<img src="~@/assets/logo.png" alt="" srcset="" class="imge">
</div>
谭毅彬
authored
9 months ago
8
<div id="text">华恒WMS仓储管理系统</div>
肖超群
authored
10 months ago
9
10
</div>
<div id="backgroundImg">
谭毅彬
authored
9 months ago
11
<img src="~@/assets/beijingtu.jpg" alt="" srcset="" class="imge"/>
肖超群
authored
10 months ago
12
13
</div>
<div id="copyright">
谭毅彬
authored
9 months ago
14
<div id="company">Copyright © 2024 华恒焊接股份有限公司</div>
肖超群
authored
10 months ago
15
16
17
</div>
</div>
<div class="right-div">
谭毅彬
authored
9 months ago
18
<a-form-model ref="form" :model="model" :rules="validatorRules">
谭毅彬
authored
7 months ago
19
<div id="welcome">欢迎来到华恒仓储管理系统 !</div>
谭毅彬
authored
9 months ago
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<a-form-model-item required prop="username">
<a-input id="name" v-model="model.username" size="default" autocomplete="off" placeholder="请输入帐户名 / admin" @blur="getWarehouse">
</a-input>
</a-form-model-item>
<a-form-model-item required prop="password">
<a-input id="password" v-model="model.password" size="default" type="password" autocomplete="new-password" @input="maskPassword" placeholder="请输入密码">
</a-input>
</a-form-model-item>
<a-form-model-item prop="warehouseCode">
<a-select
show-search
placeholder="请选择仓库"
option-filter-prop="label"
v-model="model.warehouseCode" id="warehouseCode">
<a-select-option v-for="item in warehouseList" :key="item.name" :value="item.code">{{
item.name
}}
</a-select-option>
</a-select>
</a-form-model-item>
<a-form-item>
<a-button id="logIn" size="default" type="primary" htmlType="submit" class="login-button"
:loading="loginBtn" @click.stop.prevent="handleSubmit" :disabled="loginBtn">登 录</a-button>
</a-form-item>
</a-form-model>
</div>
肖超群
authored
10 months ago
46
47
48
49
50
51
52
<two-step-captcha v-if="requiredTwoStepCaptcha" :visible="stepCaptchaVisible" @success="stepCaptchaSuccess" @cancel="stepCaptchaCancel"></two-step-captcha>
<login-select-tenant ref="loginSelect" @success="loginSelectOk" ></login-select-tenant>
</div>
</template>
<script>
谭毅彬
authored
9 months ago
53
54
55
56
57
58
59
60
61
import RouteView from '@/components/layouts/RouteView'
import { mixinDevice } from '@/utils/mixin.js'
import LoginAccount from '@views/user/LoginAccount.vue'
import { mapActions } from 'vuex'
import { getAction } from '@api/manage'
import { getWarehouseByUserCode } from '@api/api'
import TwoStepCaptcha from '@comp/tools/TwoStepCaptcha.vue'
import LoginSelectTenant from '@views/user/LoginSelectTenant.vue'
import { timeFix } from '@/utils/util'
肖超群
authored
10 months ago
62
63
export default {
谭毅彬
authored
9 months ago
64
65
name: 'UserLayout',
components: { LoginSelectTenant, TwoStepCaptcha },
肖超群
authored
10 months ago
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
data() {
return {
requestCodeSuccess: false,
randCodeImage: '',
currdatetime: '',
requiredTwoStepCaptcha: false,
stepCaptchaVisible: false,
maskedPassword: '',
loginType: 0,
loginBtn: false,
warehouseList: {},
querySource: {},
model: {
username: '',
password: '',
谭毅彬
authored
9 months ago
81
warehouseCode: ''
肖超群
authored
10 months ago
82
83
84
85
// inputCode: ''
},
validatorRules: {
username: [
谭毅彬
authored
9 months ago
86
87
{
required: true,
谭毅彬
authored
7 months ago
88
message: <span style="color: red; font-weight: bold; margin-left: 10%; font-size: 0.85vw;">请输入用户名!</span>
谭毅彬
authored
9 months ago
89
90
},
{ validator: this.handleUsernameOrEmail }
肖超群
authored
10 months ago
91
],
谭毅彬
authored
9 months ago
92
93
94
password: [
{
required: true,
谭毅彬
authored
7 months ago
95
message: <span style="color: red; font-weight: bold; margin-left: 10%; font-size: 0.85vw;">请输入密码!</span>,
谭毅彬
authored
9 months ago
96
97
98
99
100
101
validator: 'click'
}
],
warehouseCode: [
{
required: true,
谭毅彬
authored
7 months ago
102
message: <span style="color: red; font-weight: bold; margin-left: 10%; font-size: 0.85vw;">请选择仓库!</span>,
谭毅彬
authored
9 months ago
103
104
105
106
trigger: 'change',
validator: 'click'
}
]
肖超群
authored
10 months ago
107
108
109
110
}
}
},
created() {
谭毅彬
authored
9 months ago
111
112
this.handleChangeCheckCode()
this.getWarehouse()
肖超群
authored
10 months ago
113
114
115
116
117
118
119
120
121
},
methods: {
stepCaptchaCancel() {
this.Logout().then(() => {
this.loginBtn = false
this.stepCaptchaVisible = false
})
},
肖超群
authored
10 months ago
122
肖超群
authored
10 months ago
123
124
125
126
stepCaptchaSuccess() {
this.loginSuccess()
},
handleSubmit() {
谭毅彬
authored
9 months ago
127
this.loginBtn = true
肖超群
authored
10 months ago
128
// if (this.customActiveKey === 'tab1') {
谭毅彬
authored
9 months ago
129
130
// 使用账户密码登录
this.handleLogin(this.rememberMe)
肖超群
authored
10 months ago
131
132
133
134
135
136
137
// } else {
// //手机号码登录
// this.$refs.plogin.handleLogin(this.rememberMe)
// }
},
// 校验失败
validateFail() {
谭毅彬
authored
9 months ago
138
this.loginBtn = false
肖超群
authored
10 months ago
139
140
141
142
143
144
145
146
},
requestSuccess(loginResult) {
this.$refs.loginSelect.show(loginResult)
},
loginSelectOk() {
this.loginSuccess()
},
loginSuccess() {
谭毅彬
authored
9 months ago
147
this.$router.push({ path: '/dashboard/analysis' })
肖超群
authored
10 months ago
148
149
this.$notification.success({
message: '欢迎',
谭毅彬
authored
9 months ago
150
151
description: `${timeFix()},欢迎回来`
})
肖超群
authored
10 months ago
152
153
154
},
//登录后台失败
requestFailed(err) {
谭毅彬
authored
9 months ago
155
let description = ((err.response || {}).data || {}).message || err.message || '请求出现错误,请稍后再试'
肖超群
authored
10 months ago
156
157
158
this.$notification['error']({
message: '登录失败',
description: description,
谭毅彬
authored
9 months ago
159
160
duration: 4
})
肖超群
authored
10 months ago
161
162
163
164
//账户密码登录错误后更新验证码
if (this.customActiveKey === 'tab1' && description.indexOf('密码错误') > 0) {
this.$refs.alogin.handleChangeCheckCode()
}
谭毅彬
authored
9 months ago
165
this.loginBtn = false
肖超群
authored
10 months ago
166
167
168
169
},
...mapActions(['Login']),
/**刷新验证码*/
handleChangeCheckCode() {
谭毅彬
authored
9 months ago
170
this.currdatetime = new Date().getTime()
肖超群
authored
10 months ago
171
// this.model.inputCode = ''
谭毅彬
authored
9 months ago
172
173
174
175
176
177
178
179
180
181
182
getAction(`/sys/randomImage/${this.currdatetime}`)
.then(res => {
if (res.success) {
this.randCodeImage = res.result
this.requestCodeSuccess = true
} else {
this.$message.error(res.message)
this.requestCodeSuccess = false
}
})
.catch(() => {
肖超群
authored
10 months ago
183
this.requestCodeSuccess = false
谭毅彬
authored
9 months ago
184
})
肖超群
authored
10 months ago
185
186
187
},
getWarehouse() {
谭毅彬
authored
9 months ago
188
189
190
191
192
const that = this
this.querySource.username = that.model.username
let obj = getWarehouseByUserCode(that.querySource)
obj.then(res => {
that.warehouseList = res.result
肖超群
authored
10 months ago
193
if (this.warehouseList != null) {
谭毅彬
authored
9 months ago
194
this.model.warehouseCode = this.warehouseList[0].code
肖超群
authored
10 months ago
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
}
})
},
maskPassword() {
//获取输入框的值
let value = this.model.password
if (value != '') {
//如果不为空,逐个字符判断是否为圆点
for (let i = 0; i < value.length; i++) {
if (value.charAt(i) != '\u25CF') {
//如果不是圆点,表示该字符为用户输入的值,放到真实值的对应位置
let char = value.charAt(i)
this.maskedPassword = this.maskedPassword.slice(0, i) + char + this.maskedPassword.slice(i)
//将该字符替换为圆点
value = value.slice(0, i) + '\u25CF' + value.slice(i + 1)
}
}
//防止真实值和圆点的数量不对应。
this.maskedPassword = this.maskedPassword.slice(0, value.length)
//将转换过的字符串显示给用户
this.model.password = value
} else {
//保持一致性
this.maskedPassword = ''
}
},
// 判断登录类型
handleUsernameOrEmail(rule, value, callback) {
谭毅彬
authored
9 months ago
225
const regex = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/
肖超群
authored
10 months ago
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
if (regex.test(value)) {
this.loginType = 0
} else {
this.loginType = 1
}
callback()
},
/**
* 验证字段
* @param arr
* @param callback
*/
validateFields(arr, callback) {
let promiseArray = []
for (let item of arr) {
let p = new Promise((resolve, reject) => {
谭毅彬
authored
9 months ago
242
this.$refs['form'].validateField(item, err => {
肖超群
authored
10 months ago
243
if (!err) {
谭毅彬
authored
9 months ago
244
resolve()
肖超群
authored
10 months ago
245
} else {
谭毅彬
authored
9 months ago
246
reject(err)
肖超群
authored
10 months ago
247
248
}
})
谭毅彬
authored
9 months ago
249
})
肖超群
authored
10 months ago
250
251
promiseArray.push(p)
}
谭毅彬
authored
9 months ago
252
253
254
255
256
257
258
Promise.all(promiseArray)
.then(() => {
callback()
})
.catch(err => {
callback(err)
})
肖超群
authored
10 months ago
259
260
261
262
263
264
},
acceptUsername(username) {
this.model['username'] = username
},
// 账号密码登录
handleLogin(rememberMe) {
谭毅彬
authored
9 months ago
265
this.validateFields(['username', 'password'], err => {
肖超群
authored
10 months ago
266
267
268
269
270
271
if (!err) {
let loginParams = {
username: this.model.username,
password: this.maskedPassword,
warehouseCode: this.model.warehouseCode,
checkKey: this.currdatetime,
谭毅彬
authored
9 months ago
272
remember_me: rememberMe
肖超群
authored
10 months ago
273
}
谭毅彬
authored
9 months ago
274
275
276
277
278
279
280
281
282
283
284
285
286
this.Login(loginParams)
.then(res => {
this.$emit('success', res.result)
this.loginSuccess()
})
.catch(err => {
this.validateFail()
this.requestFailed(err)
this.$emit('fail', err)
if (err.code == 499) {
this.$router.push({ path: '/user/systemTokenModal' })
}
})
肖超群
authored
10 months ago
287
288
289
290
291
292
293
294
295
296
297
} else {
this.validateFail()
this.$emit('validateFail')
}
})
}
}
}
</script>
<style lang="less" scoped>
谭毅彬
authored
9 months ago
298
299
300
301
302
303
304
#userLayout {
height: 100%;
display: flex; /* 设置flex布局 */
width: 100%; /* 容器宽度设置为100% */
}
::v-deep .ant-select-selection {
border-width: 1px;
谭毅彬
authored
7 months ago
305
border-style: solid;
谭毅彬
authored
9 months ago
306
border-radius: 0.6vw;
谭毅彬
authored
9 months ago
307
308
width: 100% !important;
height: 100% !important;
谭毅彬
authored
7 months ago
309
line-height: 3vw;
谭毅彬
authored
9 months ago
310
background-image: url(../../assets/cangku.png);
谭毅彬
authored
7 months ago
311
padding-left: 12%; /* 留出图片的空间 */
谭毅彬
authored
9 months ago
312
background-repeat: no-repeat;
谭毅彬
authored
7 months ago
313
314
315
316
background-position: 0.6vw center;
background-size: 1.6vw 1.6vw;
font-size: 1vw;
color: #333333;
谭毅彬
authored
9 months ago
317
318
box-shadow: 2px 5px 5px #c3c3c3;
}
肖超群
authored
10 months ago
319
谭毅彬
authored
9 months ago
320
/deep/ .ant-select-selection__rendered {
谭毅彬
authored
7 months ago
321
margin-top: 0.6vw;
谭毅彬
authored
9 months ago
322
}
谭毅彬
authored
7 months ago
323
324
325
/deep/ .ant-form {
width: 100%;
}
肖超群
authored
10 months ago
326
谭毅彬
authored
9 months ago
327
328
329
330
///deep/ .ant-select-dropdown-menu-item-selected{
// font-size: 18px;
// height: 30px;
//}
肖超群
authored
10 months ago
331
谭毅彬
authored
9 months ago
332
.left-div {
谭毅彬
authored
7 months ago
333
flex: 0 0 68%; /* 左侧div宽度为容器的70% */
谭毅彬
authored
9 months ago
334
}
肖超群
authored
10 months ago
335
谭毅彬
authored
9 months ago
336
.right-div {
谭毅彬
authored
7 months ago
337
display: flex;
谭毅彬
authored
7 months ago
338
flex: 0 0 32%;
谭毅彬
authored
9 months ago
339
background-color: #fafafa;
谭毅彬
authored
7 months ago
340
341
342
343
344
display: flex; /* 使用 flex 布局 */
flex-direction: column; /* 垂直排列子元素 */
justify-content: center; /* 垂直居中 */
align-items: center; /* 水平居中 */
height: 100%; /* 使 div 占满父容器高度 */
谭毅彬
authored
9 months ago
345
}
谭毅彬
authored
7 months ago
346
347
348
349
350
351
352
353
354
355
#logo {
height: 10%;
width: 100%;
//background-color: red;
//margin-left: 150px;
//margin-left: 11%;
//margin-top: -3%;
display: flex;
// margin-top: 0;
}
谭毅彬
authored
9 months ago
356
357
358
359
#backgroundImg {
height: 80%;
display: flex;
justify-content: center;
谭毅彬
authored
7 months ago
360
align-items: center;
谭毅彬
authored
9 months ago
361
362
.imge {
height: 75%;
肖超群
authored
10 months ago
363
364
365
366
background-size: contain;
background-repeat: no-repeat;
position: relative;
}
谭毅彬
authored
9 months ago
367
}
谭毅彬
authored
7 months ago
368
369
370
371
372
#copyright {
height: 10%; /* 高度为视口的 10% */
width: 100%; /* 确保宽度不超出容器 */
position: fixed; /* 固定定位 */
bottom: 0; /* 靠底部对齐 */
谭毅彬
authored
9 months ago
373
display: flex;
谭毅彬
authored
7 months ago
374
375
align-items: flex-end; /* 垂直方向上靠下对齐 */
padding: 10px; /* 添加内边距 */
谭毅彬
authored
9 months ago
376
377
}
#logoImg {
谭毅彬
authored
7 months ago
378
width: 22%;
谭毅彬
authored
9 months ago
379
380
381
382
383
height: 100%;
float: right;
position: relative;
//background-color: yellow;
.imge {
谭毅彬
authored
7 months ago
384
385
width: 83%;
height: 30%;
谭毅彬
authored
9 months ago
386
position: absolute;
谭毅彬
authored
7 months ago
387
388
389
right: 5%; /* 水平居右 */
top: 20%; /* 从顶部偏移50% */
// transform: translateY(-50%); /* 向上移动自身高度的50%,实现垂直居中 */
谭毅彬
authored
9 months ago
390
391
392
393
394
//object-fit: contain;
//top: 39%;
//left: 45%;
//object-fit: cover; /* 或 contain、fill、none、scale-down */
//object-position: center;
肖超群
authored
10 months ago
395
}
谭毅彬
authored
9 months ago
396
397
}
#text {
谭毅彬
authored
7 months ago
398
height: 69%;
谭毅彬
authored
9 months ago
399
width: 100%;
谭毅彬
authored
7 months ago
400
font-size: 1.1vw;
谭毅彬
authored
9 months ago
401
402
403
404
405
406
407
408
409
410
411
412
413
414
align-content: center;
color: #333333;
//margin-left: 5px;
font-family: 'Microsoft YaHei', 'SimSun', sans-serif;
font-weight: bold;
//background-color: blue;
}
#form-container {
width: 200px; /* 设置宽度 */
height: 50px; /* 设置高度 */
//margin-left: 820px;
//margin-top: 100px;
}
#company {
谭毅彬
authored
7 months ago
415
416
417
418
419
text-align: center; /* 水平居中对齐 */
// color: #ac1e2b; /* 字体颜色 */
font-size: 0.9vw; /* 字体大小 */
font-family: 'Microsoft YaHei', 'SimSun', sans-serif; /* 字体系列 */
width: 100%; /* 宽度 100% */
谭毅彬
authored
9 months ago
420
421
}
#welcome {
谭毅彬
authored
7 months ago
422
margin-top: 20px;
谭毅彬
authored
9 months ago
423
424
color: #333333;
font-size: 1.5vw;
谭毅彬
authored
7 months ago
425
align-content: end;
谭毅彬
authored
9 months ago
426
font-family: 'Microsoft YaHei', 'SimSun', sans-serif;
谭毅彬
authored
7 months ago
427
428
text-align: center;
margin-left: 1vw;
谭毅彬
authored
7 months ago
429
}
谭毅彬
authored
9 months ago
430
431
432
433
434
435
436
#name {
border-width: 1px;
border-style: solid;
border-radius: 0.6vw;
width: 85%;
height: 3vw;
line-height: 3vw;
谭毅彬
authored
7 months ago
437
margin-top: 3vw;
谭毅彬
authored
9 months ago
438
margin-left: 8%;
谭毅彬
authored
7 months ago
439
margin-bottom: 0.5vw;
谭毅彬
authored
9 months ago
440
441
442
background-image: url(../../assets/huiyuan.png);
padding-left: 12%; /* 留出图片的空间 */
background-repeat: no-repeat;
谭毅彬
authored
7 months ago
443
444
background-position: 0.6vw center;
background-size: 1.6vw 1.6vw;
谭毅彬
authored
9 months ago
445
446
447
448
449
450
451
452
453
454
455
456
font-size: 1vw;
color: #333333;
box-shadow: 2px 5px 5px #c3c3c3;
}
#name::after {
content: '';
display: inline-block;
width: 0;
height: 0;
overflow: hidden;
}
#name::placeholder {
谭毅彬
authored
7 months ago
457
font-size: 1vw;
谭毅彬
authored
9 months ago
458
459
460
461
462
463
464
465
466
467
468
color: #999999;
padding-left: 0px;
}
#password {
border-width: 1px;
border-style: solid;
border-radius: 0.6vw;
width: 85%;
height: 3vw;
line-height: 3vw;
margin-left: 8%;
谭毅彬
authored
7 months ago
469
margin-bottom: 0.5vw;
谭毅彬
authored
9 months ago
470
471
472
background-image: url(../../assets/mima.png);
padding-left: 12%; /* 留出图片的空间 */
background-repeat: no-repeat;
谭毅彬
authored
7 months ago
473
474
background-position: 0.6vw center;
background-size: 1.6vw 1.6vw;
谭毅彬
authored
9 months ago
475
476
477
478
font-size: 1vw;
color: #333333;
box-shadow: 2px 5px 5px #c3c3c3;
}
谭毅彬
authored
7 months ago
479
480
481
482
483
484
485
486
487
488
489
490
491
492
#warehouseCode {
border-color: #ebf3fd;
border-width: 1px;
border-style: solid;
border-radius: 0.6vw;
width: 85%;
height: 3vw;
line-height: 3vw;
margin-left: 8%;
margin-bottom: 2.5vw;
font-size: 1vw;
text-align: center;
//color: #333333;
}
谭毅彬
authored
9 months ago
493
494
495
496
497
498
499
500
#password::after {
content: '';
display: inline-block;
width: 0;
height: 0;
overflow: hidden;
}
#password::placeholder {
谭毅彬
authored
7 months ago
501
font-size: 1vw;
谭毅彬
authored
9 months ago
502
503
504
color: #999999;
padding-left: 0px;
}
谭毅彬
authored
7 months ago
505
506
/deep/ .ant-form-item-control {
line-height: 3vw;
谭毅彬
authored
9 months ago
507
}
谭毅彬
authored
9 months ago
508
/deep/ .ant-select-selection__rendered {
谭毅彬
authored
7 months ago
509
line-height: 1.5vw;
谭毅彬
authored
9 months ago
510
}
谭毅彬
authored
7 months ago
511
谭毅彬
authored
9 months ago
512
513
514
515
516
517
518
a-select {
width: 100%;
height: 100%;
font-size: 16px;
color: #333;
background-color: #fff;
border: 1px solid #ccc;
谭毅彬
authored
9 months ago
519
border-radius: 0.6vw;
谭毅彬
authored
9 months ago
520
521
522
523
524
525
526
527
528
529
}
#logIn {
border-color: #ac1e2b;
border-width: 1px;
border-style: solid;
border-radius: 0.6vw;
width: 85%;
height: 3vw;
line-height: 3vw;
margin-left: 8%;
谭毅彬
authored
7 months ago
530
font-size: 1.2vw;
谭毅彬
authored
9 months ago
531
532
533
534
535
536
537
align-items: center;
justify-content: center;
display: flex;
color: #ebf3fd;
background-color: red;
box-shadow: 2px 5px 5px #c3c3c3;
}
肖超群
authored
10 months ago
538
</style>