import type { BasicColumn } from '/@/components/Table'; import type { FormSchema } from '/@/components/Table'; import { h } from 'vue'; import { StatusColorEnum } from '/@/enums/jeecgEnum'; import { useMineDepartmentStore } from '/@/store/modules/mine'; import { getWindrectList, getWindrectRegulation } from './windPointManage.api'; /** 按矿编码(fax)在组织树中匹配部门名称,未匹配时回退显示原编码 */ function renderMineNameByFax(mineCode: string): string { if (!mineCode) return '-'; const mine = useMineDepartmentStore().findDepart((n) => n.fax === mineCode, useMineDepartmentStore().getDepartTree); return mine?.departName || mineCode; } /** 注册测风点位管理表格列 */ export const pointColumns: BasicColumn[] = [ { title: '煤矿编号', dataIndex: 'mineCode', width: 140, fixed: 'left', customRender: ({ text }) => h('span', renderMineNameByFax(String(text ?? ''))), }, { title: '区域名称', dataIndex: 'name', width: 150, fixed: 'left', }, { title: '层级', dataIndex: 'level', width: 100, customRender: ({ text }) => { const map: Record = { 1: '矿井进风', 2: '采区进风', 3: '采区用风', 4: '采区回风', 5: '矿井回风', }; return map[text] || text; }, }, { title: '风量(m³/min)', dataIndex: 'airVolume', width: 100, }, // { // title: '规程值', // dataIndex: 'regulationId', // width: 90, // }, { title: '测风设备', dataIndex: 'windrectId', width: 100, customRender({ record }) { return h('span', record.windrectId ? '已绑定' : '未绑定'); }, }, { title: '创建时间', dataIndex: 'createTime', width: 150, }, // { // title: '状态', // dataIndex: 'status', // width: 80, // customRender: ({ text }) => { // const val = text ?? 'active'; // const color = val === 'active' ? StatusColorEnum.green : StatusColorEnum.gray; // const label = val === 'active' ? '在用' : '停用'; // return h('span', { style: { color } }, label); // }, // }, ]; /** 上传数据布点表格列(Windrect) */ export const windrectColumns: BasicColumn[] = [ // { // title: '设备编码', // dataIndex: 'deviceCode', // width: 130, // fixed: 'left', // }, { title: '设备位置', dataIndex: 'devicePos', width: 200, }, { title: '矿井名称', dataIndex: 'mineName', width: 160, }, { title: '状态', dataIndex: 'status', width: 100, customRender: ({ text }) => { const normal = String(text) === '1'; const color = normal ? StatusColorEnum.green : StatusColorEnum.red; const label = normal ? '正常' : '停用'; return h('span', { style: { color, fontWeight: 'bold' } }, label); }, }, // { // title: '创建时间', // dataIndex: 'createTime', // width: 160, // }, ]; /** 新增/编辑 MineArea 表单 */ export const formSchema: FormSchema[] = [ { label: 'id', field: 'id', component: 'Input', show: false, }, { label: '煤矿编号', field: 'mineCode', component: 'MineCascader', required: true, // 编辑态(已有 id)禁用矿编码,避免误改归属矿井;新增态保持可选 dynamicDisabled: ({ values }) => !!values.id, // 切换煤矿时清空已选测风设备,避免绑定到其他矿的设备 componentProps: ({ formActionType }) => ({ placeholder: '请输入煤矿编号', changeOnSelect: true, initFromStore: false, syncFromStore: false, onChange: () => { formActionType.setFieldsValue({ windrectId: undefined }); }, }), }, { label: '测风地点名称', field: 'name', required: true, component: 'Input', componentProps: { placeholder: '请输入矿井名称', }, }, { label: '层级', field: 'level', component: 'Select', required: true, componentProps: { placeholder: '请选择层级', options: [ { label: '矿井进风', value: 1 }, { label: '采区进风', value: 2 }, { label: '采区用风', value: 3 }, { label: '采区回风', value: 4 }, { label: '矿井回风', value: 5 }, ], }, }, { label: '需风量(m³/min)', field: 'airVolume', component: 'InputNumber', required: true, componentProps: { placeholder: '请输入需风量', min: 0, style: 'width: 100%', }, }, { label: '巷道分类', field: 'regulationId', component: 'ApiSelect', required: true, componentProps: { api: getWindrectRegulation, labelField: 'name', valueField: 'id', placeholder: '请选择巷道分类', }, }, { label: '测风设备', field: 'windrectId', component: 'ApiSelect', // 与「煤矿编号」联动:按选中矿(MineCascader 值为部门 id)过滤本矿测风设备; // ApiSelect 深度监听 params 变化,切矿后自动重新请求 componentProps: ({ formModel }) => ({ api: getWindrectList, labelField: 'devicePos', valueField: 'id', placeholder: '请输入测风设备', searchable: true, params: formModel?.mineCode ? { deptId: formModel.mineCode } : {}, }), }, ]; /* ====== 判识模型管理(暂注释,待接口就绪后恢复)====== /* 判识模型参数配置表格列 export const modelConfigColumns: BasicColumn[] = [ { title: '判识指标', dataIndex: 'paramName', width: 200, fixed: 'left', }, { title: '判别条件', dataIndex: 'paramFormula', width: 150, }, { title: '阈值参数', dataIndex: 'paramKey', width: 150, }, { title: '阈值参数', dataIndex: 'currentValue', width: 120, edit: true, editComponent: 'Input', }, { title: '默认值', dataIndex: 'defaultValue', width: 120, }, { title: '当前值', dataIndex: 'value', width: 120, }, { title: '权重', dataIndex: 'weight', width: 120, }, ]; /* 判识模型参数编辑表单(与 modelConfigColumns 字段对齐) export const modelConfigFormSchema: FormSchema[] = [ { label: '判识指标', field: 'paramName', component: 'Input', componentProps: { disabled: true }, }, { label: '判别条件', field: 'paramFormula', component: 'Input', componentProps: { placeholder: '请输入判别条件' }, }, { label: '阈值参数', field: 'paramKey', required: true, component: 'Input', componentProps: { placeholder: '请输入阈值参数字段名' }, }, { label: '阈值参数值', field: 'currentValue', required: true, component: 'Input', componentProps: { placeholder: '请输入阈值参数值' }, }, { label: '默认值', field: 'defaultValue', component: 'Input', componentProps: { placeholder: '请输入默认值' }, }, { label: '当前值', field: 'value', component: 'Input', componentProps: { placeholder: '请输入当前值' }, }, { label: '权重', field: 'weight', component: 'InputNumber', componentProps: { placeholder: '请输入权重', min: 0, max: 1, step: 0.01, style: 'width:100%' }, }, { label: '单位', field: 'unit', component: 'Input', componentProps: { placeholder: '请输入单位' }, }, { label: '说明', field: 'description', component: 'InputTextArea', componentProps: { placeholder: '请输入说明', rows: 3 }, }, ]; /* 判识模型默认配置数据 export const defaultModelConfigs = [ { paramName: '风速上限', paramKey: 'windSpeedUpperLimit', currentValue: '6.0', defaultValue: '6.0', unit: 'm/s', description: '实测风速超过此值即触发风速超限报警', }, { paramName: '风量不足裕度', paramKey: 'volumeLowMargin', currentValue: '20', defaultValue: '20', unit: '%', description: '实测风量低于标准风量×(1-裕度)即触发风量不足报警', }, { paramName: '不闭合阈值', paramKey: 'unclosedThreshold', currentValue: '10', defaultValue: '10', unit: '%', description: '进风量与回风量差值占比超过此值即触发风量不闭合报警', }, { paramName: '缺失点位报警数', paramKey: 'missingPointAlarm', currentValue: '1', defaultValue: '1', unit: '个', description: '上传测风点数少于注册测风点数超过此值即触发报警', }, { paramName: '关联异常点数', paramKey: 'relatedAbnormalPoints', currentValue: '2', defaultValue: '2', unit: '个', description: '同一区域多个测风点同时异常超过此值即触发关联异常报警', }, { paramName: '综合判识阈值', paramKey: 'compositeThreshold', currentValue: '0.60', defaultValue: '0.60', unit: '', description: '加权风险得分达到此值判定为"疑似"隐蔽工作面', }, { paramName: '采区风量差值异常周期', paramKey: 'diffAbnormalCycles', currentValue: '3', defaultValue: '3', unit: '个测风周期', description: '差值持续为正且超过此测风周期数即触发异常', }, { paramName: '采区有效风量率警戒线', paramKey: 'effectiveRateWarning', currentValue: '70', defaultValue: '70', unit: '%', description: '采区有效风量率低于此值即触发预警', }, ]; */