Commit 16b3e910e4d2d7c9cae013780f64bf6532d3c508
1 parent
b1caa1a1
perf: vxe
Showing
3 changed files
with
23 additions
and
65 deletions
yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts
| ... | ... | @@ -26,33 +26,18 @@ type VxeCrudColumns = Omit<VxeTableColumn, 'children'> & { |
| 26 | 26 | field: string |
| 27 | 27 | title?: string |
| 28 | 28 | formatter?: VxeColumnPropTypes.Formatter |
| 29 | - search?: CrudSearchParams | |
| 30 | - table?: CrudTableParams | |
| 31 | - form?: CrudFormParams | |
| 32 | - detail?: CrudDescriptionsParams | |
| 29 | + isSearch?: boolean | |
| 30 | + search?: VxeFormItemProps | |
| 31 | + isTable?: boolean | |
| 32 | + table?: VxeTableDefines.ColumnOptions | |
| 33 | + isForm?: boolean | |
| 34 | + form?: FormSchema | |
| 35 | + isDetail?: boolean | |
| 36 | + detail?: DescriptionsSchema | |
| 33 | 37 | print?: CrudPrintParams |
| 34 | 38 | children?: VxeCrudColumns[] |
| 35 | 39 | dictType?: string |
| 36 | 40 | } |
| 37 | -type CrudSearchParams = { | |
| 38 | - // 是否显示在查询项 | |
| 39 | - show?: boolean | |
| 40 | -} & Omit<VxeFormItemProps, 'field'> | |
| 41 | - | |
| 42 | -type CrudTableParams = { | |
| 43 | - // 是否显示表头 | |
| 44 | - show?: boolean | |
| 45 | -} & Omit<VxeTableDefines.ColumnOptions, 'field'> | |
| 46 | - | |
| 47 | -type CrudFormParams = { | |
| 48 | - // 是否显示表单项 | |
| 49 | - show?: boolean | |
| 50 | -} & Omit<FormSchema, 'field'> | |
| 51 | - | |
| 52 | -type CrudDescriptionsParams = { | |
| 53 | - // 是否显示表单项 | |
| 54 | - show?: boolean | |
| 55 | -} & Omit<DescriptionsSchema, 'field'> | |
| 56 | 41 | |
| 57 | 42 | type CrudPrintParams = { |
| 58 | 43 | // 是否显示表单项 |
| ... | ... | @@ -108,7 +93,7 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema): VxeFormItemProps[] => { |
| 108 | 93 | const searchSchema: VxeFormItemProps[] = [] |
| 109 | 94 | eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => { |
| 110 | 95 | // 判断是否显示 |
| 111 | - if (schemaItem?.search?.show) { | |
| 96 | + if (schemaItem?.isSearch) { | |
| 112 | 97 | let itemRenderName = schemaItem?.search?.itemRender?.name || '$input' |
| 113 | 98 | const options: any[] = [] |
| 114 | 99 | let itemRender: FormItemRenderOptions = { |
| ... | ... | @@ -122,7 +107,7 @@ const filterSearchSchema = (crudSchema: VxeCrudSchema): VxeFormItemProps[] => { |
| 122 | 107 | options.push(dict) |
| 123 | 108 | }) |
| 124 | 109 | itemRender.options = options |
| 125 | - if (!schemaItem.search.itemRender?.name) itemRenderName = '$select' | |
| 110 | + if (!schemaItem?.search?.itemRender?.name) itemRenderName = '$select' | |
| 126 | 111 | itemRender = { |
| 127 | 112 | name: itemRenderName, |
| 128 | 113 | options: options, |
| ... | ... | @@ -174,7 +159,7 @@ const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns |
| 174 | 159 | } |
| 175 | 160 | eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => { |
| 176 | 161 | // 判断是否显示 |
| 177 | - if (schemaItem?.table?.show !== false) { | |
| 162 | + if (schemaItem?.isTable !== false) { | |
| 178 | 163 | const tableSchemaItem = { |
| 179 | 164 | ...schemaItem.table, |
| 180 | 165 | field: schemaItem.field, |
| ... | ... | @@ -190,9 +175,6 @@ const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns |
| 190 | 175 | } |
| 191 | 176 | } |
| 192 | 177 | |
| 193 | - // 删除不必要的字段 | |
| 194 | - delete tableSchemaItem.show | |
| 195 | - | |
| 196 | 178 | tableSchema.push(tableSchemaItem) |
| 197 | 179 | } |
| 198 | 180 | }) |
| ... | ... | @@ -217,7 +199,7 @@ const filterFormSchema = (crudSchema: VxeCrudSchema): FormSchema[] => { |
| 217 | 199 | |
| 218 | 200 | eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => { |
| 219 | 201 | // 判断是否显示 |
| 220 | - if (schemaItem?.form?.show !== false) { | |
| 202 | + if (schemaItem?.isForm !== false) { | |
| 221 | 203 | let component = schemaItem?.form?.component || 'Input' |
| 222 | 204 | const options: ComponentOptions[] = [] |
| 223 | 205 | let comonentProps = {} |
| ... | ... | @@ -239,9 +221,6 @@ const filterFormSchema = (crudSchema: VxeCrudSchema): FormSchema[] => { |
| 239 | 221 | label: schemaItem.form?.label || schemaItem.title |
| 240 | 222 | } |
| 241 | 223 | |
| 242 | - // 删除不必要的字段 | |
| 243 | - delete formSchemaItem.show | |
| 244 | - | |
| 245 | 224 | formSchema.push(formSchemaItem) |
| 246 | 225 | } |
| 247 | 226 | }) |
| ... | ... | @@ -255,16 +234,13 @@ const filterDescriptionsSchema = (crudSchema: VxeCrudSchema): DescriptionsSchema |
| 255 | 234 | |
| 256 | 235 | eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => { |
| 257 | 236 | // 判断是否显示 |
| 258 | - if (schemaItem?.detail?.show !== false) { | |
| 237 | + if (schemaItem?.isDetail !== false) { | |
| 259 | 238 | const descriptionsSchemaItem = { |
| 260 | 239 | ...schemaItem.detail, |
| 261 | 240 | field: schemaItem.field, |
| 262 | 241 | label: schemaItem.detail?.label || schemaItem.title |
| 263 | 242 | } |
| 264 | 243 | |
| 265 | - // 删除不必要的字段 | |
| 266 | - delete descriptionsSchemaItem.show | |
| 267 | - | |
| 268 | 244 | descriptionsSchema.push(descriptionsSchemaItem) |
| 269 | 245 | } |
| 270 | 246 | }) | ... | ... |
yudao-ui-admin-vue3/src/views/system/errorCode/errorCode.data.ts
| ... | ... | @@ -20,23 +20,17 @@ const crudSchemas = reactive<VxeCrudSchema>({ |
| 20 | 20 | title: '错误码类型', |
| 21 | 21 | field: 'type', |
| 22 | 22 | dictType: DICT_TYPE.SYSTEM_ERROR_CODE_TYPE, |
| 23 | - search: { | |
| 24 | - show: true | |
| 25 | - } | |
| 23 | + isSearch: true | |
| 26 | 24 | }, |
| 27 | 25 | { |
| 28 | 26 | title: '应用名', |
| 29 | 27 | field: 'applicationName', |
| 30 | - search: { | |
| 31 | - show: true | |
| 32 | - } | |
| 28 | + isSearch: true | |
| 33 | 29 | }, |
| 34 | 30 | { |
| 35 | 31 | title: '错误码编码', |
| 36 | 32 | field: 'code', |
| 37 | - search: { | |
| 38 | - show: true | |
| 39 | - } | |
| 33 | + isSearch: true | |
| 40 | 34 | }, |
| 41 | 35 | { |
| 42 | 36 | title: '错误码错误提示', |
| ... | ... | @@ -46,11 +40,9 @@ const crudSchemas = reactive<VxeCrudSchema>({ |
| 46 | 40 | title: t('common.createTime'), |
| 47 | 41 | field: 'createTime', |
| 48 | 42 | formatter: 'formatDate', |
| 49 | - form: { | |
| 50 | - show: false | |
| 51 | - }, | |
| 43 | + isForm: false, | |
| 44 | + isSearch: true, | |
| 52 | 45 | search: { |
| 53 | - show: true, | |
| 54 | 46 | itemRender: { |
| 55 | 47 | name: 'XDataTimePicker' |
| 56 | 48 | } | ... | ... |
yudao-ui-admin-vue3/src/views/system/post/post.data.ts
| ... | ... | @@ -21,16 +21,12 @@ const crudSchemas = reactive<VxeCrudSchema>({ |
| 21 | 21 | { |
| 22 | 22 | title: '岗位名称', |
| 23 | 23 | field: 'name', |
| 24 | - search: { | |
| 25 | - show: true | |
| 26 | - } | |
| 24 | + isSearch: true | |
| 27 | 25 | }, |
| 28 | 26 | { |
| 29 | 27 | title: '岗位编码', |
| 30 | 28 | field: 'code', |
| 31 | - search: { | |
| 32 | - show: true | |
| 33 | - } | |
| 29 | + isSearch: true | |
| 34 | 30 | }, |
| 35 | 31 | { |
| 36 | 32 | title: '岗位顺序', |
| ... | ... | @@ -40,24 +36,18 @@ const crudSchemas = reactive<VxeCrudSchema>({ |
| 40 | 36 | title: t('common.status'), |
| 41 | 37 | field: 'status', |
| 42 | 38 | dictType: DICT_TYPE.COMMON_STATUS, |
| 43 | - search: { | |
| 44 | - show: true | |
| 45 | - } | |
| 39 | + isSearch: true | |
| 46 | 40 | }, |
| 47 | 41 | { |
| 48 | 42 | title: '备注', |
| 49 | 43 | field: 'remark', |
| 50 | - table: { | |
| 51 | - show: false | |
| 52 | - } | |
| 44 | + isTable: false | |
| 53 | 45 | }, |
| 54 | 46 | { |
| 55 | 47 | title: t('common.createTime'), |
| 56 | 48 | field: 'createTime', |
| 57 | 49 | formatter: 'formatDate', |
| 58 | - form: { | |
| 59 | - show: false | |
| 60 | - } | |
| 50 | + isForm: false | |
| 61 | 51 | } |
| 62 | 52 | ] |
| 63 | 53 | }) | ... | ... |