Showing
44 changed files
with
210 additions
and
181 deletions
... | ... | @@ -40,6 +40,7 @@ enum DataBoardShareUrl { |
40 | 40 | |
41 | 41 | enum SendCommand { |
42 | 42 | ONEWAY = '/plugins/rpc/oneway', |
43 | + TWOWAY = '/plugins/rpc/twoway', | |
43 | 44 | } |
44 | 45 | |
45 | 46 | enum DeviceUrl { |
... | ... | @@ -229,6 +230,16 @@ export const sendCommandOneway = (params: SendCommandParams) => { |
229 | 230 | ); |
230 | 231 | }; |
231 | 232 | |
233 | +export const sendCommandTwoway = (params: SendCommandParams) => { | |
234 | + return defHttp.post( | |
235 | + { | |
236 | + url: `${SendCommand.TWOWAY}/${params.deviceId}`, | |
237 | + params: params.value, | |
238 | + }, | |
239 | + { joinPrefix: false, withShareToken: isShareMode() } | |
240 | + ); | |
241 | +}; | |
242 | + | |
232 | 243 | export const getDeviceRelation = (params: { deviceId: string; isSlave: boolean }) => { |
233 | 244 | return defHttp.get<string>({ |
234 | 245 | url: DeviceUrl.GET_DEVICE_RELATION, | ... | ... |
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | import { DynamicProps } from '/#/utils'; |
7 | 7 | import { Specs, StructJSON } from '/@/api/device/model/modelOfMatterModel'; |
8 | 8 | import { BasicForm, FormProps, FormSchema, useForm } from '/@/components/Form'; |
9 | + import { ReadAndWriteEnum } from '/@/enums/toolEnum'; | |
9 | 10 | |
10 | 11 | const props = withDefaults( |
11 | 12 | defineProps<{ |
... | ... | @@ -174,7 +175,10 @@ |
174 | 175 | const transformToFormSchema = (inputData: StructJSON[]) => { |
175 | 176 | const schemas: FormSchema[] = []; |
176 | 177 | for (const item of inputData) { |
177 | - const { dataType, identifier, functionName } = item; | |
178 | + const { dataType, identifier, functionName, accessMode } = item; | |
179 | + if (accessMode === ReadAndWriteEnum.READ) { | |
180 | + continue; | |
181 | + } | |
178 | 182 | const { type, specs } = dataType! || {}; |
179 | 183 | |
180 | 184 | const params: BasicCreateFormParams = { | ... | ... |
... | ... | @@ -74,7 +74,10 @@ |
74 | 74 | : {}), |
75 | 75 | }; |
76 | 76 | |
77 | - if (validateRepeat(_value, props.valueList)) { | |
77 | + if ( | |
78 | + unref(modalReceiveRecord).mode === OpenModalMode.CREATE && | |
79 | + validateRepeat(_value, props.valueList) | |
80 | + ) { | |
78 | 81 | createMessage.error('存在一致的标识符'); |
79 | 82 | return; |
80 | 83 | } | ... | ... |
... | ... | @@ -18,6 +18,7 @@ import { TransportTypeEnum } from '/@/views/device/profiles/components/Transport |
18 | 18 | import { useComponentRegister } from '/@/components/Form'; |
19 | 19 | import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect'; |
20 | 20 | import { isArray } from '/@/utils/is'; |
21 | +import { ReadAndWriteEnum } from '/@/enums/toolEnum'; | |
21 | 22 | |
22 | 23 | useComponentRegister('OrgTreeSelect', OrgTreeSelect); |
23 | 24 | |
... | ... | @@ -646,7 +647,9 @@ export const actionSchema: FormSchema[] = [ |
646 | 647 | callType: selected.callType, |
647 | 648 | serviceIdentifier: selected?.identifier, |
648 | 649 | thingsModelKeys: isArray(selected?.functionJson?.inputData) |
649 | - ? selected?.functionJson?.inputData.map((item) => item.identifier) | |
650 | + ? selected?.functionJson?.inputData | |
651 | + .filter((item) => item.accessMode === ReadAndWriteEnum.READ_AND_WRITE) | |
652 | + .map((item) => item.identifier) | |
650 | 653 | : [], |
651 | 654 | }); |
652 | 655 | return record; |
... | ... | @@ -669,7 +672,9 @@ export const actionSchema: FormSchema[] = [ |
669 | 672 | callType: options.callType, |
670 | 673 | serviceIdentifier: options.identifier, |
671 | 674 | thingsModelKeys: isArray(options?.functionJson?.inputData) |
672 | - ? options?.functionJson?.inputData.map((item) => item.identifier) | |
675 | + ? options?.functionJson?.inputData | |
676 | + .filter((item) => item.accessMode === ReadAndWriteEnum.READ_AND_WRITE) | |
677 | + .filter((item) => item.identifier) | |
673 | 678 | : [], |
674 | 679 | }; |
675 | 680 | transportType === TransportTypeEnum.TCP | ... | ... |
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | |
17 | 17 | const searchInfo = ref<Recordable>({}); |
18 | 18 | |
19 | - const activeKey = ref(ActiveKey.RULE); | |
19 | + const activeKey = ref(ActiveKey.TCP); | |
20 | 20 | |
21 | 21 | const syncValue = (value: Recordable) => { |
22 | 22 | searchInfo.value = { ...unref(searchInfo), ...value }; |
... | ... | @@ -62,16 +62,16 @@ |
62 | 62 | type="card" |
63 | 63 | class="w-full h-full bg-light-50 !p-4 dark:bg-dark-900" |
64 | 64 | > |
65 | - <Tabs.TabPane tab="规则链转换脚本" :key="ActiveKey.RULE"> | |
66 | - <RuleChainConversionScript | |
67 | - ref="ruleChainTableRefEl" | |
65 | + <Tabs.TabPane tab="TCP转换脚本" :key="ActiveKey.TCP"> | |
66 | + <TcpConversionScript | |
67 | + ref="tcpTableRefEl" | |
68 | 68 | :search-info="searchInfo" |
69 | 69 | class="p-4 bg-neutral-100 dark:bg-dark-700" |
70 | 70 | /> |
71 | 71 | </Tabs.TabPane> |
72 | - <Tabs.TabPane tab="TCP转换脚本" :key="ActiveKey.TCP"> | |
73 | - <TcpConversionScript | |
74 | - ref="tcpTableRefEl" | |
72 | + <Tabs.TabPane tab="规则链转换脚本" :key="ActiveKey.RULE"> | |
73 | + <RuleChainConversionScript | |
74 | + ref="ruleChainTableRefEl" | |
75 | 75 | :search-info="searchInfo" |
76 | 76 | class="p-4 bg-neutral-100 dark:bg-dark-700" |
77 | 77 | /> | ... | ... |
... | ... | @@ -40,7 +40,7 @@ |
40 | 40 | |
41 | 41 | const [registerModal, { openModal }] = useModal(); |
42 | 42 | |
43 | - const { trackUpdate, triggerUpdate } = useUpdateQueue(props); | |
43 | + const { trackUpdate, triggerUpdate, clear } = useUpdateQueue(props); | |
44 | 44 | |
45 | 45 | const spinning = ref(false); |
46 | 46 | |
... | ... | @@ -156,6 +156,9 @@ |
156 | 156 | if (value && value.length) { |
157 | 157 | nextTick(); |
158 | 158 | setFormValues(value); |
159 | + } else { | |
160 | + dataSourceFormsEl.value = []; | |
161 | + clear(); | |
159 | 162 | } |
160 | 163 | } |
161 | 164 | ); | ... | ... |
... | ... | @@ -19,5 +19,9 @@ export const useUpdateQueue = (props: { dataSource: DataSourceType[] }) => { |
19 | 19 | return uuid; |
20 | 20 | }; |
21 | 21 | |
22 | - return { trackUpdate, triggerUpdate }; | |
22 | + const clear = () => { | |
23 | + needUpdateQueue.length = 0; | |
24 | + }; | |
25 | + | |
26 | + return { trackUpdate, triggerUpdate, clear }; | |
23 | 27 | }; | ... | ... |
... | ... | @@ -133,7 +133,6 @@ |
133 | 133 | [oldCategory, category].some((item) => item === PackagesCategoryEnum.CONTROL) && |
134 | 134 | oldCategory !== category && |
135 | 135 | firstEnter; |
136 | - | |
137 | 136 | dataSource.value = unref(dataSource).map((item) => ({ |
138 | 137 | ...item, |
139 | 138 | ...(needReset ? { attribute: null } : {}), |
... | ... | @@ -248,6 +247,7 @@ |
248 | 247 | componentKey: TextComponent1Config.key, |
249 | 248 | categoryKey: PackagesCategoryEnum.TEXT, |
250 | 249 | }; |
250 | + dataSource.value = []; | |
251 | 251 | loading.value = false; |
252 | 252 | } |
253 | 253 | }; | ... | ... |
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | service: value.service, |
34 | 34 | command: value.command, |
35 | 35 | commandType: value.commandType, |
36 | + callType: value.callType, | |
36 | 37 | }, |
37 | 38 | }; |
38 | 39 | return value; |
... | ... | @@ -46,6 +47,7 @@ |
46 | 47 | service: customCommand?.service || (record as Recordable).service, |
47 | 48 | command: customCommand?.command || (record as Recordable).command, |
48 | 49 | commandType: customCommand?.commandType || (record as Recordable).commandType, |
50 | + callType: customCommand?.callType || (record as Recordable).callType, | |
49 | 51 | } as unknown as Partial<CommonDataSourceBindValueType>); |
50 | 52 | }; |
51 | 53 | ... | ... |
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | import { option } from './config'; |
4 | 4 | import { useDataFetch } from '/@/views/visual/packages/hook/useSocket'; |
5 | 5 | import { Spin } from 'ant-design-vue'; |
6 | - import { ref } from 'vue'; | |
6 | + import { computed, ref } from 'vue'; | |
7 | 7 | import { useComponentScale } from '../../../hook/useComponentScale'; |
8 | 8 | import { useSendCommand } from '../../../hook/useSendCommand'; |
9 | 9 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
... | ... | @@ -16,6 +16,14 @@ |
16 | 16 | |
17 | 17 | const currentValue = ref(false); |
18 | 18 | |
19 | + const getDesign = computed(() => { | |
20 | + const { option } = props.config; | |
21 | + const { attribute, attributeRename, attributeName } = option; | |
22 | + return { | |
23 | + attribute: attributeRename || attributeName || attribute, | |
24 | + }; | |
25 | + }); | |
26 | + | |
19 | 27 | const { sendCommand, loading } = useSendCommand(); |
20 | 28 | const handleChange = async (event: Event) => { |
21 | 29 | const target = event.target as HTMLInputElement; |
... | ... | @@ -52,7 +60,9 @@ |
52 | 60 | <span class="on">ON</span> |
53 | 61 | <span class="off">OFF</span> |
54 | 62 | </label> |
55 | - <div class="text-center mt-2 text-gray-700" :style="getScale"> 属性 </div> | |
63 | + <div class="text-center mt-2 text-gray-700" :style="getScale"> | |
64 | + {{ getDesign.attribute || '属性' }} | |
65 | + </div> | |
56 | 66 | </Spin> |
57 | 67 | </main> |
58 | 68 | </main> | ... | ... |
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | service: value.service, |
34 | 34 | command: value.command, |
35 | 35 | commandType: value.commandType, |
36 | + callType: value.callType, | |
36 | 37 | }, |
37 | 38 | }; |
38 | 39 | return value; |
... | ... | @@ -46,6 +47,7 @@ |
46 | 47 | service: customCommand?.service || (record as Recordable).service, |
47 | 48 | command: customCommand?.command || (record as Recordable).command, |
48 | 49 | commandType: customCommand?.commandType || (record as Recordable).commandType, |
50 | + callType: customCommand?.callType || (record as Recordable).callType, | |
49 | 51 | } as unknown as Partial<CommonDataSourceBindValueType>); |
50 | 52 | }; |
51 | 53 | ... | ... |
... | ... | @@ -18,13 +18,13 @@ |
18 | 18 | |
19 | 19 | const getDesign = computed(() => { |
20 | 20 | const { option, persetOption } = props.config; |
21 | - const { componentInfo, attribute, attributeRename } = option; | |
21 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
22 | 22 | const { icon: presetIcon, iconColor: presetIconColor } = persetOption || {}; |
23 | 23 | const { icon, iconColor } = componentInfo || {}; |
24 | 24 | return { |
25 | 25 | icon: icon ?? presetIcon, |
26 | 26 | iconColor: iconColor || presetIconColor, |
27 | - attribute: attributeRename || attribute, | |
27 | + attribute: attributeRename || attributeName || attribute, | |
28 | 28 | }; |
29 | 29 | }); |
30 | 30 | ... | ... |
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | service: value.service, |
34 | 34 | command: value.command, |
35 | 35 | commandType: value.commandType, |
36 | + callType: value.callType, | |
36 | 37 | }, |
37 | 38 | }; |
38 | 39 | return value; |
... | ... | @@ -46,6 +47,7 @@ |
46 | 47 | service: customCommand?.service || (record as Recordable).service, |
47 | 48 | command: customCommand?.command || (record as Recordable).command, |
48 | 49 | commandType: customCommand?.commandType || (record as Recordable).commandType, |
50 | + callType: customCommand?.callType || (record as Recordable).callType, | |
49 | 51 | } as unknown as Partial<CommonDataSourceBindValueType>); |
50 | 52 | }; |
51 | 53 | ... | ... |
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | import { option } from './config'; |
4 | 4 | import { useDataFetch } from '/@/views/visual/packages/hook/useSocket'; |
5 | 5 | import { Spin } from 'ant-design-vue'; |
6 | - import { ref } from 'vue'; | |
6 | + import { computed, ref } from 'vue'; | |
7 | 7 | import { useComponentScale } from '../../../hook/useComponentScale'; |
8 | 8 | import { useSendCommand } from '../../../hook/useSendCommand'; |
9 | 9 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
... | ... | @@ -16,6 +16,14 @@ |
16 | 16 | |
17 | 17 | const currentValue = ref(false); |
18 | 18 | |
19 | + const getDesign = computed(() => { | |
20 | + const { option } = props.config; | |
21 | + const { attribute, attributeRename, attributeName } = option; | |
22 | + return { | |
23 | + attribute: attributeRename || attributeName || attribute, | |
24 | + }; | |
25 | + }); | |
26 | + | |
19 | 27 | const { loading, sendCommand } = useSendCommand(); |
20 | 28 | const handleChange = async (event: Event) => { |
21 | 29 | const target = event.target as HTMLInputElement; |
... | ... | @@ -51,7 +59,9 @@ |
51 | 59 | </div> |
52 | 60 | </label> |
53 | 61 | </div> |
54 | - <div class="text-center mt-2 text-gray-500" :style="getScale">属性</div> | |
62 | + <div class="text-center mt-2 text-gray-500" :style="getScale">{{ | |
63 | + getDesign.attribute || '属性' | |
64 | + }}</div> | |
55 | 65 | </Spin> |
56 | 66 | </main> |
57 | 67 | </main> | ... | ... |
... | ... | @@ -22,12 +22,12 @@ |
22 | 22 | |
23 | 23 | const getDesign = computed(() => { |
24 | 24 | const { option, persetOption } = props.config; |
25 | - const { componentInfo, attribute, attributeRename } = option; | |
25 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
26 | 26 | const { controlBarColor: persetControlBarColor, fonColor: persetFontColor } = |
27 | 27 | persetOption || {}; |
28 | 28 | const { controlBarColor, fontColor } = componentInfo || {}; |
29 | 29 | return { |
30 | - attribute: attributeRename || attribute, | |
30 | + attribute: attributeRename || attributeName || attribute, | |
31 | 31 | controlBarColor: controlBarColor ?? persetControlBarColor, |
32 | 32 | fontColor: fontColor ?? persetFontColor, |
33 | 33 | }; |
... | ... | @@ -87,7 +87,7 @@ |
87 | 87 | :style="{ color: getDesign.fontColor }" |
88 | 88 | class="mt-3 truncate font-bold text-xs text-center" |
89 | 89 | > |
90 | - {{ getDesign.attribute || '设备1' }} | |
90 | + {{ getDesign.attribute || '属性' }} | |
91 | 91 | </span> |
92 | 92 | </div> |
93 | 93 | </Spin> | ... | ... |
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | import { ref } from 'vue'; |
7 | 7 | import { unref } from 'vue'; |
8 | 8 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
9 | + import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; | |
9 | 10 | |
10 | 11 | const props = defineProps<{ |
11 | 12 | config: ComponentPropsConfigType<typeof option>; |
... | ... | @@ -13,9 +14,11 @@ |
13 | 14 | |
14 | 15 | const currentValue = ref(25); |
15 | 16 | |
17 | + const time = ref<Nullable<number>>(null); | |
18 | + | |
16 | 19 | const getDesign = computed(() => { |
17 | 20 | const { option, persetOption } = props.config; |
18 | - const { componentInfo } = option; | |
21 | + const { componentInfo, attribute, attributeName, attributeRename } = option; | |
19 | 22 | const { flowmeterConfig, unit, fontColor } = componentInfo || {}; |
20 | 23 | const { backgroundColor, waveFirst, waveSecond, waveThird } = flowmeterConfig || {}; |
21 | 24 | const { |
... | ... | @@ -36,6 +39,7 @@ |
36 | 39 | waveThird: waveThird ?? presetWaveThird, |
37 | 40 | unit: unit ?? persetUnit, |
38 | 41 | fontColor: fontColor ?? presetFontColor, |
42 | + attribute: attributeRename || attributeName || attribute, | |
39 | 43 | }; |
40 | 44 | }); |
41 | 45 | |
... | ... | @@ -62,7 +66,8 @@ |
62 | 66 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
63 | 67 | const { data = {} } = message; |
64 | 68 | const [latest] = data[attribute] || []; |
65 | - const [_, value] = latest; | |
69 | + const [timespan, value] = latest; | |
70 | + time.value = timespan; | |
66 | 71 | currentValue.value = Number(value); |
67 | 72 | }; |
68 | 73 | |
... | ... | @@ -112,6 +117,10 @@ |
112 | 117 | <div>{{ currentValue }}</div> |
113 | 118 | <div class="ml-1">{{ getDesign.unit }}</div> |
114 | 119 | </div> |
120 | + <div class="text-gray-500 text-sm truncate" style="flex: 0 0 20px">{{ | |
121 | + getDesign.attribute || '属性' | |
122 | + }}</div> | |
123 | + <UpdateTime :time="time" /> | |
115 | 124 | </main> |
116 | 125 | </template> |
117 | 126 | ... | ... |
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | import { ref } from 'vue'; |
7 | 7 | import { unref } from 'vue'; |
8 | 8 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
9 | + import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; | |
9 | 10 | |
10 | 11 | const props = defineProps<{ |
11 | 12 | config: ComponentPropsConfigType<typeof option>; |
... | ... | @@ -13,9 +14,11 @@ |
13 | 14 | |
14 | 15 | const currentValue = ref(25); |
15 | 16 | |
17 | + const time = ref<Nullable<number>>(null); | |
18 | + | |
16 | 19 | const getDesign = computed(() => { |
17 | 20 | const { option, persetOption } = props.config; |
18 | - const { componentInfo } = option; | |
21 | + const { componentInfo, attribute, attributeName, attributeRename } = option; | |
19 | 22 | const { flowmeterConfig, unit, fontColor } = componentInfo || {}; |
20 | 23 | const { backgroundColor, waveFirst, waveSecond, waveThird } = flowmeterConfig || {}; |
21 | 24 | const { |
... | ... | @@ -36,6 +39,7 @@ |
36 | 39 | waveThird: waveThird ?? presetWaveThird, |
37 | 40 | unit: unit ?? persetUnit, |
38 | 41 | fontColor: fontColor ?? presetFontColor, |
42 | + attribute: attributeRename || attributeName || attribute, | |
39 | 43 | }; |
40 | 44 | }); |
41 | 45 | |
... | ... | @@ -52,7 +56,8 @@ |
52 | 56 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
53 | 57 | const { data = {} } = message; |
54 | 58 | const [latest] = data[attribute] || []; |
55 | - const [_, value] = latest; | |
59 | + const [timespan, value] = latest; | |
60 | + time.value = timespan; | |
56 | 61 | currentValue.value = Number(value); |
57 | 62 | }; |
58 | 63 | |
... | ... | @@ -105,6 +110,10 @@ |
105 | 110 | <div>{{ currentValue }}</div> |
106 | 111 | <div class="ml-1">{{ getDesign.unit }}</div> |
107 | 112 | </div> |
113 | + <div class="text-gray-500 text-sm truncate" style="flex: 0 0 20px">{{ | |
114 | + getDesign.attribute || '属性' | |
115 | + }}</div> | |
116 | + <UpdateTime :time="time" /> | |
108 | 117 | </main> |
109 | 118 | </template> |
110 | 119 | ... | ... |
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | import { computed } from 'vue'; |
7 | 7 | import { unref } from 'vue'; |
8 | 8 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
9 | + import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; | |
9 | 10 | |
10 | 11 | const props = defineProps<{ |
11 | 12 | config: ComponentPropsConfigType<typeof option>; |
... | ... | @@ -13,6 +14,8 @@ |
13 | 14 | |
14 | 15 | const currentValue = ref(50); |
15 | 16 | |
17 | + const time = ref<Nullable<number>>(null); | |
18 | + | |
16 | 19 | const getValue = computed(() => { |
17 | 20 | const maxHeight = 190; |
18 | 21 | const minHeight = 15; |
... | ... | @@ -34,17 +37,19 @@ |
34 | 37 | const getDesign = computed(() => { |
35 | 38 | const { persetOption, option } = props.config; |
36 | 39 | const { fontColor: presetFontColor } = persetOption || {}; |
37 | - const { componentInfo } = option || {}; | |
40 | + const { componentInfo, attribute, attributeName, attributeRename } = option || {}; | |
38 | 41 | const { fontColor } = componentInfo || {}; |
39 | 42 | return { |
40 | 43 | fontColor: fontColor ?? presetFontColor, |
44 | + attribute: attributeRename || attributeName || attribute, | |
41 | 45 | }; |
42 | 46 | }); |
43 | 47 | |
44 | 48 | const updateFn: DataFetchUpdateFn = (message, attribute) => { |
45 | 49 | const { data = {} } = message; |
46 | 50 | const [latest] = data[attribute] || []; |
47 | - const [_, value] = latest; | |
51 | + const [timespan, value] = latest; | |
52 | + time.value = timespan; | |
48 | 53 | |
49 | 54 | currentValue.value = Number(value); |
50 | 55 | }; |
... | ... | @@ -247,6 +252,10 @@ |
247 | 252 | <span>{{ '℃' }}</span> |
248 | 253 | </div> |
249 | 254 | </div> |
255 | + <div class="text-gray-500 text-sm truncate" style="flex: 0 0 20px">{{ | |
256 | + getDesign.attribute || '属性' | |
257 | + }}</div> | |
258 | + <UpdateTime :time="time" /> | |
250 | 259 | </main> |
251 | 260 | </template> |
252 | 261 | ... | ... |
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | import { Space } from 'ant-design-vue'; |
7 | 7 | import { useComponentScale } from '/@/views/visual/packages/hook/useComponentScale'; |
8 | 8 | import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; |
9 | + import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; | |
9 | 10 | |
10 | 11 | const props = defineProps<{ |
11 | 12 | config: ComponentPropsConfigType<typeof option>; |
... | ... | @@ -45,13 +46,13 @@ |
45 | 46 | |
46 | 47 | const getDesign = computed(() => { |
47 | 48 | const { option, persetOption } = props.config; |
48 | - const { componentInfo, attribute, attributeRename } = option; | |
49 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
49 | 50 | const { fontColor: presetFontColor, unit: presetUnit } = persetOption || {}; |
50 | 51 | const { unit, fontColor } = componentInfo || {}; |
51 | 52 | return { |
52 | 53 | unit: unit ?? presetUnit, |
53 | 54 | fontColor: fontColor ?? presetFontColor, |
54 | - attribute: attributeRename || attribute, | |
55 | + attribute: attributeRename || attributeName || attribute, | |
55 | 56 | }; |
56 | 57 | }); |
57 | 58 | |
... | ... | @@ -71,6 +72,8 @@ |
71 | 72 | <template> |
72 | 73 | <main class="w-full h-full flex flex-col justify-center items-center"> |
73 | 74 | <div class="flex flex-col w-full h-full"> |
75 | + <DeviceName class="text-center" :config="config" /> | |
76 | + | |
74 | 77 | <div class="flex-1 flex justify-center items-center"> |
75 | 78 | <div class="flex px-4 items-center transform scale-75" :style="getScale"> |
76 | 79 | <Space | ... | ... |
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | |
23 | 23 | const getDesign = computed(() => { |
24 | 24 | const { option, persetOption } = props.config; |
25 | - const { componentInfo, attribute, attributeRename } = option; | |
25 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
26 | 26 | const { |
27 | 27 | fontColor: presetFontColor, |
28 | 28 | unit: presetUnit, |
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 | return { |
36 | 36 | unit: unit ?? presetUnit, |
37 | 37 | fontColor: fontColor ?? presetFontColor, |
38 | - attribute: attributeRename || attribute, | |
38 | + attribute: attributeRename || attributeName || attribute, | |
39 | 39 | pointerColor: pointerColor ?? presetPointerColor, |
40 | 40 | instrumentPanelColor: instrumentPanelColor ?? presetInstrumentPanelColor, |
41 | 41 | gradientInfo: gradientInfo ?? presetGradientInfo, | ... | ... |
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | |
23 | 23 | const getDesign = computed(() => { |
24 | 24 | const { option, persetOption } = props.config; |
25 | - const { componentInfo, attribute, attributeRename } = option; | |
25 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
26 | 26 | const { |
27 | 27 | fontColor: presetFontColor, |
28 | 28 | unit: presetUnit, |
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | return { |
37 | 37 | unit: unit ?? presetUnit, |
38 | 38 | fontColor: fontColor ?? presetFontColor, |
39 | - attribute: attributeRename || attribute, | |
39 | + attribute: attributeRename || attributeName || attribute, | |
40 | 40 | pointerColor: pointerColor ?? presetPointerColor, |
41 | 41 | instrumentPanelColor: instrumentPanelColor ?? presetInstrumentPanelColor, |
42 | 42 | progressBarCircle: progressBarCircle ?? presetProgressBarCircle, | ... | ... |
... | ... | @@ -32,7 +32,8 @@ |
32 | 32 | return { |
33 | 33 | dataSource: dataSource.map((item) => { |
34 | 34 | const { unit, fontColor, showDeviceName } = item.componentInfo || {}; |
35 | - const { deviceName, deviceRename, attribute, attributeRename, deviceId } = item; | |
35 | + const { deviceName, deviceRename, attribute, attributeRename, deviceId, attributeName } = | |
36 | + item; | |
36 | 37 | // return { |
37 | 38 | // unit: unit ?? persetUnit, |
38 | 39 | // fontColor: fontColor ?? persetFontColor, |
... | ... | @@ -49,6 +50,7 @@ |
49 | 50 | showDeviceName: showDeviceName ?? presetShowDeviceName, |
50 | 51 | deviceName, |
51 | 52 | deviceRename, |
53 | + attributeName, | |
52 | 54 | id: deviceId, |
53 | 55 | }; |
54 | 56 | }), |
... | ... | @@ -151,10 +153,8 @@ |
151 | 153 | const series = ref( |
152 | 154 | unref(getDesign).dataSource.map((item, index) => ({ |
153 | 155 | value: 30, |
154 | - name: `${ | |
155 | - item.showDeviceName | |
156 | - ? (item.deviceRename || item.deviceName) + '-' + (item.attributeRename || item.attribute) | |
157 | - : '' | |
156 | + name: `${item.showDeviceName ? `${item.deviceRename || item.deviceName}-` : ''}${ | |
157 | + item.attributeRename || item.attributeName || item.attribute | |
158 | 158 | }`, |
159 | 159 | attribute: item.attribute, |
160 | 160 | id: item.id, |
... | ... | @@ -334,9 +334,6 @@ |
334 | 334 | <main class="w-full h-full flex flex-col justify-center items-center"> |
335 | 335 | <DeviceName :config="config" /> |
336 | 336 | <div ref="chartRefEl" class="flex-1 w-full h-full"> </div> |
337 | - <!-- <div class="text-gray-500 text-xs text-center truncate">{{ | |
338 | - getDesign.attribute || '湿度' | |
339 | - }}</div> --> | |
340 | 337 | <UpdateTime :time="time" /> |
341 | 338 | </main> |
342 | 339 | </template> | ... | ... |
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | |
22 | 22 | const getDesign = computed(() => { |
23 | 23 | const { option, persetOption } = props.config; |
24 | - const { componentInfo, attribute, attributeRename } = option; | |
24 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
25 | 25 | const { |
26 | 26 | fontColor: presetFontColor, |
27 | 27 | unit: presetUnit, |
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | return { |
35 | 35 | unit: unit ?? presetUnit, |
36 | 36 | fontColor: fontColor ?? presetFontColor, |
37 | - attribute: attributeRename || attribute, | |
37 | + attribute: attributeRename || attributeName || attribute, | |
38 | 38 | pointerColor: pointerColor ?? presetPointerColor, |
39 | 39 | instrumentPanelColor: instrumentPanelColor ?? presetInstrumentPanelColor, |
40 | 40 | gradientInfo: gradientInfo ?? presetGradientInfo, | ... | ... |
... | ... | @@ -25,13 +25,13 @@ |
25 | 25 | |
26 | 26 | const getDesign = computed(() => { |
27 | 27 | const { option, persetOption } = props.config; |
28 | - const { componentInfo, attribute, attributeRename } = option; | |
28 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
29 | 29 | const { fontColor: presetFontColor, unit: presetUnit } = persetOption || {}; |
30 | 30 | const { unit, fontColor } = componentInfo || {}; |
31 | 31 | return { |
32 | 32 | unit: unit ?? presetUnit, |
33 | 33 | fontColor: fontColor ?? presetFontColor, |
34 | - attribute: attributeRename || attribute, | |
34 | + attribute: attributeRename || attributeName || attribute, | |
35 | 35 | }; |
36 | 36 | }); |
37 | 37 | ... | ... |
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 | import { UpdateTime } from '/@/views/visual/commonComponents/UpdateTime'; |
11 | 11 | import { useIntervalFn } from '@vueuse/core'; |
12 | 12 | import { nextTick } from 'vue'; |
13 | + import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; | |
13 | 14 | |
14 | 15 | const props = defineProps<{ |
15 | 16 | config: ComponentPropsConfigType<typeof option>; |
... | ... | @@ -28,7 +29,7 @@ |
28 | 29 | |
29 | 30 | const getDesign = computed(() => { |
30 | 31 | const { option, persetOption } = props.config; |
31 | - const { componentInfo, attributeRename, attribute } = option; | |
32 | + const { componentInfo, attributeRename, attribute, attributeName } = option; | |
32 | 33 | |
33 | 34 | const { |
34 | 35 | fontColor: presetFontColor, |
... | ... | @@ -41,7 +42,7 @@ |
41 | 42 | unit: unit ?? presetUnit, |
42 | 43 | fontColor: fontColor ?? presetFontColor, |
43 | 44 | gradientInfo: gradientInfo ?? presetGradientInfo, |
44 | - attribute: attributeRename || attribute, | |
45 | + attribute: attributeRename || attributeName || attribute, | |
45 | 46 | }; |
46 | 47 | }); |
47 | 48 | |
... | ... | @@ -204,6 +205,7 @@ |
204 | 205 | |
205 | 206 | <template> |
206 | 207 | <main class="w-full h-full flex flex-col justify-center items-center"> |
208 | + <DeviceName :config="config" /> | |
207 | 209 | <div ref="chartRefEl" class="flex-1 w-full h-full"> </div> |
208 | 210 | <div class="text-center text-gray-500 text-xs truncate"> |
209 | 211 | {{ getDesign.attribute || '速度' }} | ... | ... |
... | ... | @@ -24,13 +24,14 @@ |
24 | 24 | closeColor: persetCloseColor, |
25 | 25 | showDeviceName: persetShowDeviceName, |
26 | 26 | } = persetOption || {}; |
27 | - const { componentInfo } = option; | |
27 | + const { componentInfo, attribute, attributeName, attributeRename } = option; | |
28 | 28 | |
29 | 29 | const { openColor, closeColor, showDeviceName } = componentInfo || {}; |
30 | 30 | return { |
31 | 31 | openColor: openColor ?? persetOpenColor, |
32 | 32 | closeColor: closeColor ?? persetCloseColor, |
33 | 33 | showDeviceName: showDeviceName ?? persetShowDeviceName, |
34 | + attribute: attributeRename || attributeName || attribute, | |
34 | 35 | }; |
35 | 36 | }); |
36 | 37 | |
... | ... | @@ -60,6 +61,7 @@ |
60 | 61 | <template> |
61 | 62 | <main :style="getScale" class="w-full h-full flex flex-col justify-center items-center"> |
62 | 63 | <DeviceName :config="config" class="text-center" /> |
64 | + | |
63 | 65 | <div |
64 | 66 | :style="{ |
65 | 67 | '--open-color': getDesign.openColor, |
... | ... | @@ -67,6 +69,7 @@ |
67 | 69 | }" |
68 | 70 | :class="isOpenClose ? 'switch_open' : 'switch_close'" |
69 | 71 | ></div> |
72 | + <div class="text-gray-500 text-sm truncate">{{ getDesign.attribute }}</div> | |
70 | 73 | <UpdateTime :time="time" /> |
71 | 74 | </main> |
72 | 75 | </template> | ... | ... |
... | ... | @@ -31,21 +31,14 @@ |
31 | 31 | return { |
32 | 32 | dataSource: dataSource?.map((item) => { |
33 | 33 | const { unit, fontColor, showDeviceName } = item.componentInfo || {}; |
34 | - const { attribute, attributeRename, deviceName, deviceRename, deviceId } = item; | |
35 | - // return { | |
36 | - // unit: unit ?? presetUnit, | |
37 | - // fontColor: fontColor ?? presetFontColor, | |
38 | - // attribute, | |
39 | - // attributeRename, | |
40 | - // deviceName, | |
41 | - // deviceRename, | |
42 | - // showDeviceName: showDeviceName ?? presetShowDeviceName, | |
43 | - // }; | |
34 | + const { attribute, attributeName, attributeRename, deviceName, deviceRename, deviceId } = | |
35 | + item; | |
44 | 36 | return { |
45 | 37 | unit: unit ?? presetUnit, |
46 | 38 | fontColor: fontColor ?? presetFontColor, |
47 | 39 | attribute, |
48 | 40 | attributeRename, |
41 | + attributeName, | |
49 | 42 | showDeviceName: showDeviceName ?? presetShowDeviceName, |
50 | 43 | deviceName, |
51 | 44 | deviceRename, |
... | ... | @@ -58,10 +51,8 @@ |
58 | 51 | const series = ref( |
59 | 52 | unref(getDesign).dataSource.map((item) => ({ |
60 | 53 | value: 0, |
61 | - name: `${ | |
62 | - item.showDeviceName | |
63 | - ? (item.deviceRename || item.deviceName) + '-' + (item.attributeRename || item.attribute) | |
64 | - : '' | |
54 | + name: `${item.showDeviceName ? `${item.deviceRename || item.deviceName}-` : ''}${ | |
55 | + item.attributeRename || item.attributeName || item.attribute | |
65 | 56 | }`, |
66 | 57 | attribute: item.attribute, |
67 | 58 | id: item.id, |
... | ... | @@ -125,19 +116,9 @@ |
125 | 116 | chartInstance.value.setOption(options()); |
126 | 117 | }; |
127 | 118 | |
128 | - // const randomFn = () => { | |
129 | - // useIntervalFn(() => { | |
130 | - // const value = (Math.random() * 100).toFixed(0); | |
131 | - // unref(chartInstance)?.setOption({ | |
132 | - // series: [{ data: [{ value }] }, { data: [{ value }] }], | |
133 | - // } as EChartsOption); | |
134 | - // }, 3000); | |
135 | - // }; | |
136 | - | |
137 | 119 | const updateChart = (data: SeriesOption['data']) => { |
138 | 120 | unref(chartInstance)?.setOption({ |
139 | 121 | series: [{ data }], |
140 | - // color: unref(list).map((item) => item.title.color), | |
141 | 122 | } as EChartsOption); |
142 | 123 | }; |
143 | 124 | |
... | ... | @@ -154,32 +135,12 @@ |
154 | 135 | }); |
155 | 136 | |
156 | 137 | updateChart(unref(series)); |
157 | - // const { data = {} } = message; | |
158 | - // const { dataSource } = unref(getDesign); | |
159 | - // const series = dataSource.map((item) => { | |
160 | - // const { attribute, fontColor, unit, showDeviceName, deviceName, deviceRename } = item; | |
161 | - // const [latest] = data[attribute] || []; | |
162 | - // const [_timespan, value] = latest || []; | |
163 | - | |
164 | - // return { | |
165 | - // value, | |
166 | - // name: showDeviceName ? (deviceRename ? deviceRename : deviceName) : '', | |
167 | - // itemStyle: { color: fontColor }, | |
168 | - // tooltip: { | |
169 | - // valueFormatter(value) { | |
170 | - // return `${value} ${unit ?? ''}`; | |
171 | - // }, | |
172 | - // }, | |
173 | - // } as SeriesOption['data']; | |
174 | - // }); | |
175 | - // updateChart(series); | |
176 | 138 | }; |
177 | 139 | |
178 | 140 | useMultipleDataFetch(props, updateFn); |
179 | 141 | |
180 | 142 | onMounted(() => { |
181 | 143 | initial(); |
182 | - // !props.config.option.uuid && randomFn(); | |
183 | 144 | !props.config.option.uuid; |
184 | 145 | }); |
185 | 146 | ... | ... |
... | ... | @@ -32,16 +32,8 @@ |
32 | 32 | return { |
33 | 33 | dataSource: dataSource?.map((item) => { |
34 | 34 | const { unit, fontColor, showDeviceName } = item.componentInfo || {}; |
35 | - const { attribute, attributeRename, deviceName, deviceRename, deviceId } = item; | |
36 | - // return { | |
37 | - // unit: unit ?? presetUnit, | |
38 | - // fontColor: fontColor ?? presetFontColor, | |
39 | - // attribute, | |
40 | - // attributeRename, | |
41 | - // deviceName, | |
42 | - // deviceRename, | |
43 | - // showDeviceName: showDeviceName ?? presetShowDeviceName, | |
44 | - // }; | |
35 | + const { attribute, attributeName, attributeRename, deviceName, deviceRename, deviceId } = | |
36 | + item; | |
45 | 37 | return { |
46 | 38 | unit: unit ?? presetUnit, |
47 | 39 | fontColor: fontColor ?? presetFontColor, |
... | ... | @@ -50,6 +42,7 @@ |
50 | 42 | showDeviceName: showDeviceName ?? presetShowDeviceName, |
51 | 43 | deviceName, |
52 | 44 | deviceRename, |
45 | + attributeName, | |
53 | 46 | id: deviceId, |
54 | 47 | }; |
55 | 48 | }), |
... | ... | @@ -57,7 +50,6 @@ |
57 | 50 | }); |
58 | 51 | |
59 | 52 | const options = (): EChartsOption => { |
60 | - // getStageColor(gradientInfo); | |
61 | 53 | return { |
62 | 54 | tooltip: { |
63 | 55 | trigger: 'item', |
... | ... | @@ -112,19 +104,9 @@ |
112 | 104 | chartInstance.value.setOption(options()); |
113 | 105 | }; |
114 | 106 | |
115 | - // const randomFn = () => { | |
116 | - // useIntervalFn(() => { | |
117 | - // const value = (Math.random() * 100).toFixed(0); | |
118 | - // unref(chartInstance)?.setOption({ | |
119 | - // series: [{ data: [{ value }] }, { data: [{ value }] }], | |
120 | - // } as EChartsOption); | |
121 | - // }, 3000); | |
122 | - // }; | |
123 | - | |
124 | 107 | const updateChart = (data: SeriesOption['data']) => { |
125 | 108 | unref(chartInstance)?.setOption({ |
126 | 109 | series: [{ data }], |
127 | - // color: unref(list).map((item) => item.title.color), | |
128 | 110 | } as EChartsOption); |
129 | 111 | }; |
130 | 112 | const { forEachGroupMessage } = useReceiveMessage(); |
... | ... | @@ -133,10 +115,8 @@ |
133 | 115 | const series = ref( |
134 | 116 | unref(getDesign).dataSource.map((item) => ({ |
135 | 117 | value: 0, |
136 | - name: `${ | |
137 | - item.showDeviceName | |
138 | - ? (item.deviceRename || item.deviceName) + '-' + (item.attributeRename || item.attribute) | |
139 | - : '' | |
118 | + name: `${item.showDeviceName ? `${item.deviceRename || item.deviceName}-` : ''}${ | |
119 | + item.attributeRename || item.attributeName || item.attribute | |
140 | 120 | }`, |
141 | 121 | itemStyle: { color: item.fontColor }, |
142 | 122 | attribute: item.attribute, |
... | ... | @@ -150,7 +130,6 @@ |
150 | 130 | ); |
151 | 131 | |
152 | 132 | const updateFn: MultipleDataFetchUpdateFn = (message, deviceId, attribute) => { |
153 | - // console.log(unref(series), 'series', unref(getDesign).dataSource); | |
154 | 133 | forEachGroupMessage(message, deviceId, attribute, (attribute, value, timespan) => { |
155 | 134 | series.value.forEach((item) => { |
156 | 135 | if (item.id === deviceId && item.attribute === attribute) { |
... | ... | @@ -179,7 +158,6 @@ |
179 | 158 | |
180 | 159 | onMounted(() => { |
181 | 160 | initial(); |
182 | - // !props.config.option.uuid && randomFn(); | |
183 | 161 | !props.config.option.uuid; |
184 | 162 | }); |
185 | 163 | ... | ... |
... | ... | @@ -3,7 +3,6 @@ |
3 | 3 | import { option } from './config'; |
4 | 4 | import { useComponentScale } from '/@/views/visual/packages/hook/useComponentScale'; |
5 | 5 | import { useDataFetch } from '/@/views/visual/packages/hook/useSocket'; |
6 | - import { computed } from 'vue'; | |
7 | 6 | import { ref, onMounted, unref } from 'vue'; |
8 | 7 | import { useIntervalFn } from '@vueuse/core'; |
9 | 8 | import { DeviceName } from '/@/views/visual/commonComponents/DeviceName'; |
... | ... | @@ -15,23 +14,6 @@ |
15 | 14 | |
16 | 15 | const isOpenClose = ref<boolean>(true); |
17 | 16 | |
18 | - const getDesign = computed(() => { | |
19 | - const { persetOption = {}, option } = props.config; | |
20 | - const { | |
21 | - openColor: persetOpenColor, | |
22 | - closeColor: persetCloseColor, | |
23 | - showDeviceName: persetShowDeviceName, | |
24 | - } = persetOption || {}; | |
25 | - const { componentInfo } = option; | |
26 | - | |
27 | - const { openColor, closeColor, showDeviceName } = componentInfo || {}; | |
28 | - return { | |
29 | - openColor: openColor ?? persetOpenColor, | |
30 | - closeColor: closeColor ?? persetCloseColor, | |
31 | - showDeviceName: showDeviceName ?? persetShowDeviceName, | |
32 | - }; | |
33 | - }); | |
34 | - | |
35 | 17 | const randomFn = () => { |
36 | 18 | useIntervalFn(() => { |
37 | 19 | isOpenClose.value = !unref(isOpenClose); |
... | ... | @@ -58,12 +40,10 @@ |
58 | 40 | <main :style="getScale" class="w-full h-full flex flex-col justify-center items-center"> |
59 | 41 | <DeviceName :config="config" class="text-center" /> |
60 | 42 | <div |
61 | - :style="{ | |
62 | - '--open-color': getDesign.openColor, | |
63 | - '--close-color': getDesign.closeColor, | |
64 | - }" | |
43 | + style="--open-color: `${getDesign.openColor}`; --close-color: `${getDesign.closeColor}`" | |
65 | 44 | :class="isOpenClose ? 'switch_open' : 'switch_close'" |
66 | - ></div> | |
45 | + > | |
46 | + </div> | |
67 | 47 | </main> |
68 | 48 | </template> |
69 | 49 | <style lang="less" scoped> | ... | ... |
... | ... | @@ -18,12 +18,12 @@ |
18 | 18 | |
19 | 19 | const { fontColor: persetFontColor } = persetOption; |
20 | 20 | |
21 | - const { componentInfo, attribute, attributeRename } = option; | |
21 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
22 | 22 | |
23 | 23 | const { fontColor } = componentInfo || {}; |
24 | 24 | return { |
25 | 25 | fontColor: fontColor || persetFontColor, |
26 | - attribute: attributeRename || attribute, | |
26 | + attribute: attributeRename || attributeName || attribute, | |
27 | 27 | }; |
28 | 28 | }); |
29 | 29 | |
... | ... | @@ -46,7 +46,7 @@ |
46 | 46 | <h1 class="my-4 font-bold text-xl !my-2 truncate" :style="{ color: getDesign.fontColor }"> |
47 | 47 | {{ currentValue || 0 }} |
48 | 48 | </h1> |
49 | - <div class="text-gray-500 text-lg truncate">{{ getDesign.attribute || '温度' }}</div> | |
49 | + <div class="text-gray-500 text-sm truncate">{{ getDesign.attribute || '温度' }}</div> | |
50 | 50 | <!-- <div v-if="config.option.componentInfo.showDeviceName"> |
51 | 51 | {{ config.option.deviceRename || config.option.deviceName }} |
52 | 52 | </div> --> | ... | ... |
... | ... | @@ -20,13 +20,13 @@ |
20 | 20 | |
21 | 21 | const { fontColor: persetFontColor } = persetOption; |
22 | 22 | |
23 | - const { componentInfo, attribute, attributeRename } = option; | |
23 | + const { componentInfo, attribute, attributeName, attributeRename } = option; | |
24 | 24 | |
25 | 25 | const { fontColor } = componentInfo || {}; |
26 | 26 | |
27 | 27 | return { |
28 | 28 | fontColor: fontColor || persetFontColor, |
29 | - attribute: attributeRename || attribute, | |
29 | + attribute: attributeRename || attributeName || attribute, | |
30 | 30 | }; |
31 | 31 | }); |
32 | 32 | |
... | ... | @@ -51,7 +51,7 @@ |
51 | 51 | <h1 class="my-4 font-bold text-xl !my-2 truncate" :style="{ color: getDesign.fontColor }"> |
52 | 52 | {{ currentValue || 0 }} |
53 | 53 | </h1> |
54 | - <div class="text-gray-500 text-lg truncate">{{ getDesign.attribute || '温度' }}</div> | |
54 | + <div class="text-gray-500 text-sm truncate">{{ getDesign.attribute || '温度' }}</div> | |
55 | 55 | </div> |
56 | 56 | <UpdateTime :time="time" /> |
57 | 57 | </main> | ... | ... |
... | ... | @@ -27,7 +27,7 @@ |
27 | 27 | fontColor: persetFontColor, |
28 | 28 | } = persetOption; |
29 | 29 | |
30 | - const { componentInfo, attribute, attributeRename } = option; | |
30 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
31 | 31 | |
32 | 32 | const { icon, iconColor, fontColor, unit } = componentInfo || {}; |
33 | 33 | return { |
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 | unit: unit ?? perseUnit, |
36 | 36 | icon: icon || persetIcon, |
37 | 37 | fontColor: fontColor || persetFontColor, |
38 | - attribute: attributeRename || attribute, | |
38 | + attribute: attributeRename || attributeName || attribute, | |
39 | 39 | }; |
40 | 40 | }); |
41 | 41 | |
... | ... | @@ -66,7 +66,7 @@ |
66 | 66 | <span> {{ currentValue || 0 }}</span> |
67 | 67 | <span>{{ getDesign.unit }} </span> |
68 | 68 | </h1> |
69 | - <div class="text-gray-500 text-lg truncate">{{ getDesign.attribute || '温度' }}</div> | |
69 | + <div class="text-gray-500 text-sm truncate">{{ getDesign.attribute || '温度' }}</div> | |
70 | 70 | </div> |
71 | 71 | <UpdateTime :time="time" /> |
72 | 72 | </main> | ... | ... |
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | fontColor: persetFontColor, |
25 | 25 | } = persetOption; |
26 | 26 | |
27 | - const { componentInfo, attribute, attributeRename } = option; | |
27 | + const { componentInfo, attribute, attributeRename, attributeName } = option; | |
28 | 28 | |
29 | 29 | const { icon, iconColor, fontColor, unit } = componentInfo || {}; |
30 | 30 | return { |
... | ... | @@ -32,7 +32,7 @@ |
32 | 32 | unit: unit ?? perseUnit, |
33 | 33 | icon: icon || persetIcon, |
34 | 34 | fontColor: fontColor || persetFontColor, |
35 | - attribute: attributeRename || attribute, | |
35 | + attribute: attributeRename || attributeName || attribute, | |
36 | 36 | }; |
37 | 37 | }); |
38 | 38 | |
... | ... | @@ -62,7 +62,7 @@ |
62 | 62 | <span>{{ currentValue || 0 }}</span> |
63 | 63 | <span>{{ getDesign.unit }}</span> |
64 | 64 | </h1> |
65 | - <div class="text-gray-500 text-lg truncate">{{ getDesign.attribute || '温度' }}</div> | |
65 | + <div class="text-gray-500 text-sm truncate">{{ getDesign.attribute || '温度' }}</div> | |
66 | 66 | </div> |
67 | 67 | </main> |
68 | 68 | </template> | ... | ... |
... | ... | @@ -30,6 +30,7 @@ |
30 | 30 | attributeRename?: string; |
31 | 31 | deviceId?: string; |
32 | 32 | deviceName?: string; |
33 | + attributeName?: string; | |
33 | 34 | deviceRename?: string; |
34 | 35 | } |
35 | 36 | |
... | ... | @@ -65,7 +66,8 @@ |
65 | 66 | return { |
66 | 67 | dataSource: dataSource.map((item) => { |
67 | 68 | const { unit, fontColor, backgroundColor } = item.componentInfo || {}; |
68 | - const { attribute, attributeRename, deviceName, deviceRename, deviceId } = item; | |
69 | + const { attribute, attributeRename, deviceName, deviceRename, deviceId, attributeName } = | |
70 | + item; | |
69 | 71 | return { |
70 | 72 | unit: unit ?? presetUnit, |
71 | 73 | fontColor: fontColor ?? presetFontColor, |
... | ... | @@ -74,6 +76,7 @@ |
74 | 76 | deviceRename, |
75 | 77 | attribute, |
76 | 78 | attributeRename, |
79 | + attributeName, | |
77 | 80 | id: deviceId, |
78 | 81 | } as PercentType; |
79 | 82 | }), |
... | ... | @@ -112,11 +115,11 @@ |
112 | 115 | class="mt-2 flex flex-col ml-3 mr-3 items-stretch" |
113 | 116 | > |
114 | 117 | <div class="flex justify-between"> |
115 | - <div class="text-gray-500 text-lg truncate" :style="{ color: item.fontColor }"> | |
118 | + <div class="text-gray-500 text-sm truncate" :style="{ color: item.fontColor }"> | |
116 | 119 | {{ |
117 | - (item.deviceRename || item.deviceName) + | |
118 | - '-' + | |
119 | - (item.attributeRename || item.attribute) || '温度' | |
120 | + `${item.deviceRename || item.deviceName} | |
121 | + - | |
122 | + ${item.attributeRename || item.attributeName || item.attribute || '温度'}` | |
120 | 123 | }} |
121 | 124 | </div> |
122 | 125 | <span class="text-lg" :style="{ color: item.fontColor }" | ... | ... |
... | ... | @@ -2,10 +2,7 @@ import { TextComponent1Config } from './TextComponent1'; |
2 | 2 | import { TextComponent2Config } from './TextComponent2'; |
3 | 3 | import { TextComponent3Config } from './TextComponent3'; |
4 | 4 | import { TextComponent4Config } from './TextComponent4'; |
5 | -import { SwitchSignalLightConfig } from './SwitchSignalLight'; | |
6 | -// import { SwitchStatusConfig } from './SwitchStatus'; | |
7 | 5 | import { ValueList1Config } from './ValueList1'; |
8 | -// import { ValueList2Config } from './ValueList2'; | |
9 | 6 | |
10 | 7 | export const TextList = [ |
11 | 8 | TextComponent1Config, |
... | ... | @@ -13,7 +10,4 @@ export const TextList = [ |
13 | 10 | TextComponent3Config, |
14 | 11 | TextComponent4Config, |
15 | 12 | ValueList1Config, |
16 | - // ValueList2Config, | |
17 | - SwitchSignalLightConfig, | |
18 | - // SwitchStatusConfig, | |
19 | 13 | ]; | ... | ... |
... | ... | @@ -23,6 +23,7 @@ export interface CommonDataSourceBindValueType extends Record<DataSourceField, s |
23 | 23 | service?: string; |
24 | 24 | command?: string; |
25 | 25 | commandType?: string; |
26 | + callType?: string; | |
26 | 27 | }; |
27 | 28 | } |
28 | 29 | |
... | ... | @@ -44,6 +45,7 @@ export enum DataSourceField { |
44 | 45 | COMMAND = 'command', |
45 | 46 | COMMAND_TYPE = 'commandType', |
46 | 47 | SERVICE = 'service', |
48 | + CALL_TYPE = 'callType', | |
47 | 49 | } |
48 | 50 | |
49 | 51 | const isTcpProfile = (transportType: string) => transportType === TransportTypeEnum.TCP; |
... | ... | @@ -292,12 +294,22 @@ export const commonDataSourceSchemas = (): FormSchema[] => { |
292 | 294 | valueField: 'itemValue', |
293 | 295 | placeholder: '请选择命令类型', |
294 | 296 | onChange() { |
295 | - setFieldsValue({ [DataSourceField.COMMAND]: null, [DataSourceField.SERVICE]: null }); | |
297 | + setFieldsValue({ | |
298 | + [DataSourceField.COMMAND]: null, | |
299 | + [DataSourceField.SERVICE]: null, | |
300 | + [DataSourceField.CALL_TYPE]: null, | |
301 | + }); | |
296 | 302 | }, |
297 | 303 | }; |
298 | 304 | }, |
299 | 305 | }, |
300 | 306 | { |
307 | + field: DataSourceField.CALL_TYPE, | |
308 | + component: 'Input', | |
309 | + ifShow: false, | |
310 | + label: 'callType', | |
311 | + }, | |
312 | + { | |
301 | 313 | field: DataSourceField.SERVICE, |
302 | 314 | component: 'ApiSelect', |
303 | 315 | label: '服务', |
... | ... | @@ -317,7 +329,13 @@ export const commonDataSourceSchemas = (): FormSchema[] => { |
317 | 329 | api: async () => { |
318 | 330 | try { |
319 | 331 | if (deviceProfileId) { |
320 | - return await getDeviceService(deviceProfileId); | |
332 | + const services = await getDeviceService(deviceProfileId); | |
333 | + const value = formModel[DataSourceField.SERVICE]; | |
334 | + if (value) { | |
335 | + const selected = services.find((item) => item.value === value); | |
336 | + selected && setFieldsValue({ [DataSourceField.CALL_TYPE]: selected.callType }); | |
337 | + } | |
338 | + return services; | |
321 | 339 | } |
322 | 340 | } catch (error) {} |
323 | 341 | return []; |
... | ... | @@ -328,7 +346,10 @@ export const commonDataSourceSchemas = (): FormSchema[] => { |
328 | 346 | const command = value |
329 | 347 | ? (options.functionJson.inputData || [])[0]?.serviceCommand |
330 | 348 | : null; |
331 | - setFieldsValue({ [DataSourceField.COMMAND]: command }); | |
349 | + setFieldsValue({ | |
350 | + [DataSourceField.COMMAND]: command, | |
351 | + [DataSourceField.CALL_TYPE]: value ? options.callType : null, | |
352 | + }); | |
332 | 353 | }, |
333 | 354 | }; |
334 | 355 | }, | ... | ... |
1 | 1 | import { ref } from 'vue'; |
2 | 2 | import { DataSource } from '../../palette/types'; |
3 | -import { sendCommandOneway } from '/@/api/dataBoard'; | |
3 | +import { sendCommandOneway, sendCommandTwoway } from '/@/api/dataBoard'; | |
4 | 4 | import { useMessage } from '/@/hooks/web/useMessage'; |
5 | 5 | import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; |
6 | +import { ServiceCallTypeEnum } from '/@/enums/toolEnum'; | |
6 | 7 | |
7 | 8 | const { createMessage } = useMessage(); |
8 | 9 | export function useSendCommand() { |
... | ... | @@ -16,7 +17,6 @@ export function useSendCommand() { |
16 | 17 | const sendCommand = async (record: DataSource, value: any) => { |
17 | 18 | if (!record) return false; |
18 | 19 | const { customCommand, attribute } = record || {}; |
19 | - | |
20 | 20 | const { deviceId } = record; |
21 | 21 | if (!deviceId) return false; |
22 | 22 | |
... | ... | @@ -26,21 +26,23 @@ export function useSendCommand() { |
26 | 26 | [attribute!]: Number(value), |
27 | 27 | }; |
28 | 28 | |
29 | + let sendCommandFn = sendCommandOneway; | |
29 | 30 | // 如果是TCP设备从物模型中获取下发命令(TCP网关子设备无物模型服务与事件) |
30 | 31 | if (customCommand?.transportType === TransportTypeEnum.TCP) { |
31 | 32 | params = customCommand.command!; |
33 | + if (customCommand.callType === ServiceCallTypeEnum.ASYNC) { | |
34 | + sendCommandFn = sendCommandTwoway; | |
35 | + } | |
32 | 36 | } |
33 | 37 | |
34 | - console.log(params); | |
35 | - | |
36 | 38 | // 控制按钮下发命令为0 或 1 |
37 | - await sendCommandOneway({ | |
39 | + await sendCommandFn({ | |
38 | 40 | deviceId, |
39 | 41 | value: { |
40 | 42 | params: params || null, |
41 | 43 | persistent: true, |
42 | 44 | additionalInfo: { |
43 | - cmdType: 'API', | |
45 | + cmdType: customCommand.commandType || 'API', | |
44 | 46 | }, |
45 | 47 | method: 'methodThingskit', |
46 | 48 | }, | ... | ... |
... | ... | @@ -137,7 +137,7 @@ export interface PackagesType { |
137 | 137 | [PackagesCategoryEnum.CONTROL]: ConfigType[]; |
138 | 138 | [PackagesCategoryEnum.MAP]: ConfigType[]; |
139 | 139 | [PackagesCategoryEnum.FLOWMETER]: ConfigType[]; |
140 | - [PackagesCategoryEnum.STATISTICS]: ConfigType[]; | |
140 | + // [PackagesCategoryEnum.STATISTICS]: ConfigType[]; | |
141 | 141 | [PackagesCategoryEnum.OTHER]: ConfigType[]; |
142 | 142 | } |
143 | 143 | ... | ... |
... | ... | @@ -5,7 +5,7 @@ import { MapList } from './components/Map'; |
5 | 5 | import { OtherList } from './components/Other'; |
6 | 6 | // import { PictureList } from './components/Picture'; |
7 | 7 | import { TextList } from './components/Text'; |
8 | -import { STATISTICSList } from './components/Statistics'; | |
8 | +// import { STATISTICSList } from './components/Statistics'; | |
9 | 9 | import { PackagesCategoryEnum, PackagesType } from './index.type'; |
10 | 10 | |
11 | 11 | export const packageList: PackagesType = { |
... | ... | @@ -15,6 +15,6 @@ export const packageList: PackagesType = { |
15 | 15 | [PackagesCategoryEnum.CONTROL]: ControlList, |
16 | 16 | [PackagesCategoryEnum.MAP]: MapList, |
17 | 17 | [PackagesCategoryEnum.FLOWMETER]: FlowmeterList, |
18 | - [PackagesCategoryEnum.STATISTICS]: STATISTICSList, | |
18 | + // [PackagesCategoryEnum.STATISTICS]: STATISTICSList, | |
19 | 19 | [PackagesCategoryEnum.OTHER]: OtherList, |
20 | 20 | }; | ... | ... |