Vue3 重构:REVIEW 用户管理

This commit is contained in:
YunaiV 2023-03-28 23:50:32 +08:00
parent c9e63c320e
commit 7ab8aa7168
2 changed files with 16 additions and 11 deletions

View File

@ -8,12 +8,12 @@
<el-input v-model="formData.nickname" :disabled="true" /> <el-input v-model="formData.nickname" :disabled="true" />
</el-form-item> </el-form-item>
<el-form-item label="角色"> <el-form-item label="角色">
<el-select v-model="formData.roleIds" multiple placeholder="请选择"> <el-select v-model="formData.roleIds" multiple placeholder="请选择角色">
<el-option <el-option
v-for="item in roleOptions" v-for="item in roleOptions"
:key="parseInt(item.id)" :key="item.id"
:label="item.name" :label="item.name"
:value="parseInt(item.id)" :value="item.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -28,6 +28,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
// TODO el-dialog Dialog
import { assignUserRoleApi, PermissionAssignUserRoleReqVO } from '@/api/system/permission' import { assignUserRoleApi, PermissionAssignUserRoleReqVO } from '@/api/system/permission'
interface Props { interface Props {
@ -86,5 +87,3 @@ const submit = async () => {
} }
} }
</script> </script>
<style></style>

View File

@ -269,6 +269,7 @@
import type { ElTree } from 'element-plus' import type { ElTree } from 'element-plus'
import { handleTree, defaultProps } from '@/utils/tree' import { handleTree, defaultProps } from '@/utils/tree'
// vue3apiApi // vue3apiApi
// TODO 使 DeptApi
import { getSimpleDeptList as getSimpleDeptListApi } from '@/api/system/dept' import { getSimpleDeptList as getSimpleDeptListApi } from '@/api/system/dept'
import { getSimplePostList as getSimplePostListApi, PostVO } from '@/api/system/post' import { getSimplePostList as getSimplePostListApi, PostVO } from '@/api/system/post'
import { DICT_TYPE, getDictOptions } from '@/utils/dict' import { DICT_TYPE, getDictOptions } from '@/utils/dict'
@ -279,16 +280,15 @@ import {
updateUserStatusApi, updateUserStatusApi,
UserVO UserVO
} from '@/api/system/user' } from '@/api/system/user'
import { parseTime } from './utils' import { parseTime } from './utils' // TODO 使 formatTime
import AddForm from './AddForm.vue' import AddForm from './AddForm.vue' // TODO UserForm
import ImportForm from './ImportForm.vue' import ImportForm from './ImportForm.vue' // TODO UserImportForm
import RoleForm from './RoleForm.vue' import RoleForm from './RoleForm.vue' // TODO UserAssignRoleForm
import { getUserApi, getUserPageApi } from '@/api/system/user' import { getUserApi, getUserPageApi } from '@/api/system/user'
import { getSimpleRoleList as getSimpleRoleListApi } from '@/api/system/role' import { getSimpleRoleList as getSimpleRoleListApi } from '@/api/system/role'
import { listUserRolesApi } from '@/api/system/permission' import { listUserRolesApi } from '@/api/system/permission'
import { CommonStatusEnum } from '@/utils/constants' import { CommonStatusEnum } from '@/utils/constants'
import download from '@/utils/download' import download from '@/utils/download'
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
@ -304,10 +304,11 @@ const queryParams = reactive({
const showSearch = ref(true) const showSearch = ref(true)
const showAddDialog = ref(false) const showAddDialog = ref(false)
// - // - // TODO vue getIntDictOptions getIntDictOptions
const statusDictDatas = getDictOptions(DICT_TYPE.COMMON_STATUS) const statusDictDatas = getDictOptions(DICT_TYPE.COMMON_STATUS)
// ========== ========== // ========== ==========
// TODO handleDeptNodeClick
const deptName = ref('') const deptName = ref('')
watch( watch(
() => deptName.value, () => deptName.value,
@ -375,6 +376,7 @@ const resetQuery = () => {
// //
const addEditFormRef = ref() const addEditFormRef = ref()
// //
// TODO openForm tree position
const handleAdd = () => { const handleAdd = () => {
addEditFormRef?.value.resetForm() addEditFormRef?.value.resetForm()
// //
@ -389,6 +391,7 @@ const handleImport = () => {
} }
// //
// TODO await
const exportLoading = ref(false) const exportLoading = ref(false)
const handleExport = () => { const handleExport = () => {
message message
@ -432,6 +435,7 @@ const handleCommand = (command: string, index: number, row: UserVO) => {
} }
// //
// TODO await
const handleStatusChange = (row: UserVO) => { const handleStatusChange = (row: UserVO) => {
let text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用' let text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
message message
@ -466,6 +470,7 @@ const handleUpdate = (row: UserVO) => {
} }
// //
// TODO await
const handleDelete = (row: UserVO) => { const handleDelete = (row: UserVO) => {
const ids = row.id const ids = row.id
message message
@ -481,6 +486,7 @@ const handleDelete = (row: UserVO) => {
} }
// //
// TODO await
const handleResetPwd = (row: UserVO) => { const handleResetPwd = (row: UserVO) => {
message.prompt('请输入"' + row.username + '"的新密码', t('common.reminder')).then(({ value }) => { message.prompt('请输入"' + row.username + '"的新密码', t('common.reminder')).then(({ value }) => {
resetUserPwdApi(row.id, value) resetUserPwdApi(row.id, value)