Commit 9794d1cfd7b461a2b66a4960f2ab2698f607e642

Authored by xingyu4j
1 parent ecb7ade7

refactor: reloadList

yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts
@@ -113,7 +113,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => { @@ -113,7 +113,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
113 }) 113 })
114 114
115 // 刷新列表 115 // 刷新列表
116 - const getList = async (ref) => { 116 + const reloadList = async (ref) => {
117 await nextTick() 117 await nextTick()
118 ref.value?.commitProxy('query') 118 ref.value?.commitProxy('query')
119 } 119 }
@@ -147,7 +147,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => { @@ -147,7 +147,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
147 147
148 return { 148 return {
149 gridOptions, 149 gridOptions,
150 - getList, 150 + reloadList,
151 getSearchData, 151 getSearchData,
152 delList 152 delList
153 } 153 }
yudao-ui-admin-vue3/src/views/system/errorCode/index.vue
@@ -83,9 +83,10 @@ const { t } = useI18n() // 国际化 @@ -83,9 +83,10 @@ 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 } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({ 86 +const { gridOptions, reloadList, delList } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({
87 allSchemas: allSchemas, 87 allSchemas: allSchemas,
88 - getListApi: ErrorCodeApi.getErrorCodePageApi 88 + getListApi: ErrorCodeApi.getErrorCodePageApi,
  89 + delListApi: ErrorCodeApi.deleteErrorCodeApi
89 }) 90 })
90 // 弹窗相关的变量 91 // 弹窗相关的变量
91 const dialogVisible = ref(false) // 是否显示弹出层 92 const dialogVisible = ref(false) // 是否显示弹出层
@@ -125,16 +126,7 @@ const handleDetail = async (rowId: number) =&gt; { @@ -125,16 +126,7 @@ const handleDetail = async (rowId: number) =&gt; {
125 126
126 // 删除操作 127 // 删除操作
127 const handleDelete = async (rowId: number) => { 128 const handleDelete = async (rowId: number) => {
128 - message  
129 - .delConfirm()  
130 - .then(async () => {  
131 - await ErrorCodeApi.deleteErrorCodeApi(rowId)  
132 - message.success(t('common.delSuccess'))  
133 - })  
134 - .finally(() => {  
135 - // 刷新列表  
136 - xGrid.value?.commitProxy('query')  
137 - }) 129 + delList(xGrid, rowId)
138 } 130 }
139 131
140 // 提交新增/修改的表单 132 // 提交新增/修改的表单
@@ -158,7 +150,7 @@ const submitForm = async () =&gt; { @@ -158,7 +150,7 @@ const submitForm = async () =&gt; {
158 } finally { 150 } finally {
159 actionLoading.value = false 151 actionLoading.value = false
160 // 刷新列表 152 // 刷新列表
161 - xGrid.value?.commitProxy('query') 153 + reloadList(xGrid)
162 } 154 }
163 } 155 }
164 }) 156 })
yudao-ui-admin-vue3/src/views/system/loginlog/index.vue
@@ -42,7 +42,7 @@ const { t } = useI18n() // 国际化 @@ -42,7 +42,7 @@ const { t } = useI18n() // 国际化
42 const message = useMessage() // 消息弹窗 42 const message = useMessage() // 消息弹窗
43 // 列表相关的变量 43 // 列表相关的变量
44 const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref 44 const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
45 -const { gridOptions } = useVxeGrid<LoginLogVO>({ 45 +const { gridOptions, getSearchData } = useVxeGrid<LoginLogVO>({
46 allSchemas: allSchemas, 46 allSchemas: allSchemas,
47 getListApi: getLoginLogPageApi 47 getListApi: getLoginLogPageApi
48 }) 48 })
@@ -61,10 +61,7 @@ const handleDetail = async (row: LoginLogVO) =&gt; { @@ -61,10 +61,7 @@ const handleDetail = async (row: LoginLogVO) =&gt; {
61 // 导出操作 61 // 导出操作
62 const handleExport = async () => { 62 const handleExport = async () => {
63 message.exportConfirm().then(async () => { 63 message.exportConfirm().then(async () => {
64 - const queryParams = Object.assign(  
65 - {},  
66 - JSON.parse(JSON.stringify(xGrid.value?.getRefMaps().refForm.value.data)) // TODO @星语:这个有没办法,封装个 util 获取哈?  
67 - ) 64 + const queryParams = await getSearchData(xGrid)
68 const res = await exportLoginLogApi(queryParams) 65 const res = await exportLoginLogApi(queryParams)
69 download.excel(res, '登录列表.xls') 66 download.excel(res, '登录列表.xls')
70 }) 67 })
yudao-ui-admin-vue3/src/views/system/notice/index.vue
@@ -82,9 +82,10 @@ const { t } = useI18n() // 国际化 @@ -82,9 +82,10 @@ 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 } = useVxeGrid<NoticeApi.NoticeVO>({ 85 +const { gridOptions, reloadList, delList } = useVxeGrid<NoticeApi.NoticeVO>({
86 allSchemas: allSchemas, 86 allSchemas: allSchemas,
87 - getListApi: NoticeApi.getNoticePageApi 87 + getListApi: NoticeApi.getNoticePageApi,
  88 + delListApi: NoticeApi.deleteNoticeApi
88 }) 89 })
89 // 弹窗相关的变量 90 // 弹窗相关的变量
90 const dialogVisible = ref(false) // 是否显示弹出层 91 const dialogVisible = ref(false) // 是否显示弹出层
@@ -124,16 +125,7 @@ const handleDetail = async (rowId: number) =&gt; { @@ -124,16 +125,7 @@ const handleDetail = async (rowId: number) =&gt; {
124 125
125 // 删除操作 126 // 删除操作
126 const handleDelete = async (rowId: number) => { 127 const handleDelete = async (rowId: number) => {
127 - message  
128 - .delConfirm()  
129 - .then(async () => {  
130 - await NoticeApi.deleteNoticeApi(rowId)  
131 - message.success(t('common.delSuccess'))  
132 - })  
133 - .finally(() => {  
134 - // 刷新列表  
135 - xGrid.value?.commitProxy('query')  
136 - }) 128 + delList(xGrid, rowId)
137 } 129 }
138 130
139 // 提交新增/修改的表单 131 // 提交新增/修改的表单
@@ -157,7 +149,7 @@ const submitForm = async () =&gt; { @@ -157,7 +149,7 @@ const submitForm = async () =&gt; {
157 } finally { 149 } finally {
158 actionLoading.value = false 150 actionLoading.value = false
159 // 刷新列表 151 // 刷新列表
160 - xGrid.value?.commitProxy('query') 152 + reloadList(xGrid)
161 } 153 }
162 } 154 }
163 }) 155 })
yudao-ui-admin-vue3/src/views/system/oauth2/client/index.vue
@@ -94,9 +94,10 @@ const message = useMessage() // 消息弹窗 @@ -94,9 +94,10 @@ const message = useMessage() // 消息弹窗
94 94
95 // 列表相关的变量 95 // 列表相关的变量
96 const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref 96 const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
97 -const { gridOptions } = useVxeGrid<ClientApi.OAuth2ClientVO>({ 97 +const { gridOptions, reloadList, delList } = useVxeGrid<ClientApi.OAuth2ClientVO>({
98 allSchemas: allSchemas, 98 allSchemas: allSchemas,
99 - getListApi: ClientApi.getOAuth2ClientPageApi 99 + getListApi: ClientApi.getOAuth2ClientPageApi,
  100 + delListApi: ClientApi.deleteOAuth2ClientApi
100 }) 101 })
101 // 弹窗相关的变量 102 // 弹窗相关的变量
102 const dialogVisible = ref(false) // 是否显示弹出层 103 const dialogVisible = ref(false) // 是否显示弹出层
@@ -135,16 +136,7 @@ const handleDetail = async (rowId: number) =&gt; { @@ -135,16 +136,7 @@ const handleDetail = async (rowId: number) =&gt; {
135 136
136 // 删除操作 137 // 删除操作
137 const handleDelete = async (rowId: number) => { 138 const handleDelete = async (rowId: number) => {
138 - message  
139 - .delConfirm()  
140 - .then(async () => {  
141 - await ClientApi.deleteOAuth2ClientApi(rowId)  
142 - message.success(t('common.delSuccess'))  
143 - })  
144 - .finally(() => {  
145 - // 刷新列表  
146 - xGrid.value?.commitProxy('query')  
147 - }) 139 + delList(xGrid, rowId)
148 } 140 }
149 141
150 // 提交新增/修改的表单 142 // 提交新增/修改的表单
@@ -168,7 +160,7 @@ const submitForm = async () =&gt; { @@ -168,7 +160,7 @@ const submitForm = async () =&gt; {
168 } finally { 160 } finally {
169 actionLoading.value = false 161 actionLoading.value = false
170 // 刷新列表 162 // 刷新列表
171 - xGrid.value?.commitProxy('query') 163 + reloadList(xGrid)
172 } 164 }
173 } 165 }
174 }) 166 })
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 } = useVxeGrid<TokenApi.OAuth2TokenVO>({ 42 +const { gridOptions, reloadList } = 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(() => { 66 .finally(() => {
67 // 刷新列表 67 // 刷新列表
68 - xGrid.value?.commitProxy('query') 68 + reloadList(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, getList, delList, getSearchData } = useVxeGrid<PostApi.PostVO>({ 93 +const { gridOptions, reloadList, delList, getSearchData } = useVxeGrid<PostApi.PostVO>({
94 allSchemas: allSchemas, 94 allSchemas: allSchemas,
95 getListApi: PostApi.getPostPageApi, 95 getListApi: PostApi.getPostPageApi,
96 delListApi: PostApi.deletePostApi 96 delListApi: PostApi.deletePostApi
@@ -163,7 +163,7 @@ const submitForm = async () =&gt; { @@ -163,7 +163,7 @@ const submitForm = async () =&gt; {
163 } finally { 163 } finally {
164 actionLoading.value = false 164 actionLoading.value = false
165 // 刷新列表 165 // 刷新列表
166 - getList(xGrid) 166 + reloadList(xGrid)
167 } 167 }
168 } 168 }
169 }) 169 })