perf: crud
This commit is contained in:
parent
519b08f251
commit
e6acf9e8dc
@ -156,6 +156,7 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema): VxeFormItemProps[] => {
|
|||||||
searchSchema.push(searchSchemaItem)
|
searchSchema.push(searchSchemaItem)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (searchSchema.length > 0) {
|
||||||
// 添加搜索按钮
|
// 添加搜索按钮
|
||||||
const buttons: VxeFormItemProps = {
|
const buttons: VxeFormItemProps = {
|
||||||
span: 24,
|
span: 24,
|
||||||
@ -170,6 +171,7 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema): VxeFormItemProps[] => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
searchSchema.push(buttons)
|
searchSchema.push(buttons)
|
||||||
|
}
|
||||||
return searchSchema
|
return searchSchema
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,10 +12,11 @@ const message = useMessage() // 消息弹窗
|
|||||||
interface UseVxeGridConfig<T = any> {
|
interface UseVxeGridConfig<T = any> {
|
||||||
allSchemas: VxeAllSchemas
|
allSchemas: VxeAllSchemas
|
||||||
topActionSlots?: boolean // 是否开启表格内顶部操作栏插槽
|
topActionSlots?: boolean // 是否开启表格内顶部操作栏插槽
|
||||||
treeConfig?: VxeTablePropTypes.TreeConfig
|
treeConfig?: VxeTablePropTypes.TreeConfig // 树形表单配置
|
||||||
getListApi: (option: any) => Promise<T>
|
isList?: boolean // 是否不带分页的list
|
||||||
deleteApi?: (option: any) => Promise<T>
|
getListApi: (option: any) => Promise<T> // 获取列表接口
|
||||||
exportListApi?: (option: any) => Promise<T>
|
deleteApi?: (option: any) => Promise<T> // 删除接口
|
||||||
|
exportListApi?: (option: any) => Promise<T> // 导出接口
|
||||||
exportName?: string // 导出文件夹名称
|
exportName?: string // 导出文件夹名称
|
||||||
queryParams?: any // 其他查询参数
|
queryParams?: any // 其他查询参数
|
||||||
}
|
}
|
||||||
@ -110,6 +111,24 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
|
|||||||
|
|
||||||
if (config?.treeConfig) {
|
if (config?.treeConfig) {
|
||||||
gridOptions.treeConfig = config.treeConfig
|
gridOptions.treeConfig = config.treeConfig
|
||||||
|
} else if (config?.isList) {
|
||||||
|
gridOptions.proxyConfig = {
|
||||||
|
seq: true, // 启用动态序号代理(分页之后索引自动计算为当前页的起始序号)
|
||||||
|
form: true, // 启用表单代理,当点击表单提交按钮时会自动触发 reload 行为
|
||||||
|
props: { result: 'data' },
|
||||||
|
ajax: {
|
||||||
|
query: ({ form }) => {
|
||||||
|
let queryParams: any = Object.assign({}, JSON.parse(JSON.stringify(form)))
|
||||||
|
if (config?.queryParams) {
|
||||||
|
queryParams = Object.assign(queryParams, config.queryParams)
|
||||||
|
}
|
||||||
|
gridOptions.loading = false
|
||||||
|
return new Promise(async (resolve) => {
|
||||||
|
resolve(await config?.getListApi(queryParams))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
gridOptions.pagerConfig = {
|
gridOptions.pagerConfig = {
|
||||||
border: false, // 带边框
|
border: false, // 带边框
|
||||||
|
Loading…
Reference in New Issue
Block a user