Browse Source

fix: resolve merge conflicts and clean up code formatting in index.vue

pull/79/head
CJL6015 1 month ago
parent
commit
d1630dc16a
  1. 529
      src/views/model/train/index.vue

529
src/views/model/train/index.vue

@ -1,10 +1,10 @@
<script lang="ts"> <script lang="ts">
import type { ComponentPublicInstance } from 'vue' import type { ComponentPublicInstance } from "vue";
import type { Dayjs } from 'dayjs' import type { Dayjs } from "dayjs";
import { debounce } from 'lodash-es' import { debounce } from "lodash-es";
import dayjs from 'dayjs' import dayjs from "dayjs";
import { computed, defineComponent, onMounted, ref, toRaw, watch } from 'vue' import { computed, defineComponent, onMounted, ref, toRaw, watch } from "vue";
import { useRoute, useRouter } from 'vue-router' import { useRoute } from "vue-router";
import { import {
Button, Button,
Card, Card,
@ -25,11 +25,12 @@ import {
Steps, Steps,
Table, Table,
Tabs, Tabs,
} from 'ant-design-vue' Transfer,
import VueECharts from 'vue-echarts' } from "ant-design-vue";
import { pointTableSchema, sampleInfoTableSchema } from './data' import VueECharts from "vue-echarts";
import { BasicTable, useTable } from '@/components/Table' import { pointTableSchema, sampleInfoTableSchema } from "./data";
import { PageWrapper } from '@/components/Page' import { BasicTable, useTable } from "@/components/Table";
import { PageWrapper } from "@/components/Page";
import { import {
bottomModelApi, bottomModelApi,
createDraftVersionApi, createDraftVersionApi,
@ -151,14 +152,14 @@ export default defineComponent({
pagination: true, pagination: true,
dataSource: pointData, dataSource: pointData,
scroll: { y: 300 }, scroll: { y: 300 },
}) });
const trainTime = computed(() => model.value?.trainTime || []) const trainTime = computed(() => model.value?.trainTime || []);
const [trainTimeTable] = useTable({ const [trainTimeTable] = useTable({
columns: sampleInfoTableSchema, columns: sampleInfoTableSchema,
dataSource: trainTime, dataSource: trainTime,
scroll: { y: 300 }, scroll: { y: 300 },
}) });
const updatePrincipalFromTrainTime = (trainTimeList: any[]) => { const updatePrincipalFromTrainTime = (trainTimeList: any[]) => {
if (!Array.isArray(trainTimeList) || !model.value) if (!Array.isArray(trainTimeList) || !model.value)
@ -189,34 +190,33 @@ export default defineComponent({
const echartsRefs = ref<any[]>([]) const echartsRefs = ref<any[]>([])
async function getHistory() { async function getHistory() {
if (!historyTime.value) if (!historyTime.value) return;
return spinning.value = true;
spinning.value = true
if (model.value.para) { if (model.value.para) {
await getTestData() await getTestData()
} }
else { else {
const params = { const params = {
startTime: historyTime.value[0].format('YYYY-MM-DD HH:mm:ss'), startTime: historyTime.value[0].format("YYYY-MM-DD HH:mm:ss"),
endTime: historyTime.value[1].format('YYYY-MM-DD HH:mm:ss'), endTime: historyTime.value[1].format("YYYY-MM-DD HH:mm:ss"),
itemName: model.value?.pointInfo itemName: model.value?.pointInfo
.map(item => item.pointId) .map((item) => item.pointId)
.join(','), .join(","),
interval: model.value.sampling, interval: model.value.sampling,
} };
const history = await getExaHistorys(params) const history = await getExaHistorys(params);
historyList.value = history.map((item, index) => { historyList.value = history.map((item, index) => {
const point = model.value?.pointInfo[index] const point = model.value?.pointInfo[index];
return { return {
data: [item], data: [item],
name: `${index + 1}.${point?.description}(${point?.pointId})`, name: `${index + 1}.${point?.description}(${point?.pointId})`,
} };
}) });
echartsRefs.value = Array.from({ length: historyList.value.length }) echartsRefs.value = Array.from({ length: historyList.value.length });
brushActivated.value = new Set() brushActivated.value = new Set();
} }
spinning.value = false spinning.value = false;
} }
async function getTestData(range?: RangeValue) { async function getTestData(range?: RangeValue) {
@ -247,7 +247,7 @@ export default defineComponent({
model.value.sampling * 1000, model.value.sampling * 1000,
) )
historyList.value = sampleData.map((item, index) => { historyList.value = sampleData.map((item, index) => {
const point = model.value?.pointInfo[index] const point = model.value?.pointInfo[index];
return { return {
data: [ data: [
(Array.isArray(item) ? item : []).map((t, i) => { (Array.isArray(item) ? item : []).map((t, i) => {
@ -258,15 +258,17 @@ export default defineComponent({
}), }),
], ],
name: `${index + 1}.${point?.description}(${point?.pointId})`, name: `${index + 1}.${point?.description}(${point?.pointId})`,
} };
}) });
brushActivated.value = new Set() brushActivated.value = new Set();
} }
function generateTimeList(time: RangeValue, intervalMs: number) { function generateTimeList(time: RangeValue, intervalMs: number) {
const [t1, t2] = time const [t1, t2] = time;
const count = Math.floor(t2.diff(t1, 'millisecond') / intervalMs) + 1 const count = Math.floor(t2.diff(t1, "millisecond") / intervalMs) + 1;
return Array.from({ length: count }, (_, i) => t1.add(i * intervalMs, 'millisecond').valueOf()) return Array.from({ length: count }, (_, i) =>
t1.add(i * intervalMs, "millisecond").valueOf()
);
} }
function normalizeTrainTime(modelInfo: any) { function normalizeTrainTime(modelInfo: any) {
@ -290,37 +292,37 @@ export default defineComponent({
} }
function getOption(item: any) { function getOption(item: any) {
const name = ['测量值', '模型值', ''] const name = ["测量值", "模型值", ""];
const color = ['blue', '#ff6f00', 'red'] const color = ["blue", "#ff6f00", "red"];
const yIndex = [0, 0, 1] const yIndex = [0, 0, 1];
const option = { const option = {
xAxis: { xAxis: {
type: 'time', type: "time",
axisLabel: { axisLabel: {
formatter(value) { formatter(value) {
const date = new Date(value) const date = new Date(value);
return date.toLocaleString() return date.toLocaleString();
}, },
}, },
}, },
yAxis: [{ type: 'value' }, { type: 'value', max: 10, show: false }], yAxis: [{ type: "value" }, { type: "value", max: 10, show: false }],
series: item.data.map((item, index) => { series: item.data.map((item, index) => {
return { return {
data: item, data: item,
type: 'line', type: "line",
smooth: true, smooth: true,
symbol: 'none', symbol: "none",
name: name[index], name: name[index],
color: color[index], color: color[index],
yAxisIndex: yIndex[index], yAxisIndex: yIndex[index],
} };
}), }),
legend: {}, legend: {},
dataZoom: [{}], dataZoom: [{}],
brush: { brush: {
toolbox: ['lineX'], toolbox: ["lineX"],
xAxisIndex: 0, xAxisIndex: 0,
brushType: 'lineX', brushType: "lineX",
}, },
grid: [ grid: [
{ {
@ -330,54 +332,49 @@ export default defineComponent({
top: 30, top: 30,
}, },
], ],
} };
return option return option;
} }
function setChartRef( function setChartRef(
el: Element | ComponentPublicInstance | null, el: Element | ComponentPublicInstance | null,
index: number, index: number
) { ) {
let dom: HTMLElement | null = null let dom: HTMLElement | null = null;
if (el) { if (el) {
if ('$el' in el && (el as any).$el instanceof HTMLElement) if ("$el" in el && (el as any).$el instanceof HTMLElement)
dom = (el as any).$el dom = (el as any).$el;
else if (el instanceof HTMLElement) else if (el instanceof HTMLElement) dom = el;
dom = el
} }
if (dom) if (dom) useECharts(ref(dom as HTMLDivElement));
useECharts(ref(dom as HTMLDivElement))
} }
function setEchartsRef(el: any, index: number) { function setEchartsRef(el: any, index: number) {
if (el) if (el) echartsRefs.value[index] = el;
echartsRefs.value[index] = el
} }
const isInitBrush = ref(true) const isInitBrush = ref(true);
function onChartFinished(index: number) { function onChartFinished(index: number) {
if (brushActivated.value.has(index)) if (brushActivated.value.has(index)) return;
return const chart = echartsRefs.value[index];
const chart = echartsRefs.value[index] if (!chart) return;
if (!chart)
return
chart.dispatchAction({ chart.dispatchAction({
type: 'takeGlobalCursor', type: "takeGlobalCursor",
key: 'brush', key: "brush",
brushOption: { brushOption: {
brushType: 'lineX', brushType: "lineX",
brushMode: 'multiple', brushMode: "multiple",
}, },
}) });
const areas = (model.value?.trainTime || []).map(row => ({ const areas = (model.value?.trainTime || []).map((row) => ({
brushType: 'lineX', brushType: "lineX",
xAxisIndex: 0, xAxisIndex: 0,
coordRange: [ coordRange: [
dayjs(row.st).format('YYYY-MM-DD HH:mm:ss'), dayjs(row.st).format("YYYY-MM-DD HH:mm:ss"),
dayjs(row.et).format('YYYY-MM-DD HH:mm:ss'), dayjs(row.et).format("YYYY-MM-DD HH:mm:ss"),
], ],
})) }));
chart.dispatchAction({ chart.dispatchAction({
type: 'brush', type: "brush",
areas, areas,
}) })
isInitBrush.value = true isInitBrush.value = true
@ -385,148 +382,131 @@ export default defineComponent({
} }
onMounted(async () => { onMounted(async () => {
await fetchModelInfo() await fetchModelInfo();
}) });
const onBrushSelected = debounce((params) => { const onBrushSelected = debounce((params) => {
if (isInitBrush.value) { if (isInitBrush.value) {
isInitBrush.value = false isInitBrush.value = false;
return return;
} }
if (!isInitBrush.value && model.value?.version != 'v-test') if (!isInitBrush.value && model?.Cur_Version != "v-test") {
return return;
}
const selected = params.batch[0].selected const selected = params.batch[0].selected;
if (selected.length > 0) { if (selected.length > 0) {
const areas = mergeAreas(params.batch[0].areas).map(area => ({ const areas = mergeAreas(params.batch[0].areas).map((area) => ({
brushType: area.brushType, brushType: area.brushType,
xAxisIndex: 0, xAxisIndex: 0,
coordRange: area.coordRange, coordRange: area.coordRange,
})) }));
const trainTime = areas.map((area) => { const trainTime = areas.map((area) => {
const [stRaw, etRaw] = area.coordRange const [stRaw, etRaw] = area.coordRange;
const st = typeof stRaw === 'string' ? dayjs(stRaw).valueOf() : stRaw const st = typeof stRaw === "string" ? dayjs(stRaw).valueOf() : stRaw;
const et = typeof etRaw === 'string' ? dayjs(etRaw).valueOf() : etRaw const et = typeof etRaw === "string" ? dayjs(etRaw).valueOf() : etRaw;
console.log('Selected area:', { st, et }, area) console.log("Selected area:", { st, et }, area);
return { return {
st: dayjs(st).format('YYYY-MM-DD HH:mm:ss'), st: dayjs(st).format("YYYY-MM-DD HH:mm:ss"),
et: dayjs(et).format('YYYY-MM-DD HH:mm:ss'), et: dayjs(et).format("YYYY-MM-DD HH:mm:ss"),
duration: Math.round((et - st) / 1000), duration: Math.round((et - st) / 1000),
number: '', // number: "", //
filter: '', // filter: "", //
mode: '', // mode: "", //
} };
}) });
console.log('Selected train time:', trainTime) console.log("Selected train time:", trainTime);
if (trainTimeCopy === JSON.stringify(trainTime)) if (trainTimeCopy === JSON.stringify(trainTime)) return;
return model.value.trainTime = trainTime;
model.value.trainTime = trainTime trainTimeCopy = JSON.stringify(trainTime);
trainTimeCopy = JSON.stringify(trainTime)
echartsRefs.value.forEach((chart, index) => { echartsRefs.value.forEach((chart, index) => {
if (chart) { if (chart) {
chart.dispatchAction({ chart.dispatchAction({
type: 'brush', type: "brush",
areas, areas,
}) });
isInitBrush.value = true isInitBrush.value = true;
} }
}) });
updateModelInfoDebounced() updateModelInfoDebounced();
} }
}, 300) }, 300);
function mergeAreas(areas: any[]) { function mergeAreas(areas: any[]) {
if (!areas.length) if (!areas.length) return [];
return []
// brushType xAxisIndex // brushType xAxisIndex
const sorted = [...areas].sort( const sorted = [...areas].sort(
(a, b) => a.coordRange[0] - b.coordRange[0], (a, b) => a.coordRange[0] - b.coordRange[0]
) );
const merged: any[] = [] const merged: any[] = [];
for (const area of sorted) { for (const area of sorted) {
if ( if (
merged.length merged.length &&
&& merged[merged.length - 1].brushType === area.brushType merged[merged.length - 1].brushType === area.brushType &&
&& merged[merged.length - 1].xAxisIndex === area.xAxisIndex merged[merged.length - 1].xAxisIndex === area.xAxisIndex &&
&& merged[merged.length - 1].coordRange[1] >= area.coordRange[0] merged[merged.length - 1].coordRange[1] >= area.coordRange[0]
) { ) {
// //
merged[merged.length - 1].coordRange[1] = Math.max( merged[merged.length - 1].coordRange[1] = Math.max(
merged[merged.length - 1].coordRange[1], merged[merged.length - 1].coordRange[1],
area.coordRange[1], area.coordRange[1]
) );
} } else {
else {
// //
merged.push({ merged.push({
brushType: area.brushType, brushType: area.brushType,
xAxisIndex: area.xAxisIndex, xAxisIndex: area.xAxisIndex,
coordRange: [...area.coordRange], coordRange: [...area.coordRange],
}) });
} }
} }
return merged return merged;
} }
// //
const updateModelInfoDebounced = debounce(() => { const updateModelInfoDebounced = debounce(() => {
const val = toRaw(model.value) const val = toRaw(model.value);
if (val && val.id) if (val && val.id) updateModelInfo(val);
updateModelInfo(val) }, 500);
}, 500)
function handleDeleteTrainTime(index: number) { function handleDeleteTrainTime(index: number) {
if (!canEditModel.value) { if (!model.value?.trainTime) return;
createMessage.warning('非草稿版本不可修改训练时间')
return
}
if (!model.value?.trainTime)
return
// //
model.value.trainTime = [ model.value.trainTime = [
...model.value.trainTime.slice(0, index), ...model.value.trainTime.slice(0, index),
...model.value.trainTime.slice(index + 1), ...model.value.trainTime.slice(index + 1),
] ];
// brush // brush
const areas = (model.value.trainTime || []).map(row => ({ const areas = (model.value.trainTime || []).map((row) => ({
brushType: 'lineX', brushType: "lineX",
xAxisIndex: 0, xAxisIndex: 0,
coordRange: [dayjs(row.st).valueOf(), dayjs(row.et).valueOf()], coordRange: [dayjs(row.st).valueOf(), dayjs(row.et).valueOf()],
})) }));
echartsRefs.value.forEach((chart) => { echartsRefs.value.forEach((chart) => {
if (chart) { if (chart) {
chart.dispatchAction({ chart.dispatchAction({
type: 'brush', type: "brush",
areas, areas,
}) });
isInitBrush.value = true isInitBrush.value = true;
} }
}) });
updateModelInfoDebounced() updateModelInfoDebounced();
} }
async function clearModel() { async function clearModel() {
if (!canEditModel.value) { model.value.para = null;
createMessage.warning('非草稿版本不可清除训练结果') updateModelInfoDebounced();
return await getHistory();
}
model.value.para = null
updateModelInfoDebounced()
await getHistory()
} }
async function trainModel() { async function trainModel() {
if (!canEditModel.value) { const modelInfo = model.value;
createMessage.warning('非草稿版本不可训练模型')
return
}
const modelInfo = model.value
if (!modelInfo || !modelInfo.id) { if (!modelInfo || !modelInfo.id) {
console.error('模型信息不完整,无法训练') console.error("模型信息不完整,无法训练");
return return;
} }
const pointInfo = modelInfo.pointInfo || [] const pointInfo = modelInfo.pointInfo || [];
if (pointInfo.length === 0) { if (pointInfo.length === 0) {
console.error('模型参数点信息为空,无法训练') console.error("模型参数点信息为空,无法训练");
return return;
} }
const params = { const params = {
conditon: modelInfo.alarmmodelset?.alarmcondition || '1=1', conditon: modelInfo.alarmmodelset?.alarmcondition || '1=1',
@ -534,27 +514,27 @@ export default defineComponent({
percent: modelInfo.rate, percent: modelInfo.rate,
}, },
Train_Data: { Train_Data: {
points: pointInfo.map(item => item.pointId).join(','), points: pointInfo.map((item) => item.pointId).join(","),
dead: pointInfo.map(item => (item.dead ? '1' : '0')).join(','), dead: pointInfo.map((item) => (item.dead ? "1" : "0")).join(","),
limit: pointInfo.map(item => (item.limit ? '1' : '0')).join(','), limit: pointInfo.map((item) => (item.limit ? "1" : "0")).join(","),
uplow: pointInfo uplow: pointInfo
.map( .map(
item => (item) =>
`${item.Upper ? item.Upper : null},${ `${item.Upper ? item.Upper : null},${
item.Lower ? item.Lower : null item.Lower ? item.Lower : null
}`, }`
) )
.join(';'), .join(";"),
interval: modelInfo.sampling * 1000, interval: modelInfo.sampling * 1000,
time: modelInfo.trainTime time: modelInfo.trainTime
.map(item => `${item.st},${item.et}`) .map((item) => `${item.st},${item.et}`)
.join(';'), .join(";"),
}, },
type: 'PCA', type: "PCA",
smote_config: [], smote_config: [],
smote: true, smote: true,
} };
spinning.value = true spinning.value = true;
try { try {
const response = await trainModelApi(params) const response = await trainModelApi(params)
model.value.para = response model.value.para = response
@ -640,19 +620,19 @@ export default defineComponent({
createMessage.error('模型训练失败') createMessage.error('模型训练失败')
} }
spinning.value = false spinning.value = false;
} }
const editForm = ref({ const editForm = ref({
index: -1, index: -1,
Upper: '', Upper: "",
Lower: '', Lower: "",
lowerBound: '', lowerBound: "",
upperBound: '', upperBound: "",
dead: true, dead: true,
limit: false, limit: false,
}) });
const openEditPointModal = ref<boolean>(false) const openEditPointModal = ref<boolean>(false);
let pointEditRecord = null let pointEditRecord = null;
function editPoint() { function editPoint() {
// //
model.value.pointInfo[editForm.value.index] = { model.value.pointInfo[editForm.value.index] = {
@ -663,15 +643,15 @@ export default defineComponent({
upperBound: editForm.value.upperBound, upperBound: editForm.value.upperBound,
dead: editForm.value.dead, dead: editForm.value.dead,
limit: editForm.value.limit, limit: editForm.value.limit,
} };
updateModelInfoDebounced() updateModelInfoDebounced();
pointEditRecord.Upper = editForm.value.Upper pointEditRecord.Upper = editForm.value.Upper;
pointEditRecord.Lower = editForm.value.Lower pointEditRecord.Lower = editForm.value.Lower;
pointEditRecord.lowerBound = editForm.value.lowerBound pointEditRecord.lowerBound = editForm.value.lowerBound;
pointEditRecord.upperBound = editForm.value.upperBound pointEditRecord.upperBound = editForm.value.upperBound;
pointEditRecord.dead = editForm.value.dead pointEditRecord.dead = editForm.value.dead;
pointEditRecord.limit = editForm.value.limit pointEditRecord.limit = editForm.value.limit;
openEditPointModal.value = false openEditPointModal.value = false;
} }
function openPointModal(index, record) { function openPointModal(index, record) {
@ -680,29 +660,22 @@ export default defineComponent({
return return
} }
// index // index
const pageIndex = index const pageIndex = index;
// index // index
const globalIndex = model.value.pointInfo.findIndex( const globalIndex = model.value.pointInfo.findIndex(
item => item.pointId === record.pointId, (item) => item.pointId === record.pointId
) );
openEditPointModal.value = true openEditPointModal.value = true;
pointEditRecord = record pointEditRecord = record;
const normalizeBool = (val: any) => {
if (val === true || val === '是' || val === 1 || val === '1')
return true
if (val === false || val === '否' || val === 0 || val === '0')
return false
return !!val
}
editForm.value = { editForm.value = {
index: globalIndex, index: globalIndex,
Upper: record?.Upper ?? '', Upper: record?.Upper ?? "",
Lower: record?.Lower ?? '', Lower: record?.Lower ?? "",
lowerBound: record?.lowerBound ?? '', lowerBound: record?.lowerBound ?? "",
upperBound: record?.upperBound ?? '', upperBound: record?.upperBound ?? "",
dead: normalizeBool(record?.dead), dead: !!record?.dead,
limit: normalizeBool(record?.limit), limit: !!record?.limit,
} };
} }
const mode = ref({ const mode = ref({
@ -713,58 +686,92 @@ export default defineComponent({
const normalizeVersion = (val?: string | null) => (val ? String(val).trim().toLowerCase() : '') const normalizeVersion = (val?: string | null) => (val ? String(val).trim().toLowerCase() : '')
function openEditMode() { function openEditMode() {
if (!canEditModel.value) { openEditModeModal.value = true;
createMessage.warning('非草稿版本不可修改模式')
return
}
openEditModeModal.value = true
mode.value = { mode.value = {
alarmcondition: model.value?.alarmmodelset?.alarmcondition || '1=1', alarmcondition: model.value?.alarmmodelset?.alarmcondition || '1=1',
alarmname: model.value?.alarmmodelset?.alarmname || '全工况运行', alarmname: model.value?.alarmmodelset?.alarmname || '全工况运行',
} }
} }
function closeEditMode() { function closeEditMode() {
openEditModeModal.value = false openEditModeModal.value = false;
} }
function handleEditMode() { function handleEditMode() {
// //
model.value.alarmmodelset = mode.value model.value.alarmmodelset = mode.value;
updateModelInfoDebounced() updateModelInfoDebounced();
closeEditMode() closeEditMode();
} }
const openEditModelModal = ref(false) const openEditModelModal = ref(false);
const editModelForm = ref({ const editModelForm = ref({
sampling: 0, sampling: 0,
rate: 0, rate: 0,
selectedKeys: [], selectedKeys: [],
}) });
function openEditModel() { // 穿
if (!canEditModel.value) { const transferData = ref([]); // 穿
createMessage.warning('非草稿版本不可修改模型')
return //
async function fetchAllPoints(keyword = "") {
// keyword
// const res = await fetchPointsApi({ keyword })
//
const data = await pointListApi({ keyword });
console.log("Fetched points:", data);
transferData.value = transferData.value
.filter((item) => editModelForm.value.selectedKeys.includes(item.key))
.concat(
data.map((item) => ({
key: item.id,
title: item.name,
}))
);
console.log("Transfer data:", transferData.value);
}
onMounted(() => {
fetchAllPoints();
});
function handleTransferSearch(dir, value) {
if (dir === "left") {
//
fetchAllPoints(value);
} else {
//
transferData.value = (model.value?.pointInfo || [])
.filter(
(item) =>
editModelForm.value.selectedKeys.includes(
`${item.description}|${item.pointId}|${item.unit}|${item.Lower}|${item.Upper}`
) && `${item.description || ""}(${item.pointId})`.includes(value)
)
.map((item) => ({
key: `${item.description}|${item.pointId}|${item.unit}|${item.Lower}|${item.Upper}`,
title: `${item.description || ""} (${item.pointId})`,
}));
} }
editModelForm.value.sampling = model.value?.sampling || 0 }
editModelForm.value.rate = model.value?.rate || 0
editModelForm.value.selectedKeys = (model.value?.pointInfo || []).map(item => buildPointKeyFromInfo({ function openEditModel() {
description: item.description ?? item.Description, editModelForm.value.sampling = model.value?.sampling || 0;
pointId: item.pointId ?? item.PointId, editModelForm.value.rate = model.value?.rate || 0;
unit: item.unit ?? item.Unit, editModelForm.value.selectedKeys = (model.value?.pointInfo || []).map(
Lower: item.Lower ?? item.lower, (item) =>
Upper: item.Upper ?? item.upper, `${item.description}|${item.pointId}|${item.unit}|${item.Lower}|${item.Upper}`
})) );
openEditModelModal.value = true transferData.value = (model.value?.pointInfo || []).map((item) => ({
key: `${item.description}|${item.pointId}|${item.unit}|${item.Lower}|${item.Upper}`,
title: `${item.description || ""} (${item.pointId})`,
}));
console.log("transferData:", transferData.value);
openEditModelModal.value = true;
} }
function handleEditModelOk() { function handleEditModelOk() {
if (!canEditModel.value) { model.value.sampling = editModelForm.value.sampling;
createMessage.warning('非草稿版本不可修改模型') model.value.rate = editModelForm.value.rate;
return
}
model.value.sampling = editModelForm.value.sampling
model.value.rate = editModelForm.value.rate
model.value.pointInfo = editModelForm.value.selectedKeys.map((key) => { model.value.pointInfo = editModelForm.value.selectedKeys.map((key) => {
const { description, pointId, unit, Lower, Upper } = parsePointKey(key) const [description, pointId, unit, Lower, Upper] = key.split("|");
return { return {
description, description,
pointId, pointId,
@ -773,13 +780,13 @@ export default defineComponent({
Upper, Upper,
dead: true, dead: true,
limit: false, limit: false,
} };
}) });
clearModel() clearModel();
openEditModelModal.value = false openEditModelModal.value = false;
} }
function handleEditModelCancel() { function handleEditModelCancel() {
openEditModelModal.value = false openEditModelModal.value = false;
} }
const reportModalVisible = ref(false) const reportModalVisible = ref(false)
@ -1056,7 +1063,7 @@ export default defineComponent({
canEditModel, canEditModel,
} }
}, },
}) });
</script> </script>
<template> <template>
@ -1145,7 +1152,7 @@ export default defineComponent({
( (
model?.trainTime.reduce( model?.trainTime.reduce(
(total, item) => total + item.duration, (total, item) => total + item.duration,
0, 0
) / 3600 ) / 3600
).toFixed(2) || "暂无" ).toFixed(2) || "暂无"
}} }}
@ -1337,12 +1344,8 @@ export default defineComponent({
/> />
</a-form-item> </a-form-item>
<a-form-item label="清洗方式" style="margin-top: 16px"> <a-form-item label="清洗方式" style="margin-top: 16px">
<a-checkbox v-model:checked="editForm.dead"> <a-checkbox v-model:checked="editForm.dead"> 死区清洗 </a-checkbox>
死区清洗 <a-checkbox v-model:checked="editForm.limit"> 限值清洗 </a-checkbox>
</a-checkbox>
<a-checkbox v-model:checked="editForm.limit">
限值清洗
</a-checkbox>
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-modal> </a-modal>
@ -1403,10 +1406,24 @@ export default defineComponent({
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<div style="display: flex; justify-content: center; margin-top: 24px;margin-bottom: 10px;"> <div
<PointTransfer style="
v-model:selected-keys="editModelForm.selectedKeys" display: flex;
:prefill-points="model?.pointInfo || []" justify-content: center;
margin-top: 24px;
margin-bottom: 10px;
"
>
<a-transfer
v-model:target-keys="editModelForm.selectedKeys"
:data-source="transferData"
:render="(item) => item.title"
:row-key="(item) => item.key"
:pagination="false"
:show-search="true"
:filter="true"
search-placeholder="搜索测点"
:titles="['可选测点', '已选测点']"
:list-style="{ :list-style="{
width: '500px', width: '500px',
height: '450px', height: '450px',

Loading…
Cancel
Save