Commit 36e69e2d2c36db405570523eb1de6fef3e720268
Merge branch 'fix/DEFECT-1888' into 'main_dev'
fix: 修复引用模板创建组态时图表组件不显示设备名称 See merge request yunteng/thingskit-scada!215
Showing
10 changed files
with
37 additions
and
20 deletions
@@ -111,7 +111,7 @@ const handleSave = async () => { | @@ -111,7 +111,7 @@ const handleSave = async () => { | ||
111 | if (operationPassword.checked) | 111 | if (operationPassword.checked) |
112 | await validatePassword() | 112 | await validatePassword() |
113 | if (contentDataStore.getIsTemplate)// 判断组态是不是模板 | 113 | if (contentDataStore.getIsTemplate)// 判断组态是不是模板 |
114 | - dataSourceJson = { ...value, deviceProfileId: value?.deviceProfileTemplateId, deviceId: null } | 114 | + dataSourceJson = { ...value, deviceProfileId: value?.deviceProfileTemplateId, deviceId: null, deviceName: null } |
115 | await saveNodeAllData({ dataSourceJson, eventJson: { ...eventJson, OPERATION_PASSWORD: unref(getCellInfo).category === PackageCategoryEnum.CONTROL ? operationPassword : undefined }, actJson }) | 115 | await saveNodeAllData({ dataSourceJson, eventJson: { ...eventJson, OPERATION_PASSWORD: unref(getCellInfo).category === PackageCategoryEnum.CONTROL ? operationPassword : undefined }, actJson }) |
116 | createMessage.success('操作成功') | 116 | createMessage.success('操作成功') |
117 | savePageContent() | 117 | savePageContent() |
@@ -34,7 +34,7 @@ const handleSubmit = async () => { | @@ -34,7 +34,7 @@ const handleSubmit = async () => { | ||
34 | const formValues = unref(dataSourceFormRef)?.getFieldsValue() | 34 | const formValues = unref(dataSourceFormRef)?.getFieldsValue() |
35 | let dataSourceJson = formValues | 35 | let dataSourceJson = formValues |
36 | if (contentDataStore.getIsTemplate) | 36 | if (contentDataStore.getIsTemplate) |
37 | - dataSourceJson = { ...formValues, deviceProfileId: formValues?.deviceProfileTemplateId, deviceId: null } | 37 | + dataSourceJson = { ...formValues, deviceProfileId: formValues?.deviceProfileTemplateId, deviceId: null, deviceName: null } |
38 | 38 | ||
39 | saveNodeAllData({ dataSourceJson: { ...dataSourceJson, circularFlowMeterOption: unref(colorConfig) } }) | 39 | saveNodeAllData({ dataSourceJson: { ...dataSourceJson, circularFlowMeterOption: unref(colorConfig) } }) |
40 | createMessage.success('保存成功~') | 40 | createMessage.success('保存成功~') |
@@ -9,6 +9,7 @@ import { useOnMessage } from '@/core/Library/hook/useOnMessage' | @@ -9,6 +9,7 @@ import { useOnMessage } from '@/core/Library/hook/useOnMessage' | ||
9 | import type { NodeDataDataSourceJsonType } from '@/api/node/model' | 9 | import type { NodeDataDataSourceJsonType } from '@/api/node/model' |
10 | import { useLatestMessageValue } from '@/core/Library/hook/useLatestMessageValue' | 10 | import { useLatestMessageValue } from '@/core/Library/hook/useLatestMessageValue' |
11 | import { useContentDataStore } from '@/store/modules/contentData' | 11 | import { useContentDataStore } from '@/store/modules/contentData' |
12 | +import { useProductsStore } from '@/store/modules/products' | ||
12 | 13 | ||
13 | const props = defineProps<{ | 14 | const props = defineProps<{ |
14 | config: CreateComponentType | 15 | config: CreateComponentType |
@@ -24,6 +25,8 @@ const chartElRef = ref<Nullable<HTMLDivElement>>() | @@ -24,6 +25,8 @@ const chartElRef = ref<Nullable<HTMLDivElement>>() | ||
24 | 25 | ||
25 | const chartInstance = ref<Nullable<ECharts>>() | 26 | const chartInstance = ref<Nullable<ECharts>>() |
26 | 27 | ||
28 | +const productsStore = useProductsStore() | ||
29 | + | ||
27 | function initChartInstance() { | 30 | function initChartInstance() { |
28 | const { dataSourceJson } = unref(getCurrentNodeData) || {} | 31 | const { dataSourceJson } = unref(getCurrentNodeData) || {} |
29 | const { circularFlowMeterOption } = dataSourceJson || {} | 32 | const { circularFlowMeterOption } = dataSourceJson || {} |
@@ -34,11 +37,13 @@ function initChartInstance() { | @@ -34,11 +37,13 @@ function initChartInstance() { | ||
34 | const { onMessage } = useOnMessage({ | 37 | const { onMessage } = useOnMessage({ |
35 | onReceiveDataSourceMessage(commandSource, message) { | 38 | onReceiveDataSourceMessage(commandSource, message) { |
36 | const { data } = commandSource | 39 | const { data } = commandSource |
37 | - const { attr } = data as NodeDataDataSourceJsonType | ||
38 | - const { latestValue } = useLatestMessageValue(message.data, attr) | 40 | + const { attr, deviceName, deviceProfileId } = data as NodeDataDataSourceJsonType |
41 | + | ||
42 | + const { functionName } = productsStore.getObjectModelByIdWithIdentifier(deviceProfileId, (attr) as string) || {} | ||
43 | + const { latestValue } = useLatestMessageValue(message.data, (attr as string)) | ||
39 | unref(chartInstance)?.setOption({ | 44 | unref(chartInstance)?.setOption({ |
40 | title: { | 45 | title: { |
41 | - // text: `${deviceName || ''}-${attrInfo.name || ''}`, | 46 | + text: `${deviceName || ''} - ${functionName || ''}`, |
42 | }, | 47 | }, |
43 | series: [{ | 48 | series: [{ |
44 | data: getSetValue(Number(latestValue)), | 49 | data: getSetValue(Number(latestValue)), |
@@ -45,7 +45,7 @@ const handleSubmit = async () => { | @@ -45,7 +45,7 @@ const handleSubmit = async () => { | ||
45 | const values = getFieldsValue() | 45 | const values = getFieldsValue() |
46 | let dataSourceJson = value | 46 | let dataSourceJson = value |
47 | if (contentDataStore.getIsTemplate) | 47 | if (contentDataStore.getIsTemplate) |
48 | - dataSourceJson = { ...value, deviceProfileId: value?.deviceProfileTemplateId, deviceId: null } | 48 | + dataSourceJson = { ...value, deviceProfileId: value?.deviceProfileTemplateId, deviceId: null, deviceName: null } |
49 | 49 | ||
50 | await saveNodeAllData({ dataSourceJson: { ...dataSourceJson, attr: typeof value.attr == 'string' ? [value.attr] : value.attr, chartOption: { ...values } } }) | 50 | await saveNodeAllData({ dataSourceJson: { ...dataSourceJson, attr: typeof value.attr == 'string' ? [value.attr] : value.attr, chartOption: { ...values } } }) |
51 | savePageContent() | 51 | savePageContent() |
@@ -42,7 +42,7 @@ const handleSubmit = async () => { | @@ -42,7 +42,7 @@ const handleSubmit = async () => { | ||
42 | const values = getFieldsValue() | 42 | const values = getFieldsValue() |
43 | let dataSourceJson = value | 43 | let dataSourceJson = value |
44 | if (contentDataStore.getIsTemplate) | 44 | if (contentDataStore.getIsTemplate) |
45 | - dataSourceJson = { ...value, deviceProfileId: value?.deviceProfileTemplateId, deviceId: null } | 45 | + dataSourceJson = { ...value, deviceProfileId: value?.deviceProfileTemplateId, deviceId: null, deviceName: null } |
46 | 46 | ||
47 | await saveNodeAllData({ dataSourceJson: { ...dataSourceJson, chartOption: values } }) | 47 | await saveNodeAllData({ dataSourceJson: { ...dataSourceJson, chartOption: values } }) |
48 | createMessage.success('操作成功~') | 48 | createMessage.success('操作成功~') |
@@ -55,9 +55,9 @@ const handleSubmit = async () => { | @@ -55,9 +55,9 @@ const handleSubmit = async () => { | ||
55 | 55 | ||
56 | const handleSetFormValues = async () => { | 56 | const handleSetFormValues = async () => { |
57 | const { dataSourceJson } = unref(getNodeData) || {} | 57 | const { dataSourceJson } = unref(getNodeData) || {} |
58 | - const { deviceId, attr, chartOption, deviceProfileId, deviceProfileTemplateId } = dataSourceJson || {} | 58 | + const { deviceId, attr, chartOption, deviceProfileId, deviceProfileTemplateId, deviceName } = dataSourceJson || {} |
59 | await nextTick() | 59 | await nextTick() |
60 | - unref(dataSourceElRef)?.setFieldsValue({ deviceId, attr, deviceProfileId, deviceProfileTemplateId }) | 60 | + unref(dataSourceElRef)?.setFieldsValue({ deviceId, attr, deviceProfileId, deviceName, deviceProfileTemplateId }) |
61 | setFieldsValue({ ...chartOption }) | 61 | setFieldsValue({ ...chartOption }) |
62 | } | 62 | } |
63 | 63 |
@@ -10,6 +10,7 @@ import type { CommandSource } from '@/core/websocket/processor' | @@ -10,6 +10,7 @@ import type { CommandSource } from '@/core/websocket/processor' | ||
10 | import type { NodeDataDataSourceJsonType } from '@/api/node/model' | 10 | import type { NodeDataDataSourceJsonType } from '@/api/node/model' |
11 | import type { SubscriptionUpdateMsg } from '@/core/websocket/type/message' | 11 | import type { SubscriptionUpdateMsg } from '@/core/websocket/type/message' |
12 | import { useContentDataStore } from '@/store/modules/contentData' | 12 | import { useContentDataStore } from '@/store/modules/contentData' |
13 | +import { useProductsStore } from '@/store/modules/products' | ||
13 | 14 | ||
14 | const props = defineProps<{ | 15 | const props = defineProps<{ |
15 | config: CreateComponentType | 16 | config: CreateComponentType |
@@ -23,6 +24,8 @@ const chartInstance = ref<Nullable<ECharts>>() | @@ -23,6 +24,8 @@ const chartInstance = ref<Nullable<ECharts>>() | ||
23 | 24 | ||
24 | const contentDataStore = useContentDataStore() | 25 | const contentDataStore = useContentDataStore() |
25 | 26 | ||
27 | +const productsStore = useProductsStore() | ||
28 | + | ||
26 | function initChartInstance() { | 29 | function initChartInstance() { |
27 | chartInstance.value = init(unref(chartElRef)) | 30 | chartInstance.value = init(unref(chartElRef)) |
28 | const currentNodeData = unref(contentDataStore.getCurrentNodeDataById(props.config)) | 31 | const currentNodeData = unref(contentDataStore.getCurrentNodeDataById(props.config)) |
@@ -36,15 +39,16 @@ onMounted(() => { | @@ -36,15 +39,16 @@ onMounted(() => { | ||
36 | 39 | ||
37 | const onReceiveDataSourceMessage = (commandSource: CommandSource, message: SubscriptionUpdateMsg) => { | 40 | const onReceiveDataSourceMessage = (commandSource: CommandSource, message: SubscriptionUpdateMsg) => { |
38 | const { data } = commandSource | 41 | const { data } = commandSource |
39 | - const { attr } = data as NodeDataDataSourceJsonType | ||
40 | - const { latestValue } = useLatestMessageValue(message.data, attr) | 42 | + const { attr, deviceName, deviceProfileId } = data as NodeDataDataSourceJsonType |
43 | + const { functionName } = productsStore.getObjectModelByIdWithIdentifier(deviceProfileId, (attr) as string) || {} | ||
44 | + const { latestValue } = useLatestMessageValue(message.data, (attr as string)) | ||
41 | unref(chartInstance)?.setOption({ | 45 | unref(chartInstance)?.setOption({ |
42 | series: [{ | 46 | series: [{ |
43 | data: [{ value: latestValue }], | 47 | data: [{ value: latestValue }], |
44 | 48 | ||
45 | }], | 49 | }], |
46 | title: { | 50 | title: { |
47 | - // text: `${deviceName || ''}-${attrInfo.name || ''}`, | 51 | + text: `${deviceName || ''}- ${functionName || ''} `, |
48 | }, | 52 | }, |
49 | } as EChartsOption) | 53 | } as EChartsOption) |
50 | } | 54 | } |
@@ -54,7 +54,7 @@ const handleSubmit = async () => { | @@ -54,7 +54,7 @@ const handleSubmit = async () => { | ||
54 | const values = getFieldsValue() | 54 | const values = getFieldsValue() |
55 | let dataSourceJson = value | 55 | let dataSourceJson = value |
56 | if (contentDataStore.getIsTemplate) | 56 | if (contentDataStore.getIsTemplate) |
57 | - dataSourceJson = { ...value, deviceProfileId: value?.deviceProfileTemplateId, deviceId: null } | 57 | + dataSourceJson = { ...value, deviceProfileId: value?.deviceProfileTemplateId, deviceId: null, deviceName: null } |
58 | 58 | ||
59 | saveNodeAllData({ dataSourceJson: { ...dataSourceJson, attr: typeof value.attr == 'string' ? [value.attr] : value.attr, chartOption: { ...values } } }) | 59 | saveNodeAllData({ dataSourceJson: { ...dataSourceJson, attr: typeof value.attr == 'string' ? [value.attr] : value.attr, chartOption: { ...values } } }) |
60 | createMessage.success('操作成功~') | 60 | createMessage.success('操作成功~') |
@@ -34,7 +34,7 @@ const handleSubmit = async () => { | @@ -34,7 +34,7 @@ const handleSubmit = async () => { | ||
34 | const formValues = unref(dataSourceFormRef)?.getFieldsValue() | 34 | const formValues = unref(dataSourceFormRef)?.getFieldsValue() |
35 | let dataSourceJson = formValues | 35 | let dataSourceJson = formValues |
36 | if (contentDataStore.getIsTemplate) | 36 | if (contentDataStore.getIsTemplate) |
37 | - dataSourceJson = { ...formValues, deviceProfileId: formValues?.deviceProfileTemplateId, deviceId: null } | 37 | + dataSourceJson = { ...formValues, deviceProfileId: formValues?.deviceProfileTemplateId, deviceId: null, deviceName: null } |
38 | 38 | ||
39 | await saveNodeAllData({ dataSourceJson: { ...dataSourceJson, rectFlowMeterOption: unref(colorConfig) } }) | 39 | await saveNodeAllData({ dataSourceJson: { ...dataSourceJson, rectFlowMeterOption: unref(colorConfig) } }) |
40 | createMessage.success('保存成功') | 40 | createMessage.success('保存成功') |
@@ -9,6 +9,7 @@ import { useOnMessage } from '@/core/Library/hook/useOnMessage' | @@ -9,6 +9,7 @@ import { useOnMessage } from '@/core/Library/hook/useOnMessage' | ||
9 | import type { NodeDataDataSourceJsonType } from '@/api/node/model' | 9 | import type { NodeDataDataSourceJsonType } from '@/api/node/model' |
10 | import { useLatestMessageValue } from '@/core/Library/hook/useLatestMessageValue' | 10 | import { useLatestMessageValue } from '@/core/Library/hook/useLatestMessageValue' |
11 | import { useContentDataStore } from '@/store/modules/contentData' | 11 | import { useContentDataStore } from '@/store/modules/contentData' |
12 | +import { useProductsStore } from '@/store/modules/products' | ||
12 | 13 | ||
13 | const props = defineProps<{ | 14 | const props = defineProps<{ |
14 | config: CreateComponentType | 15 | config: CreateComponentType |
@@ -22,6 +23,8 @@ const getCellBounds = computed(() => props.config.cellBounds || { width: 300, he | @@ -22,6 +23,8 @@ const getCellBounds = computed(() => props.config.cellBounds || { width: 300, he | ||
22 | 23 | ||
23 | const chartElRef = ref<Nullable<HTMLDivElement>>() | 24 | const chartElRef = ref<Nullable<HTMLDivElement>>() |
24 | 25 | ||
26 | +const productsStore = useProductsStore() | ||
27 | + | ||
25 | const chartInstance = ref<Nullable<ECharts>>() | 28 | const chartInstance = ref<Nullable<ECharts>>() |
26 | 29 | ||
27 | function initChartInstance() { | 30 | function initChartInstance() { |
@@ -34,11 +37,12 @@ function initChartInstance() { | @@ -34,11 +37,12 @@ function initChartInstance() { | ||
34 | const { onMessage } = useOnMessage({ | 37 | const { onMessage } = useOnMessage({ |
35 | onReceiveDataSourceMessage(commandSource, message) { | 38 | onReceiveDataSourceMessage(commandSource, message) { |
36 | const { data } = commandSource | 39 | const { data } = commandSource |
37 | - const { attr } = data as NodeDataDataSourceJsonType | ||
38 | - const { latestValue } = useLatestMessageValue(message.data, attr) | 40 | + const { attr, deviceName, deviceProfileId } = data as NodeDataDataSourceJsonType |
41 | + const { functionName } = productsStore.getObjectModelByIdWithIdentifier(deviceProfileId, (attr as string)) || {} | ||
42 | + const { latestValue } = useLatestMessageValue(message.data, (attr as string)) | ||
39 | unref(chartInstance)?.setOption({ | 43 | unref(chartInstance)?.setOption({ |
40 | title: { | 44 | title: { |
41 | - // text: `${deviceName || ''}-${attrInfo.name || ''}`, | 45 | + text: `${deviceName || ''} - ${functionName || ''}`, |
42 | }, | 46 | }, |
43 | series: [{ | 47 | series: [{ |
44 | data: getSetValue(Number(latestValue)), | 48 | data: getSetValue(Number(latestValue)), |
@@ -7,6 +7,7 @@ import type { CreateComponentType, RenderComponentExposeType } from '@/core/Libr | @@ -7,6 +7,7 @@ import type { CreateComponentType, RenderComponentExposeType } from '@/core/Libr | ||
7 | import type { NodeDataDataSourceJsonType } from '@/api/node/model' | 7 | import type { NodeDataDataSourceJsonType } from '@/api/node/model' |
8 | import { useLatestMessageValue } from '@/core/Library/hook/useLatestMessageValue' | 8 | import { useLatestMessageValue } from '@/core/Library/hook/useLatestMessageValue' |
9 | import { useOnMessage } from '@/core/Library/hook/useOnMessage' | 9 | import { useOnMessage } from '@/core/Library/hook/useOnMessage' |
10 | +import { useProductsStore } from '@/store/modules/products' | ||
10 | 11 | ||
11 | const props = defineProps<{ | 12 | const props = defineProps<{ |
12 | config: CreateComponentType | 13 | config: CreateComponentType |
@@ -18,6 +19,8 @@ const chartElRef = ref<Nullable<HTMLDivElement>>() | @@ -18,6 +19,8 @@ const chartElRef = ref<Nullable<HTMLDivElement>>() | ||
18 | 19 | ||
19 | const chartInstance = ref<Nullable<ECharts>>() | 20 | const chartInstance = ref<Nullable<ECharts>>() |
20 | 21 | ||
22 | +const productsStore = useProductsStore() | ||
23 | + | ||
21 | function initChartInstance() { | 24 | function initChartInstance() { |
22 | chartInstance.value = init(unref(chartElRef)) | 25 | chartInstance.value = init(unref(chartElRef)) |
23 | chartInstance.value.setOption(getDefaultOption) | 26 | chartInstance.value.setOption(getDefaultOption) |
@@ -26,11 +29,12 @@ function initChartInstance() { | @@ -26,11 +29,12 @@ function initChartInstance() { | ||
26 | const { onMessage } = useOnMessage({ | 29 | const { onMessage } = useOnMessage({ |
27 | onReceiveDataSourceMessage(commandSource, message) { | 30 | onReceiveDataSourceMessage(commandSource, message) { |
28 | const { data } = commandSource | 31 | const { data } = commandSource |
29 | - const { attr } = data as NodeDataDataSourceJsonType | ||
30 | - const { latestValue } = useLatestMessageValue(message.data, attr) | 32 | + const { attr, deviceName, deviceProfileId } = data as NodeDataDataSourceJsonType |
33 | + const { functionName } = productsStore.getObjectModelByIdWithIdentifier(deviceProfileId, (attr as string)) || {} | ||
34 | + const { latestValue } = useLatestMessageValue(message.data, (attr as string)) | ||
31 | unref(chartInstance)?.setOption({ | 35 | unref(chartInstance)?.setOption({ |
32 | title: { | 36 | title: { |
33 | - // text: `${deviceName || ''}-${attrInfo.name || ''}`, | 37 | + text: `${deviceName || ''} - ${functionName || ''}`, |
34 | }, | 38 | }, |
35 | series: [{ | 39 | series: [{ |
36 | data: [{ | 40 | data: [{ |