refactor: reloadList

This commit is contained in:
xingyu4j 2022-11-15 14:39:39 +08:00
parent ecb7ade767
commit 9794d1cfd7
7 changed files with 23 additions and 50 deletions

View File

@ -113,7 +113,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
})
// 刷新列表
const getList = async (ref) => {
const reloadList = async (ref) => {
await nextTick()
ref.value?.commitProxy('query')
}
@ -147,7 +147,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
return {
gridOptions,
getList,
reloadList,
getSearchData,
delList
}

View File

@ -83,9 +83,10 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // grid Ref
const { gridOptions } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({
const { gridOptions, reloadList, delList } = useVxeGrid<ErrorCodeApi.ErrorCodeVO>({
allSchemas: allSchemas,
getListApi: ErrorCodeApi.getErrorCodePageApi
getListApi: ErrorCodeApi.getErrorCodePageApi,
delListApi: ErrorCodeApi.deleteErrorCodeApi
})
//
const dialogVisible = ref(false) //
@ -125,16 +126,7 @@ const handleDetail = async (rowId: number) => {
//
const handleDelete = async (rowId: number) => {
message
.delConfirm()
.then(async () => {
await ErrorCodeApi.deleteErrorCodeApi(rowId)
message.success(t('common.delSuccess'))
})
.finally(() => {
//
xGrid.value?.commitProxy('query')
})
delList(xGrid, rowId)
}
// /
@ -158,7 +150,7 @@ const submitForm = async () => {
} finally {
actionLoading.value = false
//
xGrid.value?.commitProxy('query')
reloadList(xGrid)
}
}
})

View File

@ -42,7 +42,7 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions } = useVxeGrid<LoginLogVO>({
const { gridOptions, getSearchData } = useVxeGrid<LoginLogVO>({
allSchemas: allSchemas,
getListApi: getLoginLogPageApi
})
@ -61,10 +61,7 @@ const handleDetail = async (row: LoginLogVO) => {
//
const handleExport = async () => {
message.exportConfirm().then(async () => {
const queryParams = Object.assign(
{},
JSON.parse(JSON.stringify(xGrid.value?.getRefMaps().refForm.value.data)) // TODO @ util
)
const queryParams = await getSearchData(xGrid)
const res = await exportLoginLogApi(queryParams)
download.excel(res, '登录列表.xls')
})

View File

@ -82,9 +82,10 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions } = useVxeGrid<NoticeApi.NoticeVO>({
const { gridOptions, reloadList, delList } = useVxeGrid<NoticeApi.NoticeVO>({
allSchemas: allSchemas,
getListApi: NoticeApi.getNoticePageApi
getListApi: NoticeApi.getNoticePageApi,
delListApi: NoticeApi.deleteNoticeApi
})
//
const dialogVisible = ref(false) //
@ -124,16 +125,7 @@ const handleDetail = async (rowId: number) => {
//
const handleDelete = async (rowId: number) => {
message
.delConfirm()
.then(async () => {
await NoticeApi.deleteNoticeApi(rowId)
message.success(t('common.delSuccess'))
})
.finally(() => {
//
xGrid.value?.commitProxy('query')
})
delList(xGrid, rowId)
}
// /
@ -157,7 +149,7 @@ const submitForm = async () => {
} finally {
actionLoading.value = false
//
xGrid.value?.commitProxy('query')
reloadList(xGrid)
}
}
})

View File

@ -94,9 +94,10 @@ const message = useMessage() // 消息弹窗
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions } = useVxeGrid<ClientApi.OAuth2ClientVO>({
const { gridOptions, reloadList, delList } = useVxeGrid<ClientApi.OAuth2ClientVO>({
allSchemas: allSchemas,
getListApi: ClientApi.getOAuth2ClientPageApi
getListApi: ClientApi.getOAuth2ClientPageApi,
delListApi: ClientApi.deleteOAuth2ClientApi
})
//
const dialogVisible = ref(false) //
@ -135,16 +136,7 @@ const handleDetail = async (rowId: number) => {
//
const handleDelete = async (rowId: number) => {
message
.delConfirm()
.then(async () => {
await ClientApi.deleteOAuth2ClientApi(rowId)
message.success(t('common.delSuccess'))
})
.finally(() => {
//
xGrid.value?.commitProxy('query')
})
delList(xGrid, rowId)
}
// /
@ -168,7 +160,7 @@ const submitForm = async () => {
} finally {
actionLoading.value = false
//
xGrid.value?.commitProxy('query')
reloadList(xGrid)
}
}
})

View File

@ -39,7 +39,7 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions } = useVxeGrid<TokenApi.OAuth2TokenVO>({
const { gridOptions, reloadList } = useVxeGrid<TokenApi.OAuth2TokenVO>({
allSchemas: allSchemas,
getListApi: TokenApi.getAccessTokenPageApi
})
@ -65,7 +65,7 @@ const handleForceLogout = (rowId: number) => {
})
.finally(() => {
//
xGrid.value?.commitProxy('query')
reloadList(xGrid)
})
}
</script>

View File

@ -90,7 +90,7 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
//
const xGrid = ref<VxeGridInstance>() // Grid Ref
const { gridOptions, getList, delList, getSearchData } = useVxeGrid<PostApi.PostVO>({
const { gridOptions, reloadList, delList, getSearchData } = useVxeGrid<PostApi.PostVO>({
allSchemas: allSchemas,
getListApi: PostApi.getPostPageApi,
delListApi: PostApi.deletePostApi
@ -163,7 +163,7 @@ const submitForm = async () => {
} finally {
actionLoading.value = false
//
getList(xGrid)
reloadList(xGrid)
}
}
})