Browse Source

Merge pull request 'fix:exa历史增加时间间隔选择框' (#106) from dev-xjf into master

Reviewed-on: http://120.26.116.243:3000/root/alert-front/pulls/106
pull/108/head
xiaojinfei 2 weeks ago
parent
commit
4c9ef56050
  1. 5
      src/views/exa/config/index.vue
  2. 3
      src/views/exa/exa.data.ts
  3. 132
      src/views/exa/history/index.vue
  4. 200
      src/views/run/instant/detail1.vue
  5. 127
      src/views/run/instant/instant.data.ts

5
src/views/exa/config/index.vue

@ -112,10 +112,10 @@ async function handleDelete(record: Recordable) {
<BasicTable @register="registerTable"> <BasicTable @register="registerTable">
<template #form-advanceAfter> <template #form-advanceAfter>
<Space > <Space >
<a-button v-auth="['system:role:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate"> <a-button type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate">
{{ t('action.create') }} {{ t('action.create') }}
</a-button> </a-button>
<a-button v-auth="['system:role:create']" type="primary" :pre-icon="IconEnum.ADDS" @click="handleCreateBatch"> <a-button type="primary" :pre-icon="IconEnum.ADDS" @click="handleCreateBatch">
{{ t('action.createBatch') }} {{ t('action.createBatch') }}
</a-button> </a-button>
</Space> </Space>
@ -145,7 +145,6 @@ async function handleDelete(record: Recordable) {
icon: IconEnum.DELETE, icon: IconEnum.DELETE,
danger: true, danger: true,
label: t('action.delete'), label: t('action.delete'),
auth: 'alert:exa:delete',
popConfirm: { popConfirm: {
title: t('common.delMessage'), title: t('common.delMessage'),
placement: 'left', placement: 'left',

3
src/views/exa/exa.data.ts

@ -126,6 +126,9 @@ export const formHistory: FormSchema[] = [
console.log(e) console.log(e)
}, },
}, },
colProps: {
span: 10,
},
}, },
{ {
label: '时间间隔', label: '时间间隔',

132
src/views/exa/history/index.vue

@ -1,46 +1,53 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, reactive, ref } from 'vue' import {reactive, ref, nextTick} from 'vue'
import type { Dayjs } from 'dayjs'
import moment from 'moment' import moment from 'moment'
import { Button, Card, Empty, Form, FormItem, RangePicker, Space, message } from 'ant-design-vue' import {BasicForm, useForm} from '@/components/Form'
import {Card, message, Space} from 'ant-design-vue'
import HistoryLine from '../HistoryLine.vue' import HistoryLine from '../HistoryLine.vue'
import PointModal from './PointModal.vue' import PointModal from './PointModal.vue'
import { getExaHistorys } from '@/api/alert/exa' import {getExaHistorys} from '@/api/alert/exa'
import { useModal } from '@/components/Modal' import {useModal} from '@/components/Modal'
import {useForm} from "@/components/Form";
import {calcFormSchemas} from "@/views/run/calc/calc.data"; import {calcFormSchemas} from "@/views/run/calc/calc.data";
import {formHistory} from "@/views/exa/exa.data";
import {EXAHistoryReqVO} from "@/api/alert/warn";
const [registerForm, {getFieldsValue}] = useForm({
labelWidth: 100,
schemas: formHistory,
showSubmitButton: false,
showResetButton: false,
layout: 'horizontal',
model: {time: [moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')]},
fieldMapToTime: [
// datastartTimeendTime
['time', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss'],
],
interface FormState {
publishTime: any[]
}
const searchForm = reactive<FormState>({
publishTime: [],
}) })
const loading = ref(true) //
const handleRegisterForm = (instance) => {
function onRangeChange(value: [Dayjs, Dayjs], dateString: [string, string]) { //
console.log('Selected Time: ', value) registerForm(instance)
console.log('Formatted Selected Time: ', dateString) // model + fieldMapToTime
} nextTick(() => {
getHistoryChart()
function onRangeOk(value: [Dayjs, Dayjs]) { })
console.log('onOk: ', value)
console.log(searchForm.publishTime)
searchForm.publishTime = value
} }
const loading = ref(false)
const selectedData = ref<Recordable[]>([]) const selectedData = ref<Recordable[]>([])
interface RowKeys { interface RowKeys {
selectedRowKeys: number[] selectedRowKeys: number[]
} }
const state = reactive<RowKeys>({ const state = reactive<RowKeys>({
selectedRowKeys: [], selectedRowKeys: [],
}) })
onMounted(() => { //
searchForm.publishTime = [moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')] // onMounted(() => {
getHistoryChart() // getHistoryChart()
}) // })
const historyData = ref() const historyData = ref()
const legendName = ref<any[]>([]) const legendName = ref<any[]>([])
@ -56,20 +63,18 @@ async function getHistoryChart() {
message.info('暂无测点') message.info('暂无测点')
const pointCode = selectedData.value.map(item => (item.itemName)).join(',') const pointCode = selectedData.value.map(item => (item.itemName)).join(',')
const pointDesc: any[] = selectedData.value.map(item => (item.descriptor+'('+item.itemName+')')) const pointDesc: any[] = selectedData.value.map(item => (item.descriptor + '(' + item.itemName + ')'))
const exaHistoryReqVO = { const exaHistoryReqVO = getFieldsValue() as EXAHistoryReqVO
startTime: searchForm.publishTime[0], exaHistoryReqVO.itemName = pointCode;
endTime: searchForm.publishTime[1], console.log(exaHistoryReqVO)
itemName: pointCode,
interval: 100,
}
historyData.value = await getExaHistorys(exaHistoryReqVO) historyData.value = await getExaHistorys(exaHistoryReqVO)
legendName.value = pointDesc; legendName.value = pointDesc;
loading.value = false loading.value = false
} }
const [registerPointModal, { openModal: openPointModal }] = useModal() const [registerPointModal, {openModal: openPointModal}] = useModal()
function handlePointModal() { function handlePointModal() {
openPointModal(true) openPointModal(true)
} }
@ -78,32 +83,43 @@ function handlePointModal() {
<template> <template>
<div> <div>
<Card> <Card>
<Form layout="inline" :model="searchForm"> <BasicForm @register="handleRegisterForm" :actionColOptions="{ span: 0 }">
<FormItem label="时间范围"> <template #formFooter>
<RangePicker <div style="margin-left: 10px">
:model="searchForm.publishTime" <Space>
:show-time="{ format: 'HH:mm:ss' }" <a-button type="primary" @click="getHistoryChart">查看趋势</a-button>
:placeholder="['开始时间', '结束时间']" :default-value="[moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')]" <a-button @click="handlePointModal">测点配置</a-button>
value-format="YYYY-MM-DD HH:mm:ss" </Space>
@change="onRangeChange" </div>
@ok="onRangeOk" </template>
/> </BasicForm>
</FormItem> <!-- <Form layout="inline" :model="searchForm">-->
<FormItem> <!-- <FormItem label="时间范围">-->
<Space wrap> <!-- <RangePicker-->
<Button type="primary" @click="getHistoryChart"> <!-- :model="searchForm.publishTime"-->
查看趋势 <!-- :show-time="{ format: 'HH:mm:ss' }"-->
</Button> <!-- :placeholder="['开始时间', '结束时间']" :default-value="[moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')]"-->
<Button @click="handlePointModal"> <!-- value-format="YYYY-MM-DD HH:mm:ss"-->
测点配置 <!-- @change="onRangeChange"-->
</Button> <!-- @ok="onRangeOk"-->
</Space> <!-- />-->
</FormItem> <!-- </FormItem>-->
</Form> <!-- <FormItem>-->
<!-- <Space wrap>-->
<!-- <Button type="primary" @click="getHistoryChart">-->
<!-- 查看趋势-->
<!-- </Button>-->
<!-- <Button @click="handlePointModal">-->
<!-- 测点配置-->
<!-- </Button>-->
<!-- </Space>-->
<!-- </FormItem>-->
<!-- </Form>-->
</Card> </Card>
<Card style="margin:5px" :loading="loading"> <Card style="margin:5px" :loading="loading">
<HistoryLine :data="historyData" :name="legendName" height="70vh" /> <HistoryLine :data="historyData" :name="legendName" height="70vh"/>
</Card> </Card>
<PointModal :selected-row-keys="state.selectedRowKeys" :selected-data="selectedData" @register="registerPointModal" @success="getHistoryChart" /> <PointModal :selected-row-keys="state.selectedRowKeys" :selected-data="selectedData"
@register="registerPointModal" @success="getHistoryChart"/>
</div> </div>
</template> </template>

200
src/views/run/instant/detail1.vue

@ -1,200 +0,0 @@
<script lang="ts" setup>
import { onMounted, reactive, ref } from 'vue'
import type { Dayjs } from 'dayjs'
import moment from 'moment'
import { Card, Descriptions, DescriptionsItem, Form, FormItem, RangePicker, Space, Switch, message } from 'ant-design-vue'
import { mount } from 'sortablejs'
import { number } from 'vue-types'
import { useRoute } from 'vue-router'
import HistoryLine from '../../exa/HistoryLine.vue'
import { detailColumns, instantForm } from './instant.data'
import { getExaHistorys } from '@/api/alert/exa'
import { useModal } from '@/components/Modal'
import { BasicTable, TableAction, useTable } from '@/components/Table'
import { getInstant, getInstantChart, getInstantPage, getInstantPoint } from '@/api/alert/run/instant'
import { useI18n } from '@/hooks/web/useI18n'
import { router } from '@/router'
import { BasicForm, useForm } from '@/components/Form'
import PropsPanel from '@/components/FormDesign/src/components/VFormDesign/modules/PropsPanel.vue'
import echarts from '@/utils/lib/echarts'
defineOptions({ name: 'InstantDetail' })
const route = useRoute()
// const props = defineProps({
// id: {
// type: Number,
// default: null,
// },
// })
const { t } = useI18n()
const loadingBasic = ref<boolean>(false)
const loadingChart = ref<boolean>(false)
const basicInfo = ref<any>({})
const modelInfo = ref<any>({})
const pointInfo = ref<any>({})
const pointList = ref<any>([])
const historyList = ref<any>([])
const [registerForm, { getFieldsValue, setProps }] = useForm({
labelWidth: 100,
// baseColProps: { span: 24 },
schemas: instantForm,
showResetButton: false,
layout: 'horizontal',
// model: { time: [moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')] },
fieldMapToTime: [
// datastartTimeendTime
['time', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss'],
],
actionColOptions: {
span: 2,
style:{
marginLeft:'5px'
}},
})
const instantId = ref<any>(route.query.mpId) // URLquery
onMounted(async () => {
loadingBasic.value = true
basicInfo.value = await getInstant(instantId.value)
loadingBasic.value = false
modelInfo.value = JSON.parse(basicInfo.value.modelInfo)
pointInfo.value = modelInfo.value.pointInfo
console.log(modelInfo.value)
pointList.value = await getInstantPoint(instantId.value)
getChartsData()
})
function handleSubmitR() {
getChartsData()
}
async function getChartsData() {
setProps({
submitButtonOptions: {
loading: true,
},
})
loadingChart.value = true
console.log(getFieldsValue())
const instantForm = getFieldsValue()
historyList.value = await getInstantChart({ ...{ id: instantId.value }, ...instantForm })
echarts.connect('async')
loadingChart.value = false
setProps({
submitButtonOptions: {
loading: false,
},
})
}
const [registerTable] = useTable({
title: '测点列表',
size: 'small',
dataSource: pointList,
columns: detailColumns,
useSearchForm: false,
showTableSetting: true,
showIndexColumn: false,
actionColumn: {
width: 140,
title: t('common.action'),
dataIndex: 'action',
fixed: 'right',
},
})
function handleDetail(record) {
console.log(record)
router.push('/run/instant/detail')
}
function handleFaultConfig(field) {
console.log(field)
}
</script>
<template>
<div>
<Card :loading="loadingBasic">
<Descriptions size="small" title="模型基本信息" bordered :column="{ xxl: 4, xl: 3, lg: 3, md: 3, sm: 2, xs: 1 }">
<DescriptionsItem label="实例名称" :span="4">
{{ basicInfo.mpName }}
</DescriptionsItem>
<DescriptionsItem label="创建人">
{{ basicInfo.createName }}
</DescriptionsItem>
<DescriptionsItem label="创建时间">
{{ moment(basicInfo.createTime).format("YYYY-MM-DD HH:mm:ss") }}
</DescriptionsItem>
<DescriptionsItem label="最近修改人">
{{ basicInfo.updateName }}
</DescriptionsItem>
<DescriptionsItem label="最近修改时间">
{{ moment(basicInfo.updateTime).format("YYYY-MM-DD HH:mm:ss") }}
</DescriptionsItem>
<DescriptionsItem label="算法">
{{ basicInfo.algorithmShortname }}
</DescriptionsItem>
<DescriptionsItem label="训练采样间隔">
{{ modelInfo.sampling }}
</DescriptionsItem>
<DescriptionsItem label="参数个数">
{{ pointInfo.length }}
</DescriptionsItem>
<DescriptionsItem label="最小主元贡献率">
{{ modelInfo.rate }}
</DescriptionsItem>
<DescriptionsItem label="主元个数">
{{ modelInfo.principal }}
</DescriptionsItem>
<DescriptionsItem label="模型精度">
{{ modelInfo.precision }}
</DescriptionsItem>
</Descriptions>
</Card>
<Card>
<BasicTable @register="registerTable">
<template #detail="{ record }">
<a class="click-status" @click="handleDetail(record)">
{{ record.mpName }}
</a>
<!-- <SlidersOutlined class="click-status" /> -->
</template>
</BasicTable>
</Card>
<Card>
<BasicForm @register="registerForm" @submit="handleSubmitR">
<!-- 添加button的插槽 -->
<template #configButton="{ field }">
<a-button @click="handleFaultConfig(field)">
故障配置
</a-button>
</template>
</BasicForm>
</Card>
<Card :loading="loadingChart">
<div>
<div v-for="(item, index) in historyList" :key="index">
<div style="border:1px solid #ccc">
<HistoryLine :is-async="index !== 0" :title="item.title" :data="item.seriesData" :name="item.name" height="250px" />
</div>
</div>
</div>
</Card>
</div>
</template>
<style lang="less" scoped>
:deep(.ant-table-body){
height:100% !important;
max-height:100% !important
}
</style>

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

@ -82,143 +82,17 @@ export const columns: BasicColumn[] = [
slots: { customRender: 'status' }, slots: { customRender: 'status' },
fixed: 'right', fixed: 'right',
}, },
// { // {
// title: '实时值', // title: '实时值',
// dataIndex: 'value', // dataIndex: 'value',
// width: 90, // width: 90,
// className: 'value', // className: 'value',
// slots: { customRender: 'value' }, // slots: { customRender: 'value' },
// } // }
] ]
const optionList = await optionListApi() const optionList = await optionListApi()
const systemOptions = ref<any>([]) 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
// 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 * schema
* @param showAlgorithm * @param showAlgorithm
@ -233,6 +107,7 @@ export function getSearchFormSchema(showAlgorithm = true): FormSchema[] {
colProps: { span: 4 }, colProps: { span: 4 },
componentProps: ({ formModel }) => ({ componentProps: ({ formModel }) => ({
placeholder: '全部机组', placeholder: '全部机组',
style: { 'color': 'green', fontSize: '14px' },
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 param: systemSelectParams = { unitId: e, typeId: formModel.type } const param: systemSelectParams = { unitId: e, typeId: formModel.type }

Loading…
Cancel
Save