mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-27 09:41:58 +08:00
parent
998d23db61
commit
905385d4ae
@ -7,14 +7,10 @@ import { DescriptionsSchema } from '@/types/descriptions'
|
|||||||
import { ComponentOptions } from '@/types/components'
|
import { ComponentOptions } from '@/types/components'
|
||||||
|
|
||||||
export type CrudSchema = Omit<TableColumn, 'children'> & {
|
export type CrudSchema = Omit<TableColumn, 'children'> & {
|
||||||
isSearch?: boolean // 是否在查询显示
|
search?: CrudSearchParams
|
||||||
search?: CrudSearchParams // 查询的详细配置
|
table?: CrudTableParams
|
||||||
isTable?: boolean // 是否在列表显示
|
form?: CrudFormParams
|
||||||
table?: CrudTableParams // 列表的详细配置
|
detail?: CrudDescriptionsParams
|
||||||
isForm?: boolean // 是否在表单显示
|
|
||||||
form?: CrudFormParams // 表单的详细配置
|
|
||||||
isDetail?: boolean // 是否在详情显示
|
|
||||||
detail?: CrudDescriptionsParams // 详情的详细配置
|
|
||||||
children?: CrudSchema[]
|
children?: CrudSchema[]
|
||||||
dictType?: string // 字典类型
|
dictType?: string // 字典类型
|
||||||
dictData?: 'string' | 'number' | 'boolean' // 字典数据类型 string | number | boolean
|
dictData?: 'string' | 'number' | 'boolean' // 字典数据类型 string | number | boolean
|
||||||
@ -84,7 +80,7 @@ const filterSearchSchema = (crudSchema: CrudSchema[]): FormSchema[] => {
|
|||||||
|
|
||||||
eachTree(crudSchema, (schemaItem: CrudSchema) => {
|
eachTree(crudSchema, (schemaItem: CrudSchema) => {
|
||||||
// 判断是否显示
|
// 判断是否显示
|
||||||
if (schemaItem?.isSearch || schemaItem.search?.show) {
|
if (schemaItem?.search?.show) {
|
||||||
let component = schemaItem?.search?.component || 'Input'
|
let component = schemaItem?.search?.component || 'Input'
|
||||||
const options: ComponentOptions[] = []
|
const options: ComponentOptions[] = []
|
||||||
let comonentProps = {}
|
let comonentProps = {}
|
||||||
@ -97,7 +93,7 @@ const filterSearchSchema = (crudSchema: CrudSchema[]): FormSchema[] => {
|
|||||||
comonentProps = {
|
comonentProps = {
|
||||||
options: options
|
options: options
|
||||||
}
|
}
|
||||||
if (!schemaItem.search?.component) component = 'Select'
|
if (!schemaItem.search.component) component = 'Select'
|
||||||
}
|
}
|
||||||
const searchSchemaItem = {
|
const searchSchemaItem = {
|
||||||
// 默认为 input
|
// 默认为 input
|
||||||
@ -120,7 +116,7 @@ const filterSearchSchema = (crudSchema: CrudSchema[]): FormSchema[] => {
|
|||||||
const filterTableSchema = (crudSchema: CrudSchema[]): TableColumn[] => {
|
const filterTableSchema = (crudSchema: CrudSchema[]): TableColumn[] => {
|
||||||
const tableColumns = treeMap<CrudSchema>(crudSchema, {
|
const tableColumns = treeMap<CrudSchema>(crudSchema, {
|
||||||
conversion: (schema: CrudSchema) => {
|
conversion: (schema: CrudSchema) => {
|
||||||
if (schema?.isTable !== false || schema?.table?.show !== false) {
|
if (schema?.table?.show !== false) {
|
||||||
return {
|
return {
|
||||||
...schema.table,
|
...schema.table,
|
||||||
...schema
|
...schema
|
||||||
@ -144,7 +140,7 @@ const filterFormSchema = (crudSchema: CrudSchema[]): FormSchema[] => {
|
|||||||
|
|
||||||
eachTree(crudSchema, (schemaItem: CrudSchema) => {
|
eachTree(crudSchema, (schemaItem: CrudSchema) => {
|
||||||
// 判断是否显示
|
// 判断是否显示
|
||||||
if (schemaItem?.isForm !== false || schemaItem?.form?.show == true) {
|
if (schemaItem?.form?.show !== false) {
|
||||||
let component = schemaItem?.form?.component || 'Input'
|
let component = schemaItem?.form?.component || 'Input'
|
||||||
let defaultValue: any = ''
|
let defaultValue: any = ''
|
||||||
if (schemaItem.form?.value) {
|
if (schemaItem.form?.value) {
|
||||||
@ -201,7 +197,7 @@ const filterDescriptionsSchema = (crudSchema: CrudSchema[]): DescriptionsSchema[
|
|||||||
|
|
||||||
eachTree(crudSchema, (schemaItem: CrudSchema) => {
|
eachTree(crudSchema, (schemaItem: CrudSchema) => {
|
||||||
// 判断是否显示
|
// 判断是否显示
|
||||||
if (schemaItem?.isDetail !== false || schemaItem.detail?.show !== false) {
|
if (schemaItem?.detail?.show !== false) {
|
||||||
const descriptionsSchemaItem = {
|
const descriptionsSchemaItem = {
|
||||||
...schemaItem.detail,
|
...schemaItem.detail,
|
||||||
field: schemaItem.field,
|
field: schemaItem.field,
|
||||||
|
@ -181,7 +181,7 @@ const filterTableSchema = (crudSchema: VxeCrudSchema): VxeGridPropTypes.Columns
|
|||||||
}
|
}
|
||||||
eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => {
|
eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => {
|
||||||
// 判断是否显示
|
// 判断是否显示
|
||||||
if (schemaItem?.isTable !== false && schemaItem?.table?.show !== false) {
|
if (schemaItem?.isTable !== false) {
|
||||||
const tableSchemaItem = {
|
const tableSchemaItem = {
|
||||||
...schemaItem.table,
|
...schemaItem.table,
|
||||||
field: schemaItem.field,
|
field: schemaItem.field,
|
||||||
@ -278,7 +278,7 @@ const filterDescriptionsSchema = (crudSchema: VxeCrudSchema): DescriptionsSchema
|
|||||||
|
|
||||||
eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => {
|
eachTree(crudSchema.columns, (schemaItem: VxeCrudColumns) => {
|
||||||
// 判断是否显示
|
// 判断是否显示
|
||||||
if (schemaItem?.isDetail !== false || schemaItem.detail?.show !== false) {
|
if (schemaItem?.isDetail !== false) {
|
||||||
const descriptionsSchemaItem = {
|
const descriptionsSchemaItem = {
|
||||||
...schemaItem.detail,
|
...schemaItem.detail,
|
||||||
field: schemaItem.field,
|
field: schemaItem.field,
|
||||||
|
@ -17,28 +17,40 @@ const crudSchemas = reactive<CrudSchema[]>([
|
|||||||
label: t('common.index'),
|
label: t('common.index'),
|
||||||
field: 'id',
|
field: 'id',
|
||||||
type: 'index',
|
type: 'index',
|
||||||
isForm: false,
|
form: {
|
||||||
isDetail: false
|
show: false
|
||||||
|
},
|
||||||
|
detail: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '表名称',
|
label: '表名称',
|
||||||
field: 'tableName',
|
field: 'tableName',
|
||||||
isSearch: true
|
search: {
|
||||||
|
show: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '表描述',
|
label: '表描述',
|
||||||
field: 'tableComment',
|
field: 'tableComment',
|
||||||
isSearch: true
|
search: {
|
||||||
|
show: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '实体',
|
label: '实体',
|
||||||
field: 'className',
|
field: 'className',
|
||||||
isSearch: true
|
search: {
|
||||||
|
show: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('common.createTime'),
|
label: t('common.createTime'),
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
isForm: false,
|
form: {
|
||||||
|
show: false
|
||||||
|
},
|
||||||
search: {
|
search: {
|
||||||
show: true,
|
show: true,
|
||||||
component: 'DatePicker',
|
component: 'DatePicker',
|
||||||
@ -52,14 +64,20 @@ const crudSchemas = reactive<CrudSchema[]>([
|
|||||||
{
|
{
|
||||||
label: t('common.updateTime'),
|
label: t('common.updateTime'),
|
||||||
field: 'updateTime',
|
field: 'updateTime',
|
||||||
isForm: false
|
form: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('table.action'),
|
label: t('table.action'),
|
||||||
field: 'action',
|
field: 'action',
|
||||||
width: '350px',
|
width: '500px',
|
||||||
isForm: false,
|
form: {
|
||||||
isDetail: false
|
show: false
|
||||||
|
},
|
||||||
|
detail: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
export const { allSchemas } = useCrudSchemas(crudSchemas)
|
export const { allSchemas } = useCrudSchemas(crudSchemas)
|
||||||
|
Loading…
Reference in New Issue
Block a user