| 
@@ -10,11 +10,11 @@ | 
 | 
@@ -10,11 +10,11 @@ | 
| 
10
 | 
     >
 | 
10
 | 
     >
 | 
| 
11
 | 
       <a-form-item
 | 
11
 | 
       <a-form-item
 | 
| 
12
 | 
         :label="ifAdd ? '名称' : '输入参数'"
 | 
12
 | 
         :label="ifAdd ? '名称' : '输入参数'"
 | 
| 
13
 | 
-        :name="ifAdd ? 'name' : 'inputParams'"
 | 
13
 | 
+        :name="ifAdd ? 'name' : 'params'"
 | 
| 
14
 | 
         :rules="[{ required: true, message: ifAdd ? '请输入脚本名称' : '请输入参数' }]"
 | 
14
 | 
         :rules="[{ required: true, message: ifAdd ? '请输入脚本名称' : '请输入参数' }]"
 | 
| 
15
 | 
       >
 | 
15
 | 
       >
 | 
| 
16
 | 
         <a-input v-if="ifAdd" v-model:value="scriptForm.name" placeholder="请输入脚本名称" />
 | 
16
 | 
         <a-input v-if="ifAdd" v-model:value="scriptForm.name" placeholder="请输入脚本名称" />
 | 
| 
17
 | 
-        <a-input v-else v-model:value="scriptForm.inputParams" placeholder="请输入参数" />
 | 
17
 | 
+        <a-input v-else v-model:value="scriptForm.params" placeholder="请输入参数" />
 | 
| 
18
 | 
       </a-form-item>
 | 
18
 | 
       </a-form-item>
 | 
| 
19
 | 
       <a-form-item
 | 
19
 | 
       <a-form-item
 | 
| 
20
 | 
         label="上报数据类型"
 | 
20
 | 
         label="上报数据类型"
 | 
 | 
@@ -25,10 +25,13 @@ | 
 | 
@@ -25,10 +25,13 @@ | 
| 
25
 | 
           <a-radio-group v-model:value="scriptForm.reportType" :options="typeOptions" />
 | 
25
 | 
           <a-radio-group v-model:value="scriptForm.reportType" :options="typeOptions" />
 | 
| 
26
 | 
         </a-space>
 | 
26
 | 
         </a-space>
 | 
| 
27
 | 
       </a-form-item>
 | 
27
 | 
       </a-form-item>
 | 
| 
28
 | 
-      <a-form-item label="脚本内容" name="convertJs">
 | 
28
 | 
+      <a-form-item label="脚本内容" :name="ifAdd ? 'convertJs' : 'script'">
 | 
| 
29
 | 
         <Card title="脚本内容" :bodyStyle="{ padding: 0, height: '280px' }">
 | 
29
 | 
         <Card title="脚本内容" :bodyStyle="{ padding: 0, height: '280px' }">
 | 
| 
30
 | 
           <template #extra>
 | 
30
 | 
           <template #extra>
 | 
| 
31
 | 
             <a-button @click="handleFormat" size="small">格式化</a-button>
 | 
31
 | 
             <a-button @click="handleFormat" size="small">格式化</a-button>
 | 
| 
 | 
   | 
32
 | 
+            <Tooltip :title="defaultTitle" class="ml-2">
 | 
| 
 | 
   | 
33
 | 
+              <QuestionCircleOutlined style="font-size: 1rem" />
 | 
| 
 | 
   | 
34
 | 
+            </Tooltip>
 | 
| 
32
 | 
           </template>
 | 
35
 | 
           </template>
 | 
| 
33
 | 
           <div ref="aceRef" class="overflow-hidden"></div>
 | 
36
 | 
           <div ref="aceRef" class="overflow-hidden"></div>
 | 
| 
34
 | 
         </Card>
 | 
37
 | 
         </Card>
 | 
 | 
@@ -39,21 +42,18 @@ | 
 | 
@@ -39,21 +42,18 @@ | 
| 
39
 | 
           copy
 | 
42
 | 
           copy
 | 
| 
40
 | 
         </Button>
 | 
43
 | 
         </Button>
 | 
| 
41
 | 
       </a-form-item>
 | 
44
 | 
       </a-form-item>
 | 
| 
42
 | 
-      <a-form-item
 | 
 | 
   | 
| 
43
 | 
-        :label="ifAdd ? '备注' : '输出参数'"
 | 
 | 
   | 
| 
44
 | 
-        :name="ifAdd ? 'description' : 'outputParams'"
 | 
 | 
   | 
| 
45
 | 
-      >
 | 
45
 | 
+      <a-form-item :label="ifAdd ? '备注' : '输出参数'" :name="ifAdd ? 'description' : 'output'">
 | 
| 
46
 | 
         <a-textarea
 | 
46
 | 
         <a-textarea
 | 
| 
47
 | 
-          :rows="5"
 | 
47
 | 
+          :rows="3"
 | 
| 
48
 | 
           v-if="ifAdd"
 | 
48
 | 
           v-if="ifAdd"
 | 
| 
49
 | 
           v-model:value="scriptForm.description"
 | 
49
 | 
           v-model:value="scriptForm.description"
 | 
| 
50
 | 
           placeholder="请输入备注"
 | 
50
 | 
           placeholder="请输入备注"
 | 
| 
51
 | 
         />
 | 
51
 | 
         />
 | 
| 
52
 | 
         <a-textarea
 | 
52
 | 
         <a-textarea
 | 
| 
53
 | 
-          :rows="5"
 | 
53
 | 
+          :rows="3"
 | 
| 
54
 | 
           v-else
 | 
54
 | 
           v-else
 | 
| 
55
 | 
-          v-model:value="scriptForm.outputParams"
 | 
 | 
   | 
| 
56
 | 
-          placeholder="请输入输出参数"
 | 
55
 | 
+          v-model:value="scriptForm.output"
 | 
| 
 | 
   | 
56
 | 
+          placeholder="输出参数为服务端返回的内容"
 | 
| 
57
 | 
         />
 | 
57
 | 
         />
 | 
| 
58
 | 
       </a-form-item>
 | 
58
 | 
       </a-form-item>
 | 
| 
59
 | 
     </a-form>
 | 
59
 | 
     </a-form>
 | 
 | 
@@ -62,7 +62,7 @@ | 
 | 
@@ -62,7 +62,7 @@ | 
| 
62
 | 
 <script setup lang="ts">
 | 
62
 | 
 <script setup lang="ts">
 | 
| 
63
 | 
   import { ref, unref, reactive, onMounted, toRefs } from 'vue';
 | 
63
 | 
   import { ref, unref, reactive, onMounted, toRefs } from 'vue';
 | 
| 
64
 | 
   import ace from 'ace-builds';
 | 
64
 | 
   import ace from 'ace-builds';
 | 
| 
65
 | 
-  import { Card, Button } from 'ant-design-vue';
 | 
65
 | 
+  import { Card, Button, Tooltip } from 'ant-design-vue';
 | 
| 
66
 | 
   import 'ace-builds/src-noconflict/theme-chrome'; // 默认设置的主题
 | 
66
 | 
   import 'ace-builds/src-noconflict/theme-chrome'; // 默认设置的主题
 | 
| 
67
 | 
   import 'ace-builds/src-noconflict/mode-javascript'; // 默认设置的语言模式
 | 
67
 | 
   import 'ace-builds/src-noconflict/mode-javascript'; // 默认设置的语言模式
 | 
| 
68
 | 
   import { beautify } from 'ace-builds/src-noconflict/ext-beautify.js';
 | 
68
 | 
   import { beautify } from 'ace-builds/src-noconflict/ext-beautify.js';
 | 
 | 
@@ -70,17 +70,20 @@ | 
 | 
@@ -70,17 +70,20 @@ | 
| 
70
 | 
   import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
 | 
70
 | 
   import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
 | 
| 
71
 | 
   import { useMessage } from '/@/hooks/web/useMessage';
 | 
71
 | 
   import { useMessage } from '/@/hooks/web/useMessage';
 | 
| 
72
 | 
   import { findDictItemByCode } from '/@/api/system/dict';
 | 
72
 | 
   import { findDictItemByCode } from '/@/api/system/dict';
 | 
| 
 | 
   | 
73
 | 
+  import { QuestionCircleOutlined } from '@ant-design/icons-vue';
 | 
| 
 | 
   | 
74
 | 
+  import { defaultTitle, defaultScriptContent } from './config.data';
 | 
| 
73
 | 
 
 | 
75
 | 
 
 | 
| 
74
 | 
   defineEmits(['register']);
 | 
76
 | 
   defineEmits(['register']);
 | 
| 
75
 | 
-  defineProps({
 | 
77
 | 
+  const props = defineProps({
 | 
| 
76
 | 
     ifAdd: { type: Boolean, default: true },
 | 
78
 | 
     ifAdd: { type: Boolean, default: true },
 | 
| 
77
 | 
   });
 | 
79
 | 
   });
 | 
| 
78
 | 
   const scriptForm = reactive({
 | 
80
 | 
   const scriptForm = reactive({
 | 
| 
79
 | 
     name: '',
 | 
81
 | 
     name: '',
 | 
| 
80
 | 
     description: '',
 | 
82
 | 
     description: '',
 | 
| 
81
 | 
     convertJs: '',
 | 
83
 | 
     convertJs: '',
 | 
| 
82
 | 
-    inputParams: '',
 | 
 | 
   | 
| 
83
 | 
-    outputParams: '',
 | 
84
 | 
+    script: '',
 | 
| 
 | 
   | 
85
 | 
+    params: '',
 | 
| 
 | 
   | 
86
 | 
+    output: '',
 | 
| 
84
 | 
     reportType: 'HEX',
 | 
87
 | 
     reportType: 'HEX',
 | 
| 
85
 | 
   });
 | 
88
 | 
   });
 | 
| 
86
 | 
   const reportTypeOptions = reactive({
 | 
89
 | 
   const reportTypeOptions = reactive({
 | 
 | 
@@ -114,18 +117,7 @@ | 
 | 
@@ -114,18 +117,7 @@ | 
| 
114
 | 
       enableBasicAutocompletion: true,
 | 
117
 | 
       enableBasicAutocompletion: true,
 | 
| 
115
 | 
       enableLiveAutocompletion: true,
 | 
118
 | 
       enableLiveAutocompletion: true,
 | 
| 
116
 | 
     });
 | 
119
 | 
     });
 | 
| 
117
 | 
-    aceEditor.value.setValue(
 | 
 | 
   | 
| 
118
 | 
-      jsScript ??
 | 
 | 
   | 
| 
119
 | 
-        `
 | 
 | 
   | 
| 
120
 | 
-    var trimSource =source.replaceAll(" ","");
 | 
 | 
   | 
| 
121
 | 
-    if(trimSource.length==26 && trimSource.startsWith("020308")){
 | 
 | 
   | 
| 
122
 | 
-      var str = "";
 | 
 | 
   | 
| 
123
 | 
-      for(var i = 6;i<20;i+=2){
 | 
 | 
   | 
| 
124
 | 
-        str += String.fromCharCode(parseInt(trimSource[i]+trimSource[i+1],16));
 | 
 | 
   | 
| 
125
 | 
-      }
 | 
 | 
   | 
| 
126
 | 
-    }
 | 
 | 
   | 
| 
127
 | 
-      `
 | 
 | 
   | 
| 
128
 | 
-    );
 | 
120
 | 
+    aceEditor.value.setValue(jsScript ?? defaultScriptContent);
 | 
| 
129
 | 
     beautify(aceEditor.value.session);
 | 
121
 | 
     beautify(aceEditor.value.session);
 | 
| 
130
 | 
     scriptForm.convertJs = aceEditor.value.getValue();
 | 
122
 | 
     scriptForm.convertJs = aceEditor.value.getValue();
 | 
| 
131
 | 
   };
 | 
123
 | 
   };
 | 
 | 
@@ -144,15 +136,24 @@ | 
 | 
@@ -144,15 +136,24 @@ | 
| 
144
 | 
   const formRef = ref();
 | 
136
 | 
   const formRef = ref();
 | 
| 
145
 | 
   const getFormData = async () => {
 | 
137
 | 
   const getFormData = async () => {
 | 
| 
146
 | 
     const value = await formRef.value.validateFields();
 | 
138
 | 
     const value = await formRef.value.validateFields();
 | 
| 
147
 | 
-    scriptForm.convertJs = aceEditor.value.getValue();
 | 
 | 
   | 
| 
148
 | 
-    if (scriptForm.convertJs == '') {
 | 
 | 
   | 
| 
149
 | 
-      createMessage.error('请编写脚本内容');
 | 
 | 
   | 
| 
150
 | 
-      throw '请编写脚本内容';
 | 
139
 | 
+    if (props.ifAdd) {
 | 
| 
 | 
   | 
140
 | 
+      scriptForm.convertJs = aceEditor.value.getValue();
 | 
| 
 | 
   | 
141
 | 
+      if (scriptForm.convertJs == '') {
 | 
| 
 | 
   | 
142
 | 
+        createMessage.error('请编写脚本内容');
 | 
| 
 | 
   | 
143
 | 
+        throw '请编写脚本内容';
 | 
| 
 | 
   | 
144
 | 
+      }
 | 
| 
 | 
   | 
145
 | 
+    } else {
 | 
| 
 | 
   | 
146
 | 
+      scriptForm.script = aceEditor.value.getValue();
 | 
| 
 | 
   | 
147
 | 
+      if (scriptForm.script == '') {
 | 
| 
 | 
   | 
148
 | 
+        createMessage.error('请编写脚本内容');
 | 
| 
 | 
   | 
149
 | 
+        throw '请编写脚本内容';
 | 
| 
 | 
   | 
150
 | 
+      }
 | 
| 
151
 | 
     }
 | 
151
 | 
     }
 | 
| 
152
 | 
     if (!value) return;
 | 
152
 | 
     if (!value) return;
 | 
| 
153
 | 
     return {
 | 
153
 | 
     return {
 | 
| 
154
 | 
       ...value,
 | 
154
 | 
       ...value,
 | 
| 
155
 | 
-      ...{ convertJs: scriptForm.convertJs },
 | 
155
 | 
+      ...{ convertJs: props.ifAdd ? scriptForm.convertJs : null },
 | 
| 
 | 
   | 
156
 | 
+      ...{ script: !props.ifAdd ? scriptForm.script : null },
 | 
| 
156
 | 
     };
 | 
157
 | 
     };
 | 
| 
157
 | 
   };
 | 
158
 | 
   };
 | 
| 
158
 | 
   const setFormData = (v) => {
 | 
159
 | 
   const setFormData = (v) => {
 | 
 | 
@@ -163,7 +164,7 @@ | 
 | 
@@ -163,7 +164,7 @@ | 
| 
163
 | 
     handleFormat();
 | 
164
 | 
     handleFormat();
 | 
| 
164
 | 
   };
 | 
165
 | 
   };
 | 
| 
165
 | 
   const setScriptContentData = (v) => {
 | 
166
 | 
   const setScriptContentData = (v) => {
 | 
| 
166
 | 
-    aceEditor.value.setValue(v.convertJs);
 | 
167
 | 
+    aceEditor.value.setValue(v);
 | 
| 
167
 | 
     handleFormat();
 | 
168
 | 
     handleFormat();
 | 
| 
168
 | 
   };
 | 
169
 | 
   };
 | 
| 
169
 | 
   const resetFormData = () => {
 | 
170
 | 
   const resetFormData = () => {
 | 
 | 
@@ -171,6 +172,9 @@ | 
 | 
@@ -171,6 +172,9 @@ | 
| 
171
 | 
       Reflect.set(scriptForm, i, '');
 | 
172
 | 
       Reflect.set(scriptForm, i, '');
 | 
| 
172
 | 
     }
 | 
173
 | 
     }
 | 
| 
173
 | 
   };
 | 
174
 | 
   };
 | 
| 
 | 
   | 
175
 | 
+  const setScriptOutputData = (v) => {
 | 
| 
 | 
   | 
176
 | 
+    scriptForm.output = v;
 | 
| 
 | 
   | 
177
 | 
+  };
 | 
| 
174
 | 
   const handleFormat = () => beautify(aceEditor.value.session);
 | 
178
 | 
   const handleFormat = () => beautify(aceEditor.value.session);
 | 
| 
175
 | 
 
 | 
179
 | 
 
 | 
| 
176
 | 
   defineExpose({
 | 
180
 | 
   defineExpose({
 | 
 | 
@@ -179,6 +183,7 @@ | 
 | 
@@ -179,6 +183,7 @@ | 
| 
179
 | 
     resetFormData,
 | 
183
 | 
     resetFormData,
 | 
| 
180
 | 
     setFormData,
 | 
184
 | 
     setFormData,
 | 
| 
181
 | 
     setScriptContentData,
 | 
185
 | 
     setScriptContentData,
 | 
| 
 | 
   | 
186
 | 
+    setScriptOutputData,
 | 
| 
182
 | 
   });
 | 
187
 | 
   });
 | 
| 
183
 | 
 </script>
 | 
188
 | 
 </script>
 | 
| 
184
 | 
 <style lang="less" scoped>
 | 
189
 | 
 <style lang="less" scoped>
 |