Commit 6cfe5ee13476898b9789ed8f0f77853e4ec66d32
Merge branch 'perf/05-28' into 'main_dev'
perf(src/views): 优化第三方接口 See merge request yunteng/thingskit-view!270
Showing
16 changed files
with
159 additions
and
43 deletions
| 1 | 1 | <template> |
| 2 | - <div ref="el" class="go-editor-area" :style="{ width, height }"></div> | |
| 3 | - <EditorWorker></EditorWorker> | |
| 2 | + <div :style="cacheConfigStyle"> | |
| 3 | + <div ref="el" class="go-editor-area" :style="{ width, height }"></div> | |
| 4 | + <EditorWorker></EditorWorker> | |
| 5 | + <div style="margin-left:10px;"> | |
| 6 | + <n-gradient-text type="danger"> | |
| 7 | + {{ errorText }} | |
| 8 | + </n-gradient-text> | |
| 9 | +</div> | |
| 10 | + </div> | |
| 4 | 11 | </template> |
| 5 | 12 | |
| 6 | 13 | <script lang="ts" setup> |
| 7 | -import { onMounted, watch, PropType } from 'vue' | |
| 14 | +import { onMounted, watch, PropType, ref, computed } from 'vue' | |
| 8 | 15 | import { useMonacoEditor } from './index.hook' |
| 9 | 16 | import { EditorWorker } from './index' |
| 10 | 17 | |
| ... | ... | @@ -32,7 +39,11 @@ const props = defineProps({ |
| 32 | 39 | editorOptions: { |
| 33 | 40 | type: Object as PropType<object>, |
| 34 | 41 | default: () => ({}) |
| 35 | - } | |
| 42 | + }, | |
| 43 | + config: { | |
| 44 | + type: Boolean as PropType<boolean>, | |
| 45 | + default: false | |
| 46 | + }, | |
| 36 | 47 | }) |
| 37 | 48 | |
| 38 | 49 | const emits = defineEmits(['blur', 'update:modelValue']) |
| ... | ... | @@ -56,14 +67,28 @@ onMounted(() => { |
| 56 | 67 | updateMonacoVal() |
| 57 | 68 | }) |
| 58 | 69 | |
| 70 | +const errorText = ref('') | |
| 71 | + | |
| 72 | +const cacheConfigStyle = computed(() => { | |
| 73 | + const configStyle = { | |
| 74 | + display:'flex', | |
| 75 | + justifyContent: 'space-between', | |
| 76 | + alignItems: 'center' | |
| 77 | + } | |
| 78 | + return props.config ? configStyle : '' | |
| 79 | +}) | |
| 80 | + | |
| 59 | 81 | watch( |
| 60 | 82 | () => props.modelValue, |
| 61 | 83 | (val: string) => { |
| 62 | 84 | if(props.language === 'json') { |
| 63 | 85 | try { |
| 64 | - JSON.parse(val) | |
| 86 | + const res = JSON.parse(val) | |
| 87 | + if(res) { | |
| 88 | + errorText.value = '' | |
| 89 | + } | |
| 65 | 90 | } catch (_) { |
| 66 | - window.$message.error('JSON格式有误,请仔细检查!') | |
| 91 | + errorText.value = 'JSON格式有误,请仔细检查!' | |
| 67 | 92 | } |
| 68 | 93 | } |
| 69 | 94 | val !== getEditor()?.getValue() && updateMonacoVal(val) | ... | ... |
| ... | ... | @@ -10,7 +10,7 @@ import {useFilterFn} from './useFilterFn' |
| 10 | 10 | import {RequestContentTypeEnum} from '@/enums/external/httpEnum' |
| 11 | 11 | import dayjs from 'dayjs' |
| 12 | 12 | import { RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d' |
| 13 | -import { convertToCascadingData, findItemByLabel } from '@/utils/external/utils' | |
| 13 | +import { JSONParse, convertToCascadingData, findItemByLabel } from '@/utils/external/utils' | |
| 14 | 14 | import { CascaderOption } from 'naive-ui' |
| 15 | 15 | |
| 16 | 16 | |
| ... | ... | @@ -42,7 +42,8 @@ export const useChartDataFetch = ( |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | - | |
| 45 | + | |
| 46 | + // 单个组件请求 | |
| 46 | 47 | const requestIntervalFn = () => { |
| 47 | 48 | const chartEditStore = useChartEditStore() |
| 48 | 49 | if ((targetComponent.request.requestContentType as RequestContentTypeEnum) === RequestContentTypeEnum.WEB_SOCKET) return |
| ... | ... | @@ -54,6 +55,12 @@ export const useChartDataFetch = ( |
| 54 | 55 | requestInterval: globalRequestInterval |
| 55 | 56 | } = toRefs(chartEditStore.getRequestGlobalConfig) |
| 56 | 57 | |
| 58 | + // 公共配置 | |
| 59 | + const { | |
| 60 | + pondRequestGlobalInterval, | |
| 61 | + pondRequestGlobalIntervalUnit | |
| 62 | + } = toRefs(targetComponent.request) | |
| 63 | + | |
| 57 | 64 | // 目标组件 |
| 58 | 65 | const { |
| 59 | 66 | requestUrl, |
| ... | ... | @@ -131,6 +138,17 @@ export const useChartDataFetch = ( |
| 131 | 138 | try { |
| 132 | 139 | const filter = targetComponent.filter |
| 133 | 140 | const {value} = useFilterFn(filter, res) |
| 141 | + //分组更新下面子组件 | |
| 142 | + if(targetComponent.isGroup) { | |
| 143 | + const parseHistoryInput = JSONParse(targetComponent.saveHistoryInput!) | |
| 144 | + parseHistoryInput?.forEach((historyItem:Recordable) => { | |
| 145 | + const findCurrentItem = targetComponent.groupList?.find((groupItem:CreateComponentType | CreateComponentGroupType) => groupItem.id === historyItem.id) | |
| 146 | + if(findCurrentItem) { | |
| 147 | + findCurrentItem.option.dataset = value[historyItem.inputValue] | |
| 148 | + } | |
| 149 | + }) | |
| 150 | + } | |
| 151 | + // | |
| 134 | 152 | echartsUpdateHandle(value) |
| 135 | 153 | // 更新回调函数 |
| 136 | 154 | if (updateCallback) { |
| ... | ... | @@ -153,13 +171,12 @@ export const useChartDataFetch = ( |
| 153 | 171 | deep: true |
| 154 | 172 | } |
| 155 | 173 | ) |
| 156 | - | |
| 157 | 174 | // 定时时间 |
| 158 | - const time = targetInterval && targetInterval.value ? targetInterval.value : globalRequestInterval.value | |
| 175 | + const time = targetInterval && targetInterval.value ? targetInterval.value : pondRequestGlobalInterval?.value?pondRequestGlobalInterval?.value: globalRequestInterval.value | |
| 159 | 176 | // 单位 |
| 160 | - const unit = targetInterval && targetInterval.value ? targetUnit.value : globalUnit.value | |
| 177 | + const unit = targetInterval && targetInterval.value ? targetUnit.value :pondRequestGlobalIntervalUnit?.value?pondRequestGlobalIntervalUnit?.value: globalUnit.value | |
| 161 | 178 | // 开启轮询 |
| 162 | - if (time) fetchInterval = setInterval(fetchFn, intervalUnitHandle(time, unit)) | |
| 179 | + if (time) fetchInterval = setInterval(fetchFn, intervalUnitHandle(time, (unit as unknown as any))) | |
| 163 | 180 | |
| 164 | 181 | |
| 165 | 182 | } |
| ... | ... | @@ -176,11 +193,12 @@ export const useChartDataFetch = ( |
| 176 | 193 | /** |
| 177 | 194 | * 支持分组也可以接受ws |
| 178 | 195 | * 如果是分组并且绑定了ws |
| 196 | + * 也支持http轮询 | |
| 179 | 197 | */ |
| 180 | 198 | chartEditStore.getComponentList?.forEach((item: CreateComponentType | CreateComponentGroupType) => { |
| 181 | 199 | if (item.isGroup) { |
| 182 | 200 | if (item.request.requestUrl?.includes('ws')) { |
| 183 | - initial(item, useChartEditStore, updateCallback) | |
| 201 | + initial(item, useChartEditStore, updateCallback) // ws | |
| 184 | 202 | } |
| 185 | 203 | } |
| 186 | 204 | }) | ... | ... |
| ... | ... | @@ -12,17 +12,18 @@ export const useFetchTargetData = () => { |
| 12 | 12 | const fetchTargetData = async () => { |
| 13 | 13 | const { targetData } = useTargetData() |
| 14 | 14 | if (unref(targetData).request.requestDataType === RequestDataTypeEnum.STATIC) return |
| 15 | + if (!unref(targetData).request.requestUrl) return | |
| 15 | 16 | loading.value = true |
| 16 | 17 | try { |
| 17 | - const isSocketType = (targetData.value.request.requestContentType as RequestContentTypeEnum) === RequestContentTypeEnum.WEB_SOCKET | |
| 18 | - const res = isSocketType | |
| 19 | - ? await sendMessage(unref(targetData) as CreateComponentType) | |
| 20 | - : await customRequest(toRaw(targetData.value.request)) | |
| 21 | - | |
| 22 | - if (res) { | |
| 23 | - return res | |
| 24 | - } | |
| 25 | - window['$message'].warning('没有拿到返回值,请检查接口!') | |
| 18 | + const isSocketType = (targetData.value.request.requestContentType as RequestContentTypeEnum) === RequestContentTypeEnum.WEB_SOCKET | |
| 19 | + const res = isSocketType | |
| 20 | + ? await sendMessage(unref(targetData) as CreateComponentType) | |
| 21 | + : await customRequest(toRaw(targetData.value.request)) | |
| 22 | + | |
| 23 | + if (res) { | |
| 24 | + return res | |
| 25 | + } | |
| 26 | + window['$message'].warning('没有拿到返回值,请检查接口!') | |
| 26 | 27 | } catch (error) { |
| 27 | 28 | loading.value = false |
| 28 | 29 | console.error(error); | ... | ... |
| ... | ... | @@ -9,6 +9,7 @@ const getAllConfigFile = async () => { |
| 9 | 9 | |
| 10 | 10 | const getChartConfigFile = async (path: string) => { |
| 11 | 11 | const fileList = await getAllConfigFile() |
| 12 | + if (path.includes('group')) return // 分组则终止 | |
| 12 | 13 | return fileList[path]() as any |
| 13 | 14 | } |
| 14 | 15 | |
| ... | ... | @@ -41,6 +42,7 @@ export const createComponent = async (configType: ConfigType) => { |
| 41 | 42 | // |
| 42 | 43 | const hasExternalPrefix = matchExternalPrefixReg.test(chartKey) |
| 43 | 44 | const filePath = `../components${hasExternalPrefix ? '/external' : ''}/${packageName}/${category}/${key}/config.ts` |
| 45 | + if (filePath.includes('group')) return // 分组则终止 | |
| 44 | 46 | const chart = await getChartConfigFile(filePath) |
| 45 | 47 | return new chart.default() |
| 46 | 48 | } | ... | ... |
| ... | ... | @@ -230,8 +230,8 @@ export interface RequestConfigType extends RequestPublicConfigType { |
| 230 | 230 | // 请求头里的Token前缀 |
| 231 | 231 | requestTokenSuffix?: string |
| 232 | 232 | pondRequestOriginUrl?: string |
| 233 | - pondRequestInterval?: number | |
| 234 | - pondRequestIntervalUnit?: string | |
| 233 | + pondRequestGlobalInterval?: number | |
| 234 | + pondRequestGlobalIntervalUnit?: string | |
| 235 | 235 | pondRequestGlobalTokenSuffix?: string |
| 236 | 236 | pondRequestGlobalTokenKey?: string |
| 237 | 237 | pondRequestGlobalCascaderOption?: Recordable | ... | ... |
| ... | ... | @@ -158,7 +158,7 @@ const { |
| 158 | 158 | } = toRefs((props.targetData as RequestDataPondItemType).dataPondRequestConfig) |
| 159 | 159 | |
| 160 | 160 | const tabs = [RequestParamsTypeEnum.HEADER] |
| 161 | -const requestContentTypeObj = { | |
| 161 | +const requestContentTypeObj: Recordable = { | |
| 162 | 162 | [RequestContentTypeEnum.DEFAULT]: '普通请求', |
| 163 | 163 | [RequestContentTypeEnum.SQL]: 'SQL 请求' |
| 164 | 164 | } | ... | ... |
| ... | ... | @@ -47,7 +47,7 @@ const emit = defineEmits(['update:modelShow', 'sendHandle']) |
| 47 | 47 | const { chartConfig } = toRefs(props.targetData as CreateComponentType) |
| 48 | 48 | const { requestContentType } = toRefs((props.targetData as CreateComponentType).request) |
| 49 | 49 | const modelShowRef = ref(false) |
| 50 | -const requestContentTypeObj = { | |
| 50 | +const requestContentTypeObj: Recordable = { | |
| 51 | 51 | [RequestContentTypeEnum.DEFAULT]: '普通请求', |
| 52 | 52 | [RequestContentTypeEnum.SQL]: 'SQL 请求' |
| 53 | 53 | } | ... | ... |
| ... | ... | @@ -58,9 +58,21 @@ |
| 58 | 58 | <NSpace :size="15" vertical> |
| 59 | 59 | <div class="editor-data-show"> |
| 60 | 60 | <NSpace> |
| 61 | - <NText depth="3">接口返回数据(res):</NText> | |
| 61 | + <NText depth="3">原始数据:</NText> | |
| 62 | 62 | <n-collapse :default-expanded-names="['1']"> |
| 63 | - <n-collapse-item title="res" name="1"> | |
| 63 | + <n-collapse-item name="1"> | |
| 64 | + <NScrollbar style="max-height: 300px;"> | |
| 65 | + <NCode :code="toString(cacheConfig) || '暂无'" language="json" :word-wrap="true"></NCode> | |
| 66 | + </NScrollbar> | |
| 67 | + </n-collapse-item> | |
| 68 | + </n-collapse> | |
| 69 | + </NSpace> | |
| 70 | + </div> | |
| 71 | + <div class="editor-data-show"> | |
| 72 | + <NSpace> | |
| 73 | + <NText depth="3">接口返回数据(res):</NText> | |
| 74 | + <n-collapse> | |
| 75 | + <n-collapse-item name="2"> | |
| 64 | 76 | <NScrollbar style="max-height: 300px;"> |
| 65 | 77 | <NCode :code="toString(isSocketRequest ? targetData.wsOriginalMessage : sourceData) || '暂无'" language="json" :word-wrap="true"></NCode> |
| 66 | 78 | </NScrollbar> |
| ... | ... | @@ -72,7 +84,7 @@ |
| 72 | 84 | <NSpace> |
| 73 | 85 | <NText depth="3">过滤器结果:</NText> |
| 74 | 86 | <n-collapse> |
| 75 | - <n-collapse-item title="结果" name="2"> | |
| 87 | + <n-collapse-item name="3"> | |
| 76 | 88 | <NCode :code="filterRes || '暂无'" language="json" :word-wrap="true"></NCode> |
| 77 | 89 | </n-collapse-item> |
| 78 | 90 | </n-collapse> |
| ... | ... | @@ -105,7 +117,7 @@ |
| 105 | 117 | </template> |
| 106 | 118 | |
| 107 | 119 | <script lang="ts" setup> |
| 108 | -import { ref, computed, watch, unref } from 'vue' | |
| 120 | +import { ref, computed, watch, unref, onMounted } from 'vue' | |
| 109 | 121 | import { MonacoEditor } from '@/components/Pages/MonacoEditor' |
| 110 | 122 | import { icon } from '@/plugins' |
| 111 | 123 | import { goDialog, toString } from '@/utils' |
| ... | ... | @@ -114,6 +126,7 @@ import { NButton, NCard, NCode, NDivider, NIcon, NModal, NScrollbar, NSpace, NTa |
| 114 | 126 | import { useFilterFn } from '@/hooks/external/useFilterFn' |
| 115 | 127 | import { useFetchTargetData } from '@/hooks/external/useFetchTargetData' |
| 116 | 128 | import { RequestContentTypeEnum } from '@/enums/external/httpEnum' |
| 129 | +import { createComponent } from '@/packages/external/override' | |
| 117 | 130 | |
| 118 | 131 | const { DocumentTextIcon } = icon.ionicons5 |
| 119 | 132 | const { FilterIcon, FilterEditIcon } = icon.carbon |
| ... | ... | @@ -208,6 +221,19 @@ watch( |
| 208 | 221 | } |
| 209 | 222 | } |
| 210 | 223 | ) |
| 224 | + | |
| 225 | +const cacheConfig = ref() | |
| 226 | + | |
| 227 | +const fetchComponentConfig = async () => { | |
| 228 | + const config = await createComponent(targetData.value.chartConfig) | |
| 229 | + return config | |
| 230 | +} | |
| 231 | + | |
| 232 | + | |
| 233 | +onMounted(async ()=> { | |
| 234 | + const config = await fetchComponentConfig() | |
| 235 | + cacheConfig.value = config?.option?.dataset | |
| 236 | +}) | |
| 211 | 237 | </script> |
| 212 | 238 | |
| 213 | 239 | <style lang="scss" scoped> | ... | ... |
| ... | ... | @@ -12,6 +12,9 @@ import { RequestModal } from '../RequestModal' |
| 12 | 12 | import { useFetchTargetData } from '@/hooks/external/useFetchTargetData' |
| 13 | 13 | import { useFilterFn } from '@/hooks/external/useFilterFn' |
| 14 | 14 | import { RequestDataTypeEnum } from '@/enums/external/httpEnum' |
| 15 | +import { JSONParse } from '@/utils/external/utils' | |
| 16 | +import { CreateComponentGroupType, CreateComponentType } from '@/packages/index.d' | |
| 17 | +import { isArray } from '@/utils/external/is' | |
| 15 | 18 | |
| 16 | 19 | const { HelpOutlineIcon, FlashIcon } = icon.ionicons5 |
| 17 | 20 | const { targetData } = useTargetData() |
| ... | ... | @@ -54,6 +57,19 @@ const sendHandle = async () => { |
| 54 | 57 | const res = await fetchTargetData() |
| 55 | 58 | if (res) { |
| 56 | 59 | const { value } = useFilterFn(targetData.value.filter, res) |
| 60 | + //分组更新下面子组件 | |
| 61 | + if(targetData.value.isGroup) { | |
| 62 | + if (isArray(targetData.value.saveHistoryInput!)) { | |
| 63 | + const parseHistoryInput = JSONParse(targetData.value.saveHistoryInput!) | |
| 64 | + parseHistoryInput?.forEach((historyItem:Recordable) => { | |
| 65 | + const findCurrentItem = targetData.value.groupList?.find((groupItem:CreateComponentType | CreateComponentGroupType) => groupItem.id === historyItem.id) | |
| 66 | + if(findCurrentItem) { | |
| 67 | + findCurrentItem.option.dataset = value[historyItem.inputValue] | |
| 68 | + } | |
| 69 | + }) | |
| 70 | + } | |
| 71 | + } | |
| 72 | + // | |
| 57 | 73 | targetData.value.option.dataset = value |
| 58 | 74 | showMatching.value = true |
| 59 | 75 | return |
| ... | ... | @@ -86,7 +102,7 @@ watchEffect(() => { |
| 86 | 102 | //ft |
| 87 | 103 | if (lastFilter !== filter && firstFocus) { |
| 88 | 104 | lastFilter = filter |
| 89 | - sendHandle() | |
| 105 | + // sendHandle() | |
| 90 | 106 | } |
| 91 | 107 | firstFocus++ |
| 92 | 108 | }) | ... | ... |
| ... | ... | @@ -145,6 +145,10 @@ onMounted(()=>{ |
| 145 | 145 | targetData.value.request.pondRequestOriginUrl = findCurrentPond()?.dataPondRequestConfig?.pondRequestOriginUrl |
| 146 | 146 | targetData.value.request.pondRequestGlobalTokenKey = findCurrentPond()?.dataPondRequestConfig?.pondRequestGlobalTokenKey |
| 147 | 147 | targetData.value.request.pondRequestGlobalTokenSuffix = findCurrentPond()?.dataPondRequestConfig?.pondRequestGlobalTokenSuffix |
| 148 | + targetData.value.request.pondRequestInterval = findCurrentPond()?.dataPondRequestConfig?.pondRequestInterval | |
| 149 | + targetData.value.request.pondRequestIntervalUnit = findCurrentPond()?.dataPondRequestConfig?.pondRequestIntervalUnit | |
| 150 | + targetData.value.request.pondRequestGlobalInterval = findCurrentPond()?.dataPondRequestConfig?.pondRequestGlobalInterval | |
| 151 | + targetData.value.request.pondRequestGlobalIntervalUnit = findCurrentPond()?.dataPondRequestConfig?.pondRequestGlobalIntervalUnit | |
| 148 | 152 | handleExecuteRequest() |
| 149 | 153 | }) |
| 150 | 154 | </script> | ... | ... |
| ... | ... | @@ -38,7 +38,7 @@ const pondRequestOriginUrlRef= ref('') |
| 38 | 38 | |
| 39 | 39 | const pondRequestIntervalRef = ref() |
| 40 | 40 | |
| 41 | -const pondRequestIntervalUnitRef = ref('') | |
| 41 | +const pondRequestIntervalUnitRef = ref(RequestHttpIntervalEnum.SECOND) | |
| 42 | 42 | |
| 43 | 43 | const pondRequestGlobalTokenSuffixRef = ref('') |
| 44 | 44 | |
| ... | ... | @@ -62,8 +62,8 @@ const handleIsTokenSwitch = (value: boolean) => { |
| 62 | 62 | const getConfigurationData = (): Partial<RequestConfigType> => { |
| 63 | 63 | return { |
| 64 | 64 | pondRequestOriginUrl: unref(pondRequestOriginUrlRef), |
| 65 | - pondRequestInterval: unref(pondRequestIntervalRef), | |
| 66 | - pondRequestIntervalUnit: unref(pondRequestIntervalUnitRef), | |
| 65 | + pondRequestGlobalInterval: unref(pondRequestIntervalRef), | |
| 66 | + pondRequestGlobalIntervalUnit: unref(pondRequestIntervalUnitRef), | |
| 67 | 67 | pondRequestGlobalTokenSuffix: unref(pondRequestGlobalTokenSuffixRef), |
| 68 | 68 | pondRequestGlobalTokenKey: unref(pondRequestGlobalTokenKeyRef), |
| 69 | 69 | pondRequestGlobalIsToken: unref(pondRequestGlobalIsTokenRef), |
| ... | ... | @@ -71,10 +71,10 @@ const getConfigurationData = (): Partial<RequestConfigType> => { |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | const setConfigurationData = (request: Partial<RequestConfigType>) => { |
| 74 | - const { pondRequestOriginUrl, pondRequestInterval, pondRequestIntervalUnit, pondRequestGlobalTokenSuffix, pondRequestGlobalTokenKey, pondRequestGlobalIsToken } = request | |
| 74 | + const { pondRequestOriginUrl, pondRequestGlobalInterval, pondRequestGlobalIntervalUnit, pondRequestGlobalTokenSuffix, pondRequestGlobalTokenKey, pondRequestGlobalIsToken } = request | |
| 75 | 75 | pondRequestOriginUrlRef.value = pondRequestOriginUrl! |
| 76 | - pondRequestIntervalRef.value = pondRequestInterval | |
| 77 | - pondRequestIntervalUnitRef.value = pondRequestIntervalUnit! | |
| 76 | + pondRequestIntervalRef.value = pondRequestGlobalInterval | |
| 77 | + pondRequestIntervalUnitRef.value = pondRequestGlobalIntervalUnit! as RequestHttpIntervalEnum | |
| 78 | 78 | pondRequestGlobalTokenSuffixRef.value = pondRequestGlobalTokenSuffix! |
| 79 | 79 | pondRequestGlobalTokenKeyRef.value = pondRequestGlobalTokenKey! |
| 80 | 80 | pondRequestGlobalIsTokenRef.value = pondRequestGlobalIsToken! | ... | ... |
| ... | ... | @@ -41,7 +41,7 @@ const handleSyncRequestParamsBodyType = (value: RequestBodyEnum) => { |
| 41 | 41 | v-model:value="value.Body[RequestBodyEnum.X_WWW_FORM_URLENCODED]" /> |
| 42 | 42 | |
| 43 | 43 | <MonacoEditor v-if="requestParamsBodyType === RequestBodyEnum.JSON" |
| 44 | - v-model:modelValue="value.Body[RequestBodyEnum.JSON]" width="600px" height="200px" language="json" /> | |
| 44 | + v-model:modelValue="value.Body[RequestBodyEnum.JSON]" width="600px" height="200px" language="json" :config="true" /> | |
| 45 | 45 | |
| 46 | 46 | <MonacoEditor v-if="requestParamsBodyType === RequestBodyEnum.XML" |
| 47 | 47 | v-model:modelValue="value.Body[RequestBodyEnum.XML]" width="600px" height="200px" language="xml" /> | ... | ... |
| ... | ... | @@ -14,6 +14,8 @@ import { createRequestModalContext } from './useRequestModalContext' |
| 14 | 14 | import { useTargetData } from '../../../../hooks/useTargetData.hook' |
| 15 | 15 | import { useFetchTargetData } from '@/hooks/external/useFetchTargetData' |
| 16 | 16 | import { useFilterFn } from '@/hooks/external/useFilterFn' |
| 17 | +import { JSONParse } from '@/utils/external/utils' | |
| 18 | +import { isArray } from '@/utils/external/is' | |
| 17 | 19 | |
| 18 | 20 | const requestDataType = ref<RequestDataTypeEnum>(RequestDataTypeEnum.AJAX) |
| 19 | 21 | |
| ... | ... | @@ -79,6 +81,19 @@ const sendHandle = async () => { |
| 79 | 81 | const res = await fetchTargetData() |
| 80 | 82 | if (res) { |
| 81 | 83 | const { value } = useFilterFn(targetData.value.filter, res) |
| 84 | + //分组更新下面子组件 | |
| 85 | + if(targetData.value.isGroup) { | |
| 86 | + if (isArray(targetData.value.saveHistoryInput!)) { | |
| 87 | + const parseHistoryInput = JSONParse(targetData.value.saveHistoryInput!) | |
| 88 | + parseHistoryInput?.forEach((historyItem:Recordable) => { | |
| 89 | + const findCurrentItem = targetData.value.groupList?.find((groupItem:CreateComponentType | CreateComponentGroupType) => groupItem.id === historyItem.id) | |
| 90 | + if(findCurrentItem) { | |
| 91 | + findCurrentItem.option.dataset = value[historyItem.inputValue] | |
| 92 | + } | |
| 93 | + }) | |
| 94 | + } | |
| 95 | + } | |
| 96 | + // | |
| 82 | 97 | targetData.value.option.dataset = value |
| 83 | 98 | return |
| 84 | 99 | } |
| ... | ... | @@ -98,6 +113,8 @@ const handleSaveAction = async () => { |
| 98 | 113 | value.requestDataType = targetData.value.request.requestDataType |
| 99 | 114 | value.publicInterfaceSelectId = targetData.value.request.publicInterfaceSelectId |
| 100 | 115 | value.pondRequestGlobalIsToken = targetData.value.request.pondRequestGlobalIsToken |
| 116 | + value.pondRequestGlobalIntervalUnit = targetData.value.request.pondRequestGlobalIntervalUnit | |
| 117 | + value.pondRequestGlobalInterval = targetData.value.request.pondRequestGlobalInterval | |
| 101 | 118 | if (unref(selectTarget)) { |
| 102 | 119 | chartEditStore.updateComponentList(chartEditStore.fetchTargetIndex(), { |
| 103 | 120 | ...unref(selectTarget)!, | ... | ... |
| ... | ... | @@ -44,6 +44,7 @@ import { CreateComponentType, CreateComponentGroupType } from '@/packages/index. |
| 44 | 44 | import { datasetType, saveHistoryInputValueListType, historyInputValue } from './index.d' |
| 45 | 45 | import { uniqBy } from 'lodash' |
| 46 | 46 | import { SelectOption } from 'naive-ui' |
| 47 | +import { isArray } from '@/utils/external/is' | |
| 47 | 48 | |
| 48 | 49 | const { targetData } = useTargetData() |
| 49 | 50 | |
| ... | ... | @@ -107,8 +108,8 @@ watch( |
| 107 | 108 | (newValue: CreateComponentType | CreateComponentGroupType) => { |
| 108 | 109 | try { |
| 109 | 110 | const uniqHistoryInputValueList = uniqBy(saveHistoryInputValueList.value, 'id') |
| 110 | - if (uniqHistoryInputValueList) { | |
| 111 | - newValue.saveHistoryInput = JSON.stringify(uniqHistoryInputValueList) | |
| 111 | + if (isArray(uniqHistoryInputValueList)) { | |
| 112 | + targetData.value.saveHistoryInput = JSON.stringify(uniqHistoryInputValueList) | |
| 112 | 113 | window.localStorage.setItem('CACHE_HISTORY_INPUT_VALUE', JSON.stringify(uniqHistoryInputValueList)) |
| 113 | 114 | } |
| 114 | 115 | newValue?.groupList?.forEach((item: CreateComponentType) => { | ... | ... |
| ... | ... | @@ -37,11 +37,12 @@ |
| 37 | 37 | </template> |
| 38 | 38 | |
| 39 | 39 | <script setup lang="ts"> |
| 40 | -import { PropType } from 'vue' | |
| 40 | +import { PropType, onMounted } from 'vue' | |
| 41 | 41 | import { CreateComponentGroupType } from '@/packages/index.d' |
| 42 | 42 | import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils' |
| 43 | 43 | import { getSizeStyle, getComponentAttrStyle, getStatusStyle, getPreviewConfigStyle } from '../../utils' |
| 44 | -import { useLifeHandler } from '@/hooks' | |
| 44 | +import { useChartDataFetch, useLifeHandler } from '@/hooks' | |
| 45 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | |
| 45 | 46 | |
| 46 | 47 | const props = defineProps({ |
| 47 | 48 | groupData: { |
| ... | ... | @@ -61,6 +62,10 @@ const props = defineProps({ |
| 61 | 62 | required: true |
| 62 | 63 | } |
| 63 | 64 | }) |
| 65 | + | |
| 66 | +onMounted(()=>{ | |
| 67 | + useChartDataFetch(props.groupData, useChartEditStore) | |
| 68 | +}) | |
| 64 | 69 | </script> |
| 65 | 70 | |
| 66 | 71 | <style lang="scss" scoped> | ... | ... |