Commit 3cd4b2010853bd11e2fdf1715eabaf5c9b9b83a0
Merge remote-tracking branch 'origin/fix/zfl' into perf/main_dev
Showing
6 changed files
with
21 additions
and
10 deletions
@@ -148,6 +148,7 @@ export const getFormSchemas = (event: EventTypeEnum): FormSchema[] => { | @@ -148,6 +148,7 @@ export const getFormSchemas = (event: EventTypeEnum): FormSchema[] => { | ||
148 | [FormFieldsEnum.SERVICE]: undefined, | 148 | [FormFieldsEnum.SERVICE]: undefined, |
149 | [FormFieldsEnum.CUSTOM_COMMAND]: null, | 149 | [FormFieldsEnum.CUSTOM_COMMAND]: null, |
150 | [FormFieldsEnum.WAY]: CommandWayEnum.ONE_WAY, | 150 | [FormFieldsEnum.WAY]: CommandWayEnum.ONE_WAY, |
151 | + [FormFieldsEnum.THINGS_MODEL]: null, | ||
151 | }) | 152 | }) |
152 | }, | 153 | }, |
153 | } | 154 | } |
@@ -205,6 +206,9 @@ export const getFormSchemas = (event: EventTypeEnum): FormSchema[] => { | @@ -205,6 +206,9 @@ export const getFormSchemas = (event: EventTypeEnum): FormSchema[] => { | ||
205 | formModel[FormFieldsEnum.THINGS_MODEL] = value ? options : null | 206 | formModel[FormFieldsEnum.THINGS_MODEL] = value ? options : null |
206 | formModel.callType = options.callType | 207 | formModel.callType = options.callType |
207 | }, | 208 | }, |
209 | + onChange(value: string | number | undefined) { // 因为select不会执行清除选择 所以使用change时间 | ||
210 | + if (!value) formModel[FormFieldsEnum.THINGS_MODEL] = null | ||
211 | + }, | ||
208 | onOptionsChange(options: ThingsModel[]) { | 212 | onOptionsChange(options: ThingsModel[]) { |
209 | const service = formModel[FormFieldsEnum.SERVICE] | 213 | const service = formModel[FormFieldsEnum.SERVICE] |
210 | if (service) { | 214 | if (service) { |
@@ -60,7 +60,7 @@ export const formSchemas = (componentKey?: string): FormSchema[] => { | @@ -60,7 +60,7 @@ export const formSchemas = (componentKey?: string): FormSchema[] => { | ||
60 | formModel[ContentDataFieldsEnum.ATTR] = null | 60 | formModel[ContentDataFieldsEnum.ATTR] = null |
61 | }, | 61 | }, |
62 | filterOption: (inputValue: string, option: DeviceItemType) => { | 62 | filterOption: (inputValue: string, option: DeviceItemType) => { |
63 | - option.alias?.includes?.(inputValue) || option.name?.includes?.(inputValue) | 63 | + return option.alias?.includes?.(inputValue) || option.name?.includes?.(inputValue) |
64 | }, | 64 | }, |
65 | } | 65 | } |
66 | }, | 66 | }, |
@@ -89,8 +89,9 @@ export const formSchemas = (componentKey?: string): FormSchema[] => { | @@ -89,8 +89,9 @@ export const formSchemas = (componentKey?: string): FormSchema[] => { | ||
89 | onSelect(value: string, option: ThingsModelItemType) { | 89 | onSelect(value: string, option: ThingsModelItemType) { |
90 | formModel[ContentDataFieldsEnum.ATTR_INFO] = value && option ? toRaw(unref(option)) : null | 90 | formModel[ContentDataFieldsEnum.ATTR_INFO] = value && option ? toRaw(unref(option)) : null |
91 | }, | 91 | }, |
92 | - filterOption: (inputValue: string, option: ThingsModelItemType) => | ||
93 | - option.name.includes(inputValue), | 92 | + filterOption: (inputValue: string, option: ThingsModelItemType) => { |
93 | + return option.name.includes(inputValue) | ||
94 | + }, | ||
94 | } | 95 | } |
95 | }, | 96 | }, |
96 | }, | 97 | }, |
@@ -51,9 +51,9 @@ const handleSubmit = async () => { | @@ -51,9 +51,9 @@ const handleSubmit = async () => { | ||
51 | 51 | ||
52 | const handleSetFormValues = async () => { | 52 | const handleSetFormValues = async () => { |
53 | const { dataSourceJson } = unref(getNodeData) || {} | 53 | const { dataSourceJson } = unref(getNodeData) || {} |
54 | - const { deviceId, attr, chartOption, deviceProfileId, deviceProfileTemplateId, attrInfo } = dataSourceJson || {} | 54 | + const { deviceId, attr, chartOption, deviceProfileId, deviceProfileTemplateId, attrInfo, deviceInfo } = dataSourceJson || {} |
55 | await nextTick() | 55 | await nextTick() |
56 | - unref(dataSourceElRef)?.setFieldsValue({ deviceId, attr, deviceProfileId, attrInfo, deviceProfileTemplateId }) | 56 | + unref(dataSourceElRef)?.setFieldsValue({ deviceId, attr, deviceProfileId, attrInfo, deviceProfileTemplateId, deviceInfo }) |
57 | setFieldsValue({ ...chartOption }) | 57 | setFieldsValue({ ...chartOption }) |
58 | } | 58 | } |
59 | 59 |
@@ -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, attrInfo, deviceProfileTemplateId } = dataSourceJson || {} | 58 | + const { deviceId, attr, chartOption, deviceProfileId, attrInfo, deviceProfileTemplateId, deviceInfo } = dataSourceJson || {} |
59 | await nextTick() | 59 | await nextTick() |
60 | - unref(dataSourceElRef)?.setFieldsValue({ deviceId, attr, deviceProfileId, attrInfo, deviceProfileTemplateId }) | 60 | + unref(dataSourceElRef)?.setFieldsValue({ deviceId, attr, deviceProfileId, attrInfo, deviceInfo, deviceProfileTemplateId }) |
61 | setFieldsValue({ ...chartOption }) | 61 | setFieldsValue({ ...chartOption }) |
62 | } | 62 | } |
63 | 63 |
@@ -36,9 +36,15 @@ onMounted(() => { | @@ -36,9 +36,15 @@ onMounted(() => { | ||
36 | 36 | ||
37 | const onReceiveDataSourceMessage = (commandSource: CommandSource, message: SubscriptionUpdateMsg) => { | 37 | const onReceiveDataSourceMessage = (commandSource: CommandSource, message: SubscriptionUpdateMsg) => { |
38 | const { data } = commandSource | 38 | const { data } = commandSource |
39 | + const { chartOption } = data || {} | ||
40 | + const { unit } = chartOption || {} | ||
39 | const { attr } = data as NodeDataDataSourceJsonType | 41 | const { attr } = data as NodeDataDataSourceJsonType |
40 | const { latestValue } = useLatestMessageValue(message.data, attr) | 42 | const { latestValue } = useLatestMessageValue(message.data, attr) |
41 | - unref(chartInstance)?.setOption({ series: [{ data: [{ value: latestValue }] }] } as EChartsOption) | 43 | + unref(chartInstance)?.setOption({ |
44 | + series: [{ | ||
45 | + data: [{ value: latestValue }], detail: { formatter: `{value} ${unit || '℃'}` }, | ||
46 | + }], | ||
47 | + } as EChartsOption) | ||
42 | } | 48 | } |
43 | 49 | ||
44 | const { onMessage } = useOnMessage({ onReceiveDataSourceMessage }) | 50 | const { onMessage } = useOnMessage({ onReceiveDataSourceMessage }) |
@@ -32,9 +32,9 @@ const dataSourceElRef = ref<Nullable<InstanceType<typeof DataSourceForm>>>() | @@ -32,9 +32,9 @@ const dataSourceElRef = ref<Nullable<InstanceType<typeof DataSourceForm>>>() | ||
32 | 32 | ||
33 | const handleSetFormValues = async () => { | 33 | const handleSetFormValues = async () => { |
34 | const { dataSourceJson } = unref(getNodeData) || {} | 34 | const { dataSourceJson } = unref(getNodeData) || {} |
35 | - const { deviceId, attr, chartOption, deviceProfileId, deviceProfileTemplateId, attrInfo } = dataSourceJson || {} | 35 | + const { deviceId, attr, chartOption, deviceProfileId, deviceProfileTemplateId, attrInfo, deviceInfo } = dataSourceJson || {} |
36 | await nextTick() | 36 | await nextTick() |
37 | - unref(dataSourceElRef)?.setFieldsValue({ deviceId, attr, deviceProfileId, deviceProfileTemplateId, attrInfo }) | 37 | + unref(dataSourceElRef)?.setFieldsValue({ deviceId, attr, deviceProfileId, deviceProfileTemplateId, attrInfo, deviceInfo }) |
38 | setFieldsValue({ ...chartOption }) | 38 | setFieldsValue({ ...chartOption }) |
39 | } | 39 | } |
40 | 40 |