Browse Source

fix:下拉框代码数据优化

pull/105/head
肖晋飞 2 weeks ago
parent
commit
0919861507
  1. 6
      src/views/run/calc/index.vue
  2. 5
      src/views/run/instant/index.vue
  3. 293
      src/views/run/instant/instant.data.ts
  4. 27
      src/views/warn/alarm/index.vue

6
src/views/run/calc/index.vue

@ -4,7 +4,7 @@ import {onMounted, ref, reactive} from 'vue'
import moment from 'moment'
import HistoryModal from '../../exa/config/HistoryModal.vue'
import {calcFormSchemas, columns} from './calc.data'
import {searchFormSchema} from '../instant/instant.data'
import {getSearchFormSchema} from '../instant/instant.data'
import {BasicTable, TableAction, useTable} from '@/components/Table'
import {BasicForm, useForm} from '@/components/Form'
@ -30,6 +30,8 @@ const statusMap = {
//
const selectedRowss = ref<any[]>([])
const searchSchema = ref<FormSchema[]>(getSearchFormSchema(true)) //
const [registerTable, {getForm, reload, getDataSource, updateTableDataRecord}] = useTable({
title: '实例列表',
api: getInstantPage,
@ -38,7 +40,7 @@ const [registerTable, {getForm, reload, getDataSource, updateTableDataRecord}] =
columns,
formConfig: {
labelWidth: 70,
schemas: searchFormSchema,
schemas: searchSchema.value,
showResetButton: false,
actionColOptions: {
span: 2,

5
src/views/run/instant/index.vue

@ -3,7 +3,7 @@ import { Tag,Badge, Switch } from 'ant-design-vue'
import { onMounted, ref } from 'vue'
import HistoryModal from '../../exa/config/HistoryModal.vue'
import { columns, searchFormSchema } from './instant.data'
import {columns, getSearchFormSchema} from './instant.data'
import CreateModal from './CreateModal.vue'
import UpdateModal from './UpdateModal.vue'
@ -23,6 +23,7 @@ const { t } = useI18n()
const [registerHistoryModal, { openModal: openHistoryModal }] = useModal()
const [registerCreateModal, { openModal: openCreateModal }] = useModal()
const [registerUpdateModal, { openModal: openUpdateModal }] = useModal()
const searchSchema = ref<FormSchema[]>(getSearchFormSchema(true)) //
const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] = useTable({
title: '实例列表',
@ -32,7 +33,7 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }]
columns,
formConfig: {
labelWidth: 80,
schemas: searchFormSchema,
schemas: searchSchema.value,
showResetButton: false,
actionColOptions: {
span: 3,

293
src/views/run/instant/instant.data.ts

@ -98,127 +98,226 @@ const optionList = await optionListApi()
const systemOptions = ref<any>([])
// systemOptions.value = optionList.systems
export const searchFormSchema: FormSchema[] = [
{
label: '机组',
field: 'unit',
component: 'Select',
// defaultValue: optionList.units[0].id || null,
defaultValue: null,
colProps: { span: 4 },
componentProps: ({ schema, tableAction, formActionType, formModel }) => {
return {
// xxxx props
// export const searchFormSchema: FormSchema[] = [
// {
// label: '机组',
// field: 'unit',
// component: 'Select',
// // defaultValue: optionList.units[0].id || null,
// defaultValue: null,
//
// colProps: { span: 4 },
//
// componentProps: ({ schema, tableAction, formActionType, formModel }) => {
// return {
// // xxxx props
// 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,
// }
// //如果typeId是空,则不设置system'Options
// if (!param.typeId || !param.unitId) {
// systemOptions.value = []
// return
// }
// systemOptions.value = await subSystemListApi(param)
// // formModel.system = systemOptions.value[0].id
// },
// }
// },
// },
// {
// label: '系统',
// field: 'type',
// component: 'Select',
// // defaultValue: optionList.types[0].id || null,
// defaultValue: null,
//
// colProps: { span: 4 },
// componentProps: ({ formModel }) => {
// return {
// 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,
// }
// //如果typeId是空,则不设置system'Options
// if (!param.typeId || !param.unitId) {
// systemOptions.value = []
// return
// }
// systemOptions.value = await subSystemListApi(param)
// },
// }
// },
// },
// {
// label: '子系统',
// field: 'system',
// component: 'Select',
// // defaultValue: systemOptions.value[0].id || null,
// defaultValue: null,
// colProps: { span: 4 },
// componentProps: () => {
// return {
// 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:true
// },
// {
// label: '状态1',
// field: 'running',
// component: 'Input',
// show: false,
// },
// {
// label: '状态2',
// field: 'runningLog',
// component: 'Input',
// show: false,
// },
// {
// label: '状态3',
// field: 'isUpdate',
// component: 'Input',
// show: false,
// },
// ]
/**
* schema
* @param showAlgorithm
*/
export function getSearchFormSchema(showAlgorithm = true): FormSchema[] {
return [
{
label: '机组',
field: 'unit',
component: 'Select',
defaultValue: null,
colProps: { span: 4 },
componentProps: ({ formModel }) => ({
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,
}
//如果typeId是空,则不设置system'Options
const param: systemSelectParams = { unitId: e, typeId: formModel.type }
if (!param.typeId || !param.unitId) {
systemOptions.value = []
return
}
systemOptions.value = await subSystemListApi(param)
// formModel.system = systemOptions.value[0].id
},
}
}),
},
},
{
label: '系统',
field: 'type',
component: 'Select',
// defaultValue: optionList.types[0].id || null,
defaultValue: null,
colProps: { span: 4 },
componentProps: ({ formModel }) => {
return {
{
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 { reload } = tableAction
// reload()
// or
console.log(e)
const param: systemSelectParams = {
unitId: formModel.unit,
typeId: e,
}
//如果typeId是空,则不设置system'Options
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: systemOptions.value[0].id || null,
defaultValue: null,
colProps: { span: 4 },
componentProps: () => {
return {
{
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)" }],
{
label: '模型实例名称',
field: 'mpName',
component: 'Input',
labelWidth: 100,
defaultValue: '',
colProps: { span: 5 },
},
defaultValue: null,
colProps: { span: 3 },
},
{
label: '状态1',
field: 'running',
component: 'Input',
show: false,
},
{
label: '状态2',
field: 'runningLog',
component: 'Input',
show: false,
},
{
label: '状态3',
field: 'isUpdate',
component: 'Input',
show: false,
},
]
{
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[] = [
{

27
src/views/warn/alarm/index.vue

@ -1,9 +1,11 @@
<script lang="ts" setup>
import { Switch } from 'ant-design-vue'
import { onMounted,ref } from 'vue'
import {nextTick, onMounted, ref} from 'vue'
import { useRoute } from 'vue-router'
import { columns, searchFormSchema } from './alarm.data'
import { columns } from './alarm.data'
import { getSearchFormSchema } from '../../run/instant/instant.data'
import UpdateModal from '../../run/instant/warnConfig/UpdateModal.vue'
import TrendModal from './TrendModal.vue'
import { BasicTable, TableAction, useTable } from '@/components/Table'
@ -22,8 +24,8 @@ const { createMessage } = useMessage()
const { t } = useI18n()
const [registerUpdateModal, { openModal: openUpdateModal }] = useModal()
const [registerTrendModal, { openModal: openTrendModal }] = useModal()
const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] = useTable({
const searchSchema = ref<FormSchema[]>(getSearchFormSchema(false)) //
const [registerTable, { getForm,reload, getDataSource }] = useTable({
title: '集中告警列表',
api: getWarnPageReal,
rowKey: 'warnId',
@ -33,7 +35,7 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }]
useSearchForm: true,
formConfig: {
labelWidth: 80,
schemas: searchFormSchema,
schemas: searchSchema.value,
showResetButton: false,
submitButtonOptions:{
preIcon: IconEnum.SEARCH,
@ -55,13 +57,6 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }]
fixed: 'right',
}
})
async function updateStatus(record) {
await updateWarn(record)
createMessage.success(t('common.saveSuccessText'))
console.log(record)
reload()
}
function handleUpdate(record: Recordable) {
openUpdateModal(true, { record, isUpdate: true })
}
@ -79,8 +74,12 @@ async function handleTrend(record: Recordable) {
}
onMounted(async () => {
// const { setFieldsValue } = getForm()
// await setFieldsValue({ system: null })
// await nextTick();
// //algorithmId
// updateSchema([
// { field: 'algorithmId', show: false },
// ]);
})
</script>

Loading…
Cancel
Save