Commit 905385d4ae11c7a61b0155fc0c7ad748a26feeee
1 parent
998d23db
Revert "perf: crud"
This reverts commit 0b23ce416e1f58d725faaf96a65d6ee2dffd5bc6.
Showing
3 changed files
with
39 additions
and
25 deletions
yudao-ui-admin-vue3/src/hooks/web/useCrudSchemas.ts
| ... | ... | @@ -7,14 +7,10 @@ import { DescriptionsSchema } from '@/types/descriptions' |
| 7 | 7 | import { ComponentOptions } from '@/types/components' |
| 8 | 8 | |
| 9 | 9 | export type CrudSchema = Omit<TableColumn, 'children'> & { |
| 10 | - isSearch?: boolean // 是否在查询显示 | |
| 11 | - search?: CrudSearchParams // 查询的详细配置 | |
| 12 | - isTable?: boolean // 是否在列表显示 | |
| 13 | - table?: CrudTableParams // 列表的详细配置 | |
| 14 | - isForm?: boolean // 是否在表单显示 | |
| 15 | - form?: CrudFormParams // 表单的详细配置 | |
| 16 | - isDetail?: boolean // 是否在详情显示 | |
| 17 | - detail?: CrudDescriptionsParams // 详情的详细配置 | |
| 10 | + search?: CrudSearchParams | |
| 11 | + table?: CrudTableParams | |
| 12 | + form?: CrudFormParams | |
| 13 | + detail?: CrudDescriptionsParams | |
| 18 | 14 | children?: CrudSchema[] |
| 19 | 15 | dictType?: string // 字典类型 |
| 20 | 16 | dictData?: 'string' | 'number' | 'boolean' // 字典数据类型 string | number | boolean |
| ... | ... | @@ -84,7 +80,7 @@ const filterSearchSchema = (crudSchema: CrudSchema[]): FormSchema[] => { |
| 84 | 80 | |
| 85 | 81 | eachTree(crudSchema, (schemaItem: CrudSchema) => { |
| 86 | 82 | // 判断是否显示 |
| 87 | - if (schemaItem?.isSearch || schemaItem.search?.show) { | |
| 83 | + if (schemaItem?.search?.show) { | |
| 88 | 84 | let component = schemaItem?.search?.component || 'Input' |
| 89 | 85 | const options: ComponentOptions[] = [] |
| 90 | 86 | let comonentProps = {} |
| ... | ... | @@ -97,7 +93,7 @@ const filterSearchSchema = (crudSchema: CrudSchema[]): FormSchema[] => { |
| 97 | 93 | comonentProps = { |
| 98 | 94 | options: options |
| 99 | 95 | } |
| 100 | - if (!schemaItem.search?.component) component = 'Select' | |
| 96 | + if (!schemaItem.search.component) component = 'Select' | |
| 101 | 97 | } |
| 102 | 98 | const searchSchemaItem = { |
| 103 | 99 | // 默认为 input |
| ... | ... | @@ -120,7 +116,7 @@ const filterSearchSchema = (crudSchema: CrudSchema[]): FormSchema[] => { |
| 120 | 116 | const filterTableSchema = (crudSchema: CrudSchema[]): TableColumn[] => { |
| 121 | 117 | const tableColumns = treeMap<CrudSchema>(crudSchema, { |
| 122 | 118 | conversion: (schema: CrudSchema) => { |
| 123 | - if (schema?.isTable !== false || schema?.table?.show !== false) { | |
| 119 | + if (schema?.table?.show !== false) { | |
| 124 | 120 | return { |
| 125 | 121 | ...schema.table, |
| 126 | 122 | ...schema |
| ... | ... | @@ -144,7 +140,7 @@ const filterFormSchema = (crudSchema: CrudSchema[]): FormSchema[] => { |
| 144 | 140 | |
| 145 | 141 | eachTree(crudSchema, (schemaItem: CrudSchema) => { |
| 146 | 142 | // 判断是否显示 |
| 147 | - if (schemaItem?.isForm !== false || schemaItem?.form?.show == true) { | |
| 143 | + if (schemaItem?.form?.show !== false) { | |
| 148 | 144 | let component = schemaItem?.form?.component || 'Input' |
| 149 | 145 | let defaultValue: any = '' |
| 150 | 146 | if (schemaItem.form?.value) { |
| ... | ... | @@ -201,7 +197,7 @@ const filterDescriptionsSchema = (crudSchema: CrudSchema[]): DescriptionsSchema[ |
| 201 | 197 | |
| 202 | 198 | eachTree(crudSchema, (schemaItem: CrudSchema) => { |
| 203 | 199 | // 判断是否显示 |
| 204 | - if (schemaItem?.isDetail !== false || schemaItem.detail?.show !== false) { | |
| 200 | + if (schemaItem?.detail?.show !== false) { | |
| 205 | 201 | const descriptionsSchemaItem = { |
| 206 | 202 | ...schemaItem.detail, |
| 207 | 203 | field: schemaItem.field, | ... | ... |
yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts
| ... | ... | @@ -181,7 +181,7 @@ const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns |
| 181 | 181 | } |
| 182 | 182 | eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => { |
| 183 | 183 | // 判断是否显示 |
| 184 | - if (schemaItem?.isTable !== false && schemaItem?.table?.show !== false) { | |
| 184 | + if (schemaItem?.isTable !== false) { | |
| 185 | 185 | const tableSchemaItem = { |
| 186 | 186 | ...schemaItem.table, |
| 187 | 187 | field: schemaItem.field, |
| ... | ... | @@ -278,7 +278,7 @@ const filterDescriptionsSchema = (crudSchema: VxeCrudSchema): DescriptionsSchema |
| 278 | 278 | |
| 279 | 279 | eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => { |
| 280 | 280 | // 判断是否显示 |
| 281 | - if (schemaItem?.isDetail !== false || schemaItem.detail?.show !== false) { | |
| 281 | + if (schemaItem?.isDetail !== false) { | |
| 282 | 282 | const descriptionsSchemaItem = { |
| 283 | 283 | ...schemaItem.detail, |
| 284 | 284 | field: schemaItem.field, | ... | ... |
yudao-ui-admin-vue3/src/views/infra/codegen/codegen.data.ts
| ... | ... | @@ -17,28 +17,40 @@ const crudSchemas = reactive<CrudSchema[]>([ |
| 17 | 17 | label: t('common.index'), |
| 18 | 18 | field: 'id', |
| 19 | 19 | type: 'index', |
| 20 | - isForm: false, | |
| 21 | - isDetail: false | |
| 20 | + form: { | |
| 21 | + show: false | |
| 22 | + }, | |
| 23 | + detail: { | |
| 24 | + show: false | |
| 25 | + } | |
| 22 | 26 | }, |
| 23 | 27 | { |
| 24 | 28 | label: '表名称', |
| 25 | 29 | field: 'tableName', |
| 26 | - isSearch: true | |
| 30 | + search: { | |
| 31 | + show: true | |
| 32 | + } | |
| 27 | 33 | }, |
| 28 | 34 | { |
| 29 | 35 | label: '表描述', |
| 30 | 36 | field: 'tableComment', |
| 31 | - isSearch: true | |
| 37 | + search: { | |
| 38 | + show: true | |
| 39 | + } | |
| 32 | 40 | }, |
| 33 | 41 | { |
| 34 | 42 | label: '实体', |
| 35 | 43 | field: 'className', |
| 36 | - isSearch: true | |
| 44 | + search: { | |
| 45 | + show: true | |
| 46 | + } | |
| 37 | 47 | }, |
| 38 | 48 | { |
| 39 | 49 | label: t('common.createTime'), |
| 40 | 50 | field: 'createTime', |
| 41 | - isForm: false, | |
| 51 | + form: { | |
| 52 | + show: false | |
| 53 | + }, | |
| 42 | 54 | search: { |
| 43 | 55 | show: true, |
| 44 | 56 | component: 'DatePicker', |
| ... | ... | @@ -52,14 +64,20 @@ const crudSchemas = reactive<CrudSchema[]>([ |
| 52 | 64 | { |
| 53 | 65 | label: t('common.updateTime'), |
| 54 | 66 | field: 'updateTime', |
| 55 | - isForm: false | |
| 67 | + form: { | |
| 68 | + show: false | |
| 69 | + } | |
| 56 | 70 | }, |
| 57 | 71 | { |
| 58 | 72 | label: t('table.action'), |
| 59 | 73 | field: 'action', |
| 60 | - width: '350px', | |
| 61 | - isForm: false, | |
| 62 | - isDetail: false | |
| 74 | + width: '500px', | |
| 75 | + form: { | |
| 76 | + show: false | |
| 77 | + }, | |
| 78 | + detail: { | |
| 79 | + show: false | |
| 80 | + } | |
| 63 | 81 | } |
| 64 | 82 | ]) |
| 65 | 83 | export const { allSchemas } = useCrudSchemas(crudSchemas) | ... | ... |