Commit d677207af13d7cb6d9fdc3ca306d383c08bdd18e

Authored by xingyu
1 parent 7455348a

fix: user

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