Commit c7743adbfe5d9cc7392c93a121cfb8b06c05100b

Authored by xp.Huang
2 parents 987fffa0 cc379604

Merge branch 'main_dev' into 'main'

thingskit1.1.0

See merge request yunteng/thingskit-front!588
Showing 24 changed files with 178 additions and 160 deletions
... ... @@ -217,5 +217,6 @@ export const defHttp = createAxios();
217 217 export const otherHttp = createAxios({
218 218 requestOptions: {
219 219 apiUrl: 'xxx',
  220 + withToken: false,
220 221 },
221 222 });
... ...
... ... @@ -27,9 +27,9 @@
27 27 import { ShareModal } from '/@/views/common/ShareModal';
28 28 import { ViewTypeNameEnum } from '../../common/ShareModal/config';
29 29 import { useModal } from '/@/components/Modal';
30   - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
31 30 import { ViewType } from '../../visual/board/config/panelDetail';
32 31 import { useRole } from '/@/hooks/business/useRole';
  32 + import { useClipboard } from '@vueuse/core';
33 33
34 34 const listColumn = ref(5);
35 35
... ... @@ -167,12 +167,12 @@
167 167 return `${origin}${configurationPrefix}/?${searchParams.toString()}`;
168 168 };
169 169
170   - const { clipboardRef, isSuccessRef } = useCopyToClipboard();
171   - const handleCreateShareUrl = (record: ConfigurationCenterItemsModal) => {
  170 + const { copied, copy } = useClipboard();
  171 + const handleCreateShareUrl = async (record: ConfigurationCenterItemsModal) => {
172 172 if (!unref(getShareFlag)) return;
173 173 const url = createShareUrl(record);
174   - clipboardRef.value = url;
175   - if (unref(isSuccessRef)) {
  174 + await copy(url);
  175 + if (unref(copied)) {
176 176 createMessage.success('复制成功~');
177 177 }
178 178 };
... ...
... ... @@ -28,11 +28,11 @@
28 28 import { useModal } from '/@/components/Modal';
29 29 import { ShareModal } from '/@/views/common/ShareModal';
30 30 import { ViewTypeNameEnum } from '../common/ShareModal/config';
31   - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
32 31 import { ViewType } from '../visual/board/config/panelDetail';
33 32 import { useUserStore } from '/@/store/modules/user';
34 33 import { RoleEnum } from '/@/enums/roleEnum';
35 34 import { useRole } from '/@/hooks/business/useRole';
  35 + import { useClipboard } from '@vueuse/core';
36 36
37 37 const listColumn = ref(5);
38 38
... ... @@ -182,10 +182,10 @@
182 182 return userStore.getUserInfo.roles![0] !== RoleEnum.CUSTOMER_USER;
183 183 });
184 184
185   - const { clipboardRef, isSuccessRef } = useCopyToClipboard();
186   - const handleCreateShareUrl = (record: BigScreenCenterItemsModel) => {
187   - clipboardRef.value = createShareUrl(record);
188   - if (unref(isSuccessRef)) {
  185 + const { copied, copy } = useClipboard();
  186 + const handleCreateShareUrl = async (record: BigScreenCenterItemsModel) => {
  187 + await copy(createShareUrl(record));
  188 + if (unref(copied)) {
189 189 createMessage.success('复制成功~');
190 190 }
191 191 };
... ...
... ... @@ -38,7 +38,7 @@
38 38 </template>
39 39 <script lang="ts" setup name="body">
40 40 import { reactive, ref, nextTick } from 'vue';
41   - import { RequestBodyTypeEnum } from '../../../enum/index';
  41 + import { RequestBodyTypeEnum } from '../../../config/enum';
42 42 import BodyTable from './bodyTable.vue';
43 43 import { isEmpty } from '/@/utils/is';
44 44 import { useUtils } from '../../../hooks/useUtils';
... ...
... ... @@ -59,8 +59,8 @@
59 59 import { Select, Button } from 'ant-design-vue';
60 60 import { findDictItemByCode } from '/@/api/system/dict';
61 61 import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue';
62   - import { editCellTableTHeadConfig } from '../../../config';
63   - import { selectType, tableItems } from '../../../types';
  62 + import { editCellTableTHeadConfig } from '../../../config/config';
  63 + import { selectType, tableItems } from '../../../config/types';
64 64
65 65 defineProps({
66 66 method: {
... ...
... ... @@ -40,9 +40,8 @@
40 40 import { reactive, nextTick } from 'vue';
41 41 import { Button } from 'ant-design-vue';
42 42 import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue';
43   - import { editTestCellTableTHeaderConfig } from '../../../config';
44   - import { tableItems } from '../../../types';
45   -
  43 + import { editTestCellTableTHeaderConfig } from '../../../config/config';
  44 + import { tableItems } from '../../../config/types';
46 45 defineProps({
47 46 method: {
48 47 type: String,
... ...
... ... @@ -78,8 +78,8 @@
78 78 import { Select, Button } from 'ant-design-vue';
79 79 import { findDictItemByCode } from '/@/api/system/dict';
80 80 import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue';
81   - import { editCellTableTHeadConfig } from '../../../config';
82   - import { selectType, tableItems } from '../../../types';
  81 + import { editCellTableTHeadConfig } from '../../../config/config';
  82 + import { selectType, tableItems } from '../../../config/types';
83 83 import { useModal, BasicModal } from '/@/components/Modal';
84 84 import DateRangeSelect from './DateRangeSelect/index.vue';
85 85
... ...
... ... @@ -58,7 +58,7 @@
58 58 import JsonEditor from '../../SimpleRequest/components/jsonEditor.vue';
59 59 import { useMessage } from '/@/hooks/web/useMessage';
60 60 import { getTenantAllPageLists, getTenantPageList } from '/@/api/tenant/tenantApi';
61   - import { selectType } from '../../../types';
  61 + import { selectType } from '../../../config/types';
62 62 import { Select } from 'ant-design-vue';
63 63 import { getUserToken } from '/@/api/sys/user';
64 64 import { USER_INFO_KEY } from '/@/enums/cacheEnum';
... ...
... ... @@ -133,8 +133,8 @@
133 133 import { useApi } from '../../../hooks/useApi';
134 134 import { useUtils } from '../../../hooks/useUtils';
135 135 import { cloneDeep } from 'lodash-es';
136   - import { tableItems, selectType } from '../../../types';
137   - import { editTestCellTableTHeadConfig } from '../../../config';
  136 + import { tableItems, selectType } from '../../../config/types';
  137 + import { editTestCellTableTHeadConfig } from '../../../config/config';
138 138 import { QuestionCircleOutlined } from '@ant-design/icons-vue';
139 139
140 140 const props = defineProps({
... ...
... ... @@ -46,7 +46,7 @@
46 46 import { Button } from 'ant-design-vue';
47 47 import TestHeaderEditCellTable from './testEditHeaderCellTable.vue';
48 48 import { useMessage } from '/@/hooks/web/useMessage';
49   - import { selectType } from '../../../types';
  49 + import { selectType } from '../../../config/types';
50 50 import { Select } from 'ant-design-vue';
51 51 import { getUserToken } from '/@/api/sys/user';
52 52 import { USER_INFO_KEY } from '/@/enums/cacheEnum';
... ...
... ... @@ -24,8 +24,8 @@
24 24 <script lang="ts" setup name="editCellTable">
25 25 import { reactive } from 'vue';
26 26 import { cloneDeep } from 'lodash-es';
27   - import { tableItems } from '../../../types';
28   - import { editTestCellTableTHeadConfig } from '../../../config';
  27 + import { tableItems } from '../../../config/types';
  28 + import { editTestCellTableTHeadConfig } from '../../../config/config';
29 29
30 30 defineProps({
31 31 method: {
... ...
... ... @@ -49,7 +49,7 @@
49 49 import { useUtils } from '../../../hooks/useUtils';
50 50 import { useMessage } from '/@/hooks/web/useMessage';
51 51 import { getTenantAllPageLists, getTenantPageList } from '/@/api/tenant/tenantApi';
52   - import { selectType } from '../../../types';
  52 + import { selectType } from '../../../config/types';
53 53 import { Select } from 'ant-design-vue';
54 54 import { getUserToken } from '/@/api/sys/user';
55 55 import { USER_INFO_KEY } from '/@/enums/cacheEnum';
... ...
... ... @@ -174,8 +174,8 @@
174 174 import { useApi } from '../../../hooks/useApi';
175 175 import { useUtils } from '../../../hooks/useUtils';
176 176 import { cloneDeep } from 'lodash-es';
177   - import { tableItems, selectType } from '../../../types';
178   - import { editTestCellTableTHeadConfig } from '../../../config';
  177 + import { tableItems, selectType } from '../../../config/types';
  178 + import { editTestCellTableTHeadConfig } from '../../../config/config';
179 179 import { QuestionCircleOutlined } from '@ant-design/icons-vue';
180 180 import moment from 'moment';
181 181 import { AggregateDataEnum } from '/@/views/report/config/timeConfig';
... ...
src/views/dataview/publicApi/config/config.ts renamed from src/views/dataview/publicApi/config.ts
... ... @@ -5,6 +5,8 @@ import { findDictItemByCode } from '/@/api/system/dict';
5 5 import { USER_INFO_KEY } from '/@/enums/cacheEnum';
6 6 import { getAuthCache } from '/@/utils/auth';
7 7 import { isAdmin } from '/@/enums/roleEnum';
  8 +import { defaultField } from './constants';
  9 +import { useUtils } from '../hooks/useUtils';
8 10
9 11 // 表格配置
10 12 export const columns: BasicColumn[] = [
... ... @@ -116,24 +118,6 @@ export const schemas: FormSchema[] = [
116 118 placeholder: '请输入接口名称',
117 119 },
118 120 },
119   - // {
120   - // field: 'interfaceType',
121   - // component: 'ApiRadioGroup',
122   - // label: '接口类型',
123   - // required: true,
124   - // colProps: {
125   - // span: 8,
126   - // },
127   - // defaultValue: 'SYSTEM',
128   - // componentProps: {
129   - // api: findDictItemByCode,
130   - // params: {
131   - // dictCode: 'interface_Type',
132   - // },
133   - // labelField: 'itemText',
134   - // valueField: 'itemValue',
135   - // },
136   - // },
137 121 {
138 122 field: 'interfaceType',
139 123 component: 'ApiRadioGroup',
... ... @@ -144,19 +128,15 @@ export const schemas: FormSchema[] = [
144 128 },
145 129 defaultValue: 'CUSTOM',
146 130 componentProps: {
147   - options: [
148   - {
149   - label: '系统默认',
150   - value: 'SYSTEM',
151   - },
152   - {
153   - label: '自定义',
154   - value: 'CUSTOM',
155   - },
156   - ],
  131 + api: findDictItemByCode,
  132 + params: {
  133 + dictCode: 'interface_Type',
  134 + },
  135 + labelField: 'itemText',
  136 + valueField: 'itemValue',
157 137 },
158 138 ifShow: ({}) => {
159   - const userInfo: any = getAuthCache(USER_INFO_KEY);
  139 + const userInfo = getAuthCache(USER_INFO_KEY) as any;
160 140 const role: string = userInfo?.roles[0];
161 141 if (isAdmin(role)) return true;
162 142 else return false;
... ... @@ -180,14 +160,11 @@ export const schemas: FormSchema[] = [
180 160 labelField: 'itemText',
181 161 valueField: 'itemValue',
182 162 getPopupContainer: () => document.body,
183   - async onChange(e) {
184   - setFieldsValue({
185   - requestOriginUrl: '',
186   - requestHttpTypeAndUrl: {
187   - requestHttpType: undefined,
188   - requestUrl: '',
189   - },
190   - });
  163 + onChange(e) {
  164 + if (!e) return;
  165 + const { usePlaceholder } = useUtils();
  166 + const setDefaultPlaceholder = usePlaceholder(e);
  167 + setFieldsValue(defaultField);
191 168 updateSchema({
192 169 field: 'requestHttpTypeAndUrl',
193 170 componentProps: {
... ... @@ -197,9 +174,7 @@ export const schemas: FormSchema[] = [
197 174 updateSchema({
198 175 field: 'requestOriginUrl',
199 176 componentProps: {
200   - placeholder: `${
201   - e === '0' ? '示例:http://127.0.0.1' : e === '2' ? '示例:ws://127.0.0.1' : ''
202   - }`,
  177 + placeholder: setDefaultPlaceholder,
203 178 },
204 179 });
205 180 },
... ... @@ -224,11 +199,10 @@ export const schemas: FormSchema[] = [
224 199 labelField: 'itemText',
225 200 valueField: 'itemValue',
226 201 onChange: (e) => {
227   - if (e) {
228   - setFieldsValue({
229   - requestOriginUrl: '',
230   - });
231   - }
  202 + if (!e) return;
  203 + setFieldsValue({
  204 + requestOriginUrl: '',
  205 + });
232 206 },
233 207 };
234 208 },
... ... @@ -242,10 +216,9 @@ export const schemas: FormSchema[] = [
242 216 componentProps: ({ formActionType }) => {
243 217 const { getFieldsValue } = formActionType;
244 218 const type = getFieldsValue()?.requestContentType;
  219 + const { usePlaceholder } = useUtils();
245 220 return {
246   - placeholder: `${
247   - type === '0' ? '示例:http://127.0.0.1' : type === '2' ? '示例:ws://127.0.0.1' : ''
248   - }`,
  221 + placeholder: usePlaceholder(type),
249 222 };
250 223 },
251 224 ifShow: ({ values }) => values['originUrlType'] === 'custom_url',
... ...
  1 +///公共接口管理所需常量值
  2 +
  3 +import { RequestOriginTypeEnum } from './enum';
  4 +
  5 +export const commonHttpPlaceHolder = '示例:http://127.0.0.1';
  6 +
  7 +export const websocketPlaceHolder = '示例:ws://127.0.0.1';
  8 +
  9 +export const defaultField = {
  10 + originUrlType: RequestOriginTypeEnum.SERVER_URL,
  11 + requestOriginUrl: '',
  12 + requestHttpTypeAndUrl: {
  13 + requestHttpType: undefined,
  14 + requestUrl: '',
  15 + },
  16 +};
... ...
src/views/dataview/publicApi/config/enum/index.ts renamed from src/views/dataview/publicApi/enum/index.ts
  1 +///公共接口管理所需枚举值
  2 +
1 3 /**
2 4 * @description: 请求体类型
3 5 */
... ... @@ -8,3 +10,20 @@ export enum RequestBodyTypeEnum {
8 10 JSON = 'json',
9 11 XML = 'xml',
10 12 }
  13 +
  14 +/**
  15 + * @description: 请求方式
  16 + */
  17 +export enum RequestMethodTypeEnum {
  18 + COMMOM = '0',
  19 + WEBSOCKET = '2',
  20 + SQL = '1',
  21 +}
  22 +
  23 +/**
  24 + * @description: 源地址类型
  25 + */
  26 +export enum RequestOriginTypeEnum {
  27 + CUSTOM_URL = 'custom_url',
  28 + SERVER_URL = 'server_url',
  29 +}
... ...
src/views/dataview/publicApi/config/types/index.ts renamed from src/views/dataview/publicApi/types/index.ts
... ... @@ -69,7 +69,7 @@
69 69 import { ref, nextTick, watch } from 'vue';
70 70 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
71 71 import { BasicForm, useForm } from '/@/components/Form';
72   - import { schemas } from './config';
  72 + import { schemas } from './config/config';
73 73 import SimpleRequest from './components/SimpleRequest/index.vue';
74 74 import { TestSql } from './components/TestSql/index';
75 75 import {
... ...
  1 +import { commonHttpPlaceHolder, websocketPlaceHolder } from '../config/constants';
  2 +import { RequestMethodTypeEnum } from '../config/enum';
1 3 import { otherHttp } from '/@/utils/http/axios';
2 4
3 5 export const useUtils = () => {
... ... @@ -16,6 +18,7 @@ export const useUtils = () => {
16 18 });
17 19 return temps;
18 20 };
  21 +
19 22 //默认push一个
20 23 const pushObj = {
21 24 key: undefined,
... ... @@ -25,6 +28,7 @@ export const useUtils = () => {
25 28 date1: '',
26 29 date2: '',
27 30 };
  31 +
28 32 //新增时置空特定数据
29 33 const resetReqHttpType = {
30 34 requestHttpTypeAndUrl: {
... ... @@ -38,6 +42,7 @@ export const useUtils = () => {
38 42 type: '0',
39 43 },
40 44 };
  45 +
41 46 //对象转get params参数
42 47 const convertObj = (data: object) => {
43 48 const _result: any = [];
... ... @@ -53,22 +58,26 @@ export const useUtils = () => {
53 58 }
54 59 return _result.join('&');
55 60 };
  61 +
56 62 //判断服务器地址是否为http/https ws/wss
57 63 const isServerUrl = (method, type) => {
58 64 const pathUrl = window.location.host;
59 65 const protocol = window.location.protocol;
60 66 let url = '';
61   - if (method === '2') {
  67 + if (method === RequestMethodTypeEnum.WEBSOCKET) {
62 68 if (type === 'server_url') {
63   - url = `${protocol === 'http' ? 'ws:' : protocol === 'https' ? 'wss:' : 'ws:'}//${pathUrl}`;
  69 + url = `${
  70 + protocol === 'http:' ? 'ws:' : protocol === 'https:' ? 'wss:' : 'ws:'
  71 + }//${pathUrl}`;
64 72 }
65   - } else if (method === '0') {
  73 + } else if (method === RequestMethodTypeEnum.COMMOM) {
66 74 if (type === 'server_url') {
67 75 url = `${protocol}//${pathUrl}`;
68 76 }
69 77 }
70 78 return url;
71 79 };
  80 +
72 81 //TODO:待优化自定义请求
73 82 const isOtherHttp = async (url, token, params) => {
74 83 return await otherHttp.get(
... ... @@ -84,6 +93,17 @@ export const useUtils = () => {
84 93 }
85 94 );
86 95 };
  96 +
  97 + //请求方式切换动态更新源地址placeholder
  98 + const usePlaceholder = (type) =>
  99 + `${
  100 + type === RequestMethodTypeEnum.COMMOM
  101 + ? commonHttpPlaceHolder
  102 + : type === RequestMethodTypeEnum.WEBSOCKET
  103 + ? websocketPlaceHolder
  104 + : ''
  105 + }`;
  106 +
87 107 return {
88 108 getMultipleKeys,
89 109 pushObj,
... ... @@ -92,5 +112,6 @@ export const useUtils = () => {
92 112 isServerUrl,
93 113 convertObj,
94 114 isOtherHttp,
  115 + usePlaceholder,
95 116 };
96 117 };
... ...
... ... @@ -85,7 +85,7 @@
85 85 import { h, ref } from 'vue';
86 86 import { BasicTable, useTable, TableAction } from '/@/components/Table';
87 87 import { useDrawer } from '/@/components/Drawer';
88   - import { columns, searchFormSchema } from './config';
  88 + import { columns, searchFormSchema } from './config/config';
89 89 import { PublicApiForm } from './index';
90 90 import {
91 91 getDataViewInterfacePage,
... ...
... ... @@ -112,7 +112,7 @@ export const step1Schemas: FormSchema[] = [
112 112 component: 'Input',
113 113 componentProps: {
114 114 maxLength: 255,
115   - placeholder: '请输入设备标识',
  115 + placeholder: '请输入设备标识或设备地址码',
116 116 },
117 117 ifShow: ({ values }) =>
118 118 values?.transportType === TransportTypeEnum.TCP &&
... ... @@ -154,7 +154,15 @@ export const step1Schemas: FormSchema[] = [
154 154 const { organizationId, transportType } = formModel;
155 155 if (![organizationId, transportType].every(Boolean)) return {};
156 156 return {
157   - api: getGatewayDevice,
  157 + api: async (params: Recordable) => {
  158 + try {
  159 + const result = await getGatewayDevice(params as any);
  160 + return result.map((item) => ({ ...item, alias: item.alias || item.name }));
  161 + } catch (e) {
  162 + console.error(e);
  163 + return [];
  164 + }
  165 + },
158 166 showSearch: true,
159 167 params: {
160 168 organizationId,
... ...
... ... @@ -51,11 +51,20 @@
51 51 <template #extra>
52 52 <Button
53 53 v-show="ifAdd && !view"
  54 + @click="onHandleTestExampleGateway(scriptForm.scriptType)"
  55 + style="position: relative; top: -4rem; right: -6.6rem"
  56 + type="primary"
  57 + >
  58 + 直连/子设备用例</Button
  59 + >
  60 + <Button
  61 + class="ml-2"
  62 + v-show="ifAdd && !view"
54 63 @click="onHandleTestExample(scriptForm.scriptType)"
55 64 style="position: relative; top: -4rem; right: -6.6rem"
56 65 type="primary"
57 66 >
58   - 测试用例</Button
  67 + 网关用例</Button
59 68 >
60 69 <a-button @click="handleFormat" size="small">格式化</a-button>
61 70 <Tooltip
... ... @@ -120,6 +129,7 @@
120 129 defaultScriptTypeContent,
121 130 defaultTestUpExample,
122 131 defaultTestAuthExample,
  132 + defaultTestSubGatewayUpExample,
123 133 } from './config.data';
124 134 import { useAppStore } from '/@/store/modules/app';
125 135 import TestScriptModal from './TestScriptModal.vue';
... ... @@ -220,6 +230,14 @@
220 230 handleFormat();
221 231 };
222 232
  233 + const onHandleTestExampleGateway = (example) => {
  234 + if (example === 'TRANSPORT_TCP_UP') {
  235 + aceEditor.value?.setValue(defaultTestSubGatewayUpExample);
  236 + } else {
  237 + aceEditor.value?.setValue(defaultTestAuthExample);
  238 + }
  239 + handleFormat();
  240 + };
223 241 const handleCopy = () => {
224 242 const valueRef = aceEditor.value.getValue();
225 243 const value = unref(valueRef);
... ...
... ... @@ -86,88 +86,51 @@ export const defaultUpTitle = h('div', { style: 'background:#404040' }, [
86 86
87 87 // TRANSPORT_TCP_DOWN: 'out.datas = "";out.deviceName = "sensor";',
88 88 export const defaultScriptTypeContent = {
89   - TRANSPORT_TCP_UP: `var teleData = {};
90   -/*
91   -物模型数据(可选):原始数据
92   -*/
93   -teleData.source= params;
94   -/*
95   -直连/网关子设备设备:temperature是产品物模型中所定义属性的标识符
96   -*/
97   -tempVal = params;
98   -teleData.temperature= tempVal;
99   -/*
100   -网关设备:变量slaveDevice是网关子设备的“设备标识”
101   -*/
102   -slaveDevice = params.substr(0,2);
103   -teleData[slaveDevice]= params;
  89 + TRANSPORT_TCP_UP: `/*网关上行脚本*/
  90 +var teleData = {};
  91 +/*物模型数据(可选):原始数据*/
  92 +teleData.source = params;
  93 +/*网关设备:slaveDevice是网关子设备的“设备标识”*/
  94 +slaveDevice = params.substr(0, 2);
  95 +teleData[slaveDevice] = params;
104 96 out.datas = teleData;
105   -/*
106   -必填:true表示设备上报的遥测数据,false表示命令下发的响应数据
107   -*/
108 97 out.telemetry = true;
109   -/*
110   -必填:设备或命令下发的唯一标识,设备的唯一标识必须与设备信息的“设备名称”一致
111   -*/
112   -out.identifier = "01";
113   -/*
114   -可选:服务端收到设备数据后,响应的消息内容
115   -*/
116   -out.ackMsg = params;
117   -/*
118   -可选:默认使用服务器时间,可以使用数据内的时间
119   -*/
120   -out.ts = Date.now();`,
121   - TRANSPORT_TCP_AUTH: `/*
122   - 必填:设备的访问令牌
123   - */
124   - out.password = params;
125   - /*
126   - 选填:设备鉴权成功后响应给设备的信息
127   - */
128   - out.success = params;
  98 +/*必填:true表示设备上报的遥测数据,false表示命令下发的响应数据*/
  99 + `,
  100 + TRANSPORT_TCP_AUTH: `/*必填:设备的访问令牌*/
  101 +out.password = params;
  102 +/*选填:设备鉴权成功后响应给设备的信息*/
  103 +out.success = params;
129 104 `,
130 105 };
131 106
132   -export const defaultTestUpExample = `var teleData = {};
133   -/*
134   -物模型数据(可选):原始数据
135   -*/
  107 +export const defaultTestUpExample = `/*网关上行脚本*/
  108 +var teleData = {};
  109 +/*物模型数据(可选):原始数据*/
136 110 teleData.source= params;
137   -/*
138   -直连/网关子设备设备:temperature是产品物模型中所定义属性的标识符
139   -*/
140   -tempVal = params;
141   -teleData.temperature= tempVal;
142   -/*
143   -网关设备:变量slaveDevice是网关子设备的“设备标识”
144   -*/
  111 +/*网关设备:slaveDevice是网关子设备的“设备标识”*/
145 112 slaveDevice = params.substr(0,2);
146 113 teleData[slaveDevice]= params;
147 114 out.datas = teleData;
148   -/*
149   -必填:true表示设备上报的遥测数据,false表示命令下发的响应数据
150   -*/
151   -out.telemetry = true;
152   -/*
153   -必填:设备或命令下发的唯一标识,设备的唯一标识必须与设备信息的“设备名称”一致
154   -*/
155   -out.identifier = "01";
156   -/*
157   -可选:服务端收到设备数据后,响应的消息内容
158   -*/
159   -out.ackMsg = params;
160   -/*
161   -可选:默认使用服务器时间,可以使用数据内的时间
162   -*/
163   -out.ts = Date.now();`;
  115 +out.telemetry = true;/*必填:true表示设备上报的遥测数据,false表示命令下发的响应数据*/`;
164 116
165   -export const defaultTestAuthExample = `/*
166   - 必填:设备的访问令牌
167   - */
  117 +export const defaultTestAuthExample = `/*必填:设备的访问令牌*/
168 118 out.password = params;
169   -/*
170   - 选填:设备鉴权成功后响应给设备的信息
171   - */
  119 +/*选填:设备鉴权成功后响应给设备的信息*/
172 120 out.success = params;
173 121 `;
  122 +
  123 +export const defaultTestSubGatewayUpExample = `/*params为TCP上报的标准ModBus数据,实际使用或测试时请删除*/
  124 +var params = "010304026C00883BF0"
  125 +var teleData = {};
  126 +/*物模型数据(可选):原始数据*/
  127 +teleData.source = params;
  128 +/*直连设备:tempVal是产品物模型中所定义属性的标识符*/
  129 +tempVal = params;
  130 +/*物模型温度标识符*/
  131 +teleData.temperature = (parseInt('0x'+tempVal.substr(10, 4))*0.1).toFixed(2);
  132 +/*物模型湿度标识符*/
  133 +teleData.humidity = (parseInt('0x'+tempVal.substr(6, 4))*0.1).toFixed(2);
  134 +out.datas = teleData;
  135 +/*必填:true表示设备上报的遥测数据,false表示命令下发的响应数据*/
  136 +out.telemetry = true;`;
... ...
... ... @@ -3,7 +3,6 @@
3 3 import { onMounted, ref, unref } from 'vue';
4 4 import { PageWrapper } from '/@/components/Page';
5 5 import { MoreOutlined, ShareAltOutlined } from '@ant-design/icons-vue';
6   - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard';
7 6 import { useMessage } from '/@/hooks/web/useMessage';
8 7 import Dropdown from '/@/components/Dropdown/src/Dropdown.vue';
9 8 import { DropMenu } from '/@/components/Dropdown';
... ... @@ -25,6 +24,7 @@
25 24 import { ModalParamsType } from '/#/utils';
26 25 import { DataActionModeEnum } from '/@/enums/toolEnum';
27 26 import { useRole } from '/@/hooks/business/useRole';
  27 + import { useClipboard } from '@vueuse/core';
28 28
29 29 const ListItem = List.Item;
30 30 const router = useRouter();
... ... @@ -87,10 +87,10 @@
87 87 return `${origin}${DATA_BOARD_SHARE_URL(id, publicId)}`;
88 88 };
89 89
90   - const { clipboardRef } = useCopyToClipboard();
91   - const handleCopyShareUrl = (record: DataBoardRecord) => {
92   - clipboardRef.value = createShareUrl(record);
93   - unref(clipboardRef) ? createMessage.success('复制成功') : createMessage.error('未找到分享链接');
  90 + const { copied, copy } = useClipboard();
  91 + const handleCopyShareUrl = async (record: DataBoardRecord) => {
  92 + await copy(createShareUrl(record));
  93 + unref(copied) ? createMessage.success('复制成功') : createMessage.error('未找到分享链接');
94 94 };
95 95
96 96 const { isCustomerUser } = useRole();
... ...