Showing
18 changed files
with
109 additions
and
874 deletions
1 | import { FormSchema } from '../../../types/form'; | 1 | import { FormSchema } from '../../../types/form'; |
2 | import { Specs, StructJSON } from '/@/api/device/model/modelOfMatterModel'; | 2 | import { Specs, StructJSON } from '/@/api/device/model/modelOfMatterModel'; |
3 | +import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
3 | import { DataTypeEnum } from '/@/enums/objectModelEnum'; | 4 | import { DataTypeEnum } from '/@/enums/objectModelEnum'; |
4 | -import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | ||
5 | 5 | ||
6 | export const getFormSchemas = ({ | 6 | export const getFormSchemas = ({ |
7 | structJSON: structJson, | 7 | structJSON: structJson, |
src/enums/deviceEnum.ts
0 → 100644
1 | import { FormProps, FormSchema, useComponentRegister } from '/@/components/Form'; | 1 | import { FormProps, FormSchema, useComponentRegister } from '/@/components/Form'; |
2 | import { findDictItemByCode } from '/@/api/system/dict'; | 2 | import { findDictItemByCode } from '/@/api/system/dict'; |
3 | import { getGatewayDevice, queryDeviceProfileBy } from '/@/api/device/deviceManager'; | 3 | import { getGatewayDevice, queryDeviceProfileBy } from '/@/api/device/deviceManager'; |
4 | -import { TransportTypeEnum } from '../../profiles/components/TransportDescript/const'; | ||
5 | import { JSONEditorValidator } from '/@/components/CodeEditor/src/JSONEditor'; | 4 | import { JSONEditorValidator } from '/@/components/CodeEditor/src/JSONEditor'; |
6 | import { JSONEditor } from '/@/components/CodeEditor'; | 5 | import { JSONEditor } from '/@/components/CodeEditor'; |
7 | import { DeviceRecord, DeviceTypeEnum } from '/@/api/device/model/deviceModel'; | 6 | import { DeviceRecord, DeviceTypeEnum } from '/@/api/device/model/deviceModel'; |
@@ -17,6 +16,7 @@ import { createImgPreview } from '/@/components/Preview'; | @@ -17,6 +16,7 @@ import { createImgPreview } from '/@/components/Preview'; | ||
17 | import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter'; | 16 | import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter'; |
18 | import LockControlGroup from '/@/components/Form/src/components/LockControlGroup.vue'; | 17 | import LockControlGroup from '/@/components/Form/src/components/LockControlGroup.vue'; |
19 | import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect'; | 18 | import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect'; |
19 | +import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
20 | 20 | ||
21 | useComponentRegister('JSONEditor', JSONEditor); | 21 | useComponentRegister('JSONEditor', JSONEditor); |
22 | useComponentRegister('ObjectModelValidateForm', ObjectModelValidateForm); | 22 | useComponentRegister('ObjectModelValidateForm', ObjectModelValidateForm); |
@@ -5,8 +5,8 @@ import { DeviceRecord, DeviceTypeEnum } from '/@/api/device/model/deviceModel'; | @@ -5,8 +5,8 @@ import { DeviceRecord, DeviceTypeEnum } from '/@/api/device/model/deviceModel'; | ||
5 | import { findDictItemByCode } from '/@/api/system/dict'; | 5 | import { findDictItemByCode } from '/@/api/system/dict'; |
6 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 6 | import { FormSchema, useComponentRegister } from '/@/components/Form'; |
7 | import { BasicColumn } from '/@/components/Table'; | 7 | import { BasicColumn } from '/@/components/Table'; |
8 | +import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
8 | import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect'; | 9 | import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect'; |
9 | -import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | ||
10 | import XLSX, { CellObject } from 'xlsx'; | 10 | import XLSX, { CellObject } from 'xlsx'; |
11 | 11 | ||
12 | useComponentRegister('OrgTreeSelect', OrgTreeSelect); | 12 | useComponentRegister('OrgTreeSelect', OrgTreeSelect); |
@@ -9,8 +9,8 @@ | @@ -9,8 +9,8 @@ | ||
9 | </div> | 9 | </div> |
10 | </div> | 10 | </div> |
11 | </template> | 11 | </template> |
12 | -<script lang="ts"> | ||
13 | - import { defineComponent, nextTick, ref } from 'vue'; | 12 | +<script lang="ts" setup> |
13 | + import { nextTick, ref } from 'vue'; | ||
14 | import { BasicForm, useForm } from '/@/components/Form'; | 14 | import { BasicForm, useForm } from '/@/components/Form'; |
15 | import { CommandFieldsEnum, CommandSchemas, CommandType, ValueType } from '../../config/data'; | 15 | import { CommandFieldsEnum, CommandSchemas, CommandType, ValueType } from '../../config/data'; |
16 | import { commandIssuanceApi } from '/@/api/device/deviceManager'; | 16 | import { commandIssuanceApi } from '/@/api/device/deviceManager'; |
@@ -18,107 +18,95 @@ | @@ -18,107 +18,95 @@ | ||
18 | import { Button } from '/@/components/Button'; | 18 | import { Button } from '/@/components/Button'; |
19 | import { Space } from 'ant-design-vue'; | 19 | import { Space } from 'ant-design-vue'; |
20 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; | 20 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; |
21 | - import { TransportTypeEnum } from '../../../profiles/components/TransportDescript/const'; | ||
22 | import { parseStringToJSON } from '/@/components/CodeEditor/src/JSONEditor'; | 21 | import { parseStringToJSON } from '/@/components/CodeEditor/src/JSONEditor'; |
23 | import { CommandDeliveryWayEnum } from '/@/enums/toolEnum'; | 22 | import { CommandDeliveryWayEnum } from '/@/enums/toolEnum'; |
23 | + import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
24 | 24 | ||
25 | - export default defineComponent({ | ||
26 | - components: { BasicForm, Button, Space }, | ||
27 | - props: { | ||
28 | - deviceDetail: { | ||
29 | - type: Object as PropType<DeviceRecord>, | ||
30 | - required: true, | ||
31 | - }, | ||
32 | - }, | ||
33 | - emits: ['register'], | ||
34 | - setup(props) { | ||
35 | - const { createMessage } = useMessage(); | ||
36 | - const loading = ref(false); | 25 | + defineEmits(['register']); |
37 | 26 | ||
38 | - const [registerForm, { getFieldsValue, validate, resetFields, clearValidate }] = useForm({ | ||
39 | - labelWidth: 120, | ||
40 | - schemas: CommandSchemas( | ||
41 | - props.deviceDetail.deviceProfile.transportType as TransportTypeEnum, | ||
42 | - props.deviceDetail.deviceProfileId | ||
43 | - ), | ||
44 | - baseColProps: { span: 20 }, | ||
45 | - labelAlign: 'right', | ||
46 | - showSubmitButton: false, | ||
47 | - showResetButton: false, | ||
48 | - }); | 27 | + const props = defineProps<{ |
28 | + deviceDetail: DeviceRecord; | ||
29 | + }>(); | ||
49 | 30 | ||
50 | - const handleCancel = async () => { | ||
51 | - await resetFields(); | ||
52 | - await nextTick(); | ||
53 | - await clearValidate(); | ||
54 | - }; | 31 | + const { createMessage } = useMessage(); |
32 | + const loading = ref(false); | ||
55 | 33 | ||
56 | - const handleOk = async () => { | ||
57 | - loading.value = true; | ||
58 | - try { | ||
59 | - // 验证 | ||
60 | - const valid = await validate(); | ||
61 | - if (!valid) return; | ||
62 | - // 收集表单数据 | ||
63 | - const field = getFieldsValue(); | ||
64 | - let command: Recordable = { | ||
65 | - persistent: true, | ||
66 | - method: 'methodThingskit', | ||
67 | - params: field[CommandFieldsEnum.COMMAND_TEXT], | ||
68 | - }; | 34 | + const [registerForm, { getFieldsValue, validate, resetFields, clearValidate }] = useForm({ |
35 | + labelWidth: 120, | ||
36 | + schemas: CommandSchemas( | ||
37 | + props.deviceDetail.deviceProfile.transportType as TransportTypeEnum, | ||
38 | + props.deviceDetail.deviceProfileId | ||
39 | + ), | ||
40 | + baseColProps: { span: 20 }, | ||
41 | + labelAlign: 'right', | ||
42 | + showSubmitButton: false, | ||
43 | + showResetButton: false, | ||
44 | + }); | ||
69 | 45 | ||
70 | - if (field[CommandFieldsEnum.COMMAND_TYPE] === CommandType.CUSTOM) { | ||
71 | - if (field[CommandFieldsEnum.VALUE_TYPE] === ValueType.JSON) { | ||
72 | - const { json } = parseStringToJSON(field.commandValue); | ||
73 | - command.params = json; | ||
74 | - } | ||
75 | - } else { | ||
76 | - const { transportType } = props.deviceDetail.deviceProfile; | ||
77 | - command.params = | ||
78 | - transportType === TransportTypeEnum.TCP | ||
79 | - ? field[CommandFieldsEnum.TCP_SERVICE] | ||
80 | - : { | ||
81 | - [field[CommandFieldsEnum.SERVICE]]: field[CommandFieldsEnum.MODEL_INPUT], | ||
82 | - }; | ||
83 | - command.additionalInfo = { cmdType: 1 }; | ||
84 | - } | ||
85 | - commandIssuanceApi( | ||
86 | - field[CommandFieldsEnum.CUSTOM_TYPE] as CommandDeliveryWayEnum, | ||
87 | - props.deviceDetail.tbDeviceId, | ||
88 | - command | ||
89 | - ) | ||
90 | - .then((res) => { | ||
91 | - if (!res) return; | ||
92 | - createMessage.success('命令下发成功'); | ||
93 | - loading.value = true; | ||
94 | - // 请求 | ||
95 | - handleCancel(); | ||
96 | - }) | ||
97 | - .catch((e) => { | ||
98 | - if (e?.message) { | ||
99 | - createMessage.error(e?.message); | ||
100 | - } | ||
101 | - handleCancel(); | ||
102 | - }) | ||
103 | - .finally(() => { | ||
104 | - setTimeout(() => { | ||
105 | - loading.value = false; | ||
106 | - }, 300); | ||
107 | - }); | ||
108 | - } catch (e) { | ||
109 | - throw e; | ||
110 | - } finally { | ||
111 | - loading.value = false; | ||
112 | - } | ||
113 | - }; | ||
114 | - return { | ||
115 | - registerForm, | ||
116 | - handleCancel, | ||
117 | - handleOk, | ||
118 | - loading, | 46 | + const handleCancel = async () => { |
47 | + await resetFields(); | ||
48 | + await nextTick(); | ||
49 | + await clearValidate(); | ||
50 | + }; | ||
51 | + | ||
52 | + const handleOk = async () => { | ||
53 | + loading.value = true; | ||
54 | + try { | ||
55 | + // 验证 | ||
56 | + const valid = await validate(); | ||
57 | + if (!valid) return; | ||
58 | + // 收集表单数据 | ||
59 | + const field = getFieldsValue(); | ||
60 | + let command: Recordable = { | ||
61 | + persistent: true, | ||
62 | + method: 'methodThingskit', | ||
63 | + params: field[CommandFieldsEnum.COMMAND_TEXT], | ||
119 | }; | 64 | }; |
120 | - }, | ||
121 | - }); | 65 | + |
66 | + if (field[CommandFieldsEnum.COMMAND_TYPE] === CommandType.CUSTOM) { | ||
67 | + if (field[CommandFieldsEnum.VALUE_TYPE] === ValueType.JSON) { | ||
68 | + const { json } = parseStringToJSON(field.commandValue); | ||
69 | + command.params = json; | ||
70 | + } | ||
71 | + } else { | ||
72 | + const { transportType } = props.deviceDetail.deviceProfile; | ||
73 | + command.params = | ||
74 | + transportType === TransportTypeEnum.TCP | ||
75 | + ? field[CommandFieldsEnum.TCP_SERVICE] | ||
76 | + : { | ||
77 | + [field[CommandFieldsEnum.SERVICE]]: field[CommandFieldsEnum.MODEL_INPUT], | ||
78 | + }; | ||
79 | + command.additionalInfo = { cmdType: 1 }; | ||
80 | + } | ||
81 | + commandIssuanceApi( | ||
82 | + field[CommandFieldsEnum.CUSTOM_TYPE] as CommandDeliveryWayEnum, | ||
83 | + props.deviceDetail.tbDeviceId, | ||
84 | + command | ||
85 | + ) | ||
86 | + .then((res) => { | ||
87 | + if (!res) return; | ||
88 | + createMessage.success('命令下发成功'); | ||
89 | + loading.value = true; | ||
90 | + // 请求 | ||
91 | + handleCancel(); | ||
92 | + }) | ||
93 | + .catch((e) => { | ||
94 | + if (e?.message) { | ||
95 | + createMessage.error(e?.message); | ||
96 | + } | ||
97 | + handleCancel(); | ||
98 | + }) | ||
99 | + .finally(() => { | ||
100 | + setTimeout(() => { | ||
101 | + loading.value = false; | ||
102 | + }, 300); | ||
103 | + }); | ||
104 | + } catch (e) { | ||
105 | + throw e; | ||
106 | + } finally { | ||
107 | + loading.value = false; | ||
108 | + } | ||
109 | + }; | ||
122 | </script> | 110 | </script> |
123 | <style scoped lang="less"> | 111 | <style scoped lang="less"> |
124 | .jsoneditor-transform { | 112 | .jsoneditor-transform { |
@@ -12,8 +12,8 @@ | @@ -12,8 +12,8 @@ | ||
12 | import { genModbusCommand } from '/@/api/task'; | 12 | import { genModbusCommand } from '/@/api/task'; |
13 | import { TaskTypeEnum } from '/@/views/task/center/config'; | 13 | import { TaskTypeEnum } from '/@/views/task/center/config'; |
14 | import { SingleToHex, formSchemasConfig } from './config'; | 14 | import { SingleToHex, formSchemasConfig } from './config'; |
15 | - import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | ||
16 | import { DataTypeEnum } from '/@/enums/objectModelEnum'; | 15 | import { DataTypeEnum } from '/@/enums/objectModelEnum'; |
16 | + import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
17 | 17 | ||
18 | defineEmits(['register']); | 18 | defineEmits(['register']); |
19 | const props = defineProps<{ deviceId: string; deviceName: string }>(); | 19 | const props = defineProps<{ deviceId: string; deviceName: string }>(); |
1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> |
2 | import { computed } from 'vue'; | 2 | import { computed } from 'vue'; |
3 | import COAPDescription from './COAPDescription.vue'; | 3 | import COAPDescription from './COAPDescription.vue'; |
4 | - import { TransportTypeEnum } from './const'; | ||
5 | import DefaultConfiguration from './DefaultConfiguration.vue'; | 4 | import DefaultConfiguration from './DefaultConfiguration.vue'; |
6 | import LWM2MDescription from './LWM2MDescription.vue'; | 5 | import LWM2MDescription from './LWM2MDescription.vue'; |
7 | import MQTTConfiguration from './MQTTConfiguration.vue'; | 6 | import MQTTConfiguration from './MQTTConfiguration.vue'; |
8 | import SNMPDescription from './SNMPDescription.vue'; | 7 | import SNMPDescription from './SNMPDescription.vue'; |
9 | import TCPDescription from './TCPDescription.vue'; | 8 | import TCPDescription from './TCPDescription.vue'; |
10 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; | 9 | import { DeviceRecord } from '/@/api/device/model/deviceModel'; |
10 | + import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
11 | 11 | ||
12 | const props = defineProps<{ | 12 | const props = defineProps<{ |
13 | record: DeviceRecord; | 13 | record: DeviceRecord; |
1 | -export enum TransportTypeEnum { | ||
2 | - DEFAULT = 'DEFAULT', | ||
3 | - MQTT = 'MQTT', | ||
4 | - COAP = 'COAP', | ||
5 | - LWM2M = 'LWM2M', | ||
6 | - SNMP = 'SNMP', | ||
7 | - TCP = 'TCP', | ||
8 | -} | ||
9 | - | ||
10 | export enum TransportPayloadTypeEnum { | 1 | export enum TransportPayloadTypeEnum { |
11 | PROTOBUF = 'PROTOBUF', | 2 | PROTOBUF = 'PROTOBUF', |
12 | JSON = 'JSON', | 3 | JSON = 'JSON', |
@@ -10,10 +10,10 @@ | @@ -10,10 +10,10 @@ | ||
10 | import { isArray } from 'lodash'; | 10 | import { isArray } from 'lodash'; |
11 | import { OpenModelMode } from '../types'; | 11 | import { OpenModelMode } from '../types'; |
12 | import { formSchemas } from '/@/components/Form/src/externalCompns/components/StructForm/config'; | 12 | import { formSchemas } from '/@/components/Form/src/externalCompns/components/StructForm/config'; |
13 | - import { TransportTypeEnum } from '../../../../components/TransportDescript/const'; | ||
14 | import { DataTypeEnum } from '/@/enums/objectModelEnum'; | 13 | import { DataTypeEnum } from '/@/enums/objectModelEnum'; |
15 | import { ref, unref } from 'vue'; | 14 | import { ref, unref } from 'vue'; |
16 | import EnumList from '/@/components/Form/src/externalCompns/components/StructForm/EnumList.vue'; | 15 | import EnumList from '/@/components/Form/src/externalCompns/components/StructForm/EnumList.vue'; |
16 | + import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
17 | 17 | ||
18 | const props = defineProps<{ openModalMode: OpenModelMode; transportType?: string | undefined }>(); | 18 | const props = defineProps<{ openModalMode: OpenModelMode; transportType?: string | undefined }>(); |
19 | 19 |
@@ -26,10 +26,10 @@ import { DeviceTypeEnum } from '../../../dataFlow/cpns/config'; | @@ -26,10 +26,10 @@ import { DeviceTypeEnum } from '../../../dataFlow/cpns/config'; | ||
26 | import { getModelServices } from '/@/api/device/modelOfMatter'; | 26 | import { getModelServices } from '/@/api/device/modelOfMatter'; |
27 | import { ModelOfMatterParams, StructJSON } from '/@/api/device/model/modelOfMatterModel'; | 27 | import { ModelOfMatterParams, StructJSON } from '/@/api/device/model/modelOfMatterModel'; |
28 | import { DeviceProfileModel } from '/@/api/device/model/deviceModel'; | 28 | import { DeviceProfileModel } from '/@/api/device/model/deviceModel'; |
29 | -import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | ||
30 | import { JSONEditor } from '/@/components/CodeEditor'; | 29 | import { JSONEditor } from '/@/components/CodeEditor'; |
31 | import { useJsonParse } from '/@/hooks/business/useJsonParse'; | 30 | import { useJsonParse } from '/@/hooks/business/useJsonParse'; |
32 | import { validateTCPCustomCommand } from '/@/components/Form/src/externalCompns/components/ThingsModelForm'; | 31 | import { validateTCPCustomCommand } from '/@/components/Form/src/externalCompns/components/ThingsModelForm'; |
32 | +import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
33 | 33 | ||
34 | export enum FormFieldsEnum { | 34 | export enum FormFieldsEnum { |
35 | OUT_TARGET = 'outTarget', | 35 | OUT_TARGET = 'outTarget', |
@@ -7,7 +7,7 @@ import { FormActionType, ThingsModelForm } from '/@/components/Form'; | @@ -7,7 +7,7 @@ import { FormActionType, ThingsModelForm } from '/@/components/Form'; | ||
7 | import { AlarmLevelEnum } from '/@/enums/alarmEnum'; | 7 | import { AlarmLevelEnum } from '/@/enums/alarmEnum'; |
8 | import { CommandTypeEnum, ExecutionActionEnum, TriggerEntityTypeEnum } from '/@/enums/linkedgeEnum'; | 8 | import { CommandTypeEnum, ExecutionActionEnum, TriggerEntityTypeEnum } from '/@/enums/linkedgeEnum'; |
9 | import { ServiceCallTypeEnum } from '/@/enums/toolEnum'; | 9 | import { ServiceCallTypeEnum } from '/@/enums/toolEnum'; |
10 | -import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | 10 | +import { TransportTypeEnum } from '/@/enums/deviceEnum'; |
11 | 11 | ||
12 | export interface ExecutionActionListRefItemType { | 12 | export interface ExecutionActionListRefItemType { |
13 | key: string; | 13 | key: string; |
@@ -8,11 +8,11 @@ import { | @@ -8,11 +8,11 @@ import { | ||
8 | ExecutionActionListRefItemType, | 8 | ExecutionActionListRefItemType, |
9 | } from './type'; | 9 | } from './type'; |
10 | import { CommandTypeEnum, ExecutionActionEnum } from '/@/enums/linkedgeEnum'; | 10 | import { CommandTypeEnum, ExecutionActionEnum } from '/@/enums/linkedgeEnum'; |
11 | -import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | ||
12 | import { useJsonParse } from '/@/hooks/business/useJsonParse'; | 11 | import { useJsonParse } from '/@/hooks/business/useJsonParse'; |
13 | import { createNewExecutionActionItem } from '.'; | 12 | import { createNewExecutionActionItem } from '.'; |
14 | import { FormFieldsEnum } from './config'; | 13 | import { FormFieldsEnum } from './config'; |
15 | import { isObject, isString } from '/@/utils/is'; | 14 | import { isObject, isString } from '/@/utils/is'; |
15 | +import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
16 | 16 | ||
17 | export function useExecutionActionData( | 17 | export function useExecutionActionData( |
18 | executionActionListRef: Ref<ExecutionActionListRefItemType[]>, | 18 | executionActionListRef: Ref<ExecutionActionListRefItemType[]>, |
@@ -29,9 +29,9 @@ import { DataTypeEnum } from '/@/enums/objectModelEnum'; | @@ -29,9 +29,9 @@ import { DataTypeEnum } from '/@/enums/objectModelEnum'; | ||
29 | import { getModelTsl } from '/@/api/device/modelOfMatter'; | 29 | import { getModelTsl } from '/@/api/device/modelOfMatter'; |
30 | import { FunctionType } from '/@/views/device/profiles/step/cpns/physical/cpns/config'; | 30 | import { FunctionType } from '/@/views/device/profiles/step/cpns/physical/cpns/config'; |
31 | import { GetModelTslParams } from '/@/api/device/model/modelOfMatterModel'; | 31 | import { GetModelTslParams } from '/@/api/device/model/modelOfMatterModel'; |
32 | -import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | ||
33 | import { FlipFlopComponentTypeEnum } from './types'; | 32 | import { FlipFlopComponentTypeEnum } from './types'; |
34 | import { OptionsType } from 'ant-design-vue/es/vc-select/interface'; | 33 | import { OptionsType } from 'ant-design-vue/es/vc-select/interface'; |
34 | +import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
35 | 35 | ||
36 | export enum FormFieldEnum { | 36 | export enum FormFieldEnum { |
37 | FLIP_FLOP_TYPE = 'flipFlopType', | 37 | FLIP_FLOP_TYPE = 'flipFlopType', |
1 | -import { ref, unref } from 'vue'; | 1 | +import { ref } from 'vue'; |
2 | import { BasicColumn, FormSchema } from '/@/components/Table'; | 2 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
3 | -import { | ||
4 | - byOrganizationIdGetMasterDevice, | ||
5 | - screenLinkOrganizationGetApi, | ||
6 | - getAttribute, | ||
7 | -} from '/@/api/ruleengine/ruleengineApi'; | ||
8 | -import { scheduleOptions } from './formatData'; | 3 | +import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi'; |
9 | import { copyTransFun } from '/@/utils/fnUtils'; | 4 | import { copyTransFun } from '/@/utils/fnUtils'; |
10 | -import { numberAndNonegativeRule } from '/@/utils/rules'; | ||
11 | -import { findDictItemByCode } from '/@/api/system/dict'; | ||
12 | -import { queryDeviceProfileBy } from '/@/api/device/deviceManager'; | ||
13 | -import { getModelServices } from '/@/api/device/modelOfMatter'; | ||
14 | -import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; | ||
15 | -import useCommonFun from '../hooks/useCommonFun'; | ||
16 | -import { DeviceProfileModel } from '/@/api/device/model/deviceModel'; | ||
17 | -import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | ||
18 | import { useComponentRegister } from '/@/components/Form'; | 5 | import { useComponentRegister } from '/@/components/Form'; |
19 | import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect'; | 6 | import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect'; |
20 | -import { isArray } from '/@/utils/is'; | ||
21 | -import { ReadAndWriteEnum } from '/@/enums/toolEnum'; | ||
22 | 7 | ||
23 | useComponentRegister('OrgTreeSelect', OrgTreeSelect); | 8 | useComponentRegister('OrgTreeSelect', OrgTreeSelect); |
24 | 9 | ||
25 | -const { useByProductGetAttribute } = useCommonFun(); | ||
26 | export type TOption = { | 10 | export type TOption = { |
27 | label: string; | 11 | label: string; |
28 | value: string; | 12 | value: string; |
29 | }; | 13 | }; |
30 | 14 | ||
31 | -export enum CommandTypeEnum { | ||
32 | - CUSTOM = 0, | ||
33 | - SERVICE = 1, | ||
34 | - ATTRIBUTE = 2, | ||
35 | -} | ||
36 | - | ||
37 | /** | 15 | /** |
38 | * 所使用的枚举值 | 16 | * 所使用的枚举值 |
39 | */ | 17 | */ |
@@ -174,733 +152,3 @@ export const searchFormSchema: FormSchema[] = [ | @@ -174,733 +152,3 @@ export const searchFormSchema: FormSchema[] = [ | ||
174 | colProps: { span: 6 }, | 152 | colProps: { span: 6 }, |
175 | }, | 153 | }, |
176 | ]; | 154 | ]; |
177 | -// 持续时间 | ||
178 | -const isTimeDuration = (type) => { | ||
179 | - return type === 'DURATION'; | ||
180 | -}; | ||
181 | -const isReplace = (type) => { | ||
182 | - return type === 'REPEATING'; | ||
183 | -}; | ||
184 | -// 部分 | ||
185 | -const isPart = (type: string) => { | ||
186 | - return type === 'PART'; | ||
187 | -}; | ||
188 | -//新增代码2022-11-23 | ||
189 | -const isPartOrAll = (type: string) => { | ||
190 | - return type === 'ALL' || type === 'PART'; | ||
191 | -}; | ||
192 | -const isService = (type: string) => { | ||
193 | - return Number(type) === 1; | ||
194 | -}; | ||
195 | -const isDefine = (type: string) => { | ||
196 | - return Number(type) === 0; | ||
197 | -}; | ||
198 | -//新增代码2022-11-23 | ||
199 | - | ||
200 | -export const trigger_condition_schema: FormSchema[] = [ | ||
201 | - { | ||
202 | - field: 'triggered', | ||
203 | - label: '', | ||
204 | - component: 'Select', | ||
205 | - defaultValue: 'SIMPLE', | ||
206 | - componentProps: { | ||
207 | - placeholder: '请选择触发类型', | ||
208 | - options: [ | ||
209 | - { label: '简单', value: 'SIMPLE' }, | ||
210 | - { label: '持续时长', value: 'DURATION' }, | ||
211 | - { label: '重复次数', value: 'REPEATING' }, | ||
212 | - ], | ||
213 | - }, | ||
214 | - colProps: { span: 6 }, | ||
215 | - }, | ||
216 | - { | ||
217 | - field: 'deviceType', | ||
218 | - label: '', | ||
219 | - component: 'ApiSelect', | ||
220 | - colProps: { span: 6 }, | ||
221 | - defaultValue: 'SENSOR', | ||
222 | - componentProps: ({ formActionType }) => { | ||
223 | - const { setFieldsValue } = formActionType; | ||
224 | - return { | ||
225 | - api: findDictItemByCode, | ||
226 | - params: { | ||
227 | - dictCode: 'device_type', | ||
228 | - }, | ||
229 | - placeholder: '请选择类型', | ||
230 | - labelField: 'itemText', | ||
231 | - valueField: 'itemValue', | ||
232 | - getPopupContainer: (triggerNode) => triggerNode.parentNode, | ||
233 | - onChange(e) { | ||
234 | - if (e) { | ||
235 | - setFieldsValue({ deviceProfileId: '' }); | ||
236 | - } | ||
237 | - }, | ||
238 | - }; | ||
239 | - }, | ||
240 | - }, | ||
241 | - { | ||
242 | - field: 'deviceProfileId', | ||
243 | - label: '', | ||
244 | - component: 'ApiSelect', | ||
245 | - colProps: { span: 6 }, | ||
246 | - componentProps: ({ formActionType, formModel }) => { | ||
247 | - const { updateSchema, setFieldsValue } = formActionType; | ||
248 | - const deviceType = formModel['deviceType']; | ||
249 | - | ||
250 | - return { | ||
251 | - api: queryDeviceProfileBy, | ||
252 | - params: { | ||
253 | - deviceType, | ||
254 | - }, | ||
255 | - showSearch: true, | ||
256 | - placeholder: '请选择产品', | ||
257 | - labelField: 'name', | ||
258 | - valueField: 'id', | ||
259 | - getPopupContainer: (triggerNode) => triggerNode.parentNode, | ||
260 | - onChange: async (e) => { | ||
261 | - if (e) { | ||
262 | - setFieldsValue({ type2: '', entityId: [] }); | ||
263 | - const res = await getAttribute(e); | ||
264 | - const options = ref<TOption[]>([]); | ||
265 | - useByProductGetAttribute(res, updateSchema, options); | ||
266 | - } | ||
267 | - }, | ||
268 | - filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => { | ||
269 | - let { label, value } = option; | ||
270 | - label = label.toLowerCase(); | ||
271 | - value = value.toLowerCase(); | ||
272 | - inputValue = inputValue.toLowerCase(); | ||
273 | - return label.includes(inputValue) || value.includes(inputValue); | ||
274 | - }, | ||
275 | - }; | ||
276 | - }, | ||
277 | - }, | ||
278 | - { | ||
279 | - field: 'device', | ||
280 | - label: '', | ||
281 | - component: 'Select', | ||
282 | - componentProps: { | ||
283 | - placeholder: '请选择设备', | ||
284 | - options: [ | ||
285 | - { label: '全部', value: 'ALL' }, | ||
286 | - { label: '部分', value: 'PART' }, | ||
287 | - ], | ||
288 | - }, | ||
289 | - colProps: { span: 6 }, | ||
290 | - }, | ||
291 | - | ||
292 | - { | ||
293 | - field: 'entityId', | ||
294 | - label: '', | ||
295 | - component: 'ApiSelect', | ||
296 | - componentProps: ({ formModel }) => { | ||
297 | - const deviceProfileId = formModel['deviceProfileId']; | ||
298 | - return { | ||
299 | - mode: 'multiple', | ||
300 | - api: async () => { | ||
301 | - if (unref(organizationId)) { | ||
302 | - try { | ||
303 | - const data = await byOrganizationIdGetMasterDevice({ | ||
304 | - organizationId: unref(organizationId), | ||
305 | - deviceProfileId, | ||
306 | - }); | ||
307 | - if (data) | ||
308 | - return data.map((item) => ({ | ||
309 | - ...item, | ||
310 | - label: item.alias || item.name, | ||
311 | - value: item.tbDeviceId, | ||
312 | - })); | ||
313 | - } catch (error) {} | ||
314 | - } | ||
315 | - return []; | ||
316 | - }, | ||
317 | - placeholder: '请选择设备', | ||
318 | - getPopupContainer: (triggerNode) => triggerNode.parentNode, | ||
319 | - filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => { | ||
320 | - let { label, value } = option; | ||
321 | - label = label.toLowerCase(); | ||
322 | - value = value.toLowerCase(); | ||
323 | - inputValue = inputValue.toLowerCase(); | ||
324 | - return label.includes(inputValue) || value.includes(inputValue); | ||
325 | - }, | ||
326 | - }; | ||
327 | - }, | ||
328 | - ifShow: ({ values }) => isPart(values.device), | ||
329 | - colProps: { span: 6 }, | ||
330 | - }, | ||
331 | - | ||
332 | - { | ||
333 | - field: 'time', | ||
334 | - label: '', | ||
335 | - component: 'Input', | ||
336 | - ifShow: ({ values }) => isTimeDuration(values.triggered), | ||
337 | - colProps: { span: 6 }, | ||
338 | - slot: 'time', | ||
339 | - rules: numberAndNonegativeRule, | ||
340 | - }, | ||
341 | - { | ||
342 | - field: 'timeUnit', | ||
343 | - label: '', | ||
344 | - component: 'Select', | ||
345 | - defaultValue: 'SECONDS', | ||
346 | - ifShow: ({ values }) => isTimeDuration(values.triggered), | ||
347 | - show: false, | ||
348 | - }, | ||
349 | - { | ||
350 | - field: 'replaceValue', | ||
351 | - label: '', | ||
352 | - component: 'Input', | ||
353 | - componentProps: { | ||
354 | - placeholder: '事件计数值', | ||
355 | - }, | ||
356 | - ifShow: ({ values }) => isReplace(values.triggered), | ||
357 | - colProps: { span: 6 }, | ||
358 | - rules: numberAndNonegativeRule, | ||
359 | - }, | ||
360 | - { | ||
361 | - field: 'triggerType', | ||
362 | - label: '', | ||
363 | - component: 'Select', | ||
364 | - componentProps: { | ||
365 | - placeholder: '设备触发', | ||
366 | - options: [ | ||
367 | - { label: '设备触发', value: 'DEVICE_TRIGGER' }, | ||
368 | - // { label: '定时触发', value: 'SCHEDULE_TRIGGER' }, | ||
369 | - // { label: '场景触发', value: 'SCENE_TRIGGER' }, | ||
370 | - // { label: '手动触发', value: 'HAND_ACT' }, | ||
371 | - ], | ||
372 | - }, | ||
373 | - colProps: { span: 6 }, | ||
374 | - }, | ||
375 | - | ||
376 | - { | ||
377 | - field: 'type1', | ||
378 | - label: '', | ||
379 | - component: 'Select', | ||
380 | - componentProps: { | ||
381 | - placeholder: '属性触发方式', | ||
382 | - options: [{ label: '属性触发', value: 'TIME_SERIES' }], | ||
383 | - }, | ||
384 | - ifShow: ({ values }) => isDevice(values.triggerType), | ||
385 | - colProps: { span: 6 }, | ||
386 | - }, | ||
387 | - { | ||
388 | - field: 'type2', | ||
389 | - label: '', | ||
390 | - component: 'Select', | ||
391 | - componentProps: { | ||
392 | - placeholder: '请选择属性', | ||
393 | - }, | ||
394 | - ifShow: ({ values }) => isDevice(values.triggerType), | ||
395 | - colProps: { span: 6 }, | ||
396 | - // rules: numberAndEngLishRule, | ||
397 | - }, | ||
398 | - { | ||
399 | - field: 'operationType', | ||
400 | - label: '', | ||
401 | - component: 'Select', | ||
402 | - slot: 'operationType', | ||
403 | - colProps: { span: 6 }, | ||
404 | - }, | ||
405 | - // { | ||
406 | - // field: 'detail', | ||
407 | - // label: '', | ||
408 | - // component: 'InputTextArea', | ||
409 | - // componentProps: { | ||
410 | - // placeholder: '请输入详情', | ||
411 | - // }, | ||
412 | - // colProps: { | ||
413 | - // span: 13, | ||
414 | - // }, | ||
415 | - // }, | ||
416 | -]; | ||
417 | -// !!!----------------------------------------------------^_^------------------------------------------------------------!!! | ||
418 | -enum ActionEnum { | ||
419 | - DEVICE_OUT = 'DEVICE_OUT', | ||
420 | - ALARM_OUT = 'MSG_NOTIFY', | ||
421 | -} | ||
422 | -const isDeviceOut = (type: string) => type === ActionEnum.DEVICE_OUT; | ||
423 | -const isAlarmOut = (type: string) => type === ActionEnum.ALARM_OUT; | ||
424 | - | ||
425 | -export const actionSchema: FormSchema[] = [ | ||
426 | - { | ||
427 | - field: 'outTarget', | ||
428 | - label: '', | ||
429 | - component: 'Select', | ||
430 | - required: true, | ||
431 | - componentProps: { | ||
432 | - placeholder: '请选择执行动作', | ||
433 | - }, | ||
434 | - slot: 'outTarget', | ||
435 | - colProps: { span: 6 }, | ||
436 | - }, | ||
437 | - { | ||
438 | - field: 'deviceType', | ||
439 | - label: '', | ||
440 | - component: 'ApiSelect', | ||
441 | - colProps: { span: 6 }, | ||
442 | - defaultValue: 'SENSOR', | ||
443 | - componentProps: ({ formActionType }) => { | ||
444 | - const { setFieldsValue } = formActionType; | ||
445 | - return { | ||
446 | - api: findDictItemByCode, | ||
447 | - params: { | ||
448 | - dictCode: 'device_type', | ||
449 | - }, | ||
450 | - placeholder: '请选择类型', | ||
451 | - labelField: 'itemText', | ||
452 | - valueField: 'itemValue', | ||
453 | - getPopupContainer: (triggerNode) => triggerNode.parentNode, | ||
454 | - onChange(e) { | ||
455 | - if (e) { | ||
456 | - setFieldsValue({ deviceProfileId: '' }); | ||
457 | - } | ||
458 | - }, | ||
459 | - }; | ||
460 | - }, | ||
461 | - ifShow: ({ values }) => isDeviceOut(values.outTarget), | ||
462 | - }, | ||
463 | - { | ||
464 | - field: 'transportType', | ||
465 | - label: '', | ||
466 | - component: 'Input', | ||
467 | - show: false, | ||
468 | - }, | ||
469 | - { | ||
470 | - field: 'deviceProfileId', | ||
471 | - label: '', | ||
472 | - component: 'ApiSelect', | ||
473 | - colProps: { span: 6 }, | ||
474 | - componentProps: ({ formActionType, formModel }) => { | ||
475 | - const { setFieldsValue } = formActionType; | ||
476 | - const deviceType = formModel['deviceType']; | ||
477 | - return { | ||
478 | - api: queryDeviceProfileBy, | ||
479 | - params: { | ||
480 | - deviceType, | ||
481 | - }, | ||
482 | - placeholder: '请选择产品', | ||
483 | - labelField: 'name', | ||
484 | - valueField: 'id', | ||
485 | - getPopupContainer: (triggerNode) => triggerNode.parentNode, | ||
486 | - onChange: (_value: string, options = {} as DeviceProfileModel) => { | ||
487 | - const oldType = formModel['transportType']; | ||
488 | - | ||
489 | - const updateFlag = | ||
490 | - oldType === TransportTypeEnum.TCP || options.transportType === TransportTypeEnum.TCP; | ||
491 | - | ||
492 | - setFieldsValue({ | ||
493 | - thingsModelId: '', | ||
494 | - deviceId: [], | ||
495 | - transportType: options.transportType, | ||
496 | - ...(updateFlag ? { doContext: null } : {}), | ||
497 | - }); | ||
498 | - }, | ||
499 | - onOptionsChange(options: DeviceProfileModel[]) { | ||
500 | - const deviceProfileId = formModel['deviceProfileId']; | ||
501 | - if (deviceProfileId) { | ||
502 | - const index = options.findIndex( | ||
503 | - (item) => (item as Recordable).value === deviceProfileId | ||
504 | - ); | ||
505 | - | ||
506 | - ~index && setFieldsValue({ transportType: options[index].transportType }); | ||
507 | - } | ||
508 | - }, | ||
509 | - }; | ||
510 | - }, | ||
511 | - ifShow: ({ values }) => isDeviceOut(values.outTarget), | ||
512 | - }, | ||
513 | - { | ||
514 | - field: 'device', | ||
515 | - label: '', | ||
516 | - component: 'Select', | ||
517 | - componentProps: ({ formActionType }) => { | ||
518 | - const { setFieldsValue } = formActionType; | ||
519 | - return { | ||
520 | - placeholder: '请选择设备', | ||
521 | - options: [ | ||
522 | - { label: '全部', value: 'ALL' }, | ||
523 | - { label: '部分', value: 'PART' }, | ||
524 | - ], | ||
525 | - onChange: () => { | ||
526 | - setFieldsValue({ deviceId: [], thingsModelId: null }); | ||
527 | - }, | ||
528 | - }; | ||
529 | - }, | ||
530 | - ifShow: ({ values }) => isDeviceOut(values.outTarget) && values['deviceProfileId'], | ||
531 | - colProps: { span: 6 }, | ||
532 | - }, | ||
533 | - { | ||
534 | - field: 'deviceId', | ||
535 | - label: '', | ||
536 | - component: 'ApiSelect', | ||
537 | - componentProps: ({ formModel }) => { | ||
538 | - const deviceProfileId = formModel['deviceProfileId']; | ||
539 | - return { | ||
540 | - mode: 'multiple', | ||
541 | - api: async () => { | ||
542 | - if (unref(organizationId)) { | ||
543 | - try { | ||
544 | - const data = await byOrganizationIdGetMasterDevice({ | ||
545 | - organizationId: unref(organizationId), | ||
546 | - deviceProfileId, | ||
547 | - }); | ||
548 | - if (data) | ||
549 | - return data.map((item) => ({ | ||
550 | - ...item, | ||
551 | - label: item.alias || item.name, | ||
552 | - value: item.tbDeviceId, | ||
553 | - })); | ||
554 | - } catch (error) {} | ||
555 | - } | ||
556 | - return []; | ||
557 | - }, | ||
558 | - placeholder: '请选择设备', | ||
559 | - getPopupContainer: (triggerNode) => triggerNode.parentNode, | ||
560 | - }; | ||
561 | - }, | ||
562 | - ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget), | ||
563 | - colProps: { span: 6 }, | ||
564 | - }, | ||
565 | - //新增代码2022-11-23 | ||
566 | - { | ||
567 | - field: 'commandType', | ||
568 | - label: '', | ||
569 | - required: true, | ||
570 | - component: 'ApiSelect', | ||
571 | - colProps: { | ||
572 | - span: 6, | ||
573 | - }, | ||
574 | - defaultValue: '0', | ||
575 | - componentProps: ({ formActionType }) => { | ||
576 | - const { setFieldsValue } = formActionType; | ||
577 | - return { | ||
578 | - placeholder: '请选择类型', | ||
579 | - api: async (parmas: Recordable) => { | ||
580 | - try { | ||
581 | - const record = await findDictItemByCode(parmas); | ||
582 | - return record.filter( | ||
583 | - (item) => | ||
584 | - item.itemValue !== CommandTypeEnum.ATTRIBUTE.toString() || item.itemText != '属性' | ||
585 | - ); | ||
586 | - } catch (error) { | ||
587 | - return []; | ||
588 | - } | ||
589 | - }, | ||
590 | - labelField: 'itemText', | ||
591 | - valueField: 'itemValue', | ||
592 | - params: { | ||
593 | - dictCode: 'custom_define', | ||
594 | - }, | ||
595 | - numberToString: true, | ||
596 | - getPopupContainer: (triggerNode) => triggerNode.parentNode, | ||
597 | - onChange: () => { | ||
598 | - setFieldsValue({ doContext: null, thingsModelId: null }); | ||
599 | - }, | ||
600 | - }; | ||
601 | - }, | ||
602 | - ifShow: ({ values }) => isDeviceOut(values.outTarget) && isPartOrAll(values.device), | ||
603 | - }, | ||
604 | - //新增代码2022-11-23 | ||
605 | - { | ||
606 | - field: 'callType', | ||
607 | - label: '', | ||
608 | - required: true, | ||
609 | - component: 'ApiSelect', | ||
610 | - colProps: { | ||
611 | - span: 6, | ||
612 | - }, | ||
613 | - defaultValue: 'SYNC', | ||
614 | - componentProps: { | ||
615 | - placeholder: '请选择类型', | ||
616 | - api: findDictItemByCode, | ||
617 | - params: { | ||
618 | - dictCode: 'call_mode', | ||
619 | - }, | ||
620 | - labelField: 'itemText', | ||
621 | - valueField: 'itemValue', | ||
622 | - getPopupContainer: (triggerNode) => triggerNode.parentNode, | ||
623 | - }, | ||
624 | - ifShow: ({ values }) => | ||
625 | - isDeviceOut(values.outTarget) && isPartOrAll(values.device) && isDefine(values.commandType), | ||
626 | - }, | ||
627 | - { | ||
628 | - field: 'serviceIdentifier', | ||
629 | - label: '', | ||
630 | - component: 'Input', | ||
631 | - show: false, | ||
632 | - }, | ||
633 | - { | ||
634 | - field: 'thingsModelKeys', | ||
635 | - label: '', | ||
636 | - show: false, | ||
637 | - component: 'Select', | ||
638 | - componentProps: { | ||
639 | - mode: 'multiple', | ||
640 | - }, | ||
641 | - }, | ||
642 | - { | ||
643 | - field: 'thingsModelId', | ||
644 | - label: '', | ||
645 | - required: true, | ||
646 | - component: 'ApiSelect', | ||
647 | - colProps: { | ||
648 | - span: 6, | ||
649 | - }, | ||
650 | - componentProps: ({ formModel, formActionType }) => { | ||
651 | - const { updateSchema, setFieldsValue } = formActionType; | ||
652 | - const deviceProfileId = Reflect.get(formModel, 'deviceProfileId'); | ||
653 | - const thingsModelId = Reflect.get(formModel, 'thingsModelId'); | ||
654 | - const transportType = Reflect.get(formModel, 'transportType'); | ||
655 | - return { | ||
656 | - placeholder: '请选择服务', | ||
657 | - api: async (params: Recordable) => { | ||
658 | - try { | ||
659 | - if (!Reflect.get(params, 'deviceProfileId')) return []; | ||
660 | - const record = | ||
661 | - (await getModelServices(params as Record<'deviceProfileId', string>)) || []; | ||
662 | - const selected = record.find((item) => item.id === thingsModelId); | ||
663 | - selected && | ||
664 | - updateSchema({ | ||
665 | - field: 'serviceInputValue', | ||
666 | - componentProps: { | ||
667 | - inputData: selected?.functionJson.inputData, | ||
668 | - }, | ||
669 | - }); | ||
670 | - selected && | ||
671 | - setFieldsValue({ | ||
672 | - callType: selected.callType, | ||
673 | - serviceIdentifier: selected?.identifier, | ||
674 | - thingsModelKeys: isArray(selected?.functionJson?.inputData) | ||
675 | - ? selected?.functionJson?.inputData | ||
676 | - .filter((item) => item.accessMode === ReadAndWriteEnum.READ_AND_WRITE) | ||
677 | - .map((item) => item.identifier) | ||
678 | - : [], | ||
679 | - }); | ||
680 | - return record; | ||
681 | - } catch (error) { | ||
682 | - console.error(error); | ||
683 | - return []; | ||
684 | - } | ||
685 | - }, | ||
686 | - params: { | ||
687 | - deviceProfileId, | ||
688 | - }, | ||
689 | - labelField: 'functionName', | ||
690 | - valueField: 'id', | ||
691 | - getPopupContainer: (triggerNode) => triggerNode.parentNode, | ||
692 | - onChange: (_, options: ModelOfMatterParams) => { | ||
693 | - if (options) { | ||
694 | - // setFieldsValue({ doContext: { ...options.functionJson, callType: options.callType } }); | ||
695 | - // if ( ) | ||
696 | - const record = { | ||
697 | - callType: options.callType, | ||
698 | - serviceIdentifier: options.identifier, | ||
699 | - thingsModelKeys: isArray(options?.functionJson?.inputData) | ||
700 | - ? options?.functionJson?.inputData | ||
701 | - .filter((item) => item.accessMode === ReadAndWriteEnum.READ_AND_WRITE) | ||
702 | - .map((item) => item.identifier) | ||
703 | - : [], | ||
704 | - }; | ||
705 | - transportType === TransportTypeEnum.TCP | ||
706 | - ? Object.assign(record, { | ||
707 | - tcpServiceCommand: options.functionJson?.inputData?.[0]?.serviceCommand, | ||
708 | - }) | ||
709 | - : updateSchema({ | ||
710 | - field: 'serviceInputValue', | ||
711 | - componentProps: { | ||
712 | - inputData: options.functionJson.inputData, | ||
713 | - }, | ||
714 | - }); | ||
715 | - | ||
716 | - setFieldsValue(record); | ||
717 | - } else { | ||
718 | - setFieldsValue({ serviceIdentifier: null }); | ||
719 | - } | ||
720 | - }, | ||
721 | - }; | ||
722 | - }, | ||
723 | - ifShow: ({ values }) => isDeviceOut(values.outTarget) && isService(values.commandType), | ||
724 | - }, | ||
725 | - //新增代码2022-11-23 | ||
726 | - { | ||
727 | - field: 'alarm_config', | ||
728 | - label: '', | ||
729 | - component: 'Input', | ||
730 | - componentProps: { | ||
731 | - placeholder: '请选择告警配置', | ||
732 | - }, | ||
733 | - slot: 'alarmConfigSlot', | ||
734 | - ifShow: ({ values }) => values.outTarget === 'MSG_NOTIFY', | ||
735 | - colProps: { span: 6 }, | ||
736 | - }, | ||
737 | - //新增代码2022-11-23 | ||
738 | - { | ||
739 | - field: 'doContext', | ||
740 | - component: 'Input', | ||
741 | - label: '', | ||
742 | - slot: 'doContext', | ||
743 | - show: ({ values }) => { | ||
744 | - return ( | ||
745 | - isDeviceOut(values.outTarget) && isPartOrAll(values.device) && isDefine(values.commandType) | ||
746 | - ); | ||
747 | - }, | ||
748 | - colProps: { | ||
749 | - span: 24, | ||
750 | - }, | ||
751 | - }, | ||
752 | - //新增代码2022-11-23 | ||
753 | - { | ||
754 | - field: 'alarm_level', | ||
755 | - component: 'Select', | ||
756 | - label: '', | ||
757 | - show: ({ values }) => isAlarmOut(values.outTarget), | ||
758 | - // dynamicRules: (params) => { | ||
759 | - // const { outTarget } = params.values; | ||
760 | - // return [ | ||
761 | - // { | ||
762 | - // required: outTarget == 'MSG_NOTIFY' ? true : false, | ||
763 | - // validator: (_, value) => { | ||
764 | - // if (!value) return Promise.reject('请选择告警配置'); | ||
765 | - // Promise.resolve(); | ||
766 | - // }, | ||
767 | - // }, | ||
768 | - // ]; | ||
769 | - // }, | ||
770 | - componentProps: { | ||
771 | - placeholder: '请选择告警等级', | ||
772 | - options: [ | ||
773 | - { | ||
774 | - label: '紧急', | ||
775 | - value: 'CRITICAL', | ||
776 | - }, | ||
777 | - { | ||
778 | - label: '重要', | ||
779 | - value: 'MAJOR', | ||
780 | - }, | ||
781 | - { | ||
782 | - label: '次要', | ||
783 | - value: 'MINOR', | ||
784 | - }, | ||
785 | - { | ||
786 | - label: '警告', | ||
787 | - value: 'WARNING', | ||
788 | - }, | ||
789 | - { | ||
790 | - label: '不确定', | ||
791 | - value: 'INDETERMINATE', | ||
792 | - }, | ||
793 | - ], | ||
794 | - }, | ||
795 | - colProps: { | ||
796 | - span: 6, | ||
797 | - }, | ||
798 | - }, | ||
799 | - { | ||
800 | - field: 'clear_alarm', | ||
801 | - component: 'Checkbox', | ||
802 | - label: '', | ||
803 | - show: ({ values }) => isAlarmOut(values.outTarget), | ||
804 | - colProps: { | ||
805 | - span: 8, | ||
806 | - }, | ||
807 | - slot: 'clearAlarm', | ||
808 | - }, | ||
809 | - { | ||
810 | - field: 'tcpServiceCommand', | ||
811 | - component: 'Input', | ||
812 | - label: '服务命令', | ||
813 | - colProps: { span: 24 }, | ||
814 | - dynamicDisabled: true, | ||
815 | - show: ({ values }) => | ||
816 | - values['thingsModelId'] && values['transportType'] === TransportTypeEnum.TCP, | ||
817 | - }, | ||
818 | - { | ||
819 | - field: 'serviceInputValue', | ||
820 | - component: 'ObjectModelValidateForm', | ||
821 | - label: '', | ||
822 | - changeEvent: 'update:value', | ||
823 | - valueField: 'value', | ||
824 | - show: ({ values }) => | ||
825 | - values['thingsModelId'] && values['transportType'] !== TransportTypeEnum.TCP, | ||
826 | - colProps: { | ||
827 | - span: 24, | ||
828 | - }, | ||
829 | - componentProps: {}, | ||
830 | - }, | ||
831 | -]; | ||
832 | - | ||
833 | -export const alarmScheduleSchemas: FormSchema[] = [ | ||
834 | - { | ||
835 | - field: 'schedule', | ||
836 | - label: '', | ||
837 | - component: 'Select', | ||
838 | - componentProps({ formActionType }) { | ||
839 | - const { resetFields } = formActionType; | ||
840 | - return { | ||
841 | - options: scheduleOptions, | ||
842 | - allowClear: false, | ||
843 | - onChange() { | ||
844 | - resetFields(); | ||
845 | - }, | ||
846 | - }; | ||
847 | - }, | ||
848 | - }, | ||
849 | - { | ||
850 | - field: 'timezone', | ||
851 | - label: '时区', | ||
852 | - component: 'Select', | ||
853 | - defaultValue: 'Asia/Shanghai', | ||
854 | - componentProps: { | ||
855 | - options: [ | ||
856 | - { | ||
857 | - label: 'Asia/Shanghai', | ||
858 | - value: 'Asia/Shanghai', | ||
859 | - }, | ||
860 | - ], | ||
861 | - allowClear: false, | ||
862 | - }, | ||
863 | - ifShow: ({ values }) => values.schedule !== 'ANY_TIME', | ||
864 | - }, | ||
865 | - { | ||
866 | - field: 'daysOfWeek', | ||
867 | - label: '天', | ||
868 | - component: 'CheckboxGroup', | ||
869 | - rules: [ | ||
870 | - { | ||
871 | - message: '请至少选择一天', | ||
872 | - required: true, | ||
873 | - }, | ||
874 | - ], | ||
875 | - componentProps: { | ||
876 | - options: [ | ||
877 | - { label: '星期一', value: 1 }, | ||
878 | - { label: '星期二', value: 2 }, | ||
879 | - { label: '星期三', value: 3 }, | ||
880 | - { label: '星期四', value: 4 }, | ||
881 | - { label: '星期五', value: 5 }, | ||
882 | - { label: '星期六', value: 6 }, | ||
883 | - { label: '星期日', value: 7 }, | ||
884 | - ], | ||
885 | - }, | ||
886 | - colProps: { | ||
887 | - span: 24, | ||
888 | - }, | ||
889 | - ifShow: ({ values }) => values.schedule === 'SPECIFIC_TIME', | ||
890 | - }, | ||
891 | - { | ||
892 | - field: 'time', | ||
893 | - label: '时间', | ||
894 | - labelWidth: 40, | ||
895 | - component: 'RangePicker', | ||
896 | - ifShow: ({ values }) => values.schedule === 'SPECIFIC_TIME', | ||
897 | - slot: 'timing', | ||
898 | - }, | ||
899 | - { | ||
900 | - field: 'day', | ||
901 | - label: '天', | ||
902 | - component: 'CheckboxGroup', | ||
903 | - slot: 'customEnable', | ||
904 | - ifShow: ({ values }) => values.schedule === 'CUSTOM', | ||
905 | - }, | ||
906 | -]; |
@@ -8,12 +8,12 @@ import { | @@ -8,12 +8,12 @@ import { | ||
8 | } from '../DevicePicker'; | 8 | } from '../DevicePicker'; |
9 | import { PollCommandInput, ModeEnum } from '../PollCommandInput'; | 9 | import { PollCommandInput, ModeEnum } from '../PollCommandInput'; |
10 | import { DeviceProfileModel } from '/@/api/device/model/deviceModel'; | 10 | import { DeviceProfileModel } from '/@/api/device/model/deviceModel'; |
11 | -import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | ||
12 | import { JSONEditorValidator } from '/@/components/CodeEditor/src/JSONEditor'; | 11 | import { JSONEditorValidator } from '/@/components/CodeEditor/src/JSONEditor'; |
13 | import { BooleanStringEnum, TimeUnitEnum, TimeUnitNameEnum } from '/@/enums/toolEnum'; | 12 | import { BooleanStringEnum, TimeUnitEnum, TimeUnitNameEnum } from '/@/enums/toolEnum'; |
14 | import { dateUtil } from '/@/utils/dateUtil'; | 13 | import { dateUtil } from '/@/utils/dateUtil'; |
15 | import { ProductPicker, validateProductPicker } from '../ProductPicker'; | 14 | import { ProductPicker, validateProductPicker } from '../ProductPicker'; |
16 | import { useGlobSetting } from '/@/hooks/setting'; | 15 | import { useGlobSetting } from '/@/hooks/setting'; |
16 | +import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
17 | 17 | ||
18 | useComponentRegister('DevicePicker', DevicePicker); | 18 | useComponentRegister('DevicePicker', DevicePicker); |
19 | useComponentRegister('ProductPicker', ProductPicker); | 19 | useComponentRegister('ProductPicker', ProductPicker); |
1 | import { ref, unref } from 'vue'; | 1 | import { ref, unref } from 'vue'; |
2 | -import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | ||
3 | -import { CommandTypeEnum } from '/@/views/rule/linkedge/config/config.data'; | ||
4 | import { TaskTypeEnum } from '/@/views/task/center/config'; | 2 | import { TaskTypeEnum } from '/@/views/task/center/config'; |
5 | import { genModbusCommand } from '/@/api/task'; | 3 | import { genModbusCommand } from '/@/api/task'; |
6 | import { useMessage } from '/@/hooks/web/useMessage'; | 4 | import { useMessage } from '/@/hooks/web/useMessage'; |
7 | import { SingleToHex } from '/@/views/device/list/cpns/tabs/ObjectModelCommandDeliveryModal/config'; | 5 | import { SingleToHex } from '/@/views/device/list/cpns/tabs/ObjectModelCommandDeliveryModal/config'; |
6 | +import { CommandTypeEnum } from '/@/enums/linkedgeEnum'; | ||
7 | +import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
8 | 8 | ||
9 | const getArray = (values) => { | 9 | const getArray = (values) => { |
10 | const str = values.replace(/\s+/g, ''); | 10 | const str = values.replace(/\s+/g, ''); |
@@ -10,12 +10,12 @@ import { getModelServices } from '/@/api/device/modelOfMatter'; | @@ -10,12 +10,12 @@ import { getModelServices } from '/@/api/device/modelOfMatter'; | ||
10 | import { findDictItemByCode } from '/@/api/system/dict'; | 10 | import { findDictItemByCode } from '/@/api/system/dict'; |
11 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 11 | import { FormSchema, useComponentRegister } from '/@/components/Form'; |
12 | import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect'; | 12 | import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect'; |
13 | -import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | ||
14 | -import { CommandTypeEnum } from '/@/views/rule/linkedge/config/config.data'; | ||
15 | import { DataActionModeEnum } from '/@/enums/toolEnum'; | 13 | import { DataActionModeEnum } from '/@/enums/toolEnum'; |
16 | import { TaskTypeEnum } from '/@/views/task/center/config'; | 14 | import { TaskTypeEnum } from '/@/views/task/center/config'; |
17 | import { createPickerSearch } from '/@/utils/pickerSearch'; | 15 | import { createPickerSearch } from '/@/utils/pickerSearch'; |
18 | import { DataTypeEnum } from '/@/enums/objectModelEnum'; | 16 | import { DataTypeEnum } from '/@/enums/objectModelEnum'; |
17 | +import { CommandTypeEnum } from '/@/enums/linkedgeEnum'; | ||
18 | +import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
19 | 19 | ||
20 | useComponentRegister('OrgTreeSelect', OrgTreeSelect); | 20 | useComponentRegister('OrgTreeSelect', OrgTreeSelect); |
21 | 21 |
@@ -2,8 +2,8 @@ import { ref } from 'vue'; | @@ -2,8 +2,8 @@ import { ref } from 'vue'; | ||
2 | import { DataSource } from '../../palette/types'; | 2 | import { DataSource } from '../../palette/types'; |
3 | import { sendCommandOneway, sendCommandTwoway } from '/@/api/dataBoard'; | 3 | import { sendCommandOneway, sendCommandTwoway } from '/@/api/dataBoard'; |
4 | import { useMessage } from '/@/hooks/web/useMessage'; | 4 | import { useMessage } from '/@/hooks/web/useMessage'; |
5 | -import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const'; | ||
6 | import { ServiceCallTypeEnum } from '/@/enums/toolEnum'; | 5 | import { ServiceCallTypeEnum } from '/@/enums/toolEnum'; |
6 | +import { TransportTypeEnum } from '/@/enums/deviceEnum'; | ||
7 | 7 | ||
8 | const { createMessage } = useMessage(); | 8 | const { createMessage } = useMessage(); |
9 | export function useSendCommand() { | 9 | export function useSendCommand() { |