import type { BasicColumn, FormSchema } from '@/components/Table' import {getAlarmLevelList} from "@/api/alert/warn"; import {subSystemListApi} from "@/api/alert/model/select"; import {getInstantList,getInstantPoint} from "@/api/alert/run/instant"; import {ref} from "vue"; const alarmLevelList = await getAlarmLevelList(); export const columns: BasicColumn[] = [ { title: '编号', dataIndex: 'warnId', width: 80, fixed: 'left', }, { title: '名称', dataIndex: 'gzpName', width: 200, fixed: 'left', }, { title: '点号', dataIndex: 'pointId', width: 200, fixed: 'left', }, { title: '描述', dataIndex: 'pointName', width: 200, }, { title: '单位', dataIndex: 'unit', width: 80, }, { title: '上限', dataIndex: 'uplimit', width: 80, }, { title: '下限', dataIndex: 'lowlimit', width: 80, }, { title: '实例名称', dataIndex: 'mpName', width: 250, }, { title: '专业', dataIndex: 'systemName', width: 100, }, { title: '报警表达式', dataIndex: 'equation', width: 200, }, { title: '输出点号', dataIndex: 'outputPoint', width: 200, }, { title: '报警类型', dataIndex: 'alarmModelRuleName', width: 120, }, { title: '报警限制', dataIndex: 'warnConstraintName', width: 120, }, { title: '告警延时', dataIndex: 'timeDurationThreshold', width: 100, slots: { customRender: 'timeDurationThreshold' }, }, { title: '短信告警', dataIndex: 'shortMessageOnOff', width: 100, slots: { customRender: 'shortMessageOnOff' }, }, { title: '光字牌告警', dataIndex: 'gzpOnOff', width: 100, slots: { customRender: 'gzpOnOff' }, }, { title: '推送诊断', dataIndex: 'copyToDiagOnOff', width: 100, slots: { customRender: 'copyToDiagOnOff' }, }, { title: '已有实例数量', dataIndex: 'number', width: 100, }, { title: '参与报警', dataIndex: 'warnStatus', width: 100, slots: { customRender: 'warnStatus' }, fixed: 'right', }, // { // title: '实时值', // dataIndex: 'value', // width: 90, // className: 'value', // slots: { customRender: 'value' }, // } ] export const searchFormSchema: FormSchema[] = [ { label: '模型实例id', field: 'mpId', component: 'Input', defaultValue: '', required: true, show: false, colProps: { span: 8 }, } ] export const updateWarnForm: FormSchema[] = [ { label: '编号', field: 'warnId', component: 'Input', required: true, show: false, }, { label: '残差上限', field: 'uplimit', component: 'Input', required: true, componentProps: { placeholder: '请输入残差上限', }, rules: [{ required: true, message: '请输入残差上限' }], colProps: { span: 12, }, }, { label: '残差下限', field: 'lowlimit', component: 'Input', required: true, componentProps: { placeholder: '请输入残差下限', }, rules: [{ required: true, message: '请输入残差下限' }], colProps: { span: 12, }, }, { label: '延时告警', field: 'timeDurationThreshold', component: 'Input', required: true, componentProps: { placeholder: '请输入延时告警', }, rules: [{ required: true, message: '请输入延时告警' }], colProps: { span: 12, }, }, { label: '告警等级', field: 'alarmLevel', component: 'Select', componentProps: { options: alarmLevelList, fieldNames: { label: 'alarmLevelName', value: 'alarmLevel', }, }, required: true, colProps: { span: 12, }, }, { label: '光字牌名称', field: 'gzpName', component: 'Input', required: true, colProps: { span: 24, }, }, { label: '光字牌状态', field: 'gzpOnOff', component: 'RadioGroup', componentProps: { // 数据源1:固定数据 options: [ { label: '是', value: 1 }, { label: '否', value: 0 }, ], }, required: true, colProps: { span: 12, }, }, { label: '短信推送', field: 'shortMessageOnOff', component: 'RadioGroup', componentProps: { options: [{ label: '是', value: 1 }, { label: '否', value: 0 }], }, required: true, colProps: { span: 12, }, }, { label: '推送诊断', field: 'copyToDiagOnOff', component: 'RadioGroup', componentProps: { options: [{ label: '是', value: 1 }, { label: '否', value: 0 }], }, required: true, colProps: { span: 12, }, }, { label: '告警限制名称', field: 'warnConstraintName', component: 'Input', required: true, colProps: { span: 12, }, }, { label: '告警限制条件', field: 'warnConstraint', component: 'Input', required: true, colProps: { span: 24, }, }, ] export const InstantBasicInfo: any[] = [ { label: '实例名称', field: 'mpName', }, { label: '创建人', field: 'creator', }, { label: '创建时间', field: 'createTime', }, { label: '最近修改人', field: 'updater', }, { label: '最近修改时间', field: 'updateTime', }, { label: '算法', field: 'algorithm_shortname', }, // modelInfo中的字段 { label: '训练采样间隔', field: 'sampling', }, { label: '参数个数', field: 'pointInfo', }, { label: '最小主元贡献率', field: 'rate', }, { label: '主元个数', field: 'principal', }, { label: '模型精度', field: 'rate', }, ] export const detailColumns: BasicColumn[] = [ { title: '编号', dataIndex: 'id', width: 80, fixed: 'left', }, { title: '测点编码', dataIndex: 'inputInfo', width: 150, fixed: 'left', }, { title: '测点名称', dataIndex: 'inputName', width: 200, fixed: 'left', }, { title: '单位', dataIndex: 'unit', width: 50, fixed: 'left', }, { title: '重构值测点', dataIndex: 'outPointInfo', width: 200, }, { title: '偏差值测点', dataIndex: 'biasPointInfo', width: 200, }, { title: '错误状态测点', dataIndex: 'faultVariablePointInfo', width: 200, }, ] interface SelectItem { unitId: number unitName: string systemTypeId: number systemTypeName: string systemId: number systemName: string mpId: number mpName: string } const selectList: SelectItem[] = await getInstantList() //机组下拉框去重 const unitList=ref([]); unitList.value = Array.from( new Map( selectList.map(item => [ item.unitId, { ...item, }, ]), ).values(), ) const typeList=ref([]); typeList.value = Array.from( new Map( selectList .filter(item => item.unitId === unitList.value[0].unitId) .map(item => [ item.systemTypeId, { ...item }, ]), ).values(), ) const systemList=ref([]); systemList.value = Array.from( new Map( selectList .filter(item => item.systemTypeId === unitList.value[0].systemTypeId && item.unitId === unitList.value[0].unitId) .map(item => [ item.systemId, { ...item }, ]), ).values(), ) const mpList=ref([]); mpList.value = Array.from( new Map( selectList .filter(item => item.systemId === unitList.value[0].systemId) .map(item => [ item.mpId, { ...item }, ]), ).values(), ) console.log(unitList.value) const pointList=ref([]); pointList.value = await getInstantPoint(mpList.value[0].mpId) export const InstantForm: FormSchema[] = [ { label: '机组', field: 'unit', component: 'Select', defaultValue: unitList.value?.[0]?.unitId, colProps: { span: 8}, componentProps: ({ formModel, formActionType }) => ({ placeholder: '机组', allowClear: false, options: unitList.value.map(unit => ({ value: unit.unitId, label: unit.unitName, })), onChange: (unit: number) => { // ⭐ 根据 unitId 从 selectList 计算系统下拉 typeList.value = Array.from( new Map( selectList .filter(item => item.unitId === unit) .map(item => [ item.systemTypeId, { ...item }, ]), ).values(), ) // ✅ 默认选中第一个系统 formModel.type = typeList.value[0].systemTypeId formActionType.setFieldsValue({ type: typeList.value[0].systemTypeId, }) }, }), }, { label: '系统', field: 'type', component: 'Select', defaultValue: typeList.value?.[0]?.systemTypeId, colProps: { span: 8}, componentProps: ({ formModel, formActionType }) => ({ placeholder: '系统', allowClear: false, options: typeList.value.map(type => ({ value: type.systemTypeId, label: type.systemTypeName, })), onChange: (type: number) => { alert("系统改变事件") // ⭐ 根据 unitId 和 system_type_id 从 selectList 计算系统下拉 systemList.value = Array.from( new Map( selectList .filter(item => item.systemTypeId === type && item.unitId === formModel.unit) .map(item => [ item.systemId, { ...item }, ]), ).values(), ) // ✅ 默认选中第一个系统 formModel.system = systemList.value[0].systemId formActionType.setFieldsValue({ system: systemList.value[0].systemId, }) }, }), }, { label: '子系统', field: 'system', component: 'Select', defaultValue: systemList.value?.[0]?.systemId, colProps: { span: 8}, componentProps: ({ formModel, formActionType }) => ({ placeholder: '子系统', allowClear: false, options: systemList.value.map(sys => ({ value: sys.systemId, label: sys.systemName, })), onChange: (system: number) => { alert("子系统改变事件") console.log(111,system) console.log(selectList) console.log(system) // ⭐ 根据 unitId 从 selectList 计算系统下拉 mpList.value = Array.from( new Map( selectList .filter(item => item.systemId === system) .map(item => [ item.mpId, { ...item }, ]), ).values(), ) console.log(mpList.value) // ✅ 默认选中第一个系统 formModel.mpId = mpList.value[0].mpId formActionType.setFieldsValue({ mpId: mpList.value[0].mpId, }) }, }) }, { label: '模型实例', field: 'mpId', component: 'Select', defaultValue: mpList.value?.[0]?.mpId, colProps: { span:10}, componentProps: () => ({ placeholder: '模型实例', allowClear: false, options:mpList.value.map(instant => ({ value: instant.mpId, label: instant.mpName, })), onChange: async (mpId: number) => { // alert("模型实例改变事件") const res = await getInstantPoint(mpId) console.log(res) pointList.value=res; formModel.inputName = res.data?.[0]?.inputName formActionType.setFieldsValue({ inputName: res.data?.[0]?.inputName, }) } })}, { label: '预警点号', field: 'inputName', component: 'Select', defaultValue: pointList.value?.[0]?.inputName, colProps: { span:11}, componentProps: () => ({ placeholder: '预警点号', allowClear: false, options:pointList.value.map(point => ({ value: point.inputName, label: point.inputName, })), onChange: async (inputName: string) => { // alert("预警点号改变事件") } })} ]