import moment from 'moment' import { ref } from 'vue' import type { BasicColumn, FormSchema } from '@/components/Table' import { DICT_TYPE, getDictOptions } from '@/utils/dict' import { optionListApi, subSystemListApi } from '@/api/alert/model/select' import type { systemSelectParams } from '@/api/alert/model/model/optionsModel' export const columns: BasicColumn[] = [ { title: '编号', dataIndex: 'mpId', width: 60, fixed: 'left', }, { title: '模型名称', dataIndex: 'modelName', width: 200, className: 'instant', slots: { customRender: 'detail' }, fixed: 'left', }, { title: '算法', dataIndex: 'algorithmShortname', width: 100, }, { title: '模式覆盖率', dataIndex: 'CoveredPercent', width: 100, }, { title: '报警次数', dataIndex: 'AlarmNumber', width: 100, }, { title: '总报警时间(m)', dataIndex: 'AlarmToatlMinutes', width: 100, }, { title: '系统维度', dataIndex: 'Dimension', width: 100, }, { title: '计算耗时(s)', dataIndex: 'CalcSeconds', width: 100, }, { title: '状态', dataIndex: 'status', width: 100, slots: { customRender: 'status' }, fixed: 'right', }, ] const optionList = await optionListApi() const systemOptions = ref([]) systemOptions.value = optionList.systems export const searchFormSchema: FormSchema[] = [ { label: '机组', field: 'unit', component: 'Select', defaultValue: optionList.units[0].id || null, colProps: { span: 5 }, componentProps: ({ formModel }) => { return { // xxxx props allowClear: false, placeholder: '请选择机组', options: optionList.units.map(unit => ({ value: unit.id, label: unit.name })), onChange: async (e: any) => { // const { reload } = tableAction // reload() // or console.log(e) const param: systemSelectParams = { unitId: e, typeId: formModel.type, } systemOptions.value = await subSystemListApi(param) formModel.system = systemOptions.value[0].id }, } }, }, { label: '系统', field: 'type', component: 'Select', defaultValue: optionList.types[0].id || null, colProps: { span: 5 }, componentProps: ({ formModel }) => { return { allowClear: false, placeholder: '请选择系统', options: optionList.types.map(type => ({ value: type.id, label: type.name })), onChange: async (e: any) => { // const { reload } = tableAction // reload() // or console.log(e) const param: systemSelectParams = { unitId: formModel.unit, typeId: e, } systemOptions.value = await subSystemListApi(param) }, } }, }, { label: '子系统', field: 'system', component: 'Select', defaultValue: systemOptions.value[0].id || null, colProps: { span: 5 }, componentProps: () => { return { allowClear: false, placeholder: '请选择子系统', options: systemOptions.value.map(system => ({ value: system.id, label: system.name })), } }, }, { label: '模型名称', field: 'modelName', component: 'Input', defaultValue: '', componentProps: { placeholder: '请输入模型名称', }, colProps: { span: 6 }, }, ] export const calcFormSchemas: FormSchema[] = [ { label: '回算时间', field: 'time', component: 'RangePicker', componentProps: { placeholder: ['开始时间', '结束时间'], defaultValue: [moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')], valueFormat: 'YYYY-MM-DD HH:mm:ss', showTime: { defaultValue: [moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')], }, onChange: (e: any) => { console.log(e) }, allowClear: false, // ← 必须用这个 }, required: true, colProps: { span: 10, }, }, { label: '采样周期', field: 'interval', component: 'Select', defaultValue: 60, componentProps: { options: [{ value: 10, label: '10秒' }, { value: 60, label: '60秒' }, { value: 300, label: '300秒' }], }, required: true, colProps: { span: 5, }, }, ]