mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-22 13:36:23 +08:00
feat: 处理全局接口编辑请求
This commit is contained in:
parent
1201f1a6e4
commit
6c24321a36
@ -72,8 +72,10 @@
|
|||||||
|
|
||||||
<!-- 底部数据展示 -->
|
<!-- 底部数据展示 -->
|
||||||
<chart-data-matching-and-show :show="showMatching && !loading" :ajax="true"></chart-data-matching-and-show>
|
<chart-data-matching-and-show :show="showMatching && !loading" :ajax="true"></chart-data-matching-and-show>
|
||||||
|
|
||||||
<!-- 骨架图 -->
|
<!-- 骨架图 -->
|
||||||
<go-skeleton :load="loading" :repeat="3"></go-skeleton>
|
<go-skeleton :load="loading" :repeat="3"></go-skeleton>
|
||||||
|
|
||||||
<!-- 请求配置model -->
|
<!-- 请求配置model -->
|
||||||
<chart-data-request
|
<chart-data-request
|
||||||
v-model:modelShow="requestShow"
|
v-model:modelShow="requestShow"
|
||||||
@ -95,7 +97,7 @@ import { http, customizeHttp } from '@/api/http'
|
|||||||
import { SelectHttpType } from '../../index.d'
|
import { SelectHttpType } from '../../index.d'
|
||||||
import { ChartDataMatchingAndShow } from '../ChartDataMatchingAndShow'
|
import { ChartDataMatchingAndShow } from '../ChartDataMatchingAndShow'
|
||||||
import { useTargetData } from '../../../hooks/useTargetData.hook'
|
import { useTargetData } from '../../../hooks/useTargetData.hook'
|
||||||
import { isDev, newFunctionHandle } from '@/utils'
|
import { newFunctionHandle } from '@/utils'
|
||||||
|
|
||||||
const { HelpOutlineIcon, FlashIcon, PulseIcon } = icon.ionicons5
|
const { HelpOutlineIcon, FlashIcon, PulseIcon } = icon.ionicons5
|
||||||
const { targetData, chartEditStore } = useTargetData()
|
const { targetData, chartEditStore } = useTargetData()
|
||||||
|
@ -117,7 +117,7 @@ const { uploadFileListRef, customRequest, beforeUpload, download } = useFile(tar
|
|||||||
|
|
||||||
// 是否展示过滤器
|
// 是否展示过滤器
|
||||||
const filterShow = computed(() => {
|
const filterShow = computed(() => {
|
||||||
return targetData.value.request.requestDataType === RequestDataTypeEnum.AJAX
|
return targetData.value.request.requestDataType !== RequestDataTypeEnum.STATIC
|
||||||
})
|
})
|
||||||
|
|
||||||
// 是支持 dataset 的图表类型
|
// 是支持 dataset 的图表类型
|
||||||
|
@ -157,8 +157,6 @@ const {
|
|||||||
requestIntervalUnit
|
requestIntervalUnit
|
||||||
} = toRefs((props.targetData as RequestDataPondItemType).dataPondRequestConfig)
|
} = toRefs((props.targetData as RequestDataPondItemType).dataPondRequestConfig)
|
||||||
|
|
||||||
console.log((props.targetData as RequestDataPondItemType).dataPondRequestConfig)
|
|
||||||
|
|
||||||
const tabs = [RequestParamsTypeEnum.HEADER]
|
const tabs = [RequestParamsTypeEnum.HEADER]
|
||||||
const requestContentTypeObj = {
|
const requestContentTypeObj = {
|
||||||
[RequestContentTypeEnum.DEFAULT]: '普通请求',
|
[RequestContentTypeEnum.DEFAULT]: '普通请求',
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, toRefs, computed, nextTick, watch } from 'vue'
|
import { ref, toRefs, computed, nextTick, watch, toRaw } from 'vue'
|
||||||
import noData from '@/assets/images/canvas/noData.png'
|
import noData from '@/assets/images/canvas/noData.png'
|
||||||
import { ChartDataPondList } from '../ChartDataPondList'
|
import { ChartDataPondList } from '../ChartDataPondList'
|
||||||
import { PondDataRequest } from '../../../ChartDataRequest'
|
import { PondDataRequest } from '../../../ChartDataRequest'
|
||||||
@ -54,6 +54,7 @@ import { ChartDataDisplay } from '../ChartDataDisplay'
|
|||||||
import { requestConfig } from '@/packages/public/publicConfig'
|
import { requestConfig } from '@/packages/public/publicConfig'
|
||||||
import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook'
|
import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook'
|
||||||
import { RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
import { RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
|
import { RequestDataTypeEnum } from '@/enums/httpEnum'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
import { getUUID, goDialog } from '@/utils'
|
import { getUUID, goDialog } from '@/utils'
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
@ -107,7 +108,7 @@ const createPond = () => {
|
|||||||
editData.value = {
|
editData.value = {
|
||||||
dataPondId: id,
|
dataPondId: id,
|
||||||
dataPondName: id,
|
dataPondName: id,
|
||||||
dataPondRequestConfig: cloneDeep(requestConfig)
|
dataPondRequestConfig: cloneDeep({ ...requestConfig, requestDataType: RequestDataTypeEnum.Pond })
|
||||||
}
|
}
|
||||||
openPond()
|
openPond()
|
||||||
}
|
}
|
||||||
@ -118,7 +119,6 @@ const saveHandle = (newData: RequestDataPondItemType) => {
|
|||||||
if (isEdit.value) {
|
if (isEdit.value) {
|
||||||
editSaveHandle(newData)
|
editSaveHandle(newData)
|
||||||
} else {
|
} else {
|
||||||
console.log(editData.value)
|
|
||||||
createSaveHandle(newData)
|
createSaveHandle(newData)
|
||||||
}
|
}
|
||||||
isEdit.value = false
|
isEdit.value = false
|
||||||
@ -173,6 +173,13 @@ const deletePond = (targetData: RequestDataPondItemType) => {
|
|||||||
|
|
||||||
// 关闭
|
// 关闭
|
||||||
const closeHandle = () => {
|
const closeHandle = () => {
|
||||||
|
// 将所选内容赋值给对象
|
||||||
|
if (pondData.value) {
|
||||||
|
targetData.value.request = {
|
||||||
|
...toRaw(pondData.value.dataPondRequestConfig),
|
||||||
|
requestDataPondId: pondData.value.dataPondId
|
||||||
|
}
|
||||||
|
}
|
||||||
emit('update:modelShow', false)
|
emit('update:modelShow', false)
|
||||||
emit('sendHandle')
|
emit('sendHandle')
|
||||||
}
|
}
|
||||||
|
@ -26,17 +26,48 @@
|
|||||||
</n-card>
|
</n-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<setting-item-box :alone="true">
|
||||||
|
<template #name>
|
||||||
|
测试
|
||||||
|
<n-tooltip trigger="hover">
|
||||||
|
<template #trigger>
|
||||||
|
<n-icon size="21" :depth="3">
|
||||||
|
<help-outline-icon></help-outline-icon>
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
默认赋值给 dataset 字段
|
||||||
|
</n-tooltip>
|
||||||
|
</template>
|
||||||
|
<n-button type="primary" ghost @click="sendHandle">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon>
|
||||||
|
<flash-icon />
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
发送请求
|
||||||
|
</n-button>
|
||||||
|
</setting-item-box>
|
||||||
|
|
||||||
|
<!-- 底部数据展示 -->
|
||||||
|
<chart-data-matching-and-show :show="showMatching && !loading" :ajax="true"></chart-data-matching-and-show>
|
||||||
|
|
||||||
|
<!-- 骨架图 -->
|
||||||
|
<go-skeleton :load="loading" :repeat="3"></go-skeleton>
|
||||||
|
|
||||||
<!-- 编辑 / 新增弹窗 -->
|
<!-- 编辑 / 新增弹窗 -->
|
||||||
<chart-data-pond-control v-model:modelShow="controlModel"></chart-data-pond-control>
|
<chart-data-pond-control v-model:modelShow="controlModel" @sendHandle="sendHandle"></chart-data-pond-control>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, toRefs, computed } from 'vue'
|
import { ref, toRefs, toRaw, onBeforeUnmount, computed, watchEffect } from 'vue'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
|
import { http, customizeHttp } from '@/api/http'
|
||||||
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||||
import { ChartDataPondControl } from './components/ChartDataPondControl'
|
import { ChartDataPondControl } from './components/ChartDataPondControl'
|
||||||
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
||||||
import { useTargetData } from '../../../hooks/useTargetData.hook'
|
import { useTargetData } from '../../../hooks/useTargetData.hook'
|
||||||
|
import { ChartDataMatchingAndShow } from '../ChartDataMatchingAndShow'
|
||||||
|
import { newFunctionHandle } from '@/utils'
|
||||||
|
|
||||||
const designStore = useDesignStore()
|
const designStore = useDesignStore()
|
||||||
const { HelpOutlineIcon, FlashIcon, PulseIcon, FishIcon } = icon.ionicons5
|
const { HelpOutlineIcon, FlashIcon, PulseIcon, FishIcon } = icon.ionicons5
|
||||||
@ -48,7 +79,12 @@ const {
|
|||||||
requestIntervalUnit: GlobalRequestIntervalUnit
|
requestIntervalUnit: GlobalRequestIntervalUnit
|
||||||
} = toRefs(chartEditStore.getRequestGlobalConfig)
|
} = toRefs(chartEditStore.getRequestGlobalConfig)
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
const controlModel = ref(false)
|
const controlModel = ref(false)
|
||||||
|
const showMatching = ref(false)
|
||||||
|
|
||||||
|
let firstFocus = 0
|
||||||
|
let lastFilter: any = undefined
|
||||||
|
|
||||||
// 所选数据池
|
// 所选数据池
|
||||||
const pondData = computed(() => {
|
const pondData = computed(() => {
|
||||||
@ -69,6 +105,46 @@ const themeColor = computed(() => {
|
|||||||
const controlModelHandle = () => {
|
const controlModelHandle = () => {
|
||||||
controlModel.value = true
|
controlModel.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
const sendHandle = async () => {
|
||||||
|
if (!targetData.value?.request) {
|
||||||
|
window.$message.warning('请选择一个公共接口!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
// const res = await customizeHttp(
|
||||||
|
// toRaw(pondData.value?.dataPondRequestConfig),
|
||||||
|
// toRaw(chartEditStore.getRequestGlobalConfig)
|
||||||
|
// )
|
||||||
|
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.getRequestGlobalConfig))
|
||||||
|
loading.value = false
|
||||||
|
if (res) {
|
||||||
|
if (!res?.data && !targetData.value.filter) window['$message'].warning('您的数据不符合默认格式,请配置过滤器!')
|
||||||
|
targetData.value.option.dataset = newFunctionHandle(res?.data, res, targetData.value.filter)
|
||||||
|
showMatching.value = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
window['$message'].warning('数据异常,请检查参数!')
|
||||||
|
} catch (error) {
|
||||||
|
loading.value = false
|
||||||
|
window['$message'].warning('数据异常,请检查参数!')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
const filter = targetData.value?.filter
|
||||||
|
if (lastFilter !== filter && firstFocus) {
|
||||||
|
lastFilter = filter
|
||||||
|
sendHandle()
|
||||||
|
}
|
||||||
|
firstFocus++
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
lastFilter = null
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user