优化修改密码

This commit is contained in:
zjl 2024-12-17 15:03:34 +08:00
parent b60ff97f57
commit 05addc0b37

View File

@ -15,12 +15,15 @@
</template>
<script lang="ts" setup>
import { ref,nextTick } from 'vue';
import { ref, nextTick } from 'vue';
import { basicModal, useModal } from '@/components/Modal';
import { message } from 'ant-design-vue';
import { BasicForm, FormSchema, useForm } from '@/components/Form/index';
import { changePassword } from '@/api/system/user';
/**
* 定义表单
*/
const schemas: FormSchema[] = [
{
name: 'password',
@ -53,7 +56,10 @@
const modalRef: any = ref(null);
const [register, { submit, resetFields,getFieldsValue }] = useForm({
/**
* 定义页面
*/
const [register, { submit, resetFields, getFieldsValue }] = useForm({
colProps: { span: 24 },
labelCol: { span: 5 },
layout: 'horizontal',
@ -61,19 +67,25 @@
schemas,
});
/**
* 定义模态
*/
const [modalRegister, { openModal, closeModal, setSubLoading }] = useModal({
title: '修改密码',
subBtuText: '提交修改',
});
/**
* 执行提交表单
*/
async function formSubmit() {
const formRes = await submit();
if (formRes) {
try{
await changePassword(getFieldsValue())
try {
await changePassword(getFieldsValue());
closeModal();
message.success('修改成功');
} catch(e){
} catch (e) {
setSubLoading(false);
}
} else {
@ -82,16 +94,26 @@
}
}
/**
* 显示弹窗
*/
async function showModal() {
openModal();
await nextTick()
resetFields()
await nextTick();
resetFields();
}
/**
* 执行重置
* @param values 参数
*/
function handleReset(values: Recordable) {
console.log(values);
}
/**
* 定义函数
*/
defineExpose({
showModal,
});