import dayjs from 'dayjs'; import { BasicColumn } from '/@/components/Table'; import { FormSchema } from '/@/components/Table'; import { TreeItem } from '/@/components/Tree/index'; import { ModuleDataChart } from '/@/components/Configurable/types'; import { h } from 'vue'; import { StatusColorEnum } from '/@/enums/jeecgEnum'; // import { getDictItemsByCode } from '/@/utils/dict'; // import { get } from 'lodash-es'; const riskMap = { '1': '低风险', '2': '一般风险', '3': '较高风险', '4': '高风险', }; const linkMap = { '0': '断线', '1': '正常', '2': '标校', }; // const dictMap = getDictItemsByCode('mineProStatus'); // 实时数据相关 export const columns: BasicColumn[] = [ // { // title: '序号', // dataIndex: 'orderNo', // width: 60, // }, // { // title: '区域', // dataIndex: 'coalSeamName', // width: 80, // }, { title: '煤矿名称', dataIndex: 'mineName', width: 200, }, { title: '密闭名称', dataIndex: 'devicePos', width: 100, }, { title: '所属煤层', dataIndex: 'coalSeamName', width: 100, }, { title: '自燃倾向性', dataIndex: 'coalSeamLevel', width: 100, }, { title: '瓦斯等级', dataIndex: 'gasLevelName', width: 100, }, { title: '生产状态', dataIndex: 'gjMineStatus', width: 100, // customRender({ text }) { // // 从动态映射取值,兜底未知状态 // const label = dictMap.find((item) => item.value == text)?.label || '-'; // // 渲染带颜色的文字 // return h( // 'span', // { // color: get({ '0': StatusColorEnum.green, '1': StatusColorEnum.blue }, text), // }, // label // ); // }, }, { title: 'CO(ppm)', dataIndex: 'coVal', width: 100, }, { title: 'CO2(%)', dataIndex: 'co2Val', width: 100, }, { title: 'CH4(%)', dataIndex: 'ch4Val', width: 100, }, { title: 'C2H2(ppm)', dataIndex: 'c2h2Val', width: 100, }, { title: 'C2H4(ppm)', dataIndex: 'c2h4Val', width: 100, }, { title: 'O2(%)', dataIndex: 'o2Val', width: 100, }, { title: '温度(℃)', dataIndex: 'temperature', width: 100, }, { title: '压差(Pa)', dataIndex: 'sourcePressure', width: 100, }, { title: '自然发火隐患等级', dataIndex: 'fireAlarm', width: 100, customRender({ record }) { return alarmCellRender(record.fireAlarm, (r) => riskMap[r.alarmName] || r.alarmName); }, }, { title: '是否漏风', dataIndex: 'leakageAlarm', width: 100, customRender({ record }) { // return alarmTextRender(record.leakageAlarm?.alarmLevel, record.leakageAlarm?.split('-')[0]); return alarmCellRender(record.leakageAlarm, (r) => r.alarmName.split('-')[1]); }, }, { title: '压差隐患等级', dataIndex: 'sourcePressureAlarm', width: 100, customRender({ record }) { return alarmCellRender(record.sourcePressureAlarm, (r) => riskMap[r.alarmName] || r.alarmName); }, }, { title: '密闭启封判定', dataIndex: 'unsealAlarm', width: 100, customRender({ record }) { return alarmCellRender(record.unsealAlarm); }, }, { title: '设备状态', dataIndex: 'linkStatus', width: 100, customRender({ record }) { return alarmCellRender( record.linkStatus, (r) => linkMap[r], (r) => String(r) ); }, }, // { // title: '爆炸危险性', // dataIndex: 'explosionHazard', // width: 80, // }, { title: '更新时间', dataIndex: 'readTime', width: 100, }, ]; export const searchFormSchema: FormSchema[] = [ // { // field: 'mineNameAbbr', // label: '煤矿简称', // component: 'Input', // colProps: { span: 6 }, // }, { field: 'gjMineStatus', label: '生产状态', component: 'JDictSelectTag', componentProps: { dictCode: 'mineProStatus', placeholder: '请选择生产状态', }, colProps: { span: 6 }, }, { field: 'coalSeamLevel', label: '自燃倾向性', component: 'Select', componentProps: { options: [ { label: 'Ⅰ类容易自燃', value: 'Ⅰ类容易自燃' }, { label: 'Ⅱ类自燃', value: 'Ⅱ类自燃' }, { label: 'Ⅲ类不易自燃', value: 'Ⅲ类不易自燃' }, ], }, colProps: { span: 6 }, }, { field: 'gasLevelName', label: '瓦斯等级', component: 'Select', componentProps: { options: [ { label: '低瓦斯', value: '低瓦斯' }, { label: '高瓦斯', value: '高瓦斯' }, { label: '突出', value: '突出' }, ], }, colProps: { span: 6 }, }, ]; export const modalDetailsData: { basicInfo: Record[]; board: Record[]; gasConcentrationConfig: ModuleDataChart; pressureConfig: ModuleDataChart; } = { basicInfo: [ { label: '煤矿名称', value: 'mineName', }, { label: '设备位置', value: 'devicePos', }, // { // label: '所属煤层', // value: 'coalSeamName', // }, // { // label: '自燃倾向性', // value: 'Ⅰ类容易自燃', // }, { label: '自然发火隐患', value: 'fireAlarm', customRender({ record }) { return alarmCellRender(record.fireAlarm, (r) => riskMap[r.alarmName] || r.alarmName); }, }, { label: '是否漏风', value: 'leakageAlarm', customRender({ record }) { return alarmCellRender(record.leakageAlarm); }, }, { label: '压差隐患等级', value: 'sourcePressureAlarm', customRender({ record }) { return alarmCellRender(record.sourcePressureAlarm, (r) => riskMap[r.alarmName] || r.alarmName); }, }, { label: '密闭启封判定', value: 'unsealAlarm', customRender({ record }) { return alarmCellRender(record.unsealAlarm); }, }, ], board: [ { label: 'CO(ppm)', value: 'coVal', }, { label: 'CO2(%)', value: 'co2Val', }, { label: 'O2(%)', value: 'o2Val', }, { label: 'CH4(%)', value: 'ch4Val', }, { label: 'C2H4(ppm)', value: 'c2h4Val', }, { label: 'C2H2(ppm)', value: 'c2h2Val', }, { label: '温度(℃)', value: 'temperature', }, { label: '压差(Pa)', value: 'sourcePressure', }, ], gasConcentrationConfig: { type: 'line_smooth', // 使用光滑曲线类型 legend: { show: true }, xAxis: [ { show: true, name: '时间', axisLabel: { color: '#000000' }, }, ], yAxis: [ { show: true, name: '浓度(%)', position: 'left', splitLine: { show: false }, axisLine: { show: true, lineStyle: { color: '#333' }, }, axisLabel: { color: '#000000' }, nameTextStyle: { color: '#000' }, }, ], series: [ { label: '氧气浓度', readFrom: 'chartData', xprop: 'readTime', yprop: 'o2Val', }, { label: '一氧化碳浓度', readFrom: 'chartData', xprop: 'readTime', yprop: 'coVal', }, { label: '二氧化碳浓度', readFrom: 'chartData', xprop: 'readTime', yprop: 'co2Val', }, ], readFrom: '', }, pressureConfig: { type: 'line', // 使用普通折线图类型 legend: { show: true }, xAxis: [ { show: true, name: '时间', axisLabel: { color: '#000000' }, }, ], yAxis: [ { show: true, position: 'left', name: '压力(kPa)', axisLabel: { color: '#000000' }, }, ], series: [ { label: '压差', readFrom: 'chartData', xprop: 'readTime', yprop: 'sourcePressure', }, ], readFrom: '', }, }; // 历史数据相关 export const historicalColumns: BasicColumn[] = [ // { // title: '序号', // dataIndex: 'orderNo', // width: 60, // }, // { // title: '区域', // dataIndex: 'enforcement', // width: 100, // }, { title: '煤矿名称', dataIndex: 'mineName', width: 200, }, { title: '密闭名称', dataIndex: 'devicePos', width: 100, }, { title: '所属煤层', dataIndex: 'coalSeamName', width: 100, }, { title: 'CO(ppm)', dataIndex: 'coVal', width: 100, }, { title: 'CO2(%)', dataIndex: 'co2Val', width: 100, }, { title: 'CH4(%)', dataIndex: 'ch4Val', width: 100, }, { title: 'C2H2(ppm)', dataIndex: 'c2h2Val', width: 100, }, { title: 'C2H4(ppm)', dataIndex: 'c2h4Val', width: 100, }, { title: 'O2(%)', dataIndex: 'o2Val', width: 100, }, { title: '温度(℃)', dataIndex: 'temperature', width: 100, }, { title: '压差(Pa)', dataIndex: 'sourcePressure', width: 100, }, // { // title: '爆炸危险性', // dataIndex: 'explosionHazard', // width: 100, // }, { title: '更新时间', dataIndex: 'createTime', width: 100, }, ]; export const historicalFormSchema: FormSchema[] = [ // { // field: 'mineCode', // label: '煤矿名称', // component: 'MineCascader', // slot: 'mine-cascader', // colProps: { span: 6 }, // }, // { // field: 'mineNameAbbr', // label: '煤矿简称', // component: 'Input', // colProps: { span: 6 }, // }, // { // field: 'productStatus', // label: '生产状态', // component: 'Select', // componentProps: { // options: [ // { label: '拟建矿井', value: '0' }, // { label: '正常生产矿井', value: '1' }, // { label: '长期停产矿井', value: '1' }, // ], // }, // colProps: { span: 6 }, // }, // { // field: 'riskLevel', // label: '自燃倾向性', // component: 'Select', // componentProps: { // options: [ // { label: 'Ⅰ类容易自燃', value: '0' }, // { label: 'Ⅱ类自燃', value: '1' }, // { label: 'Ⅲ类不易自燃', value: '2' }, // ], // }, // colProps: { span: 6 }, // }, // { // field: 'coalSeam', // label: '所属煤层', // component: 'Select', // componentProps: { // options: [ // { label: '煤层1', value: '0' }, // { label: '煤层2', value: '1' }, // { label: '煤层3', value: '2' }, // ], // }, // colProps: { span: 6 }, // }, { field: 'goafId', label: '密闭名称', component: 'ApiSelect', slot: 'goaf-select', colProps: { span: 6 }, }, { field: 'startTime', label: '起始日期', component: 'DatePicker', componentProps: { //日期格式化,页面上显示的值 format: 'YYYY-MM-DD', //返回值格式化(绑定值的格式) valueFormat: 'YYYY-MM-DD 00:00:00', }, defaultValue: dayjs().add(-30, 'day').format('YYYY-MM-DD'), colProps: { span: 6 }, }, { field: 'endTime', label: '结束日期', component: 'DatePicker', componentProps: { //日期格式化,页面上显示的值 format: 'YYYY-MM-DD', //返回值格式化(绑定值的格式) valueFormat: 'YYYY-MM-DD 23:59:59', }, defaultValue: dayjs().format('YYYY-MM-DD'), colProps: { span: 6 }, }, ]; export const treeData: TreeItem[] = [ { title: '气体参数 ', key: '0-0', children: [ { title: 'CO', key: '0-0-0' }, { title: 'CH4', key: '0-0-1' }, { title: 'C2H4', key: '0-0-2' }, { title: 'C2H2', key: '0-0-3' }, { title: 'CO2', key: '0-0-4' }, { title: 'O2', key: '0-0-5' }, ], }, { title: '内外压力及压差', key: '1-1', children: [ { title: '内压力', key: '1-1-0' }, { title: '外压力', key: '1-1-1' }, { title: '压差', key: '1-1-2' }, ], }, { title: '温度', key: '2-2', }, ]; function getTagColor(level: string) { switch (level) { case '4': return StatusColorEnum.red; case '3': return StatusColorEnum.gold; case '2': return StatusColorEnum.yellow; case '1': return StatusColorEnum.blue; case '0': return StatusColorEnum.red; default: return 'inhert'; } } export function alarmCellRender( record: any, valFn: (record: any) => string = (r) => r.alarmName, lvFn: (record: any) => string = (r) => r.alarmLevel ) { // if (!record) return h(Tag, { bordered: false, color: 'default' }, () => '-'); // return h(Tag, { bordered: false, color: getTagColor(record.alarmLevel) }, () => record.alarmName); if (!record) return h('span', '-'); const val = valFn(record); const lv = lvFn(record); return h('span', { style: { color: getTagColor(lv) } }, val); }