Commit 575ff3f01ceff549ef0e789592c1fb62fb825c48
Merge branch 'fix/DEFECT-2098' into 'v1.4.0_dev'
fix: TCP产品详情,点击传输配置时,点击测试转换脚本无效 See merge request yunteng/thingskit-front!1355
Showing
2 changed files
with
42 additions
and
9 deletions
1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> |
2 | import { Button, Tag } from 'ant-design-vue'; | 2 | import { Button, Tag } from 'ant-design-vue'; |
3 | - import { h, onMounted, ref, unref, Ref } from 'vue'; | 3 | + import { h, onMounted, ref, unref } from 'vue'; |
4 | import { DeviceProfileModel } from '/@/api/device/model/deviceModel'; | 4 | import { DeviceProfileModel } from '/@/api/device/model/deviceModel'; |
5 | import { getScriptManageMeList } from '/@/api/scriptmanage/scriptManager'; | 5 | import { getScriptManageMeList } from '/@/api/scriptmanage/scriptManager'; |
6 | import { Description, useDescription } from '/@/components/Description'; | 6 | import { Description, useDescription } from '/@/components/Description'; |
7 | import { useModal } from '/@/components/Modal'; | 7 | import { useModal } from '/@/components/Modal'; |
8 | - import { SelectTypes } from 'ant-design-vue/es/select'; | ||
9 | import { TCPProtocolTypeEnum, TCPProtocolTypeNameEnum } from '/@/enums/deviceEnum'; | 8 | import { TCPProtocolTypeEnum, TCPProtocolTypeNameEnum } from '/@/enums/deviceEnum'; |
9 | + import ConvertScriptModal from '/@/views/rule/script/TcpConversionScript/components/ConvertScriptModal.vue'; | ||
10 | + import { ScriptLanguageEnum } from '/@/enums/scriptEnum'; | ||
11 | + import { DataActionModeEnum } from '/@/enums/toolEnum'; | ||
12 | + import JavaScriptTestModal from '/@/views/rule/designer/src/components/JavaScriptFilterModal/JavaScriptTestModal.vue'; | ||
10 | 13 | ||
11 | const props = defineProps<{ | 14 | const props = defineProps<{ |
12 | record: DeviceProfileModel['profileData']['transportConfiguration']; | 15 | record: DeviceProfileModel['profileData']['transportConfiguration']; |
@@ -14,7 +17,7 @@ | @@ -14,7 +17,7 @@ | ||
14 | 17 | ||
15 | const upScriptIdStr = ref(''); | 18 | const upScriptIdStr = ref(''); |
16 | 19 | ||
17 | - const selectUpOptions: Ref<SelectTypes['options']> = ref([]); | 20 | + const selectUpOptions: any = ref([]); |
18 | 21 | ||
19 | onMounted(async () => { | 22 | onMounted(async () => { |
20 | selectUpOptions.value = await getAllScriptType('TRANSPORT_TCP_UP'); | 23 | selectUpOptions.value = await getAllScriptType('TRANSPORT_TCP_UP'); |
@@ -25,7 +28,7 @@ | @@ -25,7 +28,7 @@ | ||
25 | 28 | ||
26 | const getAllScriptType = async (type) => { | 29 | const getAllScriptType = async (type) => { |
27 | const rest = await getScriptManageMeList({ scriptType: type }); | 30 | const rest = await getScriptManageMeList({ scriptType: type }); |
28 | - return rest.map((m) => ({ label: m.name, value: m.id })); | 31 | + return rest.map((m) => ({ ...m, label: m.name, value: m.id })); |
29 | }; | 32 | }; |
30 | 33 | ||
31 | const findScriptUpName = (scriptId) => { | 34 | const findScriptUpName = (scriptId) => { |
@@ -73,17 +76,44 @@ | @@ -73,17 +76,44 @@ | ||
73 | 76 | ||
74 | const [registerModal, { openModal }] = useModal(); | 77 | const [registerModal, { openModal }] = useModal(); |
75 | 78 | ||
79 | + const testScriptLanguage = ref<string>(ScriptLanguageEnum.JavaScript); | ||
76 | const handleTestUpScript = () => { | 80 | const handleTestUpScript = () => { |
77 | - const modalParams = { | ||
78 | - record: { id: unref(upScriptIdStr) }, | ||
79 | - }; | ||
80 | - openModal(true, modalParams); | 81 | + // const modalParams = { |
82 | + // record: { id: unref(upScriptIdStr) }, | ||
83 | + // }; | ||
84 | + const record = selectUpOptions.value?.find((it) => it.value === unref(upScriptIdStr)); | ||
85 | + const { scriptLanguage = ScriptLanguageEnum.JavaScript, convertJs, convertTbel } = record; | ||
86 | + testScriptLanguage.value = scriptLanguage!; | ||
87 | + openModal(true, { | ||
88 | + mode: DataActionModeEnum.CREATE, | ||
89 | + record: scriptLanguage === ScriptLanguageEnum.JavaScript ? convertJs : convertTbel, | ||
90 | + } as ModalParamsType<string>); | ||
91 | + | ||
92 | + // openModal(true, modalParams); | ||
93 | + }; | ||
94 | + | ||
95 | + const beforeTest = (params: Recordable) => { | ||
96 | + return { ...params, needMetadataAndMsgType: true }; | ||
81 | }; | 97 | }; |
82 | </script> | 98 | </script> |
83 | 99 | ||
84 | <template> | 100 | <template> |
85 | <section> | 101 | <section> |
86 | <Description @register="register" /> | 102 | <Description @register="register" /> |
87 | - <ConverScriptModal @register="registerModal" /> | 103 | + <ConvertScriptModal @register="registerModal" /> |
104 | + <JavaScriptTestModal | ||
105 | + onlyTest | ||
106 | + @register="registerModal" | ||
107 | + :language="testScriptLanguage" | ||
108 | + :messageValue="{ | ||
109 | + params: '010304026C00883BF0', | ||
110 | + }" | ||
111 | + :javaScriptEditorProps="{ | ||
112 | + functionName: 'Transform', | ||
113 | + paramsName: ['msg', 'metadata', 'msgType'], | ||
114 | + scriptType: 'update', | ||
115 | + }" | ||
116 | + :beforeTest="beforeTest" | ||
117 | + /> | ||
88 | </section> | 118 | </section> |
89 | </template> | 119 | </template> |
@@ -136,6 +136,9 @@ | @@ -136,6 +136,9 @@ | ||
136 | const setValue = async (value) => { | 136 | const setValue = async (value) => { |
137 | const scriptOption = await getAllScriptType(props.scriptType, props.serviceType); | 137 | const scriptOption = await getAllScriptType(props.scriptType, props.serviceType); |
138 | selectOptions.value = scriptOption; | 138 | selectOptions.value = scriptOption; |
139 | + if (props.modelValue && !unref(selectOptions)?.some((item) => item.id === props.modelValue)) { | ||
140 | + emits('update:modelValue', null); | ||
141 | + } | ||
139 | if (!scriptOption.map((item) => item.value).includes(value)) { | 142 | if (!scriptOption.map((item) => item.value).includes(value)) { |
140 | scriptId.value = null; | 143 | scriptId.value = null; |
141 | } else scriptId.value = value; | 144 | } else scriptId.value = value; |