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 | 54 | <el-select v-model="leaderUserId"> |
| 55 | 55 | <el-option |
| 56 | 56 | v-for="item in userOption" |
| 57 | - :key="parseInt(item.id)" | |
| 57 | + :key="item.id" | |
| 58 | 58 | :label="item.nickname" |
| 59 | - :value="parseInt(item.id)" | |
| 59 | + :value="item.id" | |
| 60 | 60 | /> |
| 61 | 61 | </el-select> |
| 62 | 62 | </template> |
| ... | ... | @@ -83,7 +83,7 @@ import { VxeGridInstance } from 'vxe-table' |
| 83 | 83 | import { ElSelect, ElTreeSelect, ElOption } from 'element-plus' |
| 84 | 84 | import { allSchemas } from './dept.data' |
| 85 | 85 | import * as DeptApi from '@/api/system/dept' |
| 86 | -import { getListSimpleUsersApi } from '@/api/system/user' | |
| 86 | +import { getListSimpleUsersApi, UserVO } from '@/api/system/user' | |
| 87 | 87 | import { required } from '@/utils/formRules.js' |
| 88 | 88 | import { handleTree } from '@/utils/tree' |
| 89 | 89 | import { FormExpose } from '@/components/Form' |
| ... | ... | @@ -99,12 +99,7 @@ const treeConfig = { |
| 99 | 99 | parentField: 'parentId', |
| 100 | 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 | 104 | const dialogVisible = ref(false) // 是否显示弹出层 |
| 110 | 105 | const dialogTitle = ref('edit') // 弹出层标题 |
| ... | ... | @@ -114,7 +109,7 @@ const deptParentId = ref(0) // 上级ID |
| 114 | 109 | const leaderUserId = ref() |
| 115 | 110 | const formRef = ref<FormExpose>() // 表单 Ref |
| 116 | 111 | const deptOptions = ref() // 树形结构 |
| 117 | -const userOption = ref() | |
| 112 | +const userOption = ref<UserVO[]>([]) | |
| 118 | 113 | // 新增和修改的表单校验 |
| 119 | 114 | const rules = reactive({ |
| 120 | 115 | name: [required], |
| ... | ... | @@ -130,6 +125,10 @@ const defaultProps = { |
| 130 | 125 | label: 'name', |
| 131 | 126 | value: 'id' |
| 132 | 127 | } |
| 128 | +const getUserList = async () => { | |
| 129 | + const res = await getListSimpleUsersApi() | |
| 130 | + userOption.value = res | |
| 131 | +} | |
| 133 | 132 | // 获取下拉框[上级]的数据 |
| 134 | 133 | const getTree = async () => { |
| 135 | 134 | deptOptions.value = [] |
| ... | ... | @@ -138,11 +137,12 @@ const getTree = async () => { |
| 138 | 137 | dept.children = handleTree(res) |
| 139 | 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 | 182 | const data = unref(formRef)?.formModel as DeptApi.DeptVO |
| 183 | 183 | data.parentId = deptParentId.value |
| 184 | 184 | data.leaderUserId = leaderUserId.value |
| 185 | - if (dialogTitle.value.startsWith('新增')) { | |
| 185 | + console.info(data) | |
| 186 | + if (actionType.value === 'create') { | |
| 186 | 187 | await DeptApi.createDeptApi(data) |
| 187 | 188 | message.success(t('common.createSuccess')) |
| 188 | - } else if (dialogTitle.value.startsWith('修改')) { | |
| 189 | + } else if (actionType.value === 'update') { | |
| 189 | 190 | await DeptApi.updateDeptApi(data) |
| 190 | 191 | message.success(t('common.updateSuccess')) |
| 191 | 192 | } | ... | ... |