优化修改密码
This commit is contained in:
parent
b60ff97f57
commit
05addc0b37
@ -15,12 +15,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref,nextTick } from 'vue';
|
import { ref, nextTick } from 'vue';
|
||||||
import { basicModal, useModal } from '@/components/Modal';
|
import { basicModal, useModal } from '@/components/Modal';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
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,7 +56,10 @@
|
|||||||
|
|
||||||
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 },
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
@ -61,19 +67,25 @@
|
|||||||
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) {
|
||||||
setSubLoading(false);
|
setSubLoading(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -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,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user