Browse Source

fix: 统一 PointId 属性的大小写,确保一致性

pull/77/head
chenjiale 1 month ago
parent
commit
bbf5f9adcf
  1. 15
      src/views/model/components/pointTransferHelper.ts
  2. 2
      src/views/model/list/step/Step3.vue
  3. 2
      src/views/model/train/data.tsx
  4. 38
      src/views/model/train/index.vue

15
src/views/model/components/pointTransferHelper.ts

@ -1,6 +1,6 @@
export interface PointKeyInfo {
description: string
pointId: string
PointId: string
unit?: string
Lower?: string
Upper?: string
@ -8,18 +8,19 @@ export interface PointKeyInfo {
export function parsePointKey(key: string | number | undefined | null): PointKeyInfo {
const safeKey = key !== undefined && key !== null ? String(key) : ''
const [description = '', pointId = '', unit = '', Lower = '', Upper = ''] = safeKey.split('|')
return { description, pointId, unit, Lower, Upper }
const [description = '', PointId = '', unit = '', Lower = '', Upper = ''] = safeKey.split('|')
return { description, PointId, unit, Lower, Upper }
}
export function buildPointKeyFromInfo(info: Partial<PointKeyInfo>): string {
const { description = '', pointId = '', unit = '', Lower = '', Upper = '' } = info || {}
return [description, pointId, unit, Lower, Upper].join('|')
const { description = '', unit = '', Lower = '', Upper = '' } = info || {}
const PointId = (info as any)?.PointId ?? (info as any)?.pointId ?? ''
return [description, PointId, unit, Lower, Upper].join('|')
}
export function buildPointTitle(info: PointKeyInfo, fallback: string): string {
if (info.description && info.pointId)
return `${info.description} (${info.pointId})`
if (info.description && info.PointId)
return `${info.description} (${info.PointId})`
if (info.description)
return info.description
return fallback

2
src/views/model/list/step/Step3.vue

@ -74,7 +74,7 @@ export default defineComponent({
const point = parsePointKey(key)
return {
description: point.description,
pointId: point.pointId,
PointId: point.PointId,
unit: point.unit,
Lower: point.Lower,
Upper: point.Upper,

2
src/views/model/train/data.tsx

@ -84,7 +84,7 @@ export const pointTableSchema: BasicColumn[] = [
{
title: '点号',
width: 150,
dataIndex: 'pointId',
dataIndex: 'PointId',
},
{
title: '单位',

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

@ -98,6 +98,7 @@ export default defineComponent({
return
const normalized = normalizeTrainTime(payload)
const normalizedPointInfo = normalizePointInfoList(normalized?.pointInfo)
const previous = model.value || {}
const merged: any = {
...previous,
@ -106,7 +107,9 @@ export default defineComponent({
if (!Array.isArray(normalized?.trainTime))
merged.trainTime = previous?.trainTime ?? []
if (!Array.isArray(normalized?.pointInfo))
if (normalizedPointInfo)
merged.pointInfo = normalizedPointInfo
else if (!Array.isArray(normalized?.pointInfo))
merged.pointInfo = previous?.pointInfo ?? []
if (normalized?.para === undefined && previous?.para !== undefined)
merged.para = previous.para
@ -130,7 +133,7 @@ export default defineComponent({
const list = model.value?.pointInfo || []
return list.map((p: any) => ({
description: p.description ?? p.Description,
pointId: p.pointId ?? p.PointId,
PointId: p.PointId ?? p.pointId,
unit: p.unit ?? p.Unit,
Upper: p.Upper ?? p.upper,
Lower: p.Lower ?? p.lower,
@ -196,7 +199,7 @@ export default defineComponent({
startTime: historyTime.value[0].format('YYYY-MM-DD HH:mm:ss'),
endTime: historyTime.value[1].format('YYYY-MM-DD HH:mm:ss'),
itemName: model.value?.pointInfo
.map(item => item.pointId)
.map(item => item.PointId)
.join(','),
interval: model.value.sampling,
}
@ -205,7 +208,7 @@ export default defineComponent({
const point = model.value?.pointInfo[index]
return {
data: [item],
name: `${index + 1}.${point?.description}(${point?.pointId})`,
name: `${index + 1}.${point?.description}(${point?.PointId})`,
}
})
echartsRefs.value = Array.from({ length: historyList.value.length })
@ -230,7 +233,7 @@ export default defineComponent({
time: timeRange
.map(t => dayjs(t).format('YYYY-MM-DD HH:mm:ss'))
.join(','),
points: model.value.pointInfo.map(t => t.pointId).join(','),
points: model.value.pointInfo.map(t => t.PointId).join(','),
interval: model.value.sampling * 1000,
},
}
@ -257,7 +260,7 @@ export default defineComponent({
return [xData[i], t]
}),
],
name: `${index + 1}.${point?.description}(${point?.pointId})`,
name: `${index + 1}.${point?.description}(${point?.PointId})`,
}
})
brushActivated.value = new Set()
@ -269,6 +272,19 @@ export default defineComponent({
return Array.from({ length: count }, (_, i) => t1.add(i * intervalMs, 'millisecond').valueOf())
}
function normalizePointInfoList(pointInfo: any) {
if (!Array.isArray(pointInfo))
return undefined
return pointInfo.map((item: any) => {
const PointId = item?.PointId ?? item?.pointId
return {
...item,
PointId,
pointId: PointId,
}
})
}
function normalizeTrainTime(modelInfo: any) {
if (!modelInfo?.trainTime || !Array.isArray(modelInfo.trainTime))
return modelInfo
@ -535,7 +551,7 @@ export default defineComponent({
percent: modelInfo.rate,
},
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(','),
limit: pointInfo.map(item => (item.limit ? '1' : '0')).join(','),
uplow: pointInfo
@ -684,7 +700,7 @@ export default defineComponent({
const pageIndex = index
// index
const globalIndex = model.value.pointInfo.findIndex(
item => item.pointId === record.pointId,
item => item.PointId === record.PointId,
)
openEditPointModal.value = true
pointEditRecord = record
@ -750,7 +766,7 @@ export default defineComponent({
editModelForm.value.rate = model.value?.rate || 0
editModelForm.value.selectedKeys = (model.value?.pointInfo || []).map(item => buildPointKeyFromInfo({
description: item.description ?? item.Description,
pointId: item.pointId ?? item.PointId,
PointId: item.PointId ?? item.pointId,
unit: item.unit ?? item.Unit,
Lower: item.Lower ?? item.lower,
Upper: item.Upper ?? item.upper,
@ -765,10 +781,10 @@ export default defineComponent({
model.value.sampling = editModelForm.value.sampling
model.value.rate = editModelForm.value.rate
model.value.pointInfo = editModelForm.value.selectedKeys.map((key) => {
const { description, pointId, unit, Lower, Upper } = parsePointKey(key)
const { description, PointId, unit, Lower, Upper } = parsePointKey(key)
return {
description,
pointId,
PointId,
unit,
Lower,
Upper,

Loading…
Cancel
Save