Merge pull request #118 from cshaptx4869/patch-77

refactor: ♻️ 修改CURD示例
This commit is contained in:
Ray Hao
2024-05-28 16:57:34 +08:00
committed by GitHub
3 changed files with 17 additions and 24 deletions

View File

@@ -1,5 +1,4 @@
import DeptAPI from "@/api/dept";
import DictAPI from "@/api/dict";
import RoleAPI from "@/api/role";
import UserAPI from "@/api/user";
import type { UserForm } from "@/api/user/model";
@@ -55,16 +54,9 @@ const modalConfig: IModalConfig<UserForm> = {
},
},
{
type: "select",
type: "custom",
label: "性别",
prop: "gender",
attrs: {
placeholder: "请选择",
},
options: [],
async initFn(formItem) {
formItem.options = await DictAPI.getDictOptions("gender");
},
},
{
label: "角色",

View File

@@ -1,5 +1,4 @@
import DeptAPI from "@/api/dept";
import DictAPI from "@/api/dict";
import RoleAPI from "@/api/role";
import UserAPI from "@/api/user";
import type { UserForm } from "@/api/user/model";
@@ -56,16 +55,9 @@ const modalConfig: IModalConfig<UserForm> = {
},
},
{
type: "select",
type: "custom",
label: "性别",
prop: "gender",
attrs: {
placeholder: "请选择",
},
options: [],
async initFn(formItem) {
formItem.options = await DictAPI.getDictOptions("gender");
},
},
{
label: "角色",

View File

@@ -40,14 +40,22 @@
ref="addModalRef"
:modal-config="addModalConfig"
@submit-click="handleSubmitClick"
/>
>
<template #gender="scope">
<dictionary v-model="scope.formData[scope.prop]" type-code="gender" />
</template>
</page-modal>
<!-- 编辑 -->
<page-modal
ref="editModalRef"
:modal-config="editModalConfig"
@submit-click="handleSubmitClick"
/>
>
<template #gender="scope">
<dictionary v-model="scope.formData[scope.prop]" type-code="gender" />
</template>
</page-modal>
</div>
</template>
@@ -100,12 +108,13 @@ function handleOperatClick(data: IOperatData) {
cancelButtonText: "取消",
}
).then(({ value }) => {
if (!value) {
ElMessage.warning("请输入新密码");
if (!value || value.length < 6) {
ElMessage.warning("密码至少需要6位字符请重新输入");
return false;
}
// 发送网络请求
ElMessage.success("密码重置成功,新密码是:" + value);
UserAPI.updatePassword(data.row.id, value).then(() => {
ElMessage.success("密码重置成功,新密码是:" + value);
});
});
}
}