Showing
5 changed files
with
36 additions
and
4 deletions
... | ... | @@ -8,6 +8,7 @@ import type { ConfigComponentProps } from '@/core/Library/types' |
8 | 8 | import { useMessage } from '@/hooks/web/useMessage' |
9 | 9 | import type { FlowMeterColorItemType, NodeDataDataSourceJsonType } from '@/api/node/model' |
10 | 10 | import { useSavePageContent } from '@/core/Library/hook/useSavePageContent' |
11 | +import { useContentDataStoreWithOut } from '@/store/modules/contentData' | |
11 | 12 | const props = defineProps<ConfigComponentProps>() |
12 | 13 | |
13 | 14 | const { createMessage } = useMessage() |
... | ... | @@ -24,12 +25,18 @@ const dataSourceFormRef = ref<Nullable<InstanceType<typeof DataSourceForm>>>(nul |
24 | 25 | |
25 | 26 | const { savePageContent } = useSavePageContent() |
26 | 27 | |
28 | +const contentDataStore = useContentDataStoreWithOut() | |
29 | + | |
27 | 30 | const handleSubmit = async () => { |
28 | 31 | try { |
29 | 32 | loading.value = true |
30 | 33 | await unref(dataSourceFormRef)?.validate() |
31 | 34 | const formValues = unref(dataSourceFormRef)?.getFieldsValue() |
32 | - saveNodeAllData({ dataSourceJson: { ...formValues, circularFlowMeterOption: unref(colorConfig) } }) | |
35 | + let dataSourceJson = formValues | |
36 | + if (contentDataStore.getIsTemplate) | |
37 | + dataSourceJson = { ...formValues, deviceProfileId: formValues?.deviceProfileTemplateId, deviceId: null } | |
38 | + | |
39 | + saveNodeAllData({ dataSourceJson: { ...dataSourceJson, circularFlowMeterOption: unref(colorConfig) } }) | |
33 | 40 | createMessage.success('保存成功~') |
34 | 41 | savePageContent() |
35 | 42 | } | ... | ... |
... | ... | @@ -12,6 +12,7 @@ import type { ConfigComponentProps } from '@/core/Library/types' |
12 | 12 | import { useNodeData } from '@/core/Library/hook/useNodeData' |
13 | 13 | import { useMessage } from '@/hooks/web/useMessage' |
14 | 14 | import { useSavePageContent } from '@/core/Library/hook/useSavePageContent' |
15 | +import { useContentDataStoreWithOut } from '@/store/modules/contentData' | |
15 | 16 | |
16 | 17 | const props = defineProps<ConfigComponentProps>() |
17 | 18 | const loading = ref(false) |
... | ... | @@ -32,6 +33,7 @@ const [register, { getFieldsValue, setFieldsValue, validate }] = useForm({ |
32 | 33 | const { createMessage } = useMessage() |
33 | 34 | |
34 | 35 | const { savePageContent } = useSavePageContent() |
36 | +const contentDataStore = useContentDataStoreWithOut() | |
35 | 37 | |
36 | 38 | const handleSubmit = async () => { |
37 | 39 | try { |
... | ... | @@ -40,7 +42,11 @@ const handleSubmit = async () => { |
40 | 42 | await validate() |
41 | 43 | const value = unref(dataSourceElRef)?.getFieldsValue() |
42 | 44 | const values = getFieldsValue() |
43 | - await saveNodeAllData({ dataSourceJson: { ...value, chartOption: { ...values } } }) | |
45 | + let dataSourceJson = value | |
46 | + if (contentDataStore.getIsTemplate) | |
47 | + dataSourceJson = { ...value, deviceProfileId: value?.deviceProfileTemplateId, deviceId: null } | |
48 | + | |
49 | + await saveNodeAllData({ dataSourceJson: { ...dataSourceJson, chartOption: { ...values } } }) | |
44 | 50 | savePageContent() |
45 | 51 | createMessage.success('操作成功~') |
46 | 52 | } | ... | ... |
... | ... | @@ -12,6 +12,7 @@ import type { ConfigComponentProps } from '@/core/Library/types' |
12 | 12 | import { createPublicFormContext } from '@/core/Library/components/PublicForm/usePublicFormContext' |
13 | 13 | import { useMessage } from '@/hooks/web/useMessage' |
14 | 14 | import { useSavePageContent } from '@/core/Library/hook/useSavePageContent' |
15 | +import { useContentDataStoreWithOut } from '@/store/modules/contentData' | |
15 | 16 | |
16 | 17 | const props = defineProps<ConfigComponentProps>() |
17 | 18 | |
... | ... | @@ -40,6 +41,8 @@ const handleSetFormValues = async () => { |
40 | 41 | |
41 | 42 | const { createMessage } = useMessage() |
42 | 43 | const { savePageContent } = useSavePageContent() |
44 | +const contentDataStore = useContentDataStoreWithOut() | |
45 | + | |
43 | 46 | const handleSubmit = async () => { |
44 | 47 | try { |
45 | 48 | loading.value = true |
... | ... | @@ -47,7 +50,11 @@ const handleSubmit = async () => { |
47 | 50 | await validate() |
48 | 51 | const value = unref(dataSourceElRef)?.getFieldsValue() |
49 | 52 | const values = getFieldsValue() |
50 | - saveNodeAllData({ dataSourceJson: { ...value, chartOption: { ...values } } }) | |
53 | + let dataSourceJson = value | |
54 | + if (contentDataStore.getIsTemplate) | |
55 | + dataSourceJson = { ...value, deviceProfileId: value?.deviceProfileTemplateId, deviceId: null } | |
56 | + | |
57 | + saveNodeAllData({ dataSourceJson: { ...dataSourceJson, chartOption: { ...values } } }) | |
51 | 58 | createMessage.success('操作成功~') |
52 | 59 | savePageContent() |
53 | 60 | } | ... | ... |
... | ... | @@ -8,6 +8,7 @@ import type { ConfigComponentProps } from '@/core/Library/types' |
8 | 8 | import { useMessage } from '@/hooks/web/useMessage' |
9 | 9 | import type { FlowMeterColorItemType } from '@/api/node/model' |
10 | 10 | import { useSavePageContent } from '@/core/Library/hook/useSavePageContent' |
11 | +import { useContentDataStoreWithOut } from '@/store/modules/contentData' | |
11 | 12 | |
12 | 13 | const props = defineProps<ConfigComponentProps>() |
13 | 14 | |
... | ... | @@ -24,13 +25,18 @@ const { getNodeAllData, saveNodeAllData, getNodeData } = nodeDataActinType |
24 | 25 | const dataSourceFormRef = ref<Nullable<InstanceType<typeof DataSourceForm>>>(null) |
25 | 26 | |
26 | 27 | const { savePageContent } = useSavePageContent() |
28 | +const contentDataStore = useContentDataStoreWithOut() | |
27 | 29 | |
28 | 30 | const handleSubmit = async () => { |
29 | 31 | try { |
30 | 32 | loading.value = true |
31 | 33 | await unref(dataSourceFormRef)?.validate() |
32 | 34 | const formValues = unref(dataSourceFormRef)?.getFieldsValue() |
33 | - await saveNodeAllData({ dataSourceJson: { ...formValues, rectFlowMeterOption: unref(colorConfig) } }) | |
35 | + let dataSourceJson = formValues | |
36 | + if (contentDataStore.getIsTemplate) | |
37 | + dataSourceJson = { ...formValues, deviceProfileId: formValues?.deviceProfileTemplateId, deviceId: null } | |
38 | + | |
39 | + await saveNodeAllData({ dataSourceJson: { ...dataSourceJson, rectFlowMeterOption: unref(colorConfig) } }) | |
34 | 40 | createMessage.success('保存成功') |
35 | 41 | savePageContent() |
36 | 42 | } | ... | ... |
... | ... | @@ -6,6 +6,7 @@ import { useNodeData } from '@/core/Library/hook/useNodeData' |
6 | 6 | import { useMessage } from '@/hooks/web/useMessage' |
7 | 7 | import type { ConfigComponentProps } from '@/core/Library/types' |
8 | 8 | import { useSavePageContent } from '@/core/Library/hook/useSavePageContent' |
9 | +import { useContentDataStoreWithOut } from '@/store/modules/contentData' | |
9 | 10 | |
10 | 11 | const props = defineProps<ConfigComponentProps>() |
11 | 12 | |
... | ... | @@ -20,12 +21,17 @@ const nodeDataActinType = useNodeData({ cell: props.cell!, immediate: false }) |
20 | 21 | const { getNodeAllData, saveNodeAllData, getNodeData } = nodeDataActinType |
21 | 22 | |
22 | 23 | const { savePageContent } = useSavePageContent() |
24 | +const contentDataStore = useContentDataStoreWithOut() | |
23 | 25 | |
24 | 26 | const handleSubmit = async () => { |
25 | 27 | try { |
26 | 28 | loading.value = true |
27 | 29 | await unref(dataSourceFormRef)?.validate() |
28 | 30 | const formValues = unref(dataSourceFormRef)?.getFieldsValue() |
31 | + let dataSourceJson = formValues | |
32 | + if (contentDataStore.getIsTemplate) | |
33 | + dataSourceJson = { ...formValues, deviceProfileId: formValues?.deviceProfileTemplateId, deviceId: null } | |
34 | + | |
29 | 35 | await saveNodeAllData({ dataSourceJson: { ...formValues } }) |
30 | 36 | createMessage.success('保存成功~') |
31 | 37 | savePageContent() | ... | ... |