Skip to content

Commit 7ab8aa7

Browse files
committed
Vue3 重构:REVIEW 用户管理
1 parent c9e63c3 commit 7ab8aa7

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/views/system/user/RoleForm.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
<el-input v-model="formData.nickname" :disabled="true" />
99
</el-form-item>
1010
<el-form-item label="角色">
11-
<el-select v-model="formData.roleIds" multiple placeholder="请选择">
11+
<el-select v-model="formData.roleIds" multiple placeholder="请选择角色">
1212
<el-option
1313
v-for="item in roleOptions"
14-
:key="parseInt(item.id)"
14+
:key="item.id"
1515
:label="item.name"
16-
:value="parseInt(item.id)"
16+
:value="item.id"
1717
/>
1818
</el-select>
1919
</el-form-item>
@@ -28,6 +28,7 @@
2828
</template>
2929

3030
<script setup lang="ts">
31+
// TODO el-dialog 用 Dialog 组件
3132
import { assignUserRoleApi, PermissionAssignUserRoleReqVO } from '@/api/system/permission'
3233
3334
interface Props {
@@ -86,5 +87,3 @@ const submit = async () => {
8687
}
8788
}
8889
</script>
89-
90-
<style></style>

src/views/system/user/index.vue

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269
import type { ElTree } from 'element-plus'
270270
import { handleTree, defaultProps } from '@/utils/tree'
271271
// 原vue3版本api方法都是Api结尾觉得见名知义,个人觉得这个可以形成规范
272+
// TODO 使用 DeptApi 这种形式哈
272273
import { getSimpleDeptList as getSimpleDeptListApi } from '@/api/system/dept'
273274
import { getSimplePostList as getSimplePostListApi, PostVO } from '@/api/system/post'
274275
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
@@ -279,16 +280,15 @@ import {
279280
updateUserStatusApi,
280281
UserVO
281282
} from '@/api/system/user'
282-
import { parseTime } from './utils'
283-
import AddForm from './AddForm.vue'
284-
import ImportForm from './ImportForm.vue'
285-
import RoleForm from './RoleForm.vue'
283+
import { parseTime } from './utils' // TODO 可以使用 formatTime 里的方法
284+
import AddForm from './AddForm.vue' // TODO 改成 UserForm
285+
import ImportForm from './ImportForm.vue' // TODO 改成 UserImportForm
286+
import RoleForm from './RoleForm.vue' // TODO 改成 UserAssignRoleForm
286287
import { getUserApi, getUserPageApi } from '@/api/system/user'
287288
import { getSimpleRoleList as getSimpleRoleListApi } from '@/api/system/role'
288289
import { listUserRolesApi } from '@/api/system/permission'
289290
import { CommonStatusEnum } from '@/utils/constants'
290291
import download from '@/utils/download'
291-
292292
const message = useMessage() // 消息弹窗
293293
const { t } = useI18n() // 国际化
294294
@@ -304,10 +304,11 @@ const queryParams = reactive({
304304
const showSearch = ref(true)
305305
const showAddDialog = ref(false)
306306
307-
// 数据字典-
307+
// 数据字典- // TODO 可以直接 vue 那 getIntDictOptions,这样一方面少个变量,也可以 getIntDictOptions
308308
const statusDictDatas = getDictOptions(DICT_TYPE.COMMON_STATUS)
309309
310310
// ========== 创建部门树结构 ==========
311+
// TODO 要不把部门树拆成一个左侧的组件,然后点击后触发 handleDeptNodeClick
311312
const deptName = ref('')
312313
watch(
313314
() => deptName.value,
@@ -375,6 +376,7 @@ const resetQuery = () => {
375376
// 添加或编辑
376377
const addEditFormRef = ref()
377378
// 添加用户
379+
// TODO 可以参考别的模块哈,openForm;然后 tree 和 position 可以里面在加载下,让组件自己维护自己哈。
378380
const handleAdd = () => {
379381
addEditFormRef?.value.resetForm()
380382
// 获得下拉数据
@@ -389,6 +391,7 @@ const handleImport = () => {
389391
}
390392
391393
// 用户导出
394+
// TODO 改成 await 的风格;
392395
const exportLoading = ref(false)
393396
const handleExport = () => {
394397
message
@@ -432,6 +435,7 @@ const handleCommand = (command: string, index: number, row: UserVO) => {
432435
}
433436
434437
// 用户状态修改
438+
// TODO 改成 await 的风格;
435439
const handleStatusChange = (row: UserVO) => {
436440
let text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
437441
message
@@ -466,6 +470,7 @@ const handleUpdate = (row: UserVO) => {
466470
}
467471
468472
// 删除用户
473+
// TODO 改成 await 的风格;
469474
const handleDelete = (row: UserVO) => {
470475
const ids = row.id
471476
message
@@ -481,6 +486,7 @@ const handleDelete = (row: UserVO) => {
481486
}
482487
483488
// 重置密码
489+
// TODO 改成 await 的风格;
484490
const handleResetPwd = (row: UserVO) => {
485491
message.prompt('请输入"' + row.username + '"的新密码', t('common.reminder')).then(({ value }) => {
486492
resetUserPwdApi(row.id, value)

0 commit comments

Comments
 (0)