|
|
|
@ -6,7 +6,9 @@ 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"; |
|
|
|
import {getInstantList} from "@/api/alert/run/instant"; |
|
|
|
|
|
|
|
export const columns: BasicColumn[] = [ |
|
|
|
{ |
|
|
|
@ -203,29 +205,42 @@ export const columns: BasicColumn[] = [ |
|
|
|
* 获取搜索表单 schema(vben 标准版) |
|
|
|
*/ |
|
|
|
|
|
|
|
const optionList = await optionListApi() |
|
|
|
|
|
|
|
// 子系统 options 用普通变量维护(不是 ref)
|
|
|
|
const systemOptions = ref<any[]>([]) |
|
|
|
|
|
|
|
// 非“全部”时,提前加载一次
|
|
|
|
if (optionList.units?.length && optionList.types?.length) { |
|
|
|
const param: systemSelectParams = { |
|
|
|
unitId: optionList.units[0].id, |
|
|
|
typeId: optionList.types[0].id, |
|
|
|
} |
|
|
|
systemOptions.value = await subSystemListApi(param) |
|
|
|
console.log(systemOptions.value) |
|
|
|
export interface selectParams { |
|
|
|
unitId: number | null; |
|
|
|
typeId: number | null; |
|
|
|
systemId: number | null; |
|
|
|
} |
|
|
|
export function getSearchFormSchema( |
|
|
|
|
|
|
|
export async function getSearchFormSchema( |
|
|
|
showAlgorithm = true, |
|
|
|
showAll = true, |
|
|
|
showName=true, |
|
|
|
isModal=false |
|
|
|
isModal=false, |
|
|
|
haveMpId = true, |
|
|
|
haveWarn = true, |
|
|
|
): Promise<FormSchema[]> { |
|
|
|
if(showAll){ |
|
|
|
systemOptions.value=[]; |
|
|
|
} |
|
|
|
|
|
|
|
const optionList = await optionListApi() |
|
|
|
const mpList = ref<any[]>([]) |
|
|
|
// 子系统 options 用普通变量维护(不是 ref)
|
|
|
|
const systemOptions = ref<any[]>([]) |
|
|
|
if (!showAll && optionList.units?.length && optionList.types?.length) { |
|
|
|
const param: systemSelectParams = { |
|
|
|
unitId: optionList.units[0].id, |
|
|
|
typeId: optionList.types[0].id, |
|
|
|
} |
|
|
|
systemOptions.value = await subSystemListApi(param); |
|
|
|
|
|
|
|
//拿到该机组、该系统、该子系统的模型实例
|
|
|
|
const param1: selectParams = { |
|
|
|
unit: optionList.units[0].id, |
|
|
|
type: optionList.types[0].id, |
|
|
|
system: systemOptions.value[1].id, |
|
|
|
} |
|
|
|
mpList.value = await getInstantList(param1) |
|
|
|
|
|
|
|
} |
|
|
|
console.log(systemOptions.value) |
|
|
|
return [ |
|
|
|
{ |
|
|
|
label: '机组', |
|
|
|
@ -233,7 +248,7 @@ if(showAll){ |
|
|
|
component: 'Select', |
|
|
|
defaultValue: showAll ? null : optionList.units?.[0]?.id, |
|
|
|
colProps: { span: isModal?8:4 }, |
|
|
|
componentProps: ({ formModel }) => ({ |
|
|
|
componentProps: ({ formModel, formActionType }) => ({ |
|
|
|
placeholder: '全部机组', |
|
|
|
options: optionList.units?.map(unit => ({ |
|
|
|
value: unit.id, |
|
|
|
@ -248,6 +263,25 @@ if(showAll){ |
|
|
|
unitId, |
|
|
|
typeId: formModel.type, |
|
|
|
}) |
|
|
|
// ✅ 给子系统赋默认值(第一个)
|
|
|
|
if (systemOptions.value.length) { |
|
|
|
formActionType.setFieldsValue({system: systemOptions.value[1].id}) |
|
|
|
} |
|
|
|
else{ |
|
|
|
formActionType.setFieldsValue({system: null}) |
|
|
|
} |
|
|
|
// //拿到该机组、该系统、该子系统的模型实例
|
|
|
|
// mpList.value = await getInstantList({
|
|
|
|
// unit: unitId,
|
|
|
|
// type: formModel.type,
|
|
|
|
// system: formModel.system,
|
|
|
|
// })
|
|
|
|
// if (mpList.value.length) {
|
|
|
|
// formActionType.setFieldsValue({mpId: mpList.value[0].mpId})
|
|
|
|
// }
|
|
|
|
// else{
|
|
|
|
// formActionType.setFieldsValue({mpId: null})
|
|
|
|
// }
|
|
|
|
}, |
|
|
|
}), |
|
|
|
}, |
|
|
|
@ -258,7 +292,7 @@ if(showAll){ |
|
|
|
component: 'Select', |
|
|
|
defaultValue: showAll ? null : optionList.types?.[0]?.id, |
|
|
|
colProps: { span: isModal?8:4 }, |
|
|
|
componentProps: ({ formModel }) => ({ |
|
|
|
componentProps: ({ formModel, formActionType }) => ({ |
|
|
|
placeholder: '全部系统', |
|
|
|
options: optionList.types?.map(type => ({ |
|
|
|
value: type.id, |
|
|
|
@ -273,6 +307,24 @@ if(showAll){ |
|
|
|
unitId: formModel.unit, |
|
|
|
typeId, |
|
|
|
}) |
|
|
|
if (!showAll&&systemOptions.value.length) { |
|
|
|
formActionType.setFieldsValue({system: systemOptions.value[1].id}) |
|
|
|
} |
|
|
|
else{ |
|
|
|
formActionType.setFieldsValue({system: null}) |
|
|
|
} |
|
|
|
// //拿到该机组、该系统、该子系统的模型实例
|
|
|
|
// mpList.value = await getInstantList({
|
|
|
|
// unit: formModel.unit,
|
|
|
|
// type: typeId,
|
|
|
|
// system: formModel.system,
|
|
|
|
// })
|
|
|
|
// if (mpList.value.length) {
|
|
|
|
// formActionType.setFieldsValue({mpId: mpList.value[0].mpId})
|
|
|
|
// }
|
|
|
|
// else{
|
|
|
|
// formActionType.setFieldsValue({mpId: null})
|
|
|
|
// }
|
|
|
|
}, |
|
|
|
}), |
|
|
|
}, |
|
|
|
@ -281,15 +333,33 @@ if(showAll){ |
|
|
|
label: '子系统', |
|
|
|
field: 'system', |
|
|
|
component: 'Select', |
|
|
|
defaultValue: null, // ⚠️ 子系统永远不要给默认值
|
|
|
|
defaultValue: showAll? null:systemOptions.value[1].id, // ⚠️ 子系统永远不要给默认值
|
|
|
|
colProps: { span: isModal?8:4 }, |
|
|
|
componentProps: () => ({ |
|
|
|
componentProps: ({ formModel, formActionType }) => ({ |
|
|
|
placeholder: '全部子系统', |
|
|
|
options: systemOptions.value.map(system => ({ |
|
|
|
options: systemOptions.value?.map(system => ({ |
|
|
|
value: system.id, |
|
|
|
label: system.name, |
|
|
|
})), |
|
|
|
})}, |
|
|
|
})) || [], |
|
|
|
onChange: async (system: number) => { |
|
|
|
|
|
|
|
if (!system || !formModel.unit) { |
|
|
|
mpList.value = [] |
|
|
|
return |
|
|
|
} |
|
|
|
mpList.value = await getInstantList({ |
|
|
|
unit: formModel.unit, |
|
|
|
type: formModel.type, |
|
|
|
system: system, |
|
|
|
}) |
|
|
|
if (mpList.value.length) { |
|
|
|
formModel.mpId=mpList.value[0].mpId |
|
|
|
} else { |
|
|
|
formModel.mpId=null |
|
|
|
} |
|
|
|
}, |
|
|
|
}) |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: '模型实例名称', |
|
|
|
field: 'mpName', |
|
|
|
@ -316,6 +386,20 @@ if(showAll){ |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
label: '模型实例', |
|
|
|
field: 'mpId', |
|
|
|
component: 'Select', |
|
|
|
defaultValue: mpList.value.length!=0?mpList.value[0].mpId:null, |
|
|
|
colProps: { span: isModal?8:4 }, |
|
|
|
show:haveMpId, |
|
|
|
componentProps: () => ({ |
|
|
|
placeholder: '全部实例', |
|
|
|
options: mpList.value.map(instant => ({ |
|
|
|
value: instant.mpId, |
|
|
|
label: instant.mpName, |
|
|
|
})), |
|
|
|
})}, |
|
|
|
// 隐藏字段(用于后端透传)
|
|
|
|
{ label: '状态1', field: 'running', component: 'Input', show: false }, |
|
|
|
{ label: '状态2', field: 'runningLog', component: 'Input', show: false }, |
|
|
|
|