import { h } from 'vue' import { ColumnsProps } from '../../../../components/table/table-helper' import { DynamicFormTableColumnVo } from '../../../../entity/dynamic/dynamic-form-table' import { Checkbox } from 'ant-design-vue' import { FieldType, getKeyTypeMap, putTypeArray, refreshData } from './field-type' import { SEARCH_TYPE_MAP, SHOW_TYPE_MAP } from './columns' import { useDynamicTableStore } from '../../../../store/dynamic-table' const columns = (object: { [key: string]: FieldType[] }) => { const dynamicTableStore = useDynamicTableStore() // 执行初始化 Object.keys(object).forEach(key => { putTypeArray(key, object[key]) }) // 获取字段类型的下拉框属性信息 const keyTypeMap = getKeyTypeMap() return []>[ { title: '字段名称', dataIndex: 'columnComment' }, { title: '字段编号', dataIndex: 'columnName' }, { title: '字段类型', dataIndex: 'columnKeyId', customRender: ({ text, record }) => { // 进入的第一次需要进行一次刷新信息 refreshData(record, false) return keyTypeMap[text]?.label || '' } }, { title: '显示内容', width: 150, dataIndex: 'showTextField', customRender: ({ text, record }) => { if (record.columnKeyType != 3) { return '/' } return dynamicTableStore.listColumns(record.columnKeyId).find(item => item.value == text)?.label } }, { title: '字段长度', dataIndex: 'columnSize' }, { title: '默认值', dataIndex: 'defaultValue' }, { title: '是否必填', align: 'center', dataIndex: 'isRequired', customRender: ({ record }) => h(Checkbox, { checked: record.isRequired === 1, disabled: true }) }, { title: '显示状态', dataIndex: 'showType', customRender: ({ text }) => SHOW_TYPE_MAP[text] || '' }, { title: '查询条件', dataIndex: 'searchType', customRender: ({ text }) => SEARCH_TYPE_MAP[text] || '' } ] } export default columns