import { BasicColumn, FormSchema } from '/@/components/Table'; import { h } from 'vue'; // 生产状态映射表(扩展所有状态) export const productionStatusMap: Record = { 0: { label: '正常生产矿井', value: 0, color: 'green' }, 1: { label: '拟建矿井', value: 1, color: 'blue' }, 2: { label: '正常建设煤矿', value: 2, color: 'green' }, 3: { label: '自行停产矿井', value: 3, color: 'green' }, 4: { label: '正在关闭', value: 4, color: 'green' }, 5: { label: '责令停产整顿', value: 5, color: 'green' }, 6: { label: '责令停止建设', value: 6, color: 'green' }, 7: { label: '已关闭矿井', value: 7, color: 'green' }, 8: { label: '长期停产矿井', value: 8, color: 'green' }, 9: { label: '长期停建矿井', value: 9, color: 'green' }, 10: { label: '停产整改矿井', value: 10, color: 'green' }, 11: { label: '长期停建无法联系', value: 11, color: 'green' }, 12: { label: '停建整改', value: 12, color: 'green' }, 13: { label: '自行停建', value: 13, color: 'green' }, 14: { label: '正在实施关闭', value: 14, color: 'green' }, // 15: { label: '已关闭矿井', value: 15, color: 'green' }, }; // 颜色映射 const colorHexMap: Record = { blue: '#1890ff', green: '#208840', gold: '#faad14', red: '#f5222d', gray: '#8c8c8c', black: '#000000', }; /** 表格列配置 */ export const columns: BasicColumn[] = [ { title: '煤矿名称', dataIndex: 'mineName', width: 250, }, { title: '煤矿简称', dataIndex: 'mineNameAbbr', width: 150, }, { title: '生产状态', dataIndex: 'mineProStatus', width: 120, customRender: ({ record }) => { // 空值/异常值处理 const status = record.mineProStatus; const { label, color } = productionStatusMap[status] || { label: '未知状态', color: 'balck' }; return h('span', { style: { color: colorHexMap[color] || colorHexMap.gray } }, label); }, }, { title: '在线状态', dataIndex: 'mineLinkStatus', width: 100, customRender: ({ record }) => { console.log(record.mineLinkStatus); const status = record.mineLinkStatus; if (status === undefined || status === null) { return h('span', { style: { color: colorHexMap.black } }, '/'); } const text = status === 1 ? '在线' : '离线'; const textColor = status === 1 ? colorHexMap.green : colorHexMap.red; return h('span', { style: { color: textColor } }, text); }, }, { title: '质量问题详情', dataIndex: 'queJson', width: 400, ellipsis: true, slots: { customRender : 'queJson' } }, { title: '当前状态', dataIndex: 'isOk', width: 100, customRender: ({ record }) => { const status = record.isOk; const text = status ? '已解决' : '未解决'; const textColor = status ? colorHexMap.green : colorHexMap.red; return h('span', { style: { color: textColor } }, text); }, }, { title: '处理时间', dataIndex: 'updateTime', width: 180, }, ]; /** 查询表单配置 */ export const searchFormSchema: FormSchema[] = [ { field: 'mineCode', label: '煤矿名称', component: 'MineCascader', colProps: { span: 6 }, groupName: '常规查询', }, { field: 'mineNameAbbr', label: '煤矿简称', component: 'Input', colProps: { span: 6 }, groupName: '常规查询', }, { field: 'productionStatus', label: '生产状态', component: 'Select', componentProps: { options: [ { label: '拟建矿井', value: '0' }, { label: '正常生产矿井', value: '1' }, { label: '长期停产矿井', value: '1' }, ], }, colProps: { span: 6 }, groupName: '常规查询', }, { field: 'mineLinkStatus', label: '在线状态', component: 'Select', componentProps: { options: [ { label: '离线', value: '0' }, { label: '在线', value: '1' }, { label: '未连接', value: '2' }, ], }, colProps: { span: 6 }, groupName: '常规查询', }, ]; // 模拟煤矿在线状态选项数据 export const mineLinkStatusOptions = [ { label: '在线', value: 1 }, { label: '离线', value: 0 }, ]; export const topFormSchema: FormSchema[]= [ { field: 'mineCode', label: '煤矿名称', component: 'MineCascader', required: true, }, ]; /** 弹框表单配置 */ export const formSchema = [ { field: 'goafName', label: '工作面名称', component: 'Input', }, { field: 'queCon', label: '问题描述', component: 'Input', }, { field: 'startTime', label: '开始时间', component: 'DatePicker', componentProps: { showTime: true, format: 'YYYY-MM-DD HH:mm:ss', }, required: true, }, { field: 'endTime', label: '结束时间', component: 'DatePicker', componentProps: { showTime: true, format: 'YYYY-MM-DD HH:mm:ss', }, required: true, }, { field: 'param', label: '参数', component: 'Input', required: true, }, ];