Browse Source

fix:回算功能

pull/83/head
xjf 1 month ago
parent
commit
2f86b8712b
  1. 3
      src/locales/lang/en/action.json
  2. 3
      src/locales/lang/zh-CN/action.json
  3. 34
      src/views/run/calc/calc.data.ts
  4. 137
      src/views/run/calc/index.vue

3
src/locales/lang/en/action.json

@ -15,5 +15,6 @@
"createInstant": "CreateInstant", "createInstant": "CreateInstant",
"pointConfig": "PointConfig", "pointConfig": "PointConfig",
"warnConfig": "WarnConfig", "warnConfig": "WarnConfig",
"backCalc": "backCalc" "backCalc": "backCalc",
"calcIng": "calcIng"
} }

3
src/locales/lang/zh-CN/action.json

@ -16,5 +16,6 @@
"createInstant": "新增实例", "createInstant": "新增实例",
"pointConfig": "测点配置", "pointConfig": "测点配置",
"warnConfig": "预警配置", "warnConfig": "预警配置",
"backCalc": "回算" "backCalc": "回算",
"calcIng": "回算中"
} }

34
src/views/run/calc/calc.data.ts

@ -9,48 +9,48 @@ import type { systemSelectParams } from '@/api/alert/model/model/optionsModel'
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '编号', title: '编号',
dataIndex: 'id', dataIndex: 'mpId',
width: 80, width: 60,
fixed: 'left', fixed: 'left',
}, },
{ {
title: '模型名称', title: '模型名称',
dataIndex: 'modelName', dataIndex: 'modelName',
width: 250, width: 200,
className: 'instant', className: 'instant',
slots: { customRender: 'detail' }, slots: { customRender: 'detail' },
fixed: 'left', fixed: 'left',
}, },
{ {
title: '算法', title: '算法',
dataIndex: 'Algorithm', dataIndex: 'algorithmShortname',
width: 200, width: 100,
}, },
{ {
title: '模式覆盖率', title: '模式覆盖率',
dataIndex: 'CoveredPercent', dataIndex: 'CoveredPercent',
width: 200, width: 100,
}, },
{ {
title: '报警次数', title: '报警次数',
dataIndex: 'AlarmNumber', dataIndex: 'AlarmNumber',
width: 200, width: 100,
}, },
{ {
title: '总报警时间(m)', title: '总报警时间(m)',
dataIndex: 'AlarmToatlMinutes', dataIndex: 'AlarmToatlMinutes',
width: 200, width: 100,
}, },
{ {
title: '系统维度', title: '系统维度',
dataIndex: 'Dimension', dataIndex: 'Dimension',
width: 200, width: 100,
}, },
{ {
title: '计算耗时(s)', title: '计算耗时(s)',
dataIndex: 'CalcSeconds', dataIndex: 'CalcSeconds',
width: 200, width: 100,
}, },
{ {
title: '状态', title: '状态',
@ -71,7 +71,7 @@ export const searchFormSchema: FormSchema[] = [
field: 'unit', field: 'unit',
component: 'Select', component: 'Select',
defaultValue: optionList.units[0].id || null, defaultValue: optionList.units[0].id || null,
colProps: { span: 4 }, colProps: { span: 5 },
componentProps: ({ formModel }) => { componentProps: ({ formModel }) => {
return { return {
@ -99,7 +99,7 @@ export const searchFormSchema: FormSchema[] = [
field: 'type', field: 'type',
component: 'Select', component: 'Select',
defaultValue: optionList.types[0].id || null, defaultValue: optionList.types[0].id || null,
colProps: { span: 4 }, colProps: { span: 5 },
componentProps: ({ formModel }) => { componentProps: ({ formModel }) => {
return { return {
allowClear: false, allowClear: false,
@ -124,7 +124,7 @@ export const searchFormSchema: FormSchema[] = [
field: 'system', field: 'system',
component: 'Select', component: 'Select',
defaultValue: systemOptions.value[0].id || null, defaultValue: systemOptions.value[0].id || null,
colProps: { span: 4 }, colProps: { span: 5 },
componentProps: () => { componentProps: () => {
return { return {
allowClear: false, allowClear: false,
@ -143,7 +143,7 @@ export const searchFormSchema: FormSchema[] = [
componentProps: { componentProps: {
placeholder: '请输入模型名称', placeholder: '请输入模型名称',
}, },
colProps: { span: 4 }, colProps: { span: 6 },
}, },
] ]
@ -167,11 +167,11 @@ export const calcFormSchemas: FormSchema[] = [
required: true, required: true,
colProps: { colProps: {
span: 8, span: 10,
}, },
}, },
{ {
label: '回算采样周期', label: '采样周期',
field: 'interval', field: 'interval',
component: 'Select', component: 'Select',
defaultValue: 60, defaultValue: 60,
@ -181,7 +181,7 @@ export const calcFormSchemas: FormSchema[] = [
}, },
required: true, required: true,
colProps: { colProps: {
span: 4, span: 5,
}, },
}, },

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

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Badge, Button, Divider, Switch } from 'ant-design-vue' import { Space,Badge, Button, Divider, Switch } from 'ant-design-vue'
import { onMounted, ref } from 'vue' 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, searchFormSchema } from './calc.data' import { calcFormSchemas, columns, searchFormSchema } from './calc.data'
@ -19,15 +19,12 @@ import { useModal } from '@/components/Modal'
defineOptions({ name: 'InstantCalc' }) defineOptions({ name: 'InstantCalc' })
const { createMessage } = useMessage() const { createMessage } = useMessage()
const { t } = useI18n() const { t } = useI18n()
//
const [registerHistoryModal, { openModal: openHistoryModal }] = useModal() const selectedRowss = ref<any[]>([])
const [registerCreateModal, { openModal: openCreateModal }] = useModal()
const [registerUpdateModal, { openModal: openUpdateModal }] = useModal()
const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] = useTable({ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] = useTable({
title: '实例列表', title: '实例列表',
api: getInstantPage, api: getInstantPage,
rowKey: 'id', rowKey: 'mpId',
immediate: true, immediate: true,
columns, columns,
formConfig: { formConfig: {
@ -36,6 +33,10 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }]
showResetButton: false, showResetButton: false,
actionColOptions: { actionColOptions: {
span: 2, span: 2,
style: {
textAlign: 'left' ,
marginLeft: '10px',
},
}, },
}, },
@ -48,36 +49,16 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }]
dataIndex: 'action', dataIndex: 'action',
fixed: 'right', fixed: 'right',
}, },
}) //
rowSelection: {
const isShow = ref<boolean>(false) type: 'checkbox',
function handleCreate() {
openCreateModal(true, { isUpdate: false })
isShow.value = true
}
function handleEdit(record: Recordable) { onChange: (selectedRowKeys, selectedRows) => {
openUpdateModal(true, { record, isUpdate: true }) console.log(24)
selectedRowss.value = selectedRows
} }
async function handleDelete(record: Recordable) {
await deleteRole(record.id)
createMessage.success(t('common.delSuccessText'))
reload()
}
const itemName = ref<string>()
const legendName = ref<string[]>()
function handleHistory(record: Recordable) {
itemName.value = (JSON.parse(record.instantInfo)).model_state
legendName.value = []
legendName.value.push(`${record.mpName}-${itemName.value}`)
openHistoryModal(true, { record })
}
function handleWarnConfig(record: Recordable) {
router.push(`/run/warnConfig?id=${record.id}`)
} }
})
/** /**
* BasicForm绑定注册; * BasicForm绑定注册;
@ -97,21 +78,66 @@ const [registerForm] = useForm({
// datastartTimeendTime // datastartTimeendTime
['time', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss'], ['time', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss'],
], ],
actionColOptions: { span: 2 },
actionColOptions: { span: 5,style: { textAlign: 'left' ,marginLeft: '10px',} },
showSubmitButton: false, showSubmitButton: false,
showResetButton: false, showResetButton: false,
}) })
//
const calcLoading = ref<boolean>(false)
const rowCalcLoading = reactive({});
/** /**
* 点击提交按钮的value值----改为导出按钮 * 点击导出按钮
* @param values * @param values
*/ */
function handleSubmit(values: any) { function handleExport(values: any) {
console.log('提交按钮数据::::', values) console.log('导出按钮数据::::', values)
}
async function handlebeforeCalc() {
console.log("触发了回算按钮")
//
console.log('选中的实例:', selectedRowss.value)
const selectedRowIds = selectedRowss.value.map(row => row.mpId)
//check selectedRows
if (selectedRowIds.length === 0) {
createMessage.error('请选择要回算的实例')
return
}
//
const formData = await getForm().validateFields()
// id
formData.mpIds = selectedRowIds;
handleCalc(formData)
} }
// //
function handleCalc(values: any) { async function handleCalc(formData: any) {
console.log('提交按钮数据::::', values) calcLoading.value = true
console.log('点击回算按钮数据::::', formData)
//
for (const mpId of formData.mpIds) {
rowCalcLoading[mpId] = true
console.log('行内回算loading状态:', mpId, rowCalcLoading[mpId])
try {
// -
// 3
await new Promise(resolve => {
setTimeout(() => {
resolve()
}, 3000)
})
createMessage.success(t('common.success'))
} catch (error) {
createMessage.error(t('common.fail'))
} finally {
rowCalcLoading[mpId] = false
}
}
calcLoading.value = false
} }
</script> </script>
@ -128,34 +154,33 @@ function handleCalc(values: any) {
<!-- 自定义表单 --> <!-- 自定义表单 -->
<BasicForm @register="registerForm"> <BasicForm @register="registerForm">
<template #advanceBefore> <template #advanceBefore>
<a-button v-auth="['run:instant:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate"> <Space>
{{ t('action.create') }} <a-button type="primary" :loading="calcLoading" :pre-icon="IconEnum.BACK_CALC" @click="handlebeforeCalc">
{{ t('action.backCalc') }}
</a-button>
<a-button type="primary" :pre-icon="IconEnum.EXPORT" @click="handleExport">
{{ t('action.export') }}
</a-button> </a-button>
</Space>
</template> </template>
</BasicForm> </BasicForm>
</template> </template>
<!-- 统计量点击跳转历史曲线 -->
<template #history="{ record }">
<a @click="handleHistory(record)">
{{ record.pointSte }}
</a>
<!-- <SlidersOutlined class="click-status" /> -->
</template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<!-- <TableAction-->
<!-- :actions="[-->
<!-- { icon: IconEnum.BACK_CALC,label: rowCalcLoading[record.mpId] ? t('action.calcIng') : t('action.backCalc'), onClick: handleCalc.bind(null, record) },-->
<!-- ]"-->
<!-- />-->
<TableAction <TableAction
:actions="[ :actions="[
{ icon: IconEnum.BACK_CALC, label: t('action.backCalc'), onClick: handleWarnConfig.bind(null, record) }, { icon: IconEnum.BACK_CALC,label: rowCalcLoading[record.mpId] ? t('action.calcIng') : t('action.backCalc'), onClick: handlebeforeCalc,
disabled: rowCalcLoading[record.mpId]},
]" ]"
/> />
</template> </template>
</template> </template>
</BasicTable> </BasicTable>
<HistoryModal :item-name="itemName" :legend-name="legendName" @register="registerHistoryModal" />
<CreateModal :item-name="itemName" :legend-name="legendName" @register="registerCreateModal" @success="reload" />
<UpdateModal @register="registerUpdateModal" @success="reload" />
</div> </div>
</template> </template>

Loading…
Cancel
Save