import { h } from 'vue'; import { Tag } from 'ant-design-vue'; import { BasicColumn } from '/@/components/Table'; import { FormSchema } from '/@/components/Form/index'; import { adapt } from '/@/utils/adapt'; const adaptWidth = adapt(); export const columns: BasicColumn[] = [ { title: 'ID', dataIndex: 'id', align: 'left', editComponentProps: { prefix: '$', }, width: 150, }, { title: '父级', dataIndex: 'pid', width: 160, }, { title: '名称', dataIndex: 'name', width: 160, }, { title: '状态', dataIndex: 'status', width: 80, customRender: ({ record }) => { const status = record.status; const enable = status === 'normal'; const color = enable ? 'green' : 'red'; const text = enable ? '启用' : '停用'; return h(Tag, { color: color }, () => text); }, }, ]; // popup ===================================================== export const schemas: FormSchema[] = [ { field: 'pid', label: '父级', component: 'TreeSelect', componentProps: { replaceFields: { title: 'name', key: 'id', value: 'id', }, getPopupContainer: () => document.body, }, labelWidth: adaptWidth.labelWidth, colProps: { span: adaptWidth.elContainer, }, }, { field: 'name', component: 'Input', label: '名称', labelWidth: adaptWidth.labelWidth, colProps: { span: adaptWidth.elContainer, }, }, // { // field: 'rules', // component: 'Input', // label: '规则', // labelWidth: adaptWidth.labelWidth, // colProps: { // span: adaptWidth.elContainer, // }, // }, { field: 'status', label: '状态', component: 'RadioButtonGroup', defaultValue: 'normal', componentProps: { options: [ { label: '启用', value: 'normal' }, { label: '停用', value: 'locked' }, ], }, labelWidth: adaptWidth.labelWidth, colProps: { span: adaptWidth.elContainer, }, }, ];