This commit is contained in:
qsh
2024-05-23 15:24:05 +08:00
parent 3050b9a2fe
commit 33be215c0a
11 changed files with 60 additions and 127 deletions

View File

@@ -93,10 +93,10 @@
</template>
<script lang="ts" name="SystemUserForm" setup>
import { CommonStatusEnum } from '@/utils/constants'
import { defaultProps } from '@/utils/tree'
// import * as PostApi from '@/api/system/post'
// import * as DeptApi from '@/api/system/dept'
// import * as UserApi from '@/api/system/user'
import { defaultProps, handleTree } from '@/utils/tree'
import * as RoleApi from '@/api/system/role'
import * as DeptApi from '@/api/system/dept'
import * as UserApi from '@/api/system/user'
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
@@ -114,7 +114,6 @@ const formData = ref({
username: '',
password: '',
sex: 1,
postIds: [],
remark: '',
status: CommonStatusEnum.ENABLE,
roleIds: []
@@ -140,7 +139,6 @@ const formRules = {
}
const formRef = ref() // 表单 Ref
const deptList = ref<Tree[]>([]) // 树形结构
const postList = ref([]) // 岗位列表
const roleOptions = ref([])
/** 打开弹窗 */
@@ -153,31 +151,15 @@ const open = async (type: string, id?: number) => {
if (id) {
formLoading.value = true
try {
// formData.value = await UserApi.getUser(id)
formData.value = {
nickname: '',
deptId: '',
mobile: '',
email: '',
id: undefined,
username: '',
password: '',
sex: 1,
postIds: [],
remark: '',
status: CommonStatusEnum.ENABLE,
roleIds: []
}
formData.value = await UserApi.getUser(id)
} finally {
formLoading.value = false
}
}
// 加载部门树
// deptList.value = handleTree(await DeptApi.getSimpleDeptList())
deptList.value = []
deptList.value = handleTree(await DeptApi.getSimpleDeptList())
// 加载岗位列表
// postList.value = await PostApi.getSimplePostList()
postList.value = []
roleOptions.value = await RoleApi.getSimpleRoleList()
}
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
@@ -191,12 +173,12 @@ const submitForm = async () => {
// 提交请求
formLoading.value = true
try {
// const data = formData.value as unknown as UserApi.UserVO
const data = formData.value as unknown as UserApi.UserVO
if (formType.value === 'create') {
// await UserApi.createUser(data)
await UserApi.createUser(data)
message.success(t('common.createSuccess'))
} else {
// await UserApi.updateUser(data)
await UserApi.updateUser(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
@@ -217,8 +199,7 @@ const resetForm = () => {
id: undefined,
username: '',
password: '',
sex: undefined,
postIds: [],
sex: 1,
remark: '',
status: CommonStatusEnum.ENABLE,
roleIds: []