Commit 5725d4862b4b7523f7efd47d133b9a3524443ea8
1 parent
bc97bd30
perf: dept
Showing
3 changed files
with
22 additions
and
15 deletions
yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts
| @@ -42,7 +42,6 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => { | @@ -42,7 +42,6 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => { | ||
| 42 | /** | 42 | /** |
| 43 | * grid options 初始化 | 43 | * grid options 初始化 |
| 44 | */ | 44 | */ |
| 45 | - console.info(config?.allSchemas.tableSchema) | ||
| 46 | const gridOptions = reactive<VxeGridProps>({ | 45 | const gridOptions = reactive<VxeGridProps>({ |
| 47 | loading: true, | 46 | loading: true, |
| 48 | size: currentSize as any, | 47 | size: currentSize as any, |
yudao-ui-admin-vue3/src/views/system/dept/dept.data.ts
| @@ -42,7 +42,12 @@ const crudSchemas = reactive<VxeCrudSchema>({ | @@ -42,7 +42,12 @@ const crudSchemas = reactive<VxeCrudSchema>({ | ||
| 42 | }, | 42 | }, |
| 43 | { | 43 | { |
| 44 | title: '负责人', | 44 | title: '负责人', |
| 45 | - field: 'leaderUserId' | 45 | + field: 'leaderUserId', |
| 46 | + table: { | ||
| 47 | + slots: { | ||
| 48 | + default: 'leaderUserId_default' | ||
| 49 | + } | ||
| 50 | + } | ||
| 46 | }, | 51 | }, |
| 47 | { | 52 | { |
| 48 | title: '联系电话', | 53 | title: '联系电话', |
yudao-ui-admin-vue3/src/views/system/dept/index.vue
| @@ -14,6 +14,9 @@ | @@ -14,6 +14,9 @@ | ||
| 14 | <XButton title="展开所有" @click="xGrid?.setAllTreeExpand(true)" /> | 14 | <XButton title="展开所有" @click="xGrid?.setAllTreeExpand(true)" /> |
| 15 | <XButton title="关闭所有" @click="xGrid?.clearTreeExpand()" /> | 15 | <XButton title="关闭所有" @click="xGrid?.clearTreeExpand()" /> |
| 16 | </template> | 16 | </template> |
| 17 | + <template #leaderUserId_default="{ row }"> | ||
| 18 | + <span>{{ userNicknameFormat(row) }}</span> | ||
| 19 | + </template> | ||
| 17 | <template #actionbtns_default="{ row }"> | 20 | <template #actionbtns_default="{ row }"> |
| 18 | <!-- 操作:修改 --> | 21 | <!-- 操作:修改 --> |
| 19 | <XTextButton | 22 | <XTextButton |
| @@ -200,21 +203,21 @@ const handleDelete = async (rowId: number) => { | @@ -200,21 +203,21 @@ const handleDelete = async (rowId: number) => { | ||
| 200 | await deleteData(xGrid, rowId) | 203 | await deleteData(xGrid, rowId) |
| 201 | } | 204 | } |
| 202 | 205 | ||
| 203 | -//const userNicknameFormat = (row) => { | ||
| 204 | -// if (!row && !row.row && !row.row.leaderUserId) { | ||
| 205 | -// return '未设置' | ||
| 206 | -// } | ||
| 207 | -// for (const user of userOption.value) { | ||
| 208 | -// if (row.row.leaderUserId === user.id) { | ||
| 209 | -// return user.nickname | ||
| 210 | -// } | ||
| 211 | -// } | ||
| 212 | -// return '未知【' + row.row.leaderUserId + '】' | ||
| 213 | -//} | ||
| 214 | -// | 206 | +const userNicknameFormat = (row) => { |
| 207 | + if (!row || !row.leaderUserId || row.leaderUserId == null) { | ||
| 208 | + return '未设置' | ||
| 209 | + } | ||
| 210 | + for (const user of userOption.value) { | ||
| 211 | + if (row.leaderUserId === user.id) { | ||
| 212 | + return user.nickname | ||
| 213 | + } | ||
| 214 | + } | ||
| 215 | + return '未知【' + row.leaderUserId + '】' | ||
| 216 | +} | ||
| 217 | + | ||
| 215 | // ========== 初始化 ========== | 218 | // ========== 初始化 ========== |
| 216 | onMounted(async () => { | 219 | onMounted(async () => { |
| 217 | - await getTree() | ||
| 218 | await getUserList() | 220 | await getUserList() |
| 221 | + await getTree() | ||
| 219 | }) | 222 | }) |
| 220 | </script> | 223 | </script> |