Commit 1d60a05b3c433ce98e47dae49a74ccc9539d8941
Merge branch 'ft' into 'main_dev'
pref: 公共接口管理 调整接口类型根据不同管理员显示 See merge request yunteng/thingskit-front!550
Showing
11 changed files
with
202 additions
and
38 deletions
| @@ -16,6 +16,8 @@ export enum ConfigurationPermission { | @@ -16,6 +16,8 @@ export enum ConfigurationPermission { | ||
| 16 | SHARE = 'api:yt:dataview:center:share', | 16 | SHARE = 'api:yt:dataview:center:share', |
| 17 | DESIGN = 'api:yt:dataview:center:get_configuration_info:design', | 17 | DESIGN = 'api:yt:dataview:center:get_configuration_info:design', |
| 18 | PREVIEW = 'api:yt:dataview:center:get_configuration_info:preview', | 18 | PREVIEW = 'api:yt:dataview:center:get_configuration_info:preview', |
| 19 | + PUBLISH = 'api:yt:dataview:center:publish', | ||
| 20 | + CANCEL_PUBLISH = 'api:yt:dataview:center:cancel_publish', | ||
| 19 | } | 21 | } |
| 20 | 22 | ||
| 21 | // 查询字段 | 23 | // 查询字段 |
| @@ -301,7 +301,7 @@ | @@ -301,7 +301,7 @@ | ||
| 301 | }, | 301 | }, |
| 302 | { | 302 | { |
| 303 | text: '发布', | 303 | text: '发布', |
| 304 | - auth: ConfigurationPermission.UPDATE, | 304 | + auth: ConfigurationPermission.PUBLISH, |
| 305 | icon: 'ant-design:node-expand-outlined', | 305 | icon: 'ant-design:node-expand-outlined', |
| 306 | event: '', | 306 | event: '', |
| 307 | onClick: handlePublish.bind(null, item), | 307 | onClick: handlePublish.bind(null, item), |
| @@ -309,6 +309,7 @@ | @@ -309,6 +309,7 @@ | ||
| 309 | }, | 309 | }, |
| 310 | { | 310 | { |
| 311 | text: '取消发布', | 311 | text: '取消发布', |
| 312 | + auth: ConfigurationPermission.CANCEL_PUBLISH, | ||
| 312 | icon: 'ant-design:node-collapse-outlined', | 313 | icon: 'ant-design:node-collapse-outlined', |
| 313 | event: '', | 314 | event: '', |
| 314 | onClick: handleCancelPublish.bind(null, item), | 315 | onClick: handleCancelPublish.bind(null, item), |
| 1 | <template> | 1 | <template> |
| 2 | - <div class="flex" style="justify-content: space-between; align-content: center"> | 2 | + <div class="flex flex-col justify-between"> |
| 3 | <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div> | 3 | <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div> |
| 4 | <div class="ml-2 -mt-1.5"> | 4 | <div class="ml-2 -mt-1.5"> |
| 5 | - <Button v-if="showBtn" @click="onHandleCopy" type="text"> 复制测试结果 </Button> | 5 | + <Button v-if="showBtn" @click="onHandleCopy" class="mt-8 -ml-2"> |
| 6 | + <template #icon> | ||
| 7 | + <CopyOutlined /> | ||
| 8 | + </template> | ||
| 9 | + copy | ||
| 10 | + </Button> | ||
| 6 | </div> | 11 | </div> |
| 7 | </div> | 12 | </div> |
| 8 | </template> | 13 | </template> |
| @@ -13,6 +18,7 @@ | @@ -13,6 +18,7 @@ | ||
| 13 | import 'jsoneditor/dist/jsoneditor.min.css'; | 18 | import 'jsoneditor/dist/jsoneditor.min.css'; |
| 14 | import { Button } from 'ant-design-vue'; | 19 | import { Button } from 'ant-design-vue'; |
| 15 | import { useMessage } from '/@/hooks/web/useMessage'; | 20 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 21 | + import { CopyOutlined } from '@ant-design/icons-vue'; | ||
| 16 | 22 | ||
| 17 | const props = defineProps({ | 23 | const props = defineProps({ |
| 18 | showBtn: { | 24 | showBtn: { |
| @@ -36,11 +42,7 @@ | @@ -36,11 +42,7 @@ | ||
| 36 | mode: 'code', | 42 | mode: 'code', |
| 37 | mainMenuBar: false, | 43 | mainMenuBar: false, |
| 38 | statusBar: false, | 44 | statusBar: false, |
| 39 | - onFocus: () => { | ||
| 40 | - if (props.showBtn) { | ||
| 41 | - setJsonValue('测试结果为'); | ||
| 42 | - } | ||
| 43 | - }, | 45 | + onFocus: () => {}, |
| 44 | onBlur: () => {}, | 46 | onBlur: () => {}, |
| 45 | onChangeText: (e) => { | 47 | onChangeText: (e) => { |
| 46 | if (props.showBtn) { | 48 | if (props.showBtn) { |
| @@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
| 9 | @closeTest="onCloseTest" | 9 | @closeTest="onCloseTest" |
| 10 | ref="testParamsRequestRef" | 10 | ref="testParamsRequestRef" |
| 11 | :data="dataMap.mapParamsObj" | 11 | :data="dataMap.mapParamsObj" |
| 12 | + :interfaceType="interfaceType" | ||
| 12 | /> | 13 | /> |
| 13 | </TabPane> | 14 | </TabPane> |
| 14 | <TabPane | 15 | <TabPane |
| @@ -24,6 +25,7 @@ | @@ -24,6 +25,7 @@ | ||
| 24 | @testBodyInterface="handleTestBodyInterface" | 25 | @testBodyInterface="handleTestBodyInterface" |
| 25 | @closeTest="onCloseTest" | 26 | @closeTest="onCloseTest" |
| 26 | ref="testBodyRequestRef" | 27 | ref="testBodyRequestRef" |
| 28 | + :interfaceType="interfaceType" | ||
| 27 | :data="dataMap.mapBodyObj" | 29 | :data="dataMap.mapBodyObj" |
| 28 | /> | 30 | /> |
| 29 | </TabPane> | 31 | </TabPane> |
| @@ -33,6 +35,7 @@ | @@ -33,6 +35,7 @@ | ||
| 33 | @testHeaderInterface="handleTestHeaderInterface" | 35 | @testHeaderInterface="handleTestHeaderInterface" |
| 34 | @closeTest="onCloseTest" | 36 | @closeTest="onCloseTest" |
| 35 | ref="testHeaderRequestRef" | 37 | ref="testHeaderRequestRef" |
| 38 | + :interfaceType="interfaceType" | ||
| 36 | :data="dataMap.mapHeaderObj" | 39 | :data="dataMap.mapHeaderObj" |
| 37 | /> | 40 | /> |
| 38 | </TabPane> | 41 | </TabPane> |
| @@ -64,6 +67,9 @@ | @@ -64,6 +67,9 @@ | ||
| 64 | originUrlType: { | 67 | originUrlType: { |
| 65 | type: String, | 68 | type: String, |
| 66 | }, | 69 | }, |
| 70 | + interfaceType: { | ||
| 71 | + type: String, | ||
| 72 | + }, | ||
| 67 | }); | 73 | }); |
| 68 | 74 | ||
| 69 | const emits = defineEmits(['activeKey']); | 75 | const emits = defineEmits(['activeKey']); |
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | <div> | 2 | <div> |
| 3 | <div class="mt-8"> | 3 | <div class="mt-8"> |
| 4 | <div class="flex"> | 4 | <div class="flex"> |
| 5 | - <div class="flex" v-if="isAdmin(role)"> | 5 | + <div class="flex" v-if="interfaceType === 'SYSTEM' && isAdmin(role)"> |
| 6 | <Select | 6 | <Select |
| 7 | v-model:value="selectTenant" | 7 | v-model:value="selectTenant" |
| 8 | allowClear | 8 | allowClear |
| @@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
| 22 | /> | 22 | /> |
| 23 | </div> | 23 | </div> |
| 24 | <Button | 24 | <Button |
| 25 | - :disabled="isAdmin(role) ? testDisabled : false" | 25 | + :disabled="interfaceType === 'SYSTEM' && isAdmin(role) ? testDisabled : false" |
| 26 | class="ml-2" | 26 | class="ml-2" |
| 27 | @click="handleTest(isSingleClickText)" | 27 | @click="handleTest(isSingleClickText)" |
| 28 | type="primary" | 28 | type="primary" |
| @@ -75,6 +75,9 @@ | @@ -75,6 +75,9 @@ | ||
| 75 | data: { | 75 | data: { |
| 76 | type: Object, | 76 | type: Object, |
| 77 | }, | 77 | }, |
| 78 | + interfaceType: { | ||
| 79 | + type: String, | ||
| 80 | + }, | ||
| 78 | }); | 81 | }); |
| 79 | 82 | ||
| 80 | onMounted(async () => { | 83 | onMounted(async () => { |
| @@ -235,6 +238,7 @@ | @@ -235,6 +238,7 @@ | ||
| 235 | excuteData.value = { | 238 | excuteData.value = { |
| 236 | params, | 239 | params, |
| 237 | token: getToken.value, | 240 | token: getToken.value, |
| 241 | + type: props.data?.type, | ||
| 238 | }; | 242 | }; |
| 239 | return excuteData.value; | 243 | return excuteData.value; |
| 240 | }; | 244 | }; |
| @@ -100,6 +100,8 @@ | @@ -100,6 +100,8 @@ | ||
| 100 | 100 | ||
| 101 | const isShowTestResult = ref(false); | 101 | const isShowTestResult = ref(false); |
| 102 | 102 | ||
| 103 | + const postBodyType = ref(''); | ||
| 104 | + | ||
| 103 | //执行测试接口 | 105 | //执行测试接口 |
| 104 | const handleExcute = () => { | 106 | const handleExcute = () => { |
| 105 | emits('emitExcute'); | 107 | emits('emitExcute'); |
| @@ -123,6 +125,7 @@ | @@ -123,6 +125,7 @@ | ||
| 123 | isToken.value = Objects?.Params?.token; | 125 | isToken.value = Objects?.Params?.token; |
| 124 | const body = Objects?.Body?.params; | 126 | const body = Objects?.Body?.params; |
| 125 | isPostToken.value = Objects?.Body?.token; | 127 | isPostToken.value = Objects?.Body?.token; |
| 128 | + postBodyType.value = Objects?.Body?.type; | ||
| 126 | apiUrl.value = url?.restfulFormat(params); | 129 | apiUrl.value = url?.restfulFormat(params); |
| 127 | if (isWebSocketType.value === '2') { | 130 | if (isWebSocketType.value === '2') { |
| 128 | socketUrls.value = url; | 131 | socketUrls.value = url; |
| @@ -143,7 +146,8 @@ | @@ -143,7 +146,8 @@ | ||
| 143 | params, | 146 | params, |
| 144 | body, | 147 | body, |
| 145 | isToken.value, | 148 | isToken.value, |
| 146 | - isPostToken.value | 149 | + isPostToken.value, |
| 150 | + postBodyType.value | ||
| 147 | ); | 151 | ); |
| 148 | if (!resp) return; | 152 | if (!resp) return; |
| 149 | if (Object.prototype.toString.call(resp) === '[object Object]') { | 153 | if (Object.prototype.toString.call(resp) === '[object Object]') { |
| @@ -151,7 +155,10 @@ | @@ -151,7 +155,10 @@ | ||
| 151 | } else if (typeof resp === 'string') { | 155 | } else if (typeof resp === 'string') { |
| 152 | jsonEditorRef.value?.setJsonValue(resp); | 156 | jsonEditorRef.value?.setJsonValue(resp); |
| 153 | } else if (Array.isArray(resp)) { | 157 | } else if (Array.isArray(resp)) { |
| 154 | - jsonEditorRef.value?.setJsonValue(JSON.stringify(resp)); | 158 | + const temp = { |
| 159 | + data: resp, | ||
| 160 | + }; | ||
| 161 | + jsonEditorRef.value?.setJsonValue(temp); | ||
| 155 | } else { | 162 | } else { |
| 156 | jsonEditorRef.value?.setJsonValue(JSON.stringify(resp)); | 163 | jsonEditorRef.value?.setJsonValue(JSON.stringify(resp)); |
| 157 | } | 164 | } |
| @@ -217,14 +224,19 @@ | @@ -217,14 +224,19 @@ | ||
| 217 | body, | 224 | body, |
| 218 | token, | 225 | token, |
| 219 | postToken, | 226 | postToken, |
| 227 | + postBodyType, | ||
| 220 | joinPrefix = false | 228 | joinPrefix = false |
| 221 | ) => { | 229 | ) => { |
| 222 | const { convertObj } = useUtils(); | 230 | const { convertObj } = useUtils(); |
| 223 | switch (apiType) { | 231 | switch (apiType) { |
| 224 | case 'GET': | 232 | case 'GET': |
| 225 | - const objGet = Object.assign({}, headers, { | ||
| 226 | - 'X-Authorization': `Bearer ${!token ? postToken : token}`, | ||
| 227 | - }); | 233 | + const objGet = Object.assign( |
| 234 | + {}, | ||
| 235 | + { | ||
| 236 | + 'X-Authorization': `Bearer ${!token ? postToken : token}`, | ||
| 237 | + }, | ||
| 238 | + headers | ||
| 239 | + ); | ||
| 228 | return await otherHttp.get( | 240 | return await otherHttp.get( |
| 229 | { url: apiUrl, params, headers: objGet }, | 241 | { url: apiUrl, params, headers: objGet }, |
| 230 | { | 242 | { |
| @@ -235,9 +247,26 @@ | @@ -235,9 +247,26 @@ | ||
| 235 | } | 247 | } |
| 236 | ); | 248 | ); |
| 237 | case 'POST': | 249 | case 'POST': |
| 238 | - const objPost = Object.assign({}, headers, { | ||
| 239 | - 'X-Authorization': `Bearer ${!postToken ? token : postToken}`, | ||
| 240 | - }); | 250 | + console.log(postBodyType); |
| 251 | + const objPost = Object.assign( | ||
| 252 | + {}, | ||
| 253 | + { | ||
| 254 | + 'X-Authorization': `Bearer ${!postToken ? token : postToken}`, | ||
| 255 | + }, | ||
| 256 | + { | ||
| 257 | + 'Content-Type': | ||
| 258 | + postBodyType === 'xml' | ||
| 259 | + ? 'text/xml' | ||
| 260 | + : postBodyType === 'form-data' | ||
| 261 | + ? 'multipart/form-data' | ||
| 262 | + : postBodyType === 'x-www-form-urlencoded' | ||
| 263 | + ? 'application/x-www-form-urlencoded' | ||
| 264 | + : postBodyType === 'json' | ||
| 265 | + ? 'application/json' | ||
| 266 | + : 'application/json', | ||
| 267 | + }, | ||
| 268 | + headers | ||
| 269 | + ); | ||
| 241 | return await otherHttp.post( | 270 | return await otherHttp.post( |
| 242 | { url: `${apiUrl}?${convertObj(params)}`, data: body, headers: objPost }, | 271 | { url: `${apiUrl}?${convertObj(params)}`, data: body, headers: objPost }, |
| 243 | { | 272 | { |
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | <div> | 2 | <div> |
| 3 | <div class="mt-8"> | 3 | <div class="mt-8"> |
| 4 | <div class="flex"> | 4 | <div class="flex"> |
| 5 | - <div class="flex" v-if="isAdmin(role)"> | 5 | + <div class="flex" v-if="interfaceType === 'SYSTEM' && isAdmin(role)"> |
| 6 | <Select | 6 | <Select |
| 7 | allowClear | 7 | allowClear |
| 8 | v-model:value="selectTenant" | 8 | v-model:value="selectTenant" |
| @@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
| 22 | /> | 22 | /> |
| 23 | </div> | 23 | </div> |
| 24 | <Button | 24 | <Button |
| 25 | - :disabled="isAdmin(role) ? testDisabled : false" | 25 | + :disabled="interfaceType === 'SYSTEM' && isAdmin(role) ? testDisabled : false" |
| 26 | class="ml-2" | 26 | class="ml-2" |
| 27 | @click="handleTest(isSingleClickText)" | 27 | @click="handleTest(isSingleClickText)" |
| 28 | type="primary" | 28 | type="primary" |
| @@ -64,6 +64,9 @@ | @@ -64,6 +64,9 @@ | ||
| 64 | data: { | 64 | data: { |
| 65 | type: Object, | 65 | type: Object, |
| 66 | }, | 66 | }, |
| 67 | + interfaceType: { | ||
| 68 | + type: String, | ||
| 69 | + }, | ||
| 67 | }); | 70 | }); |
| 68 | 71 | ||
| 69 | onMounted(async () => { | 72 | onMounted(async () => { |
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | <div> | 2 | <div> |
| 3 | <div class="mt-8"> | 3 | <div class="mt-8"> |
| 4 | <div class="flex"> | 4 | <div class="flex"> |
| 5 | - <div class="flex" v-if="isAdmin(role)"> | 5 | + <div class="flex" v-if="interfaceType === 'SYSTEM' && isAdmin(role)"> |
| 6 | <Select | 6 | <Select |
| 7 | allowClear | 7 | allowClear |
| 8 | v-model:value="selectTenant" | 8 | v-model:value="selectTenant" |
| @@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
| 22 | /> | 22 | /> |
| 23 | </div> | 23 | </div> |
| 24 | <Button | 24 | <Button |
| 25 | - :disabled="isAdmin(role) ? testDisabled : false" | 25 | + :disabled="interfaceType === 'SYSTEM' && isAdmin(role) ? testDisabled : false" |
| 26 | class="ml-2" | 26 | class="ml-2" |
| 27 | @click="handleTest(isSingleClickText)" | 27 | @click="handleTest(isSingleClickText)" |
| 28 | type="primary" | 28 | type="primary" |
| @@ -66,6 +66,9 @@ | @@ -66,6 +66,9 @@ | ||
| 66 | data: { | 66 | data: { |
| 67 | type: Object, | 67 | type: Object, |
| 68 | }, | 68 | }, |
| 69 | + interfaceType: { | ||
| 70 | + type: String, | ||
| 71 | + }, | ||
| 69 | }); | 72 | }); |
| 70 | 73 | ||
| 71 | onMounted(async () => { | 74 | onMounted(async () => { |
| @@ -2,6 +2,9 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; | @@ -2,6 +2,9 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; | ||
| 2 | import { h } from 'vue'; | 2 | import { h } from 'vue'; |
| 3 | import { Tag } from 'ant-design-vue'; | 3 | import { Tag } from 'ant-design-vue'; |
| 4 | import { findDictItemByCode } from '/@/api/system/dict'; | 4 | import { findDictItemByCode } from '/@/api/system/dict'; |
| 5 | +import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | ||
| 6 | +import { getAuthCache } from '/@/utils/auth'; | ||
| 7 | +import { isAdmin } from '/@/enums/roleEnum'; | ||
| 5 | 8 | ||
| 6 | // 表格配置 | 9 | // 表格配置 |
| 7 | export const columns: BasicColumn[] = [ | 10 | export const columns: BasicColumn[] = [ |
| @@ -11,6 +14,14 @@ export const columns: BasicColumn[] = [ | @@ -11,6 +14,14 @@ export const columns: BasicColumn[] = [ | ||
| 11 | width: 150, | 14 | width: 150, |
| 12 | }, | 15 | }, |
| 13 | { | 16 | { |
| 17 | + title: '接口类型', | ||
| 18 | + dataIndex: 'interfaceType', | ||
| 19 | + width: 80, | ||
| 20 | + format(text) { | ||
| 21 | + return text === 'SYSTEM' ? '系统默认' : '自定义'; | ||
| 22 | + }, | ||
| 23 | + }, | ||
| 24 | + { | ||
| 14 | title: '请求方式', | 25 | title: '请求方式', |
| 15 | dataIndex: 'requestContentType', | 26 | dataIndex: 'requestContentType', |
| 16 | width: 90, | 27 | width: 90, |
| @@ -42,7 +53,7 @@ export const searchFormSchema: FormSchema[] = [ | @@ -42,7 +53,7 @@ export const searchFormSchema: FormSchema[] = [ | ||
| 42 | field: 'name', | 53 | field: 'name', |
| 43 | label: '接口名称', | 54 | label: '接口名称', |
| 44 | component: 'Input', | 55 | component: 'Input', |
| 45 | - colProps: { span: 9 }, | 56 | + colProps: { span: 7 }, |
| 46 | componentProps: { | 57 | componentProps: { |
| 47 | maxLength: 36, | 58 | maxLength: 36, |
| 48 | placeholder: '请输入接口名称', | 59 | placeholder: '请输入接口名称', |
| @@ -52,7 +63,7 @@ export const searchFormSchema: FormSchema[] = [ | @@ -52,7 +63,7 @@ export const searchFormSchema: FormSchema[] = [ | ||
| 52 | field: 'state', | 63 | field: 'state', |
| 53 | label: '发布状态', | 64 | label: '发布状态', |
| 54 | component: 'Select', | 65 | component: 'Select', |
| 55 | - colProps: { span: 9 }, | 66 | + colProps: { span: 7 }, |
| 56 | componentProps: { | 67 | componentProps: { |
| 57 | options: [ | 68 | options: [ |
| 58 | { | 69 | { |
| @@ -67,6 +78,31 @@ export const searchFormSchema: FormSchema[] = [ | @@ -67,6 +78,31 @@ export const searchFormSchema: FormSchema[] = [ | ||
| 67 | placeholder: '请选择发布状态', | 78 | placeholder: '请选择发布状态', |
| 68 | }, | 79 | }, |
| 69 | }, | 80 | }, |
| 81 | + { | ||
| 82 | + field: 'interfaceType', | ||
| 83 | + label: '接口类型', | ||
| 84 | + component: 'Select', | ||
| 85 | + colProps: { span: 7 }, | ||
| 86 | + componentProps: { | ||
| 87 | + options: [ | ||
| 88 | + { | ||
| 89 | + label: '系统默认', | ||
| 90 | + value: 'SYSTEM', | ||
| 91 | + }, | ||
| 92 | + { | ||
| 93 | + label: '自定义', | ||
| 94 | + value: 'CUSTOM', | ||
| 95 | + }, | ||
| 96 | + ], | ||
| 97 | + placeholder: '请选择接口类型', | ||
| 98 | + }, | ||
| 99 | + ifShow: ({}) => { | ||
| 100 | + const userInfo: any = getAuthCache(USER_INFO_KEY); | ||
| 101 | + const role: string = userInfo?.roles[0]; | ||
| 102 | + if (isAdmin(role)) return true; | ||
| 103 | + else return false; | ||
| 104 | + }, | ||
| 105 | + }, | ||
| 70 | ]; | 106 | ]; |
| 71 | 107 | ||
| 72 | //表单配置 | 108 | //表单配置 |
| @@ -82,6 +118,52 @@ export const schemas: FormSchema[] = [ | @@ -82,6 +118,52 @@ export const schemas: FormSchema[] = [ | ||
| 82 | placeholder: '请输入接口名称', | 118 | placeholder: '请输入接口名称', |
| 83 | }, | 119 | }, |
| 84 | }, | 120 | }, |
| 121 | + // { | ||
| 122 | + // field: 'interfaceType', | ||
| 123 | + // component: 'ApiRadioGroup', | ||
| 124 | + // label: '接口类型', | ||
| 125 | + // required: true, | ||
| 126 | + // colProps: { | ||
| 127 | + // span: 8, | ||
| 128 | + // }, | ||
| 129 | + // defaultValue: 'SYSTEM', | ||
| 130 | + // componentProps: { | ||
| 131 | + // api: findDictItemByCode, | ||
| 132 | + // params: { | ||
| 133 | + // dictCode: 'interface_Type', | ||
| 134 | + // }, | ||
| 135 | + // labelField: 'itemText', | ||
| 136 | + // valueField: 'itemValue', | ||
| 137 | + // }, | ||
| 138 | + // }, | ||
| 139 | + { | ||
| 140 | + field: 'interfaceType', | ||
| 141 | + component: 'ApiRadioGroup', | ||
| 142 | + label: '接口类型', | ||
| 143 | + required: true, | ||
| 144 | + colProps: { | ||
| 145 | + span: 8, | ||
| 146 | + }, | ||
| 147 | + defaultValue: 'CUSTOM', | ||
| 148 | + componentProps: { | ||
| 149 | + options: [ | ||
| 150 | + { | ||
| 151 | + label: '系统默认', | ||
| 152 | + value: 'SYSTEM', | ||
| 153 | + }, | ||
| 154 | + { | ||
| 155 | + label: '自定义', | ||
| 156 | + value: 'CUSTOM', | ||
| 157 | + }, | ||
| 158 | + ], | ||
| 159 | + }, | ||
| 160 | + ifShow: ({}) => { | ||
| 161 | + const userInfo: any = getAuthCache(USER_INFO_KEY); | ||
| 162 | + const role: string = userInfo?.roles[0]; | ||
| 163 | + if (isAdmin(role)) return true; | ||
| 164 | + else return false; | ||
| 165 | + }, | ||
| 166 | + }, | ||
| 85 | { | 167 | { |
| 86 | field: 'requestContentType', | 168 | field: 'requestContentType', |
| 87 | label: '请求方式', | 169 | label: '请求方式', |
| @@ -190,9 +272,17 @@ export const schemas: FormSchema[] = [ | @@ -190,9 +272,17 @@ export const schemas: FormSchema[] = [ | ||
| 190 | slot: 'slotFillAddress', | 272 | slot: 'slotFillAddress', |
| 191 | colProps: { span: 24 }, | 273 | colProps: { span: 24 }, |
| 192 | ifShow: ({ values }) => { | 274 | ifShow: ({ values }) => { |
| 193 | - if (values['requestOriginUrl']) { | ||
| 194 | - return true; | ||
| 195 | - } else return false; | 275 | + return values['originUrlType'] === 'custom_url' && values['requestOriginUrl']; |
| 276 | + }, | ||
| 277 | + }, | ||
| 278 | + { | ||
| 279 | + field: 'slotServerAddress', | ||
| 280 | + label: '完整地址', | ||
| 281 | + component: 'Input', | ||
| 282 | + slot: 'slotServerAddress', | ||
| 283 | + colProps: { span: 24 }, | ||
| 284 | + ifShow: ({ values }) => { | ||
| 285 | + return values['originUrlType'] === 'server_url'; | ||
| 196 | }, | 286 | }, |
| 197 | }, | 287 | }, |
| 198 | { | 288 | { |
| @@ -20,6 +20,7 @@ | @@ -20,6 +20,7 @@ | ||
| 20 | :method="model['requestContentType']" | 20 | :method="model['requestContentType']" |
| 21 | :requestOriginUrl="model['requestOriginUrl']" | 21 | :requestOriginUrl="model['requestOriginUrl']" |
| 22 | :originUrlType="model['originUrlType']" | 22 | :originUrlType="model['originUrlType']" |
| 23 | + :interfaceType="model['interfaceType']" | ||
| 23 | /> | 24 | /> |
| 24 | </template> | 25 | </template> |
| 25 | <template #testSql="{ model }"> | 26 | <template #testSql="{ model }"> |
| @@ -33,6 +34,19 @@ | @@ -33,6 +34,19 @@ | ||
| 33 | </template> | 34 | </template> |
| 34 | <template #slotFillAddress="{ model }"> | 35 | <template #slotFillAddress="{ model }"> |
| 35 | <div> | 36 | <div> |
| 37 | + <template v-if="model['originUrlType'] === 'custom_url'"> | ||
| 38 | + <Tag | ||
| 39 | + v-if="model['requestOriginUrl']" | ||
| 40 | + color="blue" | ||
| 41 | + style="width: 35vw; white-space: normal; height: auto" | ||
| 42 | + > | ||
| 43 | + {{ ` ${model['requestOriginUrl'] + model['requestHttpTypeAndUrl']?.requestUrl}` }} | ||
| 44 | + </Tag> | ||
| 45 | + </template> | ||
| 46 | + </div> | ||
| 47 | + </template> | ||
| 48 | + <template #slotServerAddress="{ model }"> | ||
| 49 | + <div> | ||
| 36 | <Tag | 50 | <Tag |
| 37 | v-if="model['originUrlType'] === 'server_url'" | 51 | v-if="model['originUrlType'] === 'server_url'" |
| 38 | color="blue" | 52 | color="blue" |
| @@ -45,15 +59,6 @@ | @@ -45,15 +59,6 @@ | ||
| 45 | ` | 59 | ` |
| 46 | }} | 60 | }} |
| 47 | </Tag> | 61 | </Tag> |
| 48 | - <template v-else> | ||
| 49 | - <Tag | ||
| 50 | - v-if="model['requestOriginUrl']" | ||
| 51 | - color="blue" | ||
| 52 | - style="width: 35vw; white-space: normal; height: auto" | ||
| 53 | - > | ||
| 54 | - {{ ` ${model['requestOriginUrl'] + model['requestHttpTypeAndUrl']?.requestUrl}` }} | ||
| 55 | - </Tag> | ||
| 56 | - </template> | ||
| 57 | </div> | 62 | </div> |
| 58 | </template> | 63 | </template> |
| 59 | </BasicForm> | 64 | </BasicForm> |
| @@ -12,7 +12,12 @@ | @@ -12,7 +12,12 @@ | ||
| 12 | </template> | 12 | </template> |
| 13 | </BasicTable> | 13 | </BasicTable> |
| 14 | <div style="margin-left: 0.44rem"> | 14 | <div style="margin-left: 0.44rem"> |
| 15 | - <a-button type="primary" class="mr-4" :disabled="disabled" @click="handleFrpRemote" | 15 | + <a-button |
| 16 | + v-if="isAdmin !== 'CUSTOMER_USER'" | ||
| 17 | + type="primary" | ||
| 18 | + class="mr-4" | ||
| 19 | + :disabled="disabled" | ||
| 20 | + @click="handleFrpRemote" | ||
| 16 | >远程连接</a-button | 21 | >远程连接</a-button |
| 17 | > | 22 | > |
| 18 | </div> | 23 | </div> |
| @@ -20,13 +25,15 @@ | @@ -20,13 +25,15 @@ | ||
| 20 | </template> | 25 | </template> |
| 21 | 26 | ||
| 22 | <script setup lang="ts"> | 27 | <script setup lang="ts"> |
| 23 | - import { ref, nextTick } from 'vue'; | 28 | + import { ref, nextTick, computed } from 'vue'; |
| 24 | import { BasicTable, useTable, BasicColumn } from '/@/components/Table'; | 29 | import { BasicTable, useTable, BasicColumn } from '/@/components/Table'; |
| 25 | import { Switch } from 'ant-design-vue'; | 30 | import { Switch } from 'ant-design-vue'; |
| 26 | import { h } from 'vue'; | 31 | import { h } from 'vue'; |
| 27 | import { Tag } from 'ant-design-vue'; | 32 | import { Tag } from 'ant-design-vue'; |
| 28 | import { frpGetInfoApi, frpPutInfoApi } from '/@/api/device/deviceConfigApi'; | 33 | import { frpGetInfoApi, frpPutInfoApi } from '/@/api/device/deviceConfigApi'; |
| 29 | import { useMessage } from '/@/hooks/web/useMessage'; | 34 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 35 | + import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | ||
| 36 | + import { getAuthCache } from '/@/utils/auth'; | ||
| 30 | 37 | ||
| 31 | const props = defineProps({ | 38 | const props = defineProps({ |
| 32 | deviceDetail: { | 39 | deviceDetail: { |
| @@ -35,6 +42,18 @@ | @@ -35,6 +42,18 @@ | ||
| 35 | }, | 42 | }, |
| 36 | }); | 43 | }); |
| 37 | 44 | ||
| 45 | + const userInfo = getAuthCache(USER_INFO_KEY) as unknown as any; | ||
| 46 | + | ||
| 47 | + const isAdmin = computed(() => { | ||
| 48 | + if (userInfo.roles.includes('TENANT_ADMIN')) { | ||
| 49 | + return 'TENANT_ADMIN'; | ||
| 50 | + } else if (userInfo.roles.includes('CUSTOMER_USER')) { | ||
| 51 | + return 'CUSTOMER_USER'; | ||
| 52 | + } else { | ||
| 53 | + return 'SYS_ADMIN'; | ||
| 54 | + } | ||
| 55 | + }); | ||
| 56 | + | ||
| 38 | const { createMessage } = useMessage(); | 57 | const { createMessage } = useMessage(); |
| 39 | const tableData: any = ref([]); | 58 | const tableData: any = ref([]); |
| 40 | const checked = ref<boolean>(false); | 59 | const checked = ref<boolean>(false); |