Commit 2e30dd03e28d47622e7d9dfed3dc663761b18893
1 parent
bb48e93e
fix: dept
Showing
2 changed files
with
19 additions
and
18 deletions
yudao-ui-admin-vue3/src/api/system/dept/index.ts
yudao-ui-admin-vue3/src/views/system/dept/index.vue
| @@ -54,9 +54,9 @@ | @@ -54,9 +54,9 @@ | ||
| 54 | <el-select v-model="leaderUserId"> | 54 | <el-select v-model="leaderUserId"> |
| 55 | <el-option | 55 | <el-option |
| 56 | v-for="item in userOption" | 56 | v-for="item in userOption" |
| 57 | - :key="parseInt(item.id)" | 57 | + :key="item.id" |
| 58 | :label="item.nickname" | 58 | :label="item.nickname" |
| 59 | - :value="parseInt(item.id)" | 59 | + :value="item.id" |
| 60 | /> | 60 | /> |
| 61 | </el-select> | 61 | </el-select> |
| 62 | </template> | 62 | </template> |
| @@ -83,7 +83,7 @@ import { VxeGridInstance } from 'vxe-table' | @@ -83,7 +83,7 @@ import { VxeGridInstance } from 'vxe-table' | ||
| 83 | import { ElSelect, ElTreeSelect, ElOption } from 'element-plus' | 83 | import { ElSelect, ElTreeSelect, ElOption } from 'element-plus' |
| 84 | import { allSchemas } from './dept.data' | 84 | import { allSchemas } from './dept.data' |
| 85 | import * as DeptApi from '@/api/system/dept' | 85 | import * as DeptApi from '@/api/system/dept' |
| 86 | -import { getListSimpleUsersApi } from '@/api/system/user' | 86 | +import { getListSimpleUsersApi, UserVO } from '@/api/system/user' |
| 87 | import { required } from '@/utils/formRules.js' | 87 | import { required } from '@/utils/formRules.js' |
| 88 | import { handleTree } from '@/utils/tree' | 88 | import { handleTree } from '@/utils/tree' |
| 89 | import { FormExpose } from '@/components/Form' | 89 | import { FormExpose } from '@/components/Form' |
| @@ -99,12 +99,7 @@ const treeConfig = { | @@ -99,12 +99,7 @@ const treeConfig = { | ||
| 99 | parentField: 'parentId', | 99 | parentField: 'parentId', |
| 100 | expandAll: true | 100 | expandAll: true |
| 101 | } | 101 | } |
| 102 | -const { gridOptions, getList, deleteData } = useVxeGrid<DeptApi.DeptVO>({ | ||
| 103 | - allSchemas: allSchemas, | ||
| 104 | - treeConfig: treeConfig, | ||
| 105 | - getListApi: DeptApi.getDeptPageApi, | ||
| 106 | - deleteApi: DeptApi.deleteDeptApi | ||
| 107 | -}) | 102 | + |
| 108 | // 弹窗相关的变量 | 103 | // 弹窗相关的变量 |
| 109 | const dialogVisible = ref(false) // 是否显示弹出层 | 104 | const dialogVisible = ref(false) // 是否显示弹出层 |
| 110 | const dialogTitle = ref('edit') // 弹出层标题 | 105 | const dialogTitle = ref('edit') // 弹出层标题 |
| @@ -114,7 +109,7 @@ const deptParentId = ref(0) // 上级ID | @@ -114,7 +109,7 @@ const deptParentId = ref(0) // 上级ID | ||
| 114 | const leaderUserId = ref() | 109 | const leaderUserId = ref() |
| 115 | const formRef = ref<FormExpose>() // 表单 Ref | 110 | const formRef = ref<FormExpose>() // 表单 Ref |
| 116 | const deptOptions = ref() // 树形结构 | 111 | const deptOptions = ref() // 树形结构 |
| 117 | -const userOption = ref() | 112 | +const userOption = ref<UserVO[]>([]) |
| 118 | // 新增和修改的表单校验 | 113 | // 新增和修改的表单校验 |
| 119 | const rules = reactive({ | 114 | const rules = reactive({ |
| 120 | name: [required], | 115 | name: [required], |
| @@ -130,6 +125,10 @@ const defaultProps = { | @@ -130,6 +125,10 @@ const defaultProps = { | ||
| 130 | label: 'name', | 125 | label: 'name', |
| 131 | value: 'id' | 126 | value: 'id' |
| 132 | } | 127 | } |
| 128 | +const getUserList = async () => { | ||
| 129 | + const res = await getListSimpleUsersApi() | ||
| 130 | + userOption.value = res | ||
| 131 | +} | ||
| 133 | // 获取下拉框[上级]的数据 | 132 | // 获取下拉框[上级]的数据 |
| 134 | const getTree = async () => { | 133 | const getTree = async () => { |
| 135 | deptOptions.value = [] | 134 | deptOptions.value = [] |
| @@ -138,11 +137,12 @@ const getTree = async () => { | @@ -138,11 +137,12 @@ const getTree = async () => { | ||
| 138 | dept.children = handleTree(res) | 137 | dept.children = handleTree(res) |
| 139 | deptOptions.value.push(dept) | 138 | deptOptions.value.push(dept) |
| 140 | } | 139 | } |
| 141 | -const getUserList = async () => { | ||
| 142 | - const res = await getListSimpleUsersApi() | ||
| 143 | - userOption.value = res | ||
| 144 | -} | ||
| 145 | - | 140 | +const { gridOptions, getList, deleteData } = useVxeGrid<DeptApi.DeptVO>({ |
| 141 | + allSchemas: allSchemas, | ||
| 142 | + treeConfig: treeConfig, | ||
| 143 | + getListApi: DeptApi.getDeptPageApi, | ||
| 144 | + deleteApi: DeptApi.deleteDeptApi | ||
| 145 | +}) | ||
| 146 | // ========== 新增/修改 ========== | 146 | // ========== 新增/修改 ========== |
| 147 | 147 | ||
| 148 | // 设置标题 | 148 | // 设置标题 |
| @@ -182,10 +182,11 @@ const submitForm = async () => { | @@ -182,10 +182,11 @@ const submitForm = async () => { | ||
| 182 | const data = unref(formRef)?.formModel as DeptApi.DeptVO | 182 | const data = unref(formRef)?.formModel as DeptApi.DeptVO |
| 183 | data.parentId = deptParentId.value | 183 | data.parentId = deptParentId.value |
| 184 | data.leaderUserId = leaderUserId.value | 184 | data.leaderUserId = leaderUserId.value |
| 185 | - if (dialogTitle.value.startsWith('新增')) { | 185 | + console.info(data) |
| 186 | + if (actionType.value === 'create') { | ||
| 186 | await DeptApi.createDeptApi(data) | 187 | await DeptApi.createDeptApi(data) |
| 187 | message.success(t('common.createSuccess')) | 188 | message.success(t('common.createSuccess')) |
| 188 | - } else if (dialogTitle.value.startsWith('修改')) { | 189 | + } else if (actionType.value === 'update') { |
| 189 | await DeptApi.updateDeptApi(data) | 190 | await DeptApi.updateDeptApi(data) |
| 190 | message.success(t('common.updateSuccess')) | 191 | message.success(t('common.updateSuccess')) |
| 191 | } | 192 | } |