vben
authored
5 years ago
1
import './LockAction.less';
vben
authored
5 years ago
2
3
4
import { defineComponent } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal/index';
vben
authored
5 years ago
5
import { Button } from '/@/components/Button';
6
7
8
9
10
import { BasicForm, useForm } from '/@/components/Form/index';
import headerImg from '/@/assets/images/header.jpg';
import { userStore } from '/@/store/modules/user';
vben
authored
5 years ago
11
import { useI18n } from '/@/hooks/web/useI18n';
vben
authored
5 years ago
12
import { lockStore } from '/@/store/modules/lock';
vben
authored
5 years ago
13
14
15
16
17
const prefixCls = 'lock-modal';
export default defineComponent({
name: 'LockModal',
setup(_, { attrs }) {
vben
authored
5 years ago
18
const { t } = useI18n();
vben
authored
5 years ago
19
20
const [register, { closeModal }] = useModalInner();
21
22
23
24
25
const [registerForm, { validateFields, resetFields }] = useForm({
showActionButtonGroup: false,
schemas: [
{
field: 'password',
vben
authored
5 years ago
26
label: t('layout.header.lockScreenPassword'),
27
component: 'InputPassword',
vben
authored
5 years ago
28
required: true,
29
30
31
},
],
});
vben
authored
5 years ago
32
vben
authored
5 years ago
33
34
35
36
async function lock() {
const values = (await validateFields()) as any;
const password: string | undefined = values.password;
closeModal();
37
vben
authored
5 years ago
38
39
40
41
42
lockStore.commitLockInfoState({
isLock: true,
pwd: password,
});
await resetFields();
43
}
vben
authored
5 years ago
44
45
return () => (
vben
authored
5 years ago
46
47
<BasicModal
footer={null}
vben
authored
5 years ago
48
title={t('layout.header.lockScreen')}
vben
authored
5 years ago
49
50
51
52
{...attrs}
class={prefixCls}
onRegister={register}
>
53
54
55
56
57
58
{() => (
<div class={`${prefixCls}__entry`}>
<div class={`${prefixCls}__header`}>
<img src={headerImg} class={`${prefixCls}__header-img`} />
<p class={`${prefixCls}__header-name`}>{userStore.getUserInfoState.realName}</p>
</div>
vben
authored
5 years ago
59
vben
authored
5 years ago
60
<BasicForm onRegister={registerForm} />
vben
authored
5 years ago
61
62
63
<div class={`${prefixCls}__footer`}>
<Button type="primary" block class="mt-2" onClick={lock}>
vben
authored
5 years ago
64
{() => t('layout.header.lockScreenBtn')}
65
66
67
68
69
70
71
72
</Button>
</div>
</div>
)}
</BasicModal>
);
},
});