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 moment from 'moment'
import HistoryModal from '../../exa/config/HistoryModal.vue' import HistoryModal from '../../exa/config/HistoryModal.vue'
import {calcFormSchemas, columns} from './calc.data' 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 {BasicTable, TableAction, useTable} from '@/components/Table'
import {BasicForm, useForm} from '@/components/Form' import {BasicForm, useForm} from '@/components/Form'
@ -30,6 +30,8 @@ const statusMap = {
// //
const selectedRowss = ref<any[]>([]) const selectedRowss = ref<any[]>([])
const searchSchema = ref<FormSchema[]>(getSearchFormSchema(true)) //
const [registerTable, {getForm, reload, getDataSource, updateTableDataRecord}] = useTable({ const [registerTable, {getForm, reload, getDataSource, updateTableDataRecord}] = useTable({
title: '实例列表', title: '实例列表',
api: getInstantPage, api: getInstantPage,
@ -38,7 +40,7 @@ const [registerTable, {getForm, reload, getDataSource, updateTableDataRecord}] =
columns, columns,
formConfig: { formConfig: {
labelWidth: 70, labelWidth: 70,
schemas: searchFormSchema, schemas: searchSchema.value,
showResetButton: false, showResetButton: false,
actionColOptions: { actionColOptions: {
span: 2, 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 { onMounted, ref } from 'vue'
import HistoryModal from '../../exa/config/HistoryModal.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 CreateModal from './CreateModal.vue'
import UpdateModal from './UpdateModal.vue' import UpdateModal from './UpdateModal.vue'
@ -23,6 +23,7 @@ const { t } = useI18n()
const [registerHistoryModal, { openModal: openHistoryModal }] = useModal() const [registerHistoryModal, { openModal: openHistoryModal }] = useModal()
const [registerCreateModal, { openModal: openCreateModal }] = useModal() const [registerCreateModal, { openModal: openCreateModal }] = useModal()
const [registerUpdateModal, { openModal: openUpdateModal }] = useModal() const [registerUpdateModal, { openModal: openUpdateModal }] = useModal()
const searchSchema = ref<FormSchema[]>(getSearchFormSchema(true)) //
const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] = useTable({ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] = useTable({
title: '实例列表', title: '实例列表',
@ -32,7 +33,7 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }]
columns, columns,
formConfig: { formConfig: {
labelWidth: 80, labelWidth: 80,
schemas: searchFormSchema, schemas: searchSchema.value,
showResetButton: false, showResetButton: false,
actionColOptions: { actionColOptions: {
span: 3, span: 3,

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

@ -98,127 +98,226 @@ const optionList = await optionListApi()
const systemOptions = ref<any>([]) const systemOptions = ref<any>([])
// systemOptions.value = optionList.systems // systemOptions.value = optionList.systems
export const searchFormSchema: FormSchema[] = [ // export const searchFormSchema: FormSchema[] = [
{ // {
label: '机组', // label: '机组',
field: 'unit', // field: 'unit',
component: 'Select', // component: 'Select',
// defaultValue: optionList.units[0].id || null, // // defaultValue: optionList.units[0].id || null,
defaultValue: null, // defaultValue: null,
//
colProps: { span: 4 }, // colProps: { span: 4 },
//
componentProps: ({ schema, tableAction, formActionType, formModel }) => { // componentProps: ({ schema, tableAction, formActionType, formModel }) => {
return { // return {
// xxxx props // // 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: '全部机组', placeholder: '全部机组',
options: optionList.units.map(unit => ({ value: unit.id, label: unit.name })), options: optionList.units.map(unit => ({ value: unit.id, label: unit.name })),
onChange: async (e: any) => { onChange: async (e: any) => {
// const { reload } = tableAction const param: systemSelectParams = { unitId: e, typeId: formModel.type }
// reload()
// or
console.log(e)
const param: systemSelectParams = {
unitId: e,
typeId: formModel.type,
}
//如果typeId是空,则不设置system'Options
if (!param.typeId || !param.unitId) { if (!param.typeId || !param.unitId) {
systemOptions.value = [] systemOptions.value = []
return return
} }
systemOptions.value = await subSystemListApi(param) systemOptions.value = await subSystemListApi(param)
// formModel.system = systemOptions.value[0].id
}, },
} }),
}, },
}, {
{ label: '系统',
label: '系统', field: 'type',
field: 'type', component: 'Select',
component: 'Select', defaultValue: null,
// defaultValue: optionList.types[0].id || null, colProps: { span: 4 },
defaultValue: null, componentProps: ({ formModel }) => ({
colProps: { span: 4 },
componentProps: ({ formModel }) => {
return {
placeholder: '全部系统', placeholder: '全部系统',
options: optionList.types.map(type => ({ value: type.id, label: type.name })), options: optionList.types.map(type => ({ value: type.id, label: type.name })),
onChange: async (e: any) => { onChange: async (e: any) => {
// const { reload } = tableAction const param: systemSelectParams = { unitId: formModel.unit, typeId: e }
// reload()
// or
console.log(e)
const param: systemSelectParams = {
unitId: formModel.unit,
typeId: e,
}
//如果typeId是空,则不设置system'Options
if (!param.typeId || !param.unitId) { if (!param.typeId || !param.unitId) {
systemOptions.value = [] systemOptions.value = []
return return
} }
systemOptions.value = await subSystemListApi(param) systemOptions.value = await subSystemListApi(param)
}, },
} }),
}, },
}, {
{ label: '子系统',
label: '子系统', field: 'system',
field: 'system', component: 'Select',
component: 'Select', defaultValue: null,
// defaultValue: systemOptions.value[0].id || null, colProps: { span: 4 },
defaultValue: null, componentProps: () => ({
colProps: { span: 4 },
componentProps: () => {
return {
placeholder: '全部子系统', placeholder: '全部子系统',
options: systemOptions.value.map(system => ({ value: system.id, label: system.name })), options: systemOptions.value.map(system => ({ value: system.id, label: system.name })),
} }),
}, },
}, {
label: '模型实例名称',
{ field: 'mpName',
label: '模型实例名称', component: 'Input',
field: 'mpName', labelWidth: 100,
component: 'Input', defaultValue: '',
labelWidth: 100, colProps: { span: 5 },
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 }, label: '算法',
}, field: 'algorithmId',
{ component: 'Select',
label: '状态1', labelWidth: 40,
field: 'running', componentProps: {
component: 'Input', placeholder: '全部算法',
show: false, options: [
}, { value: 1, label: '主成分分析(PCA)' },
{ { value: 2, label: '神经网络(ANN)' },
label: '状态2', ],
field: 'runningLog', },
component: 'Input', defaultValue: null,
show: false, colProps: { span: 3 },
}, show: showAlgorithm, // 根据参数决定是否显示
{ },
label: '状态3', {
field: 'isUpdate', label: '状态1',
component: 'Input', field: 'running',
show: false, component: 'Input',
}, show: false,
] },
{
label: '状态2',
field: 'runningLog',
component: 'Input',
show: false,
},
{
label: '状态3',
field: 'isUpdate',
component: 'Input',
show: false,
},
]
}
export const formSchema: FormSchema[] = [ export const formSchema: FormSchema[] = [
{ {

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

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

Loading…
Cancel
Save