Commit c7743adbfe5d9cc7392c93a121cfb8b06c05100b
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,5 +217,6 @@ export const defHttp = createAxios(); | ||
217 | export const otherHttp = createAxios({ | 217 | export const otherHttp = createAxios({ |
218 | requestOptions: { | 218 | requestOptions: { |
219 | apiUrl: 'xxx', | 219 | apiUrl: 'xxx', |
220 | + withToken: false, | ||
220 | }, | 221 | }, |
221 | }); | 222 | }); |
@@ -27,9 +27,9 @@ | @@ -27,9 +27,9 @@ | ||
27 | import { ShareModal } from '/@/views/common/ShareModal'; | 27 | import { ShareModal } from '/@/views/common/ShareModal'; |
28 | import { ViewTypeNameEnum } from '../../common/ShareModal/config'; | 28 | import { ViewTypeNameEnum } from '../../common/ShareModal/config'; |
29 | import { useModal } from '/@/components/Modal'; | 29 | import { useModal } from '/@/components/Modal'; |
30 | - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; | ||
31 | import { ViewType } from '../../visual/board/config/panelDetail'; | 30 | import { ViewType } from '../../visual/board/config/panelDetail'; |
32 | import { useRole } from '/@/hooks/business/useRole'; | 31 | import { useRole } from '/@/hooks/business/useRole'; |
32 | + import { useClipboard } from '@vueuse/core'; | ||
33 | 33 | ||
34 | const listColumn = ref(5); | 34 | const listColumn = ref(5); |
35 | 35 | ||
@@ -167,12 +167,12 @@ | @@ -167,12 +167,12 @@ | ||
167 | return `${origin}${configurationPrefix}/?${searchParams.toString()}`; | 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 | if (!unref(getShareFlag)) return; | 172 | if (!unref(getShareFlag)) return; |
173 | const url = createShareUrl(record); | 173 | const url = createShareUrl(record); |
174 | - clipboardRef.value = url; | ||
175 | - if (unref(isSuccessRef)) { | 174 | + await copy(url); |
175 | + if (unref(copied)) { | ||
176 | createMessage.success('复制成功~'); | 176 | createMessage.success('复制成功~'); |
177 | } | 177 | } |
178 | }; | 178 | }; |
@@ -28,11 +28,11 @@ | @@ -28,11 +28,11 @@ | ||
28 | import { useModal } from '/@/components/Modal'; | 28 | import { useModal } from '/@/components/Modal'; |
29 | import { ShareModal } from '/@/views/common/ShareModal'; | 29 | import { ShareModal } from '/@/views/common/ShareModal'; |
30 | import { ViewTypeNameEnum } from '../common/ShareModal/config'; | 30 | import { ViewTypeNameEnum } from '../common/ShareModal/config'; |
31 | - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; | ||
32 | import { ViewType } from '../visual/board/config/panelDetail'; | 31 | import { ViewType } from '../visual/board/config/panelDetail'; |
33 | import { useUserStore } from '/@/store/modules/user'; | 32 | import { useUserStore } from '/@/store/modules/user'; |
34 | import { RoleEnum } from '/@/enums/roleEnum'; | 33 | import { RoleEnum } from '/@/enums/roleEnum'; |
35 | import { useRole } from '/@/hooks/business/useRole'; | 34 | import { useRole } from '/@/hooks/business/useRole'; |
35 | + import { useClipboard } from '@vueuse/core'; | ||
36 | 36 | ||
37 | const listColumn = ref(5); | 37 | const listColumn = ref(5); |
38 | 38 | ||
@@ -182,10 +182,10 @@ | @@ -182,10 +182,10 @@ | ||
182 | return userStore.getUserInfo.roles![0] !== RoleEnum.CUSTOMER_USER; | 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 | createMessage.success('复制成功~'); | 189 | createMessage.success('复制成功~'); |
190 | } | 190 | } |
191 | }; | 191 | }; |
@@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
38 | </template> | 38 | </template> |
39 | <script lang="ts" setup name="body"> | 39 | <script lang="ts" setup name="body"> |
40 | import { reactive, ref, nextTick } from 'vue'; | 40 | import { reactive, ref, nextTick } from 'vue'; |
41 | - import { RequestBodyTypeEnum } from '../../../enum/index'; | 41 | + import { RequestBodyTypeEnum } from '../../../config/enum'; |
42 | import BodyTable from './bodyTable.vue'; | 42 | import BodyTable from './bodyTable.vue'; |
43 | import { isEmpty } from '/@/utils/is'; | 43 | import { isEmpty } from '/@/utils/is'; |
44 | import { useUtils } from '../../../hooks/useUtils'; | 44 | import { useUtils } from '../../../hooks/useUtils'; |
@@ -59,8 +59,8 @@ | @@ -59,8 +59,8 @@ | ||
59 | import { Select, Button } from 'ant-design-vue'; | 59 | import { Select, Button } from 'ant-design-vue'; |
60 | import { findDictItemByCode } from '/@/api/system/dict'; | 60 | import { findDictItemByCode } from '/@/api/system/dict'; |
61 | import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue'; | 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 | defineProps({ | 65 | defineProps({ |
66 | method: { | 66 | method: { |
@@ -40,9 +40,8 @@ | @@ -40,9 +40,8 @@ | ||
40 | import { reactive, nextTick } from 'vue'; | 40 | import { reactive, nextTick } from 'vue'; |
41 | import { Button } from 'ant-design-vue'; | 41 | import { Button } from 'ant-design-vue'; |
42 | import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue'; | 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 | defineProps({ | 45 | defineProps({ |
47 | method: { | 46 | method: { |
48 | type: String, | 47 | type: String, |
@@ -78,8 +78,8 @@ | @@ -78,8 +78,8 @@ | ||
78 | import { Select, Button } from 'ant-design-vue'; | 78 | import { Select, Button } from 'ant-design-vue'; |
79 | import { findDictItemByCode } from '/@/api/system/dict'; | 79 | import { findDictItemByCode } from '/@/api/system/dict'; |
80 | import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue'; | 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 | import { useModal, BasicModal } from '/@/components/Modal'; | 83 | import { useModal, BasicModal } from '/@/components/Modal'; |
84 | import DateRangeSelect from './DateRangeSelect/index.vue'; | 84 | import DateRangeSelect from './DateRangeSelect/index.vue'; |
85 | 85 |
@@ -58,7 +58,7 @@ | @@ -58,7 +58,7 @@ | ||
58 | import JsonEditor from '../../SimpleRequest/components/jsonEditor.vue'; | 58 | import JsonEditor from '../../SimpleRequest/components/jsonEditor.vue'; |
59 | import { useMessage } from '/@/hooks/web/useMessage'; | 59 | import { useMessage } from '/@/hooks/web/useMessage'; |
60 | import { getTenantAllPageLists, getTenantPageList } from '/@/api/tenant/tenantApi'; | 60 | import { getTenantAllPageLists, getTenantPageList } from '/@/api/tenant/tenantApi'; |
61 | - import { selectType } from '../../../types'; | 61 | + import { selectType } from '../../../config/types'; |
62 | import { Select } from 'ant-design-vue'; | 62 | import { Select } from 'ant-design-vue'; |
63 | import { getUserToken } from '/@/api/sys/user'; | 63 | import { getUserToken } from '/@/api/sys/user'; |
64 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | 64 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; |
@@ -133,8 +133,8 @@ | @@ -133,8 +133,8 @@ | ||
133 | import { useApi } from '../../../hooks/useApi'; | 133 | import { useApi } from '../../../hooks/useApi'; |
134 | import { useUtils } from '../../../hooks/useUtils'; | 134 | import { useUtils } from '../../../hooks/useUtils'; |
135 | import { cloneDeep } from 'lodash-es'; | 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 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; | 138 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; |
139 | 139 | ||
140 | const props = defineProps({ | 140 | const props = defineProps({ |
@@ -46,7 +46,7 @@ | @@ -46,7 +46,7 @@ | ||
46 | import { Button } from 'ant-design-vue'; | 46 | import { Button } from 'ant-design-vue'; |
47 | import TestHeaderEditCellTable from './testEditHeaderCellTable.vue'; | 47 | import TestHeaderEditCellTable from './testEditHeaderCellTable.vue'; |
48 | import { useMessage } from '/@/hooks/web/useMessage'; | 48 | import { useMessage } from '/@/hooks/web/useMessage'; |
49 | - import { selectType } from '../../../types'; | 49 | + import { selectType } from '../../../config/types'; |
50 | import { Select } from 'ant-design-vue'; | 50 | import { Select } from 'ant-design-vue'; |
51 | import { getUserToken } from '/@/api/sys/user'; | 51 | import { getUserToken } from '/@/api/sys/user'; |
52 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | 52 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; |
@@ -24,8 +24,8 @@ | @@ -24,8 +24,8 @@ | ||
24 | <script lang="ts" setup name="editCellTable"> | 24 | <script lang="ts" setup name="editCellTable"> |
25 | import { reactive } from 'vue'; | 25 | import { reactive } from 'vue'; |
26 | import { cloneDeep } from 'lodash-es'; | 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 | defineProps({ | 30 | defineProps({ |
31 | method: { | 31 | method: { |
@@ -49,7 +49,7 @@ | @@ -49,7 +49,7 @@ | ||
49 | import { useUtils } from '../../../hooks/useUtils'; | 49 | import { useUtils } from '../../../hooks/useUtils'; |
50 | import { useMessage } from '/@/hooks/web/useMessage'; | 50 | import { useMessage } from '/@/hooks/web/useMessage'; |
51 | import { getTenantAllPageLists, getTenantPageList } from '/@/api/tenant/tenantApi'; | 51 | import { getTenantAllPageLists, getTenantPageList } from '/@/api/tenant/tenantApi'; |
52 | - import { selectType } from '../../../types'; | 52 | + import { selectType } from '../../../config/types'; |
53 | import { Select } from 'ant-design-vue'; | 53 | import { Select } from 'ant-design-vue'; |
54 | import { getUserToken } from '/@/api/sys/user'; | 54 | import { getUserToken } from '/@/api/sys/user'; |
55 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | 55 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; |
@@ -174,8 +174,8 @@ | @@ -174,8 +174,8 @@ | ||
174 | import { useApi } from '../../../hooks/useApi'; | 174 | import { useApi } from '../../../hooks/useApi'; |
175 | import { useUtils } from '../../../hooks/useUtils'; | 175 | import { useUtils } from '../../../hooks/useUtils'; |
176 | import { cloneDeep } from 'lodash-es'; | 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 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; | 179 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; |
180 | import moment from 'moment'; | 180 | import moment from 'moment'; |
181 | import { AggregateDataEnum } from '/@/views/report/config/timeConfig'; | 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,6 +5,8 @@ import { findDictItemByCode } from '/@/api/system/dict'; | ||
5 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | 5 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; |
6 | import { getAuthCache } from '/@/utils/auth'; | 6 | import { getAuthCache } from '/@/utils/auth'; |
7 | import { isAdmin } from '/@/enums/roleEnum'; | 7 | import { isAdmin } from '/@/enums/roleEnum'; |
8 | +import { defaultField } from './constants'; | ||
9 | +import { useUtils } from '../hooks/useUtils'; | ||
8 | 10 | ||
9 | // 表格配置 | 11 | // 表格配置 |
10 | export const columns: BasicColumn[] = [ | 12 | export const columns: BasicColumn[] = [ |
@@ -116,24 +118,6 @@ export const schemas: FormSchema[] = [ | @@ -116,24 +118,6 @@ export const schemas: FormSchema[] = [ | ||
116 | placeholder: '请输入接口名称', | 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 | field: 'interfaceType', | 122 | field: 'interfaceType', |
139 | component: 'ApiRadioGroup', | 123 | component: 'ApiRadioGroup', |
@@ -144,19 +128,15 @@ export const schemas: FormSchema[] = [ | @@ -144,19 +128,15 @@ export const schemas: FormSchema[] = [ | ||
144 | }, | 128 | }, |
145 | defaultValue: 'CUSTOM', | 129 | defaultValue: 'CUSTOM', |
146 | componentProps: { | 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 | ifShow: ({}) => { | 138 | ifShow: ({}) => { |
159 | - const userInfo: any = getAuthCache(USER_INFO_KEY); | 139 | + const userInfo = getAuthCache(USER_INFO_KEY) as any; |
160 | const role: string = userInfo?.roles[0]; | 140 | const role: string = userInfo?.roles[0]; |
161 | if (isAdmin(role)) return true; | 141 | if (isAdmin(role)) return true; |
162 | else return false; | 142 | else return false; |
@@ -180,14 +160,11 @@ export const schemas: FormSchema[] = [ | @@ -180,14 +160,11 @@ export const schemas: FormSchema[] = [ | ||
180 | labelField: 'itemText', | 160 | labelField: 'itemText', |
181 | valueField: 'itemValue', | 161 | valueField: 'itemValue', |
182 | getPopupContainer: () => document.body, | 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 | updateSchema({ | 168 | updateSchema({ |
192 | field: 'requestHttpTypeAndUrl', | 169 | field: 'requestHttpTypeAndUrl', |
193 | componentProps: { | 170 | componentProps: { |
@@ -197,9 +174,7 @@ export const schemas: FormSchema[] = [ | @@ -197,9 +174,7 @@ export const schemas: FormSchema[] = [ | ||
197 | updateSchema({ | 174 | updateSchema({ |
198 | field: 'requestOriginUrl', | 175 | field: 'requestOriginUrl', |
199 | componentProps: { | 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,11 +199,10 @@ export const schemas: FormSchema[] = [ | ||
224 | labelField: 'itemText', | 199 | labelField: 'itemText', |
225 | valueField: 'itemValue', | 200 | valueField: 'itemValue', |
226 | onChange: (e) => { | 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,10 +216,9 @@ export const schemas: FormSchema[] = [ | ||
242 | componentProps: ({ formActionType }) => { | 216 | componentProps: ({ formActionType }) => { |
243 | const { getFieldsValue } = formActionType; | 217 | const { getFieldsValue } = formActionType; |
244 | const type = getFieldsValue()?.requestContentType; | 218 | const type = getFieldsValue()?.requestContentType; |
219 | + const { usePlaceholder } = useUtils(); | ||
245 | return { | 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 | ifShow: ({ values }) => values['originUrlType'] === 'custom_url', | 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 | * @description: 请求体类型 | 4 | * @description: 请求体类型 |
3 | */ | 5 | */ |
@@ -8,3 +10,20 @@ export enum RequestBodyTypeEnum { | @@ -8,3 +10,20 @@ export enum RequestBodyTypeEnum { | ||
8 | JSON = 'json', | 10 | JSON = 'json', |
9 | XML = 'xml', | 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,7 +69,7 @@ | ||
69 | import { ref, nextTick, watch } from 'vue'; | 69 | import { ref, nextTick, watch } from 'vue'; |
70 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 70 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
71 | import { BasicForm, useForm } from '/@/components/Form'; | 71 | import { BasicForm, useForm } from '/@/components/Form'; |
72 | - import { schemas } from './config'; | 72 | + import { schemas } from './config/config'; |
73 | import SimpleRequest from './components/SimpleRequest/index.vue'; | 73 | import SimpleRequest from './components/SimpleRequest/index.vue'; |
74 | import { TestSql } from './components/TestSql/index'; | 74 | import { TestSql } from './components/TestSql/index'; |
75 | import { | 75 | import { |
1 | +import { commonHttpPlaceHolder, websocketPlaceHolder } from '../config/constants'; | ||
2 | +import { RequestMethodTypeEnum } from '../config/enum'; | ||
1 | import { otherHttp } from '/@/utils/http/axios'; | 3 | import { otherHttp } from '/@/utils/http/axios'; |
2 | 4 | ||
3 | export const useUtils = () => { | 5 | export const useUtils = () => { |
@@ -16,6 +18,7 @@ export const useUtils = () => { | @@ -16,6 +18,7 @@ export const useUtils = () => { | ||
16 | }); | 18 | }); |
17 | return temps; | 19 | return temps; |
18 | }; | 20 | }; |
21 | + | ||
19 | //默认push一个 | 22 | //默认push一个 |
20 | const pushObj = { | 23 | const pushObj = { |
21 | key: undefined, | 24 | key: undefined, |
@@ -25,6 +28,7 @@ export const useUtils = () => { | @@ -25,6 +28,7 @@ export const useUtils = () => { | ||
25 | date1: '', | 28 | date1: '', |
26 | date2: '', | 29 | date2: '', |
27 | }; | 30 | }; |
31 | + | ||
28 | //新增时置空特定数据 | 32 | //新增时置空特定数据 |
29 | const resetReqHttpType = { | 33 | const resetReqHttpType = { |
30 | requestHttpTypeAndUrl: { | 34 | requestHttpTypeAndUrl: { |
@@ -38,6 +42,7 @@ export const useUtils = () => { | @@ -38,6 +42,7 @@ export const useUtils = () => { | ||
38 | type: '0', | 42 | type: '0', |
39 | }, | 43 | }, |
40 | }; | 44 | }; |
45 | + | ||
41 | //对象转get params参数 | 46 | //对象转get params参数 |
42 | const convertObj = (data: object) => { | 47 | const convertObj = (data: object) => { |
43 | const _result: any = []; | 48 | const _result: any = []; |
@@ -53,22 +58,26 @@ export const useUtils = () => { | @@ -53,22 +58,26 @@ export const useUtils = () => { | ||
53 | } | 58 | } |
54 | return _result.join('&'); | 59 | return _result.join('&'); |
55 | }; | 60 | }; |
61 | + | ||
56 | //判断服务器地址是否为http/https ws/wss | 62 | //判断服务器地址是否为http/https ws/wss |
57 | const isServerUrl = (method, type) => { | 63 | const isServerUrl = (method, type) => { |
58 | const pathUrl = window.location.host; | 64 | const pathUrl = window.location.host; |
59 | const protocol = window.location.protocol; | 65 | const protocol = window.location.protocol; |
60 | let url = ''; | 66 | let url = ''; |
61 | - if (method === '2') { | 67 | + if (method === RequestMethodTypeEnum.WEBSOCKET) { |
62 | if (type === 'server_url') { | 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 | if (type === 'server_url') { | 74 | if (type === 'server_url') { |
67 | url = `${protocol}//${pathUrl}`; | 75 | url = `${protocol}//${pathUrl}`; |
68 | } | 76 | } |
69 | } | 77 | } |
70 | return url; | 78 | return url; |
71 | }; | 79 | }; |
80 | + | ||
72 | //TODO:待优化自定义请求 | 81 | //TODO:待优化自定义请求 |
73 | const isOtherHttp = async (url, token, params) => { | 82 | const isOtherHttp = async (url, token, params) => { |
74 | return await otherHttp.get( | 83 | return await otherHttp.get( |
@@ -84,6 +93,17 @@ export const useUtils = () => { | @@ -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 | return { | 107 | return { |
88 | getMultipleKeys, | 108 | getMultipleKeys, |
89 | pushObj, | 109 | pushObj, |
@@ -92,5 +112,6 @@ export const useUtils = () => { | @@ -92,5 +112,6 @@ export const useUtils = () => { | ||
92 | isServerUrl, | 112 | isServerUrl, |
93 | convertObj, | 113 | convertObj, |
94 | isOtherHttp, | 114 | isOtherHttp, |
115 | + usePlaceholder, | ||
95 | }; | 116 | }; |
96 | }; | 117 | }; |
@@ -85,7 +85,7 @@ | @@ -85,7 +85,7 @@ | ||
85 | import { h, ref } from 'vue'; | 85 | import { h, ref } from 'vue'; |
86 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; | 86 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
87 | import { useDrawer } from '/@/components/Drawer'; | 87 | import { useDrawer } from '/@/components/Drawer'; |
88 | - import { columns, searchFormSchema } from './config'; | 88 | + import { columns, searchFormSchema } from './config/config'; |
89 | import { PublicApiForm } from './index'; | 89 | import { PublicApiForm } from './index'; |
90 | import { | 90 | import { |
91 | getDataViewInterfacePage, | 91 | getDataViewInterfacePage, |
@@ -112,7 +112,7 @@ export const step1Schemas: FormSchema[] = [ | @@ -112,7 +112,7 @@ export const step1Schemas: FormSchema[] = [ | ||
112 | component: 'Input', | 112 | component: 'Input', |
113 | componentProps: { | 113 | componentProps: { |
114 | maxLength: 255, | 114 | maxLength: 255, |
115 | - placeholder: '请输入设备标识', | 115 | + placeholder: '请输入设备标识或设备地址码', |
116 | }, | 116 | }, |
117 | ifShow: ({ values }) => | 117 | ifShow: ({ values }) => |
118 | values?.transportType === TransportTypeEnum.TCP && | 118 | values?.transportType === TransportTypeEnum.TCP && |
@@ -154,7 +154,15 @@ export const step1Schemas: FormSchema[] = [ | @@ -154,7 +154,15 @@ export const step1Schemas: FormSchema[] = [ | ||
154 | const { organizationId, transportType } = formModel; | 154 | const { organizationId, transportType } = formModel; |
155 | if (![organizationId, transportType].every(Boolean)) return {}; | 155 | if (![organizationId, transportType].every(Boolean)) return {}; |
156 | return { | 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 | showSearch: true, | 166 | showSearch: true, |
159 | params: { | 167 | params: { |
160 | organizationId, | 168 | organizationId, |
@@ -51,11 +51,20 @@ | @@ -51,11 +51,20 @@ | ||
51 | <template #extra> | 51 | <template #extra> |
52 | <Button | 52 | <Button |
53 | v-show="ifAdd && !view" | 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 | @click="onHandleTestExample(scriptForm.scriptType)" | 63 | @click="onHandleTestExample(scriptForm.scriptType)" |
55 | style="position: relative; top: -4rem; right: -6.6rem" | 64 | style="position: relative; top: -4rem; right: -6.6rem" |
56 | type="primary" | 65 | type="primary" |
57 | > | 66 | > |
58 | - 测试用例</Button | 67 | + 网关用例</Button |
59 | > | 68 | > |
60 | <a-button @click="handleFormat" size="small">格式化</a-button> | 69 | <a-button @click="handleFormat" size="small">格式化</a-button> |
61 | <Tooltip | 70 | <Tooltip |
@@ -120,6 +129,7 @@ | @@ -120,6 +129,7 @@ | ||
120 | defaultScriptTypeContent, | 129 | defaultScriptTypeContent, |
121 | defaultTestUpExample, | 130 | defaultTestUpExample, |
122 | defaultTestAuthExample, | 131 | defaultTestAuthExample, |
132 | + defaultTestSubGatewayUpExample, | ||
123 | } from './config.data'; | 133 | } from './config.data'; |
124 | import { useAppStore } from '/@/store/modules/app'; | 134 | import { useAppStore } from '/@/store/modules/app'; |
125 | import TestScriptModal from './TestScriptModal.vue'; | 135 | import TestScriptModal from './TestScriptModal.vue'; |
@@ -220,6 +230,14 @@ | @@ -220,6 +230,14 @@ | ||
220 | handleFormat(); | 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 | const handleCopy = () => { | 241 | const handleCopy = () => { |
224 | const valueRef = aceEditor.value.getValue(); | 242 | const valueRef = aceEditor.value.getValue(); |
225 | const value = unref(valueRef); | 243 | const value = unref(valueRef); |
@@ -86,88 +86,51 @@ export const defaultUpTitle = h('div', { style: 'background:#404040' }, [ | @@ -86,88 +86,51 @@ export const defaultUpTitle = h('div', { style: 'background:#404040' }, [ | ||
86 | 86 | ||
87 | // TRANSPORT_TCP_DOWN: 'out.datas = "";out.deviceName = "sensor";', | 87 | // TRANSPORT_TCP_DOWN: 'out.datas = "";out.deviceName = "sensor";', |
88 | export const defaultScriptTypeContent = { | 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 | out.datas = teleData; | 96 | out.datas = teleData; |
105 | -/* | ||
106 | -必填:true表示设备上报的遥测数据,false表示命令下发的响应数据 | ||
107 | -*/ | ||
108 | out.telemetry = true; | 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 | teleData.source= params; | 110 | teleData.source= params; |
137 | -/* | ||
138 | -直连/网关子设备设备:temperature是产品物模型中所定义属性的标识符 | ||
139 | -*/ | ||
140 | -tempVal = params; | ||
141 | -teleData.temperature= tempVal; | ||
142 | -/* | ||
143 | -网关设备:变量slaveDevice是网关子设备的“设备标识” | ||
144 | -*/ | 111 | +/*网关设备:slaveDevice是网关子设备的“设备标识”*/ |
145 | slaveDevice = params.substr(0,2); | 112 | slaveDevice = params.substr(0,2); |
146 | teleData[slaveDevice]= params; | 113 | teleData[slaveDevice]= params; |
147 | out.datas = teleData; | 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 | out.password = params; | 118 | out.password = params; |
169 | -/* | ||
170 | - 选填:设备鉴权成功后响应给设备的信息 | ||
171 | - */ | 119 | +/*选填:设备鉴权成功后响应给设备的信息*/ |
172 | out.success = params; | 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,7 +3,6 @@ | ||
3 | import { onMounted, ref, unref } from 'vue'; | 3 | import { onMounted, ref, unref } from 'vue'; |
4 | import { PageWrapper } from '/@/components/Page'; | 4 | import { PageWrapper } from '/@/components/Page'; |
5 | import { MoreOutlined, ShareAltOutlined } from '@ant-design/icons-vue'; | 5 | import { MoreOutlined, ShareAltOutlined } from '@ant-design/icons-vue'; |
6 | - import { useCopyToClipboard } from '/@/hooks/web/useCopyToClipboard'; | ||
7 | import { useMessage } from '/@/hooks/web/useMessage'; | 6 | import { useMessage } from '/@/hooks/web/useMessage'; |
8 | import Dropdown from '/@/components/Dropdown/src/Dropdown.vue'; | 7 | import Dropdown from '/@/components/Dropdown/src/Dropdown.vue'; |
9 | import { DropMenu } from '/@/components/Dropdown'; | 8 | import { DropMenu } from '/@/components/Dropdown'; |
@@ -25,6 +24,7 @@ | @@ -25,6 +24,7 @@ | ||
25 | import { ModalParamsType } from '/#/utils'; | 24 | import { ModalParamsType } from '/#/utils'; |
26 | import { DataActionModeEnum } from '/@/enums/toolEnum'; | 25 | import { DataActionModeEnum } from '/@/enums/toolEnum'; |
27 | import { useRole } from '/@/hooks/business/useRole'; | 26 | import { useRole } from '/@/hooks/business/useRole'; |
27 | + import { useClipboard } from '@vueuse/core'; | ||
28 | 28 | ||
29 | const ListItem = List.Item; | 29 | const ListItem = List.Item; |
30 | const router = useRouter(); | 30 | const router = useRouter(); |
@@ -87,10 +87,10 @@ | @@ -87,10 +87,10 @@ | ||
87 | return `${origin}${DATA_BOARD_SHARE_URL(id, publicId)}`; | 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 | const { isCustomerUser } = useRole(); | 96 | const { isCustomerUser } = useRole(); |