refactor: ♻️ 修改CURD示例
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import DeptAPI from "@/api/dept";
|
import DeptAPI from "@/api/dept";
|
||||||
import DictAPI from "@/api/dict";
|
|
||||||
import RoleAPI from "@/api/role";
|
import RoleAPI from "@/api/role";
|
||||||
import UserAPI from "@/api/user";
|
import UserAPI from "@/api/user";
|
||||||
import type { UserForm } from "@/api/user/model";
|
import type { UserForm } from "@/api/user/model";
|
||||||
@@ -55,16 +54,9 @@ const modalConfig: IModalConfig<UserForm> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "select",
|
type: "custom",
|
||||||
label: "性别",
|
label: "性别",
|
||||||
prop: "gender",
|
prop: "gender",
|
||||||
attrs: {
|
|
||||||
placeholder: "请选择",
|
|
||||||
},
|
|
||||||
options: [],
|
|
||||||
async initFn(formItem) {
|
|
||||||
formItem.options = await DictAPI.getDictOptions("gender");
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "角色",
|
label: "角色",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import DeptAPI from "@/api/dept";
|
import DeptAPI from "@/api/dept";
|
||||||
import DictAPI from "@/api/dict";
|
|
||||||
import RoleAPI from "@/api/role";
|
import RoleAPI from "@/api/role";
|
||||||
import UserAPI from "@/api/user";
|
import UserAPI from "@/api/user";
|
||||||
import type { UserForm } from "@/api/user/model";
|
import type { UserForm } from "@/api/user/model";
|
||||||
@@ -56,16 +55,9 @@ const modalConfig: IModalConfig<UserForm> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "select",
|
type: "custom",
|
||||||
label: "性别",
|
label: "性别",
|
||||||
prop: "gender",
|
prop: "gender",
|
||||||
attrs: {
|
|
||||||
placeholder: "请选择",
|
|
||||||
},
|
|
||||||
options: [],
|
|
||||||
async initFn(formItem) {
|
|
||||||
formItem.options = await DictAPI.getDictOptions("gender");
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "角色",
|
label: "角色",
|
||||||
|
|||||||
@@ -40,14 +40,22 @@
|
|||||||
ref="addModalRef"
|
ref="addModalRef"
|
||||||
:modal-config="addModalConfig"
|
:modal-config="addModalConfig"
|
||||||
@submit-click="handleSubmitClick"
|
@submit-click="handleSubmitClick"
|
||||||
/>
|
>
|
||||||
|
<template #gender="scope">
|
||||||
|
<dictionary v-model="scope.formData[scope.prop]" type-code="gender" />
|
||||||
|
</template>
|
||||||
|
</page-modal>
|
||||||
|
|
||||||
<!-- 编辑 -->
|
<!-- 编辑 -->
|
||||||
<page-modal
|
<page-modal
|
||||||
ref="editModalRef"
|
ref="editModalRef"
|
||||||
:modal-config="editModalConfig"
|
:modal-config="editModalConfig"
|
||||||
@submit-click="handleSubmitClick"
|
@submit-click="handleSubmitClick"
|
||||||
/>
|
>
|
||||||
|
<template #gender="scope">
|
||||||
|
<dictionary v-model="scope.formData[scope.prop]" type-code="gender" />
|
||||||
|
</template>
|
||||||
|
</page-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -100,12 +108,13 @@ function handleOperatClick(data: IOperatData) {
|
|||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
}
|
}
|
||||||
).then(({ value }) => {
|
).then(({ value }) => {
|
||||||
if (!value) {
|
if (!value || value.length < 6) {
|
||||||
ElMessage.warning("请输入新密码");
|
ElMessage.warning("密码至少需要6位字符,请重新输入");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 发送网络请求
|
UserAPI.updatePassword(data.row.id, value).then(() => {
|
||||||
ElMessage.success("密码重置成功,新密码是:" + value);
|
ElMessage.success("密码重置成功,新密码是:" + value);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user