fix: fix parmas to params
This commit is contained in:
parent
9f9cf0bf04
commit
2c7211c89d
|
@ -24,7 +24,7 @@ interface TableObject<K, L> {
|
||||||
currentPage: number
|
currentPage: number
|
||||||
total: number
|
total: number
|
||||||
tableList: K[]
|
tableList: K[]
|
||||||
parmasObj: L
|
paramsObj: L
|
||||||
loading: boolean
|
loading: boolean
|
||||||
currentRow: Nullable<K>
|
currentRow: Nullable<K>
|
||||||
}
|
}
|
||||||
|
@ -42,17 +42,17 @@ export const useTable = <T, K, L extends AxiosConfig = AxiosConfig>(
|
||||||
// 表格数据
|
// 表格数据
|
||||||
tableList: [],
|
tableList: [],
|
||||||
// AxiosConfig 配置
|
// AxiosConfig 配置
|
||||||
parmasObj: {} as L,
|
paramsObj: {} as L,
|
||||||
// 加载中
|
// 加载中
|
||||||
loading: true,
|
loading: true,
|
||||||
// 当前行的数据
|
// 当前行的数据
|
||||||
currentRow: null
|
currentRow: null
|
||||||
})
|
})
|
||||||
|
|
||||||
const parmasObj = computed(() => {
|
const paramsObj = computed(() => {
|
||||||
return {
|
return {
|
||||||
params: {
|
params: {
|
||||||
...tableObject.parmasObj.params,
|
...tableObject.paramsObj.params,
|
||||||
pageSize: tableObject.pageSize,
|
pageSize: tableObject.pageSize,
|
||||||
pageIndex: tableObject.currentPage
|
pageIndex: tableObject.currentPage
|
||||||
}
|
}
|
||||||
|
@ -116,14 +116,14 @@ export const useTable = <T, K, L extends AxiosConfig = AxiosConfig>(
|
||||||
setProps: (props: Recordable) => void
|
setProps: (props: Recordable) => void
|
||||||
getList: () => Promise<void>
|
getList: () => Promise<void>
|
||||||
setColumn: (columnProps: TableSetPropsType[]) => void
|
setColumn: (columnProps: TableSetPropsType[]) => void
|
||||||
setSearchParmas: (data: Recordable) => void
|
setSearchParams: (data: Recordable) => void
|
||||||
getSelections: () => Promise<K[]>
|
getSelections: () => Promise<K[]>
|
||||||
delList: (ids: string[] | number[], multiple: boolean, message?: boolean) => Promise<void>
|
delList: (ids: string[] | number[], multiple: boolean, message?: boolean) => Promise<void>
|
||||||
} = {
|
} = {
|
||||||
getList: async () => {
|
getList: async () => {
|
||||||
tableObject.loading = true
|
tableObject.loading = true
|
||||||
const res = await config
|
const res = await config
|
||||||
?.getListApi(unref(parmasObj) as unknown as L)
|
?.getListApi(unref(paramsObj) as unknown as L)
|
||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
tableObject.loading = false
|
tableObject.loading = false
|
||||||
|
@ -146,9 +146,9 @@ export const useTable = <T, K, L extends AxiosConfig = AxiosConfig>(
|
||||||
return (table?.selections || []) as K[]
|
return (table?.selections || []) as K[]
|
||||||
},
|
},
|
||||||
// 与Search组件结合
|
// 与Search组件结合
|
||||||
setSearchParmas: (data: Recordable) => {
|
setSearchParams: (data: Recordable) => {
|
||||||
tableObject.currentPage = 1
|
tableObject.currentPage = 1
|
||||||
tableObject.parmasObj = Object.assign(tableObject.parmasObj, {
|
tableObject.paramsObj = Object.assign(tableObject.paramsObj, {
|
||||||
params: {
|
params: {
|
||||||
pageSize: tableObject.pageSize,
|
pageSize: tableObject.pageSize,
|
||||||
pageIndex: tableObject.currentPage,
|
pageIndex: tableObject.currentPage,
|
||||||
|
|
|
@ -27,7 +27,7 @@ const { register, tableObject, methods } = useTable<
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const { getList, setSearchParmas } = methods
|
const { getList, setSearchParams } = methods
|
||||||
|
|
||||||
getList()
|
getList()
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ const save = async () => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<Search :schema="searchData" @search="setSearchParmas" @reset="setSearchParmas" />
|
<Search :schema="searchData" @search="setSearchParams" @reset="setSearchParams" />
|
||||||
|
|
||||||
<div class="mb-10px">
|
<div class="mb-10px">
|
||||||
<ElButton type="primary" @click="AddAction">{{ t('exampleDemo.add') }}</ElButton>
|
<ElButton type="primary" @click="AddAction">{{ t('exampleDemo.add') }}</ElButton>
|
||||||
|
|
|
@ -32,7 +32,7 @@ const { register, tableObject, methods } = useTable<
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const { getList, setSearchParmas } = methods
|
const { getList, setSearchParams } = methods
|
||||||
|
|
||||||
getList()
|
getList()
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ const action = (row: TableData, type: string) => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<Search :schema="searchData" @search="setSearchParmas" @reset="setSearchParmas" />
|
<Search :schema="searchData" @search="setSearchParams" @reset="setSearchParams" />
|
||||||
|
|
||||||
<div class="mb-10px">
|
<div class="mb-10px">
|
||||||
<ElButton type="primary" @click="AddAction">{{ t('exampleDemo.add') }}</ElButton>
|
<ElButton type="primary" @click="AddAction">{{ t('exampleDemo.add') }}</ElButton>
|
||||||
|
|
Loading…
Reference in New Issue