优化修改密码

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

View File

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