Commit e6acf9e8dca81b0e2ca2293fb9fb3783d9a68e4c
1 parent
519b08f2
perf: crud
Showing
2 changed files
with
37 additions
and
16 deletions
yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts
| ... | ... | @@ -156,20 +156,22 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema): VxeFormItemProps[] => { |
| 156 | 156 | searchSchema.push(searchSchemaItem) |
| 157 | 157 | } |
| 158 | 158 | }) |
| 159 | - // 添加搜索按钮 | |
| 160 | - const buttons: VxeFormItemProps = { | |
| 161 | - span: 24, | |
| 162 | - align: 'center', | |
| 163 | - collapseNode: searchSchema.length > 3, | |
| 164 | - itemRender: { | |
| 165 | - name: '$buttons', | |
| 166 | - children: [ | |
| 167 | - { props: { type: 'submit', content: t('common.query'), status: 'primary' } }, | |
| 168 | - { props: { type: 'reset', content: t('common.reset') } } | |
| 169 | - ] | |
| 159 | + if (searchSchema.length > 0) { | |
| 160 | + // 添加搜索按钮 | |
| 161 | + const buttons: VxeFormItemProps = { | |
| 162 | + span: 24, | |
| 163 | + align: 'center', | |
| 164 | + collapseNode: searchSchema.length > 3, | |
| 165 | + itemRender: { | |
| 166 | + name: '$buttons', | |
| 167 | + children: [ | |
| 168 | + { props: { type: 'submit', content: t('common.query'), status: 'primary' } }, | |
| 169 | + { props: { type: 'reset', content: t('common.reset') } } | |
| 170 | + ] | |
| 171 | + } | |
| 170 | 172 | } |
| 173 | + searchSchema.push(buttons) | |
| 171 | 174 | } |
| 172 | - searchSchema.push(buttons) | |
| 173 | 175 | return searchSchema |
| 174 | 176 | } |
| 175 | 177 | ... | ... |
yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts
| ... | ... | @@ -12,10 +12,11 @@ const message = useMessage() // 消息弹窗 |
| 12 | 12 | interface UseVxeGridConfig<T = any> { |
| 13 | 13 | allSchemas: VxeAllSchemas |
| 14 | 14 | topActionSlots?: boolean // 是否开启表格内顶部操作栏插槽 |
| 15 | - treeConfig?: VxeTablePropTypes.TreeConfig | |
| 16 | - getListApi: (option: any) => Promise<T> | |
| 17 | - deleteApi?: (option: any) => Promise<T> | |
| 18 | - exportListApi?: (option: any) => Promise<T> | |
| 15 | + treeConfig?: VxeTablePropTypes.TreeConfig // 树形表单配置 | |
| 16 | + isList?: boolean // 是否不带分页的list | |
| 17 | + getListApi: (option: any) => Promise<T> // 获取列表接口 | |
| 18 | + deleteApi?: (option: any) => Promise<T> // 删除接口 | |
| 19 | + exportListApi?: (option: any) => Promise<T> // 导出接口 | |
| 19 | 20 | exportName?: string // 导出文件夹名称 |
| 20 | 21 | queryParams?: any // 其他查询参数 |
| 21 | 22 | } |
| ... | ... | @@ -110,6 +111,24 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => { |
| 110 | 111 | |
| 111 | 112 | if (config?.treeConfig) { |
| 112 | 113 | gridOptions.treeConfig = config.treeConfig |
| 114 | + } else if (config?.isList) { | |
| 115 | + gridOptions.proxyConfig = { | |
| 116 | + seq: true, // 启用动态序号代理(分页之后索引自动计算为当前页的起始序号) | |
| 117 | + form: true, // 启用表单代理,当点击表单提交按钮时会自动触发 reload 行为 | |
| 118 | + props: { result: 'data' }, | |
| 119 | + ajax: { | |
| 120 | + query: ({ form }) => { | |
| 121 | + let queryParams: any = Object.assign({}, JSON.parse(JSON.stringify(form))) | |
| 122 | + if (config?.queryParams) { | |
| 123 | + queryParams = Object.assign(queryParams, config.queryParams) | |
| 124 | + } | |
| 125 | + gridOptions.loading = false | |
| 126 | + return new Promise(async (resolve) => { | |
| 127 | + resolve(await config?.getListApi(queryParams)) | |
| 128 | + }) | |
| 129 | + } | |
| 130 | + } | |
| 131 | + } | |
| 113 | 132 | } else { |
| 114 | 133 | gridOptions.pagerConfig = { |
| 115 | 134 | border: false, // 带边框 | ... | ... |