Commit ede3dea5a852bbd48216facc681f64776edc590f

Authored by xp.Huang
2 parents 6db4cfff 96c9a2d2

Merge branch 'ft' into 'main_dev'

pref: 调整Topic和公共接口管理

See merge request yunteng/thingskit-front!547
@@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
22 v-show="getRequestBody.content.requestParamsBodyType === 'x-www-form-urlencoded'" 22 v-show="getRequestBody.content.requestParamsBodyType === 'x-www-form-urlencoded'"
23 /> 23 />
24 <JsonEditor 24 <JsonEditor
  25 + :showBtn="false"
25 style="width: 35vw; height: 30vh" 26 style="width: 35vw; height: 30vh"
26 v-show="getRequestBody.content.requestParamsBodyType === 'json'" 27 v-show="getRequestBody.content.requestParamsBodyType === 'json'"
27 ref="jsonEditorRef" 28 ref="jsonEditorRef"
1 <template> 1 <template>
2 - <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div> 2 + <div class="flex" style="justify-content: space-between; align-content: center">
  3 + <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div>
  4 + <div class="ml-2 -mt-1.5">
  5 + <Button v-if="showBtn" @click="onHandleCopy" type="text"> 复制测试结果 </Button>
  6 + </div>
  7 + </div>
3 </template> 8 </template>
4 9
5 <script lang="ts" setup> 10 <script lang="ts" setup>
6 import { ref, onMounted, nextTick, unref } from 'vue'; 11 import { ref, onMounted, nextTick, unref } from 'vue';
7 import jsoneditor from 'jsoneditor'; 12 import jsoneditor from 'jsoneditor';
8 import 'jsoneditor/dist/jsoneditor.min.css'; 13 import 'jsoneditor/dist/jsoneditor.min.css';
  14 + import { Button } from 'ant-design-vue';
  15 + import { useMessage } from '/@/hooks/web/useMessage';
  16 +
  17 + const props = defineProps({
  18 + showBtn: {
  19 + type: Boolean,
  20 + default: false,
  21 + },
  22 + });
  23 +
  24 + const { createMessage } = useMessage();
9 25
10 // json 以及初始化JSON 26 // json 以及初始化JSON
11 const jsoneditorRef = ref(); 27 const jsoneditorRef = ref();
@@ -20,15 +36,15 @@ @@ -20,15 +36,15 @@
20 mode: 'code', 36 mode: 'code',
21 mainMenuBar: false, 37 mainMenuBar: false,
22 statusBar: false, 38 statusBar: false,
23 - onFocus: () => {},  
24 - onBlur: () => {  
25 - setJsonValue('执行测试结果为:'); 39 + onFocus: () => {
  40 + if (props.showBtn) {
  41 + setJsonValue('测试结果为');
  42 + }
26 }, 43 },
  44 + onBlur: () => {},
27 onChangeText: (e) => { 45 onChangeText: (e) => {
28 - if (e.length === 0) {  
29 - setJsonValue('执行测试结果为:');  
30 - } else {  
31 - // setJsonValue(undefined); 46 + if (props.showBtn) {
  47 + if (e.length) return setJsonValue('测试结果为');
32 } 48 }
33 }, 49 },
34 } as object; 50 } as object;
@@ -40,11 +56,11 @@ @@ -40,11 +56,11 @@
40 56
41 const getJsonValue = () => unref(jsonInstance).get(); 57 const getJsonValue = () => unref(jsonInstance).get();
42 58
43 - // const setJsonMode = (mode) => {  
44 - // nextTick(() => {  
45 - // unref(jsonInstance).setMode(mode);  
46 - // });  
47 - // }; 59 + const setJsonMode = (mode) => {
  60 + nextTick(() => {
  61 + unref(jsonInstance).setMode(mode);
  62 + });
  63 + };
48 64
49 const setJsonValue = (Json) => { 65 const setJsonValue = (Json) => {
50 nextTick(() => { 66 nextTick(() => {
@@ -52,10 +68,28 @@ @@ -52,10 +68,28 @@
52 }); 68 });
53 }; 69 };
54 70
  71 + function copyToClip(content, message) {
  72 + var aux = document.createElement('input');
  73 + aux.setAttribute('value', content);
  74 + document.body.appendChild(aux);
  75 + aux.select();
  76 + document.execCommand('copy');
  77 + document.body.removeChild(aux);
  78 + if (message == null) {
  79 + createMessage.success('复制成功!');
  80 + } else {
  81 + }
  82 + }
  83 +
  84 + const onHandleCopy = () => {
  85 + copyToClip(JSON.stringify(getJsonValue()), null);
  86 + };
  87 +
55 defineExpose({ 88 defineExpose({
56 getJsonValue, 89 getJsonValue,
57 setJsonValue, 90 setJsonValue,
58 jsonInstance, 91 jsonInstance,
  92 + setJsonMode,
59 }); 93 });
60 </script> 94 </script>
61 95
@@ -8,11 +8,6 @@ @@ -8,11 +8,6 @@
8 allowClear 8 allowClear
9 @change="onSelect" 9 @change="onSelect"
10 style="width: 150px" 10 style="width: 150px"
11 - :getPopupContainer="  
12 - (triggerNode) => {  
13 - return triggerNode.parentNode;  
14 - }  
15 - "  
16 placeholder="请选择租户" 11 placeholder="请选择租户"
17 :options="selectOptions" 12 :options="selectOptions"
18 /> 13 />
@@ -22,17 +17,12 @@ @@ -22,17 +17,12 @@
22 @change="onSelctTenant" 17 @change="onSelctTenant"
23 style="width: 150px; margin-left: 10px" 18 style="width: 150px; margin-left: 10px"
24 v-if="selectTenantOptions.length > 0" 19 v-if="selectTenantOptions.length > 0"
25 - :getPopupContainer="  
26 - (triggerNode) => {  
27 - return triggerNode.parentNode;  
28 - }  
29 - "  
30 placeholder="请选择租户" 20 placeholder="请选择租户"
31 :options="selectTenantOptions" 21 :options="selectTenantOptions"
32 /> 22 />
33 </div> 23 </div>
34 <Button 24 <Button
35 - :disabled="testDisabled" 25 + :disabled="isAdmin(role) ? testDisabled : false"
36 class="ml-2" 26 class="ml-2"
37 @click="handleTest(isSingleClickText)" 27 @click="handleTest(isSingleClickText)"
38 type="primary" 28 type="primary"
@@ -47,7 +37,7 @@ @@ -47,7 +37,7 @@
47 <TestBodyCellTable :token="getToken" ref="testEditCellTableRef" /> 37 <TestBodyCellTable :token="getToken" ref="testEditCellTableRef" />
48 </div> 38 </div>
49 <div style="width: 30vw" v-else-if="data?.type === 'json'"> 39 <div style="width: 30vw" v-else-if="data?.type === 'json'">
50 - <JsonEditor style="width: 35vw; height: 30vh" ref="jsonEditorRef" /> 40 + <JsonEditor :showBtn="false" style="width: 35vw; height: 30vh" ref="jsonEditorRef" />
51 </div> 41 </div>
52 <div style="width: 30vw" v-else-if="data?.type === 'xml'"> 42 <div style="width: 30vw" v-else-if="data?.type === 'xml'">
53 <a-textarea v-model:value="xmlContent" placeholder="请输入xml" :rows="6" /> 43 <a-textarea v-model:value="xmlContent" placeholder="请输入xml" :rows="6" />
@@ -16,14 +16,22 @@ @@ -16,14 +16,22 @@
16 </div> 16 </div>
17 </div> 17 </div>
18 <div class="mt-8"> 18 <div class="mt-8">
19 - <a-row type="flex" justify="center"> 19 + <a-row type="flex" justify="space-between" align="middle">
20 <a-col :span="24"> 20 <a-col :span="24">
21 - <JsonEditor  
22 - v-if="isWebSocketType === '2'"  
23 - style="width: 35vw; height: 40vh"  
24 - ref="jsonWebsocketEditorRef"  
25 - />  
26 - <JsonEditor v-else style="width: 35vw; height: 40vh" ref="jsonEditorRef" /> 21 + <div>
  22 + <JsonEditor
  23 + :showBtn="true"
  24 + v-if="isWebSocketType === '2'"
  25 + style="width: 40vw; height: 40vh"
  26 + ref="jsonWebsocketEditorRef"
  27 + />
  28 + <JsonEditor
  29 + :showBtn="true"
  30 + v-else
  31 + style="width: 40vw; height: 40vh"
  32 + ref="jsonEditorRef"
  33 + />
  34 + </div>
27 </a-col> 35 </a-col>
28 </a-row> 36 </a-row>
29 </div> 37 </div>
@@ -260,8 +268,8 @@ @@ -260,8 +268,8 @@
260 showTestFlag.value = false; 268 showTestFlag.value = false;
261 } 269 }
262 nextTick(() => { 270 nextTick(() => {
263 - jsonEditorRef.value?.setJsonValue('执行测试结果为:');  
264 - jsonWebsocketEditorRef.value?.setJsonValue('执行测试结果为:'); 271 + jsonEditorRef.value?.setJsonValue('测试结果为');
  272 + jsonWebsocketEditorRef.value?.setJsonValue('测试结果为');
265 }); 273 });
266 isWebSocketType.value = '0'; 274 isWebSocketType.value = '0';
267 }; 275 };
@@ -8,11 +8,6 @@ @@ -8,11 +8,6 @@
8 v-model:value="selectTenant" 8 v-model:value="selectTenant"
9 @change="onSelect" 9 @change="onSelect"
10 style="width: 150px" 10 style="width: 150px"
11 - :getPopupContainer="  
12 - (triggerNode) => {  
13 - return triggerNode.parentNode;  
14 - }  
15 - "  
16 placeholder="请选择租户" 11 placeholder="请选择租户"
17 :options="selectOptions" 12 :options="selectOptions"
18 /> 13 />
@@ -22,17 +17,12 @@ @@ -22,17 +17,12 @@
22 @change="onSelctTenant" 17 @change="onSelctTenant"
23 style="width: 150px; margin-left: 10px" 18 style="width: 150px; margin-left: 10px"
24 v-if="selectTenantOptions.length > 0" 19 v-if="selectTenantOptions.length > 0"
25 - :getPopupContainer="  
26 - (triggerNode) => {  
27 - return triggerNode.parentNode;  
28 - }  
29 - "  
30 placeholder="请选择租户" 20 placeholder="请选择租户"
31 :options="selectTenantOptions" 21 :options="selectTenantOptions"
32 /> 22 />
33 </div> 23 </div>
34 <Button 24 <Button
35 - :disabled="testDisabled" 25 + :disabled="isAdmin(role) ? testDisabled : false"
36 class="ml-2" 26 class="ml-2"
37 @click="handleTest(isSingleClickText)" 27 @click="handleTest(isSingleClickText)"
38 type="primary" 28 type="primary"
@@ -189,6 +189,11 @@ export const schemas: FormSchema[] = [ @@ -189,6 +189,11 @@ export const schemas: FormSchema[] = [
189 component: 'Input', 189 component: 'Input',
190 slot: 'slotFillAddress', 190 slot: 'slotFillAddress',
191 colProps: { span: 24 }, 191 colProps: { span: 24 },
  192 + ifShow: ({ values }) => {
  193 + if (values['requestOriginUrl']) {
  194 + return true;
  195 + } else return false;
  196 + },
192 }, 197 },
193 { 198 {
194 field: 'requestSQLKey', 199 field: 'requestSQLKey',
@@ -135,7 +135,7 @@ export const list = [ @@ -135,7 +135,7 @@ export const list = [
135 { 135 {
136 deviceType: '网关/直连设备', 136 deviceType: '网关/直连设备',
137 function: '设备端请求服务端共享属性及客户端属性', 137 function: '设备端请求服务端共享属性及客户端属性',
138 - release: 'v1/devices/me/attributes/response/$request_id', 138 + release: 'v1/devices/me/attributes/request/$request_id',
139 subscribe: 'v1/devices/me/attributes/response/+', 139 subscribe: 'v1/devices/me/attributes/response/+',
140 platform: '订阅', 140 platform: '订阅',
141 device: '发布', 141 device: '发布',
@@ -44,21 +44,23 @@ @@ -44,21 +44,23 @@
44 const selectOptions: any = ref([]); 44 const selectOptions: any = ref([]);
45 //获取对应设备属性 45 //获取对应设备属性
46 const getAttr = async (orgId, _) => { 46 const getAttr = async (orgId, _) => {
47 - const res = await getAttribute(orgId);  
48 - if (Array.isArray(res)) {  
49 - selectOptions.value = res.map((o) => {  
50 - let obj: any = {};  
51 - if (o?.identifier !== null) {  
52 - obj = {  
53 - label: o?.identifier,  
54 - value: o?.identifier,  
55 - };  
56 - return obj;  
57 - }  
58 - });  
59 - //如果服务端返回的数组里含有null 过滤null值  
60 - const excludeNull = selectOptions.value.filter(Boolean);  
61 - selectOptions.value = excludeNull; 47 + if (orgId) {
  48 + const res = await getAttribute(orgId);
  49 + if (Array.isArray(res)) {
  50 + selectOptions.value = res.map((o) => {
  51 + let obj: any = {};
  52 + if (o?.identifier !== null) {
  53 + obj = {
  54 + label: o?.identifier,
  55 + value: o?.identifier,
  56 + };
  57 + return obj;
  58 + }
  59 + });
  60 + //如果服务端返回的数组里含有null 过滤null值
  61 + const excludeNull = selectOptions.value.filter(Boolean);
  62 + selectOptions.value = excludeNull;
  63 + }
62 } 64 }
63 }; 65 };
64 //动态数据 66 //动态数据