Commit ede3dea5a852bbd48216facc681f64776edc590f
Merge branch 'ft' into 'main_dev'
pref: 调整Topic和公共接口管理 See merge request yunteng/thingskit-front!547
Showing
8 changed files
with
91 additions
and
61 deletions
| ... | ... | @@ -22,6 +22,7 @@ |
| 22 | 22 | v-show="getRequestBody.content.requestParamsBodyType === 'x-www-form-urlencoded'" |
| 23 | 23 | /> |
| 24 | 24 | <JsonEditor |
| 25 | + :showBtn="false" | |
| 25 | 26 | style="width: 35vw; height: 30vh" |
| 26 | 27 | v-show="getRequestBody.content.requestParamsBodyType === 'json'" |
| 27 | 28 | ref="jsonEditorRef" | ... | ... |
| 1 | 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 | 8 | </template> |
| 4 | 9 | |
| 5 | 10 | <script lang="ts" setup> |
| 6 | 11 | import { ref, onMounted, nextTick, unref } from 'vue'; |
| 7 | 12 | import jsoneditor from 'jsoneditor'; |
| 8 | 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 | 26 | // json 以及初始化JSON |
| 11 | 27 | const jsoneditorRef = ref(); |
| ... | ... | @@ -20,15 +36,15 @@ |
| 20 | 36 | mode: 'code', |
| 21 | 37 | mainMenuBar: false, |
| 22 | 38 | statusBar: false, |
| 23 | - onFocus: () => {}, | |
| 24 | - onBlur: () => { | |
| 25 | - setJsonValue('执行测试结果为:'); | |
| 39 | + onFocus: () => { | |
| 40 | + if (props.showBtn) { | |
| 41 | + setJsonValue('测试结果为'); | |
| 42 | + } | |
| 26 | 43 | }, |
| 44 | + onBlur: () => {}, | |
| 27 | 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 | 50 | } as object; |
| ... | ... | @@ -40,11 +56,11 @@ |
| 40 | 56 | |
| 41 | 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 | 65 | const setJsonValue = (Json) => { |
| 50 | 66 | nextTick(() => { |
| ... | ... | @@ -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 | 88 | defineExpose({ |
| 56 | 89 | getJsonValue, |
| 57 | 90 | setJsonValue, |
| 58 | 91 | jsonInstance, |
| 92 | + setJsonMode, | |
| 59 | 93 | }); |
| 60 | 94 | </script> |
| 61 | 95 | ... | ... |
| ... | ... | @@ -8,11 +8,6 @@ |
| 8 | 8 | allowClear |
| 9 | 9 | @change="onSelect" |
| 10 | 10 | style="width: 150px" |
| 11 | - :getPopupContainer=" | |
| 12 | - (triggerNode) => { | |
| 13 | - return triggerNode.parentNode; | |
| 14 | - } | |
| 15 | - " | |
| 16 | 11 | placeholder="请选择租户" |
| 17 | 12 | :options="selectOptions" |
| 18 | 13 | /> |
| ... | ... | @@ -22,17 +17,12 @@ |
| 22 | 17 | @change="onSelctTenant" |
| 23 | 18 | style="width: 150px; margin-left: 10px" |
| 24 | 19 | v-if="selectTenantOptions.length > 0" |
| 25 | - :getPopupContainer=" | |
| 26 | - (triggerNode) => { | |
| 27 | - return triggerNode.parentNode; | |
| 28 | - } | |
| 29 | - " | |
| 30 | 20 | placeholder="请选择租户" |
| 31 | 21 | :options="selectTenantOptions" |
| 32 | 22 | /> |
| 33 | 23 | </div> |
| 34 | 24 | <Button |
| 35 | - :disabled="testDisabled" | |
| 25 | + :disabled="isAdmin(role) ? testDisabled : false" | |
| 36 | 26 | class="ml-2" |
| 37 | 27 | @click="handleTest(isSingleClickText)" |
| 38 | 28 | type="primary" |
| ... | ... | @@ -47,7 +37,7 @@ |
| 47 | 37 | <TestBodyCellTable :token="getToken" ref="testEditCellTableRef" /> |
| 48 | 38 | </div> |
| 49 | 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 | 41 | </div> |
| 52 | 42 | <div style="width: 30vw" v-else-if="data?.type === 'xml'"> |
| 53 | 43 | <a-textarea v-model:value="xmlContent" placeholder="请输入xml" :rows="6" /> | ... | ... |
| ... | ... | @@ -16,14 +16,22 @@ |
| 16 | 16 | </div> |
| 17 | 17 | </div> |
| 18 | 18 | <div class="mt-8"> |
| 19 | - <a-row type="flex" justify="center"> | |
| 19 | + <a-row type="flex" justify="space-between" align="middle"> | |
| 20 | 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 | 35 | </a-col> |
| 28 | 36 | </a-row> |
| 29 | 37 | </div> |
| ... | ... | @@ -260,8 +268,8 @@ |
| 260 | 268 | showTestFlag.value = false; |
| 261 | 269 | } |
| 262 | 270 | nextTick(() => { |
| 263 | - jsonEditorRef.value?.setJsonValue('执行测试结果为:'); | |
| 264 | - jsonWebsocketEditorRef.value?.setJsonValue('执行测试结果为:'); | |
| 271 | + jsonEditorRef.value?.setJsonValue('测试结果为'); | |
| 272 | + jsonWebsocketEditorRef.value?.setJsonValue('测试结果为'); | |
| 265 | 273 | }); |
| 266 | 274 | isWebSocketType.value = '0'; |
| 267 | 275 | }; | ... | ... |
| ... | ... | @@ -8,11 +8,6 @@ |
| 8 | 8 | v-model:value="selectTenant" |
| 9 | 9 | @change="onSelect" |
| 10 | 10 | style="width: 150px" |
| 11 | - :getPopupContainer=" | |
| 12 | - (triggerNode) => { | |
| 13 | - return triggerNode.parentNode; | |
| 14 | - } | |
| 15 | - " | |
| 16 | 11 | placeholder="请选择租户" |
| 17 | 12 | :options="selectOptions" |
| 18 | 13 | /> |
| ... | ... | @@ -22,17 +17,12 @@ |
| 22 | 17 | @change="onSelctTenant" |
| 23 | 18 | style="width: 150px; margin-left: 10px" |
| 24 | 19 | v-if="selectTenantOptions.length > 0" |
| 25 | - :getPopupContainer=" | |
| 26 | - (triggerNode) => { | |
| 27 | - return triggerNode.parentNode; | |
| 28 | - } | |
| 29 | - " | |
| 30 | 20 | placeholder="请选择租户" |
| 31 | 21 | :options="selectTenantOptions" |
| 32 | 22 | /> |
| 33 | 23 | </div> |
| 34 | 24 | <Button |
| 35 | - :disabled="testDisabled" | |
| 25 | + :disabled="isAdmin(role) ? testDisabled : false" | |
| 36 | 26 | class="ml-2" |
| 37 | 27 | @click="handleTest(isSingleClickText)" |
| 38 | 28 | type="primary" | ... | ... |
| ... | ... | @@ -189,6 +189,11 @@ export const schemas: FormSchema[] = [ |
| 189 | 189 | component: 'Input', |
| 190 | 190 | slot: 'slotFillAddress', |
| 191 | 191 | colProps: { span: 24 }, |
| 192 | + ifShow: ({ values }) => { | |
| 193 | + if (values['requestOriginUrl']) { | |
| 194 | + return true; | |
| 195 | + } else return false; | |
| 196 | + }, | |
| 192 | 197 | }, |
| 193 | 198 | { |
| 194 | 199 | field: 'requestSQLKey', | ... | ... |
| ... | ... | @@ -135,7 +135,7 @@ export const list = [ |
| 135 | 135 | { |
| 136 | 136 | deviceType: '网关/直连设备', |
| 137 | 137 | function: '设备端请求服务端共享属性及客户端属性', |
| 138 | - release: 'v1/devices/me/attributes/response/$request_id', | |
| 138 | + release: 'v1/devices/me/attributes/request/$request_id', | |
| 139 | 139 | subscribe: 'v1/devices/me/attributes/response/+', |
| 140 | 140 | platform: '订阅', |
| 141 | 141 | device: '发布', | ... | ... |
| ... | ... | @@ -44,21 +44,23 @@ |
| 44 | 44 | const selectOptions: any = ref([]); |
| 45 | 45 | //获取对应设备属性 |
| 46 | 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 | //动态数据 | ... | ... |