|
|
|
@ -1,6 +1,6 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
import { Badge, Button, Divider, Switch } from 'ant-design-vue' |
|
|
|
import { onMounted, ref } from 'vue' |
|
|
|
import { Space,Badge, Button, Divider, Switch } from 'ant-design-vue' |
|
|
|
import { onMounted, ref, reactive } from 'vue' |
|
|
|
import moment from 'moment' |
|
|
|
import HistoryModal from '../../exa/config/HistoryModal.vue' |
|
|
|
import { calcFormSchemas, columns, searchFormSchema } from './calc.data' |
|
|
|
@ -19,15 +19,12 @@ import { useModal } from '@/components/Modal' |
|
|
|
defineOptions({ name: 'InstantCalc' }) |
|
|
|
const { createMessage } = useMessage() |
|
|
|
const { t } = useI18n() |
|
|
|
|
|
|
|
const [registerHistoryModal, { openModal: openHistoryModal }] = useModal() |
|
|
|
const [registerCreateModal, { openModal: openCreateModal }] = useModal() |
|
|
|
const [registerUpdateModal, { openModal: openUpdateModal }] = useModal() |
|
|
|
|
|
|
|
// 添加多选框相关状态 |
|
|
|
const selectedRowss = ref<any[]>([]) |
|
|
|
const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] = useTable({ |
|
|
|
title: '实例列表', |
|
|
|
api: getInstantPage, |
|
|
|
rowKey: 'id', |
|
|
|
rowKey: 'mpId', |
|
|
|
immediate: true, |
|
|
|
columns, |
|
|
|
formConfig: { |
|
|
|
@ -36,6 +33,10 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] |
|
|
|
showResetButton: false, |
|
|
|
actionColOptions: { |
|
|
|
span: 2, |
|
|
|
style: { |
|
|
|
textAlign: 'left' , |
|
|
|
marginLeft: '10px', |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
@ -48,37 +49,17 @@ const [registerTable, { getForm, reload, getDataSource, updateTableDataRecord }] |
|
|
|
dataIndex: 'action', |
|
|
|
fixed: 'right', |
|
|
|
}, |
|
|
|
// 添加多选框配置 |
|
|
|
rowSelection: { |
|
|
|
type: 'checkbox', |
|
|
|
|
|
|
|
onChange: (selectedRowKeys, selectedRows) => { |
|
|
|
console.log(24) |
|
|
|
selectedRowss.value = selectedRows |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
const isShow = ref<boolean>(false) |
|
|
|
|
|
|
|
function handleCreate() { |
|
|
|
openCreateModal(true, { isUpdate: false }) |
|
|
|
isShow.value = true |
|
|
|
} |
|
|
|
|
|
|
|
function handleEdit(record: Recordable) { |
|
|
|
openUpdateModal(true, { record, isUpdate: true }) |
|
|
|
} |
|
|
|
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绑定注册; |
|
|
|
*/ |
|
|
|
@ -97,22 +78,67 @@ const [registerForm] = useForm({ |
|
|
|
// data为时间组件在表单内的字段,startTime,endTime为转化后的开始时间于结束时间 |
|
|
|
['time', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss'], |
|
|
|
], |
|
|
|
actionColOptions: { span: 2 }, |
|
|
|
|
|
|
|
actionColOptions: { span: 5,style: { textAlign: 'left' ,marginLeft: '10px',} }, |
|
|
|
showSubmitButton: false, |
|
|
|
showResetButton: false, |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// 添加回算状态跟踪 |
|
|
|
const calcLoading = ref<boolean>(false) |
|
|
|
const rowCalcLoading = reactive({}); |
|
|
|
|
|
|
|
/** |
|
|
|
* 点击提交按钮的value值----改为导出按钮 |
|
|
|
* 点击导出按钮 |
|
|
|
* @param values |
|
|
|
*/ |
|
|
|
function handleSubmit(values: any) { |
|
|
|
console.log('提交按钮数据::::', values) |
|
|
|
function handleExport(values: any) { |
|
|
|
console.log('导出按钮数据::::', values) |
|
|
|
} |
|
|
|
// 回算 |
|
|
|
function handleCalc(values: any) { |
|
|
|
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) |
|
|
|
} |
|
|
|
// 回算 |
|
|
|
async function handleCalc(formData: any) { |
|
|
|
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> |
|
|
|
|
|
|
|
<template> |
|
|
|
@ -128,34 +154,33 @@ function handleCalc(values: any) { |
|
|
|
<!-- 自定义表单 --> |
|
|
|
<BasicForm @register="registerForm"> |
|
|
|
<template #advanceBefore> |
|
|
|
<a-button v-auth="['run:instant:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate"> |
|
|
|
{{ t('action.create') }} |
|
|
|
<Space> |
|
|
|
<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> |
|
|
|
</Space> |
|
|
|
</template> |
|
|
|
</BasicForm> |
|
|
|
</template> |
|
|
|
|
|
|
|
<!-- 统计量点击跳转历史曲线 --> |
|
|
|
<template #history="{ record }"> |
|
|
|
<a @click="handleHistory(record)"> |
|
|
|
{{ record.pointSte }} |
|
|
|
</a> |
|
|
|
<!-- <SlidersOutlined class="click-status" /> --> |
|
|
|
</template> |
|
|
|
|
|
|
|
<template #bodyCell="{ column, record }"> |
|
|
|
<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 |
|
|
|
: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> |
|
|
|
</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> |
|
|
|
</template> |
|
|
|
|
|
|
|
|