You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

570 lines
11 KiB

import moment from 'moment'
import { left } from 'inquirer/lib/utils/readline'
import { ref } from 'vue'
import type { BasicColumn, FormSchema } from '@/components/Table'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
import { getModelVersionList } from '@/api/alert/run/model/index'
import { optionListApi, subSystemListApi } from '@/api/alert/model/select'
import type { systemSelectParams } from '@/api/alert/model/model/optionsModel'
import {setObjToUrlParams} from "@/utils";
export const columns: BasicColumn[] = [
{
title: '编号',
dataIndex: 'mpId',
width: 80,
fixed: 'left',
},
{
title: '实例状态',
dataIndex: 'status1',
width: 100,
slots: { customRender: 'runStatus' },
fixed: 'left',
},
{
title: '实例名称',
dataIndex: 'mpName',
width: 250,
className: 'instant',
slots: { customRender: 'detail' },
fixed: 'left',
},
{
title: '专业',
dataIndex: 'systemName',
width: 200,
},
{
title: '算法',
dataIndex: 'algorithmName',
width: 200,
},
{
title: '模式',
dataIndex: 'conditionName',
width: 200,
},
{
title: '原模型名称',
dataIndex: 'modelName',
width: 200,
},
{
title: '版本',
dataIndex: 'modelVersion',
width: 200,
},
{
title: '运行日志',
dataIndex: 'runningLog',
width: 200,
},
{
title: '计算组',
dataIndex: 'groupName',
width: 200,
},
{
title: '统计量',
dataIndex: 'pointSte',
width: 120,
slots: { customRender: 'history' },
fixed: 'left',
},
{
title: '投切',
dataIndex: 'instantStatus',
width: 100,
slots: { customRender: 'status' },
fixed: 'right',
},
// {
// title: '实时值',
// dataIndex: 'value',
// width: 90,
// className: 'value',
// slots: { customRender: 'value' },
// }
]
const optionList = await optionListApi()
const systemOptions = ref<any>([])
/**
* schema
* @param showAlgorithm
*/
export function getSearchFormSchema(showAlgorithm = true): FormSchema[] {
return [
{
label: '机组',
field: 'unit',
component: 'Select',
defaultValue: null,
colProps: { span: 4 },
componentProps: ({ formModel }) => ({
placeholder: '全部机组',
style: { 'color': 'green', fontSize: '14px' },
options: optionList.units.map(unit => ({ value: unit.id, label: unit.name })),
onChange: async (e: any) => {
const param: systemSelectParams = { unitId: e, typeId: formModel.type }
if (!param.typeId || !param.unitId) {
systemOptions.value = []
return
}
systemOptions.value = await subSystemListApi(param)
},
}),
},
{
label: '系统',
field: 'type',
component: 'Select',
defaultValue: null,
colProps: { span: 4 },
componentProps: ({ formModel }) => ({
placeholder: '全部系统',
options: optionList.types.map(type => ({ value: type.id, label: type.name })),
onChange: async (e: any) => {
const param: systemSelectParams = { unitId: formModel.unit, typeId: e }
if (!param.typeId || !param.unitId) {
systemOptions.value = []
return
}
systemOptions.value = await subSystemListApi(param)
},
}),
},
{
label: '子系统',
field: 'system',
component: 'Select',
defaultValue: null,
colProps: { span: 4 },
componentProps: () => ({
placeholder: '全部子系统',
options: systemOptions.value.map(system => ({ value: system.id, label: system.name })),
}),
},
{
label: '模型实例名称',
field: 'mpName',
component: 'Input',
labelWidth: 100,
defaultValue: '',
colProps: { span: 5 },
},
{
label: '算法',
field: 'algorithmId',
component: 'Select',
labelWidth: 40,
componentProps: {
placeholder: '全部算法',
options: [
{ value: 1, label: '主成分分析(PCA)' },
{ value: 2, label: '神经网络(ANN)' },
],
},
defaultValue: null,
colProps: { span: 3 },
show: showAlgorithm, // 根据参数决定是否显示
},
{
label: '状态1',
field: 'running',
component: 'Input',
show: false,
},
{
label: '状态2',
field: 'runningLog',
component: 'Input',
show: false,
},
{
label: '状态3',
field: 'isUpdate',
component: 'Input',
show: false,
},
]
}
export const formSchema: FormSchema[] = [
{
label: '测点编码',
field: 'ItemName',
required: true,
component: 'Input',
},
{
label: '测点描述',
field: 'Descriptor',
required: true,
component: 'Input',
},
{
label: '单位',
field: 'EngUnits',
required: true,
component: 'Input',
},
{
label: '组名',
field: 'GroupName',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.COMMON_STATUS),
},
required: true,
},
{
label: '类型',
field: 'ItemType',
component: 'Select',
componentProps: {
options: [{ value: 1, label: 1 }, { value: 2, label: 2 }, { value: 3, label: 3 }, { value: 4, label: 4 }, { value: 5, label: 5 }],
},
required: true,
},
{
label: '自动保存',
field: 'AutoSave',
component: 'Select',
componentProps: {
options: [{ value: 1, label: '是' }, { value: 2, label: '否' }],
},
required: true,
},
{
label: '数据来源',
field: 'Source',
component: 'Input',
},
]
export const instantForm: FormSchema[] = [
{
label: '时间范围',
field: 'time',
show: true,
component: 'RangePicker',
defaultValue: [moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')],
componentProps: {
placeholder: ['开始时间', '结束时间'],
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)
},
colProps: {
span: 8,
},
},
},
{
label: '时间间隔',
field: 'interval',
component: 'Select',
defaultValue: 300,
labelWidth:100,
componentProps: {
options: [{ value: 1, label: '1秒' }, { value: 10, label: '10秒' }, { value: 100, label: '100秒' }, { value: 300, label: '300秒' }],
},
required: true,
colProps: {
span: 3,
},
},
{
label: '复盘',
field: 'fp',
labelWidth:100,
component: 'RadioGroup',
defaultValue: 0,
colProps: {
span: 5,
},
componentProps: {
options: [
{
label: '是',
value: 1,
},
{
label: '否',
value: 0,
},
],
},
required: true,
},
{
label: '',
field: 'faultConfig',
component: 'Input',
slot: 'configButton',
colProps: {
span: 2,
}
}
]
export const searchFormSchemaModel: FormSchema[] = [
{
label: '模型实例名称',
field: 'mpName',
component: 'Input',
defaultValue: '',
required: true,
colProps: { span: 8 },
},
]
export const createInstantForm: FormSchema[] = [
{
label: '所用模型的id',
field: 'modelId',
component: 'Input',
required: true,
show: false,
colProps: {
span: 12,
},
},
{
label: '算法id',
field: 'algorithmId',
component: 'Input',
required: true,
show: false,
colProps: {
span: 12,
},
},
{
label: '实例名称',
field: 'mpName',
component: 'Input',
required: true,
colProps: {
span: 12,
},
componentProps: {
placeholder: '请选择下方模型以生成实例',
},
rules: [{ required: true, message: '请选择下方模型以生成实例' }],
},
{
label: '运行周期',
field: 'intervalTime',
component: 'Input',
required: true,
defaultValue: 30,
colProps: {
span: 6,
},
},
{
label: '计算组',
field: 'calcGroup',
component: 'Select',
componentProps: {
options: [],
},
colProps: {
span: 6,
},
required: true,
},
{
label: '版本号',
field: 'modelVersionId',
component: 'Select',
componentProps: {
// api: getModelVersionList,
// labelField: 'version',
// valueField: 'id',
// params: {},
options: [],
},
colProps: {
span: 12,
},
required: true,
},
{
label: '是否存储',
field: 'hisSto',
component: 'RadioGroup',
defaultValue: '1',
componentProps: {
options: [
{
label: '是',
value: '1',
},
{
label: '否',
value: '0',
},
],
},
colProps: {
span: 12,
},
required: true,
},
]
export const updateInstantForm: FormSchema[] = [
{
label: '编号',
field: 'mpId',
component: 'Input',
required: true,
show: false,
},
{
label: '实例名称',
field: 'mpName',
component: 'Input',
required: true,
componentProps: {
placeholder: '请输入实例名称',
},
rules: [{ required: true, message: '请输入实例名称' }],
},
{
label: '计算组',
field: 'calcGroup',
component: 'Select',
componentProps: {
options: [],
},
required: true,
},
{
label: '版本号',
field: 'modelVersionId',
component: 'Select',
componentProps: {
options: [],
},
required: true,
},
]
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,
},
]