PasswordModal.vue
1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<template>
<div>
<BasicModal
destroyOnClose
v-bind="$attrs"
width="30rem"
:height="75"
:minHeight="75"
@register="register"
title="操作密码"
@ok="handleSuccess"
@cancel="handleClose"
>
<div>
<BasicForm @register="registerForm" />
</div>
</BasicModal>
</div>
</template>
<script setup lang="ts">
import { BasicModal, useModalInner } from '/@/components/Modal';
import { useForm, BasicForm } from '/@/components/Form';
import { formSchema } from './config';
import { useMessage } from '/@/hooks/web/useMessage';
import { ref, unref } from 'vue';
const emit = defineEmits(['register', 'success', 'cancel']);
const persetData = ref<{ [key: string]: string | number }>({});
const { createMessage } = useMessage();
const [registerForm, { getFieldsValue, validate }] = useForm({
labelWidth: 70,
schemas: formSchema,
wrapperCol: { span: 12 },
showActionButtonGroup: false,
});
const [register, { setModalProps, closeModal }] = useModalInner(async (data) => {
setModalProps({ loading: true });
persetData.value = data;
setModalProps({ loading: false });
});
const handleClose = () => {
emit('cancel');
closeModal();
};
const handleSuccess = async () => {
await validate();
const { password: passwordField } = getFieldsValue();
if (unref(persetData).password != passwordField) {
createMessage.warning('操作密码不正确');
return;
}
emit('success', unref(persetData));
closeModal();
};
</script>
<style lang="less" scoped></style>