Commit d677207af13d7cb6d9fdc3ca306d383c08bdd18e
1 parent
7455348a
fix: user
Showing
11 changed files
with
47 additions
and
49 deletions
yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts
| ... | ... | @@ -14,7 +14,8 @@ interface UseVxeGridConfig<T = any> { |
| 14 | 14 | getListApi: (option: any) => Promise<T> |
| 15 | 15 | deleteApi?: (option: any) => Promise<T> |
| 16 | 16 | exportListApi?: (option: any) => Promise<T> |
| 17 | - exportName?: string | |
| 17 | + exportName?: string // 导出文件夹名称 | |
| 18 | + queryParams?: any // 其他查询参数 | |
| 18 | 19 | } |
| 19 | 20 | |
| 20 | 21 | const appStore = useAppStore() |
| ... | ... | @@ -64,7 +65,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => { |
| 64 | 65 | pagerConfig: { |
| 65 | 66 | border: false, // 带边框 |
| 66 | 67 | background: true, // 带背景颜色 |
| 67 | - perfect: true, // 配套的样式 | |
| 68 | + perfect: false, // 配套的样式 | |
| 68 | 69 | pageSize: 10, // 每页大小 |
| 69 | 70 | pagerCount: 7, // 显示页码按钮的数量 |
| 70 | 71 | autoHidden: true, // 当只有一页时自动隐藏 |
| ... | ... | @@ -72,11 +73,11 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => { |
| 72 | 73 | layouts: [ |
| 73 | 74 | 'PrevJump', |
| 74 | 75 | 'PrevPage', |
| 75 | - 'Jump', | |
| 76 | - 'PageCount', | |
| 76 | + 'JumpNumber', | |
| 77 | 77 | 'NextPage', |
| 78 | 78 | 'NextJump', |
| 79 | 79 | 'Sizes', |
| 80 | + 'FullJump', | |
| 80 | 81 | 'Total' |
| 81 | 82 | ] |
| 82 | 83 | }, |
| ... | ... | @@ -86,7 +87,10 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => { |
| 86 | 87 | props: { result: 'list', total: 'total' }, |
| 87 | 88 | ajax: { |
| 88 | 89 | query: ({ page, form }) => { |
| 89 | - const queryParams = Object.assign({}, JSON.parse(JSON.stringify(form))) | |
| 90 | + let queryParams: any = Object.assign({}, JSON.parse(JSON.stringify(form))) | |
| 91 | + if (config?.queryParams) { | |
| 92 | + queryParams = Object.assign(queryParams, config.queryParams) | |
| 93 | + } | |
| 90 | 94 | queryParams.pageSize = page.pageSize |
| 91 | 95 | queryParams.pageNo = page.currentPage |
| 92 | 96 | gridOptions.loading = false |
| ... | ... | @@ -121,7 +125,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => { |
| 121 | 125 | * @param ref |
| 122 | 126 | * @returns |
| 123 | 127 | */ |
| 124 | - const reloadList = async (ref) => { | |
| 128 | + const getList = async (ref) => { | |
| 125 | 129 | if (!ref) { |
| 126 | 130 | console.error('未传入gridRef') |
| 127 | 131 | return |
| ... | ... | @@ -214,7 +218,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => { |
| 214 | 218 | |
| 215 | 219 | return { |
| 216 | 220 | gridOptions, |
| 217 | - reloadList, | |
| 221 | + getList, | |
| 218 | 222 | getSearchData, |
| 219 | 223 | deleteData, |
| 220 | 224 | exportList, | ... | ... |
yudao-ui-admin-vue3/src/views/system/errorCode/index.vue
| ... | ... | @@ -83,7 +83,7 @@ const { t } = useI18n() // 国际化 |
| 83 | 83 | const message = useMessage() // 消息弹窗 |
| 84 | 84 | // 列表相关的变量 |
| 85 | 85 | const xGrid = ref<VxeGridInstance>() // grid Ref |
| 86 | -const { gridOptions, reloadList, deleteData } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({ | |
| 86 | +const { gridOptions, getList, deleteData } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({ | |
| 87 | 87 | allSchemas: allSchemas, |
| 88 | 88 | getListApi: ErrorCodeApi.getErrorCodePageApi, |
| 89 | 89 | deleteApi: ErrorCodeApi.deleteErrorCodeApi |
| ... | ... | @@ -150,7 +150,7 @@ const submitForm = async () => { |
| 150 | 150 | } finally { |
| 151 | 151 | actionLoading.value = false |
| 152 | 152 | // 刷新列表 |
| 153 | - await reloadList(xGrid) | |
| 153 | + await getList(xGrid) | |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | }) | ... | ... |
yudao-ui-admin-vue3/src/views/system/notice/index.vue
| ... | ... | @@ -82,7 +82,7 @@ const { t } = useI18n() // 国际化 |
| 82 | 82 | const message = useMessage() // 消息弹窗 |
| 83 | 83 | // 列表相关的变量 |
| 84 | 84 | const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref |
| 85 | -const { gridOptions, reloadList, deleteData } = useVxeGrid<NoticeApi.NoticeVO>({ | |
| 85 | +const { gridOptions, getList, deleteData } = useVxeGrid<NoticeApi.NoticeVO>({ | |
| 86 | 86 | allSchemas: allSchemas, |
| 87 | 87 | getListApi: NoticeApi.getNoticePageApi, |
| 88 | 88 | deleteApi: NoticeApi.deleteNoticeApi |
| ... | ... | @@ -148,7 +148,7 @@ const submitForm = async () => { |
| 148 | 148 | dialogVisible.value = false |
| 149 | 149 | } finally { |
| 150 | 150 | actionLoading.value = false |
| 151 | - await reloadList(xGrid) | |
| 151 | + await getList(xGrid) | |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | }) | ... | ... |
yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue
| ... | ... | @@ -147,7 +147,7 @@ const message = useMessage() // 消息弹窗 |
| 147 | 147 | |
| 148 | 148 | // 列表相关的变量 |
| 149 | 149 | const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref |
| 150 | -const { gridOptions, reloadList, deleteData } = useVxeGrid<ClientApi.OAuth2ClientVO>({ | |
| 150 | +const { gridOptions, getList, deleteData } = useVxeGrid<ClientApi.OAuth2ClientVO>({ | |
| 151 | 151 | allSchemas: allSchemas, |
| 152 | 152 | getListApi: ClientApi.getOAuth2ClientPageApi, |
| 153 | 153 | deleteApi: ClientApi.deleteOAuth2ClientApi |
| ... | ... | @@ -213,7 +213,7 @@ const submitForm = async () => { |
| 213 | 213 | } finally { |
| 214 | 214 | actionLoading.value = false |
| 215 | 215 | // 刷新列表 |
| 216 | - await reloadList(xGrid) | |
| 216 | + await getList(xGrid) | |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | }) | ... | ... |
yudao-ui-admin-vue3/src/views/system/oauth2/token/index.vue
| ... | ... | @@ -39,7 +39,7 @@ const { t } = useI18n() // 国际化 |
| 39 | 39 | const message = useMessage() // 消息弹窗 |
| 40 | 40 | // 列表相关的变量 |
| 41 | 41 | const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref |
| 42 | -const { gridOptions, reloadList } = useVxeGrid<TokenApi.OAuth2TokenVO>({ | |
| 42 | +const { gridOptions, getList } = useVxeGrid<TokenApi.OAuth2TokenVO>({ | |
| 43 | 43 | allSchemas: allSchemas, |
| 44 | 44 | getListApi: TokenApi.getAccessTokenPageApi |
| 45 | 45 | }) |
| ... | ... | @@ -65,7 +65,7 @@ const handleForceLogout = (rowId: number) => { |
| 65 | 65 | }) |
| 66 | 66 | .finally(async () => { |
| 67 | 67 | // 刷新列表 |
| 68 | - await reloadList(xGrid) | |
| 68 | + await getList(xGrid) | |
| 69 | 69 | }) |
| 70 | 70 | } |
| 71 | 71 | </script> | ... | ... |
yudao-ui-admin-vue3/src/views/system/post/index.vue
| ... | ... | @@ -90,7 +90,7 @@ const { t } = useI18n() // 国际化 |
| 90 | 90 | const message = useMessage() // 消息弹窗 |
| 91 | 91 | // 列表相关的变量 |
| 92 | 92 | const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref |
| 93 | -const { gridOptions, reloadList, deleteData, exportList } = useVxeGrid<PostApi.PostVO>({ | |
| 93 | +const { gridOptions, getList, deleteData, exportList } = useVxeGrid<PostApi.PostVO>({ | |
| 94 | 94 | allSchemas: allSchemas, |
| 95 | 95 | getListApi: PostApi.getPostPageApi, |
| 96 | 96 | deleteApi: PostApi.deletePostApi, |
| ... | ... | @@ -167,7 +167,7 @@ const submitForm = async () => { |
| 167 | 167 | } finally { |
| 168 | 168 | actionLoading.value = false |
| 169 | 169 | // 刷新列表 |
| 170 | - await reloadList(xGrid) | |
| 170 | + await getList(xGrid) | |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | }) | ... | ... |
yudao-ui-admin-vue3/src/views/system/role/index.vue
| ... | ... | @@ -174,7 +174,7 @@ const { t } = useI18n() // 国际化 |
| 174 | 174 | const message = useMessage() // 消息弹窗 |
| 175 | 175 | // 列表相关的变量 |
| 176 | 176 | const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref |
| 177 | -const { gridOptions, reloadList, deleteData } = useVxeGrid<RoleApi.RoleVO>({ | |
| 177 | +const { gridOptions, getList, deleteData } = useVxeGrid<RoleApi.RoleVO>({ | |
| 178 | 178 | allSchemas: allSchemas, |
| 179 | 179 | getListApi: RoleApi.getRolePageApi, |
| 180 | 180 | deleteApi: RoleApi.deleteRoleApi |
| ... | ... | @@ -242,7 +242,7 @@ const submitForm = async () => { |
| 242 | 242 | } finally { |
| 243 | 243 | actionLoading.value = false |
| 244 | 244 | // 刷新列表 |
| 245 | - await reloadList(xGrid) | |
| 245 | + await getList(xGrid) | |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | }) | ... | ... |
yudao-ui-admin-vue3/src/views/system/sms/smsChannel/index.vue
| ... | ... | @@ -85,7 +85,7 @@ const message = useMessage() // 消息弹窗 |
| 85 | 85 | |
| 86 | 86 | // 列表相关的变量 |
| 87 | 87 | const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref |
| 88 | -const { gridOptions, reloadList, deleteData } = useVxeGrid<SmsChannelApi.SmsChannelVO>({ | |
| 88 | +const { gridOptions, getList, deleteData } = useVxeGrid<SmsChannelApi.SmsChannelVO>({ | |
| 89 | 89 | allSchemas: allSchemas, |
| 90 | 90 | getListApi: SmsChannelApi.getSmsChannelPageApi, |
| 91 | 91 | deleteApi: SmsChannelApi.deleteSmsChannelApi |
| ... | ... | @@ -152,7 +152,7 @@ const submitForm = async () => { |
| 152 | 152 | } finally { |
| 153 | 153 | actionLoading.value = false |
| 154 | 154 | // 刷新列表 |
| 155 | - await reloadList(xGrid) | |
| 155 | + await getList(xGrid) | |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | }) | ... | ... |
yudao-ui-admin-vue3/src/views/system/sms/smsTemplate/index.vue
| ... | ... | @@ -128,7 +128,7 @@ const message = useMessage() // 消息弹窗 |
| 128 | 128 | |
| 129 | 129 | // 列表相关的变量 |
| 130 | 130 | const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref |
| 131 | -const { gridOptions, reloadList, deleteData } = useVxeGrid<SmsTemplateApi.SmsTemplateVO>({ | |
| 131 | +const { gridOptions, getList, deleteData } = useVxeGrid<SmsTemplateApi.SmsTemplateVO>({ | |
| 132 | 132 | allSchemas: allSchemas, |
| 133 | 133 | getListApi: SmsTemplateApi.getSmsTemplatePageApi, |
| 134 | 134 | deleteApi: SmsTemplateApi.deleteSmsTemplateApi |
| ... | ... | @@ -196,7 +196,7 @@ const submitForm = async () => { |
| 196 | 196 | } finally { |
| 197 | 197 | actionLoading.value = false |
| 198 | 198 | // 刷新列表 |
| 199 | - await reloadList(xGrid) | |
| 199 | + await getList(xGrid) | |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | }) | ... | ... |
yudao-ui-admin-vue3/src/views/system/user/index.vue
| ... | ... | @@ -242,7 +242,7 @@ |
| 242 | 242 | </XModal> |
| 243 | 243 | </template> |
| 244 | 244 | <script setup lang="ts"> |
| 245 | -import { onMounted, reactive, ref, unref, watch } from 'vue' | |
| 245 | +import { nextTick, onMounted, reactive, ref, unref, watch } from 'vue' | |
| 246 | 246 | import { |
| 247 | 247 | ElTag, |
| 248 | 248 | ElInput, |
| ... | ... | @@ -287,18 +287,20 @@ const defaultProps = { |
| 287 | 287 | label: 'name', |
| 288 | 288 | value: 'id' |
| 289 | 289 | } |
| 290 | - | |
| 290 | +const queryParams = reactive({ | |
| 291 | + deptId: null | |
| 292 | +}) | |
| 291 | 293 | // ========== 列表相关 ========== |
| 292 | 294 | const tableTitle = ref('用户列表') |
| 293 | 295 | // 列表相关的变量 |
| 294 | 296 | const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref |
| 295 | -const { gridOptions, reloadList, deleteData, exportList, getSearchData } = | |
| 296 | - useVxeGrid<UserApi.UserVO>({ | |
| 297 | - allSchemas: allSchemas, | |
| 298 | - getListApi: UserApi.getUserPageApi, | |
| 299 | - deleteApi: UserApi.deleteUserApi, | |
| 300 | - exportListApi: UserApi.exportUserApi | |
| 301 | - }) | |
| 297 | +const { gridOptions, getList, deleteData, exportList } = useVxeGrid<UserApi.UserVO>({ | |
| 298 | + allSchemas: allSchemas, | |
| 299 | + queryParams: queryParams, | |
| 300 | + getListApi: UserApi.getUserPageApi, | |
| 301 | + deleteApi: UserApi.deleteUserApi, | |
| 302 | + exportListApi: UserApi.exportUserApi | |
| 303 | +}) | |
| 302 | 304 | // ========== 创建部门树结构 ========== |
| 303 | 305 | const filterText = ref('') |
| 304 | 306 | const deptOptions = ref<any[]>([]) // 树形结构 |
| ... | ... | @@ -312,13 +314,8 @@ const filterNode = (value: string, data: Tree) => { |
| 312 | 314 | return data.name.includes(value) |
| 313 | 315 | } |
| 314 | 316 | const handleDeptNodeClick = async (row: { [key: string]: any }) => { |
| 315 | - tableTitle.value = row.name | |
| 316 | - console.log(getSearchData(xGrid)) | |
| 317 | - // gridOptions.formConfig?.data.push({ | |
| 318 | - // deptId: row.id | |
| 319 | - // }) | |
| 320 | - // TODO 查询 | |
| 321 | - await reloadList(xGrid) | |
| 317 | + queryParams.deptId = row.id | |
| 318 | + await getList(xGrid) | |
| 322 | 319 | } |
| 323 | 320 | const { push } = useRouter() |
| 324 | 321 | const handleDeptEdit = () => { |
| ... | ... | @@ -351,17 +348,16 @@ const setDialogTile = async (type: string) => { |
| 351 | 348 | |
| 352 | 349 | // 新增操作 |
| 353 | 350 | const handleCreate = async () => { |
| 354 | - actionType.value = 'create' | |
| 351 | + setDialogTile('create') | |
| 355 | 352 | // 重置表单 |
| 356 | 353 | deptId.value = null |
| 357 | 354 | postIds.value = [] |
| 358 | - dialogVisible.value = true | |
| 359 | - dialogTitle.value = t('action.create') | |
| 360 | 355 | } |
| 361 | 356 | |
| 362 | 357 | // 修改操作 |
| 363 | 358 | const handleUpdate = async (rowId: number) => { |
| 364 | 359 | setDialogTile('update') |
| 360 | + await nextTick() | |
| 365 | 361 | unref(formRef)?.delSchema('username') |
| 366 | 362 | unref(formRef)?.delSchema('password') |
| 367 | 363 | // 设置数据 |
| ... | ... | @@ -400,8 +396,9 @@ const submitForm = async () => { |
| 400 | 396 | } |
| 401 | 397 | dialogVisible.value = false |
| 402 | 398 | } finally { |
| 399 | + // unref(formRef)?.setSchema(allSchemas.formSchema) | |
| 403 | 400 | // 刷新列表 |
| 404 | - await reloadList(xGrid) | |
| 401 | + await getList(xGrid) | |
| 405 | 402 | loading.value = false |
| 406 | 403 | } |
| 407 | 404 | } |
| ... | ... | @@ -416,7 +413,7 @@ const handleStatusChange = async (row: UserApi.UserVO) => { |
| 416 | 413 | await UserApi.updateUserStatusApi(row.id, row.status) |
| 417 | 414 | message.success(text + '成功') |
| 418 | 415 | // 刷新列表 |
| 419 | - await reloadList(xGrid) | |
| 416 | + await getList(xGrid) | |
| 420 | 417 | }) |
| 421 | 418 | .catch(() => { |
| 422 | 419 | row.status = |
| ... | ... | @@ -516,7 +513,7 @@ const handleFileSuccess = async (response: any): Promise<void> => { |
| 516 | 513 | text += '< ' + username + ': ' + data.failureUsernames[username] + ' >' |
| 517 | 514 | } |
| 518 | 515 | message.alert(text) |
| 519 | - await reloadList(xGrid) | |
| 516 | + await getList(xGrid) | |
| 520 | 517 | } |
| 521 | 518 | // 文件数超出提示 |
| 522 | 519 | const handleExceed = (): void => { | ... | ... |
yudao-ui-admin-vue3/src/views/system/user/user.data.ts