Commit f241489fcccc9f314d7ea0efa183b56e3e274701
Merge branch 'fix/script-manage' into 'main_dev'
fix: 修复测试转换脚本保存时数据结构不正确 See merge request yunteng/thingskit-front!1415
Showing
4 changed files
with
18 additions
and
17 deletions
... | ... | @@ -12,13 +12,7 @@ |
12 | 12 | import { isFunction, isString } from '/@/utils/is'; |
13 | 13 | import { ScriptLanguageEnum } from '/@/enums/scriptEnum'; |
14 | 14 | import { ScriptTestParams } from '/@/api/ruleChainDesigner/model'; |
15 | - | |
16 | - interface Value { | |
17 | - msg: Recordable; | |
18 | - metadata: Recordable; | |
19 | - msgType: MessageTypesEnum; | |
20 | - javascriptFunction: string; | |
21 | - } | |
15 | + import { TestModalValueType } from '.'; | |
22 | 16 | |
23 | 17 | const props = withDefaults( |
24 | 18 | defineProps<{ |
... | ... | @@ -45,8 +39,8 @@ |
45 | 39 | |
46 | 40 | const emit = defineEmits<{ |
47 | 41 | (eventName: 'cancel'): void; |
48 | - (eventName: 'test', value: Value): void; | |
49 | - (eventName: 'save', value: Value): void; | |
42 | + (eventName: 'test', value: TestModalValueType): void; | |
43 | + (eventName: 'save', value: TestModalValueType): void; | |
50 | 44 | }>(); |
51 | 45 | |
52 | 46 | const jsonEditor = ref<InstanceType<typeof JSONEditor>>(); |
... | ... | @@ -85,7 +79,7 @@ |
85 | 79 | return true; |
86 | 80 | }; |
87 | 81 | |
88 | - const getValue = (): Value => { | |
82 | + const getValue = (): TestModalValueType => { | |
89 | 83 | const msg = unref(messageContent); |
90 | 84 | const msgType = unref(messageType); |
91 | 85 | const javascriptFunction = unref(scriptContent); |
... | ... | @@ -138,14 +132,13 @@ |
138 | 132 | |
139 | 133 | const result = await executeTestScript(); |
140 | 134 | |
141 | - outputContent.value = result; | |
135 | + outputContent.value = result || ''; | |
142 | 136 | await nextTick(); |
143 | 137 | unref(jsonEditor)?.handleFormat(); |
144 | 138 | }; |
145 | 139 | |
146 | 140 | const handleSave = async () => { |
147 | 141 | const flag = await handleValidate(); |
148 | - | |
149 | 142 | flag && emit('save', getValue()); |
150 | 143 | }; |
151 | 144 | ... | ... |
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | import { DataActionModeEnum } from '/@/enums/toolEnum'; |
7 | 7 | import { computed, ref, toRaw, unref, watch } from 'vue'; |
8 | 8 | import { ScriptLanguageEnum } from '/@/enums/scriptEnum'; |
9 | - import { ScriptEditorValueType } from '.'; | |
9 | + import { ScriptEditorValueType, TestModalValueType } from '.'; | |
10 | 10 | import { ScriptTestParams } from '/@/api/ruleChainDesigner/model'; |
11 | 11 | |
12 | 12 | const props = withDefaults( |
... | ... | @@ -74,14 +74,14 @@ |
74 | 74 | }, |
75 | 75 | }); |
76 | 76 | |
77 | - const handleSave = (value: Record<'javascriptFunction', string>) => { | |
77 | + const handleSave = ({ javascriptFunction }: TestModalValueType) => { | |
78 | 78 | const { jsScript, tbelScript } = props.value || {}; |
79 | 79 | const scriptLang = unref(activeLanguage); |
80 | 80 | emit( |
81 | 81 | 'update:value', |
82 | 82 | toRaw({ |
83 | - jsScript: scriptLang === ScriptLanguageEnum.JavaScript ? value : jsScript, | |
84 | - tbelScript: scriptLang === ScriptLanguageEnum.TBEL ? value : tbelScript, | |
83 | + jsScript: scriptLang === ScriptLanguageEnum.JavaScript ? javascriptFunction : jsScript, | |
84 | + tbelScript: scriptLang === ScriptLanguageEnum.TBEL ? javascriptFunction : tbelScript, | |
85 | 85 | scriptLang, |
86 | 86 | } as ScriptEditorValueType) |
87 | 87 | ); | ... | ... |
1 | +import { MessageTypesEnum } from '../../../enum/form'; | |
1 | 2 | import { ScriptLanguageEnum } from '/@/enums/scriptEnum'; |
2 | 3 | |
3 | 4 | export { default as JavaScriptTestModal } from './JavaScriptTestModal.vue'; |
... | ... | @@ -9,3 +10,10 @@ export interface ScriptEditorValueType { |
9 | 10 | jsScript: string; |
10 | 11 | tbelScript: string; |
11 | 12 | } |
13 | + | |
14 | +export interface TestModalValueType { | |
15 | + msg: Recordable; | |
16 | + metadata: Recordable; | |
17 | + msgType: MessageTypesEnum; | |
18 | + javascriptFunction: string; | |
19 | +} | ... | ... |