Commit 3ef920cb4a93467e0969c3703755f6e72ccc7f67

Authored by xp.Huang
2 parents dc4c118a ac94f5c3

Merge branch 'ft' into 'main_dev'

perf(src/packages/public/publicConfig.ts): 修改默认为动态接口

See merge request yunteng/thingskit-view!44
... ... @@ -2,13 +2,20 @@ import { defHttp } from '@/utils/external/http/axios';
2 2 import { DeviceAttributesRecord, GetDeviceListParams, PublicInterfaceRecord, PublicInterfaceStateEnum } from './model';
3 3 import { PaginationResult } from '/#/external/axios';
4 4
5   -enum Api {
6   - PUBLIC_API = '/data_view_interface',
7   - ORG_LISt = '/organization/me/list',
8   - DEVICE_PROFILE_LIST = '/device_profile/me/list',
9   - DEVICE_LIST = '/device/list',
10   - DEVICE_ATTR_LIST = '/device/attributes',
11   - GET_PUBLIC_INTERFACE_ALL = '/data_view_interface/find_all_interface',
  5 + /**
  6 + * ft 更换接口
  7 + * 修改后的代码在注释之间,并标注好源代码和修改后代码,方便回溯
  8 + * 源代码 GET_PUBLIC_INTERFACE_ALL = '/data_view_interface/find_all_interface',
  9 + * 修改后代码 GET_PUBLIC_INTERFACE_ALL = '/data_view_interface/find/can_use_interfaces',
  10 + */
  11 + enum Api {
  12 + PUBLIC_API = '/data_view_interface',
  13 + ORG_LISt = '/organization/me/list',
  14 + DEVICE_PROFILE_LIST = '/device_profile/me/list',
  15 + DEVICE_LIST = '/device/list',
  16 + DEVICE_ATTR_LIST = '/device/attributes',
  17 + GET_PUBLIC_INTERFACE_ALL = '/data_view_interface/find/can_use_interfaces',
  18 + //ft
12 19 GET_PUBLIC_INTERFACE_DETAIL = '/data_view_interface/get_interface_details'
13 20 }
14 21
... ... @@ -52,9 +59,15 @@ export const getDeviceInterfaceDetail = async (interfaces: string[]) => {
52 59 params: interfaces
53 60 })
54 61 }
55   -
56   -export const getAllPublicInterface = async (params?: { state: PublicInterfaceStateEnum }) => {
  62 + /**
  63 + * ft 更换接口
  64 + * 修改后的代码在注释之间,并标注好源代码和修改后代码,方便回溯
  65 + * 源代码 url: `${Api.GET_PUBLIC_INTERFACE_ALL}${params?.state ? `/${params.state}` : ''}`
  66 + * 修改后代码 url: `${Api.GET_PUBLIC_INTERFACE_ALL}`
  67 + */
  68 +export const getAllPublicInterface = async () => {
57 69 return defHttp.get<PublicInterfaceRecord[]>({
58   - url: `${Api.GET_PUBLIC_INTERFACE_ALL}${params?.state ? `/${params.state}` : ''}`
  70 + url: `${Api.GET_PUBLIC_INTERFACE_ALL}`
59 71 })
60 72 }
  73 +//ft
\ No newline at end of file
... ...
... ... @@ -18,9 +18,17 @@ import {
18 18 import { chartInitConfig } from '@/settings/designSetting'
19 19 import cloneDeep from 'lodash/cloneDeep'
20 20
  21 +/**
  22 + * 这里更新版本有冲突
  23 + * ft 修改在公共接口下拉框里默认选择公共接口
  24 + * 修改后的代码在注释之间,并标注好源代码和修改后代码,方便回溯
  25 + * 源代码 requestDataType: RequestDataTypeEnum.AJAX,
  26 + * 修改后的代码 requestDataType: RequestDataTypeEnum.Pond,
  27 + * 修改后代码在//ft之间
  28 + */
21 29 // 请求基础属性
22 30 export const requestConfig: RequestConfigType = {
23   - requestDataType: RequestDataTypeEnum.STATIC,
  31 + requestDataType: RequestDataTypeEnum.Pond,
24 32 requestHttpType: RequestHttpEnum.GET,
25 33 requestUrl: '',
26 34 requestInterval: undefined,
... ... @@ -41,6 +49,7 @@ export const requestConfig: RequestConfigType = {
41 49 Params: {}
42 50 }
43 51 }
  52 +//ft之间
44 53
45 54 // 单实例类
46 55 export class PublicConfigClass implements PublicConfigType {
... ...
... ... @@ -22,7 +22,17 @@ const requestModal = ref<InstanceType<typeof RequestModal>>()
22 22 const designStore = useDesignStore()
23 23
24 24
25   -const selectedRequestType = ref(targetData.value.request.requestDataType || RequestDataTypeEnum.AJAX)
  25 +/**
  26 + * ft 修改在公共接口下拉框里默认选择公共接口
  27 + * 修改后的代码在注释之间,并标注好源代码和修改后代码,方便回溯
  28 + * 源代码 const selectedRequestType = ref(targetData.value.request.requestDataType || RequestDataTypeEnum.AJAX)
  29 + * 修改后的代码 const selectedRequestType = ref(targetData.value.request.requestDataType || RequestDataTypeEnum.Pond)
  30 + * 修改后代码在//ft之间
  31 + */
  32 +
  33 +const selectedRequestType = ref(targetData.value.request.requestDataType || RequestDataTypeEnum.Pond)
  34 +console.log(targetData.value.request.requestDataType)
  35 +//ft
26 36
27 37 const getApiRequestType: SelectOption[] = [
28 38 { label: '自定义请求', value: RequestDataTypeEnum.AJAX },
... ...
... ... @@ -2,10 +2,10 @@
2 2 import { getAllPublicInterface } from '@/api/external/dynamicRequest'
3 3 import { ParamsItemType, PublicInterfaceRecord, PublicInterfaceRequestParams, PublicInterfaceStateEnum } from '@/api/external/dynamicRequest/model';
4 4 import { SettingItem, SettingItemBox } from '@/components/Pages/ChartItemSetting';
5   -import { RequestContentTypeEnum, RequestContentTypeNameEnum } from '@/enums/external/httpEnum';
  5 +import { RequestContentTypeEnum, RequestContentTypeNameEnum, RequestEnum } from '@/enums/external/httpEnum';
6 6 import { RequestBodyEnum, RequestHttpEnum, RequestHttpIntervalEnum, RequestParams, RequestParamsTypeEnum } from '@/enums/httpEnum';
7   -import { NCard, NEmpty, NInputGroup, NInputNumber, NScrollbar, NSelect, NTabPane, NTabs, SelectOption } from 'naive-ui';
8   -import { ref, computed, unref, nextTick } from 'vue'
  7 +import { NCard, NEllipsis, NEmpty, NInputGroup, NInputNumber, NScrollbar, NSelect, NSpace, NTabPane, NTabs, SelectOption } from 'naive-ui';
  8 +import { ref, computed, unref, nextTick, h } from 'vue'
9 9 import { selectTimeOptions, selectTypeOptions } from '../../../index.d';
10 10 import ParamsTable from '../RequestModal/ParamsTable.vue';
11 11 import BodyContent from './BodyContent.vue'
... ... @@ -43,7 +43,14 @@ const getSelectedInterfaceParams = computed(() => {
43 43
44 44 const getPublicInterfaceList = async () => {
45 45 if (unref(publicInterfaceList).length) return
46   - const result = await getAllPublicInterface({ state: PublicInterfaceStateEnum.PUBLISH })
  46 + /**
  47 + * ft 更换接口
  48 + * 修改后的代码在注释之间,并标注好源代码和修改后代码,方便回溯
  49 + * 源代码 const result = await getAllPublicInterface({ state: PublicInterfaceStateEnum.PUBLISH })
  50 + * 修改后代码 const result = await getAllPublicInterface()
  51 + */
  52 + const result = await getAllPublicInterface()
  53 + //ft
47 54 publicInterfaceList.value = result
48 55 }
49 56
... ... @@ -141,6 +148,30 @@ const setConfigurationData = async (request: ExtraRequestConfigType) => {
141 148 setDynamicFormValue(request)
142 149 }
143 150
  151 + /**
  152 + * ft 修改在公共接口下拉框里加上接口类型
  153 + * 修改后的代码在注释之间,并标注好源代码和修改后代码,方便回溯
  154 + * 源代码 属于新增代码,源代码无
  155 + * 修改后代码在//ft之间
  156 + */
  157 +
  158 +const getHttpType = (httpType:RequestEnum, contentType:number) => {
  159 + if(contentType===0){
  160 + if (httpType === RequestEnum[httpType]) return RequestEnum[httpType]
  161 + }
  162 + else if (contentType===2) return 'WebSocket'
  163 +}
  164 +
  165 +const renderOption = (option: SelectOption) => {
  166 + const httpType = getHttpType(option?.requestHttpType as RequestEnum, option?.requestContentType as number)
  167 + const interfaceTypeName = option?.interfaceType === 'SYSTEM' ? '系统默认' :option?.interfaceType === 'CUSTOM'? '自定义':''
  168 + return h(NSpace, { justify: 'space-between', style: 'padding: 0 15px; height: 28px; line-height: 28px;' }, () => [
  169 + h(NEllipsis, null, () => `${!httpType?'':httpType+'/'}${interfaceTypeName}`),
  170 + h(NEllipsis, null, () => option.interfaceName),
  171 + ])
  172 +}
  173 +//ft
  174 +
144 175 defineExpose({
145 176 getConfigurationData,
146 177 setConfigurationData,
... ... @@ -154,10 +185,19 @@ defineExpose({
154 185 <SettingItemBox name="公共接口" :alone="true" :item-right-style="{ gridTemplateColumns: '5fr 2fr 1fr' }">
155 186 <SettingItem name="请求方式 & URL地址">
156 187 <NInputGroup>
  188 + <!--
  189 + /**
  190 + * ft 修改在公共接口下拉框里加上接口类型
  191 + * 修改后的代码在注释之间,并标注好源代码和修改后代码,方便回溯
  192 + * 源代码 无
  193 + * 修改后代码 新增一句 :render-label="renderOption"
  194 + */
  195 + -->
157 196 <NSelect v-model:value="selectedPublicInterface" label-field="interfaceName" value-field="id"
158 197 :options="publicInterfaceList" :filter="handleFilter" filterable :reset-menu-on-options-change="false"
159   - @update-value="handleSelectedInterfaceChange" size="small">
  198 + @update-value="handleSelectedInterfaceChange" size="small" :render-label="renderOption">
160 199 </NSelect>
  200 + <!-- ft -->
161 201 <NSelect v-if="requestContentTypeRef !== RequestContentTypeEnum.WEB_SOCKET" v-model:value="requestHttpTypeRef"
162 202 style="width: 150px;" size="small" :options="(selectTypeOptions as SelectOption[])" :disabled="true" />
163 203 <NSelect v-if="requestContentTypeRef === RequestContentTypeEnum.WEB_SOCKET" :disabled="true" style="width: 150px;"
... ... @@ -225,6 +265,7 @@ defineExpose({
225 265 </NScrollbar>
226 266 </NCard>
227 267 </SettingItemBox>
  268 + <!-- ft -->
228 269 </template>
229 270
230 271 <style scoped lang="scss">
... ...