refactor: reloadList

pull/2/head
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() await nextTick()
ref.value?.commitProxy('query') ref.value?.commitProxy('query')
} }
@ -147,7 +147,7 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
return { return {
gridOptions, gridOptions,
getList, reloadList,
getSearchData, getSearchData,
delList delList
} }

View File

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

View File

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

View File

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

View File

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

View File

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