Showing
17 changed files
with
94 additions
and
68 deletions
... | ... | @@ -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', |
... | ... | @@ -142,21 +126,17 @@ export const schemas: FormSchema[] = [ |
142 | 126 | colProps: { |
143 | 127 | span: 8, |
144 | 128 | }, |
145 | - defaultValue: 'CUSTOM', | |
129 | + defaultValue: 'SYSTEM', | |
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,6 +58,7 @@ 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; |
... | ... | @@ -69,6 +75,7 @@ export const useUtils = () => { |
69 | 75 | } |
70 | 76 | return url; |
71 | 77 | }; |
78 | + | |
72 | 79 | //TODO:待优化自定义请求 |
73 | 80 | const isOtherHttp = async (url, token, params) => { |
74 | 81 | return await otherHttp.get( |
... | ... | @@ -84,6 +91,17 @@ export const useUtils = () => { |
84 | 91 | } |
85 | 92 | ); |
86 | 93 | }; |
94 | + | |
95 | + //请求方式切换动态更新源地址placeholder | |
96 | + const usePlaceholder = (type) => | |
97 | + `${ | |
98 | + type === RequestMethodTypeEnum.COMMOM | |
99 | + ? commonHttpPlaceHolder | |
100 | + : type === RequestMethodTypeEnum.WEBSOCKET | |
101 | + ? websocketPlaceHolder | |
102 | + : '' | |
103 | + }`; | |
104 | + | |
87 | 105 | return { |
88 | 106 | getMultipleKeys, |
89 | 107 | pushObj, |
... | ... | @@ -92,5 +110,6 @@ export const useUtils = () => { |
92 | 110 | isServerUrl, |
93 | 111 | convertObj, |
94 | 112 | isOtherHttp, |
113 | + usePlaceholder, | |
95 | 114 | }; |
96 | 115 | }; | ... | ... |
... | ... | @@ -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, | ... | ... |