|
@@ -1,16 +1,28 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="go-chart-configurations-data-ajax">
|
|
<div class="go-chart-configurations-data-ajax">
|
|
|
<n-card class="n-card-shallow">
|
|
<n-card class="n-card-shallow">
|
|
|
- <setting-item-box name="基础配置">
|
|
|
|
|
- <setting-item name="请求方式">
|
|
|
|
|
|
|
+ <setting-item-box name="请求配置">
|
|
|
|
|
+ <setting-item name="类型">
|
|
|
|
|
+ <n-tag :bordered="false" type="primary">
|
|
|
|
|
+ {{ requestContentType === RequestContentTypeEnum.DEFAULT ? '普通请求' : 'SQL请求' }}
|
|
|
|
|
+ </n-tag>
|
|
|
|
|
+ </setting-item>
|
|
|
|
|
+
|
|
|
|
|
+ <setting-item name="方式">
|
|
|
<n-input size="small" :placeholder="requestHttpType || '暂无'" :disabled="true"></n-input>
|
|
<n-input size="small" :placeholder="requestHttpType || '暂无'" :disabled="true"></n-input>
|
|
|
</setting-item>
|
|
</setting-item>
|
|
|
|
|
|
|
|
- <setting-item name="请求间隔">
|
|
|
|
|
- <n-input size="small" :placeholder="requestInterval || '暂无'" :disabled="true">
|
|
|
|
|
|
|
+ <setting-item name="组件间隔(高级)">
|
|
|
|
|
+ <n-input size="small" :placeholder="`${requestInterval}` || '暂无'" :disabled="true">
|
|
|
<template #suffix> {{ SelectHttpTimeNameObj[requestIntervalUnit] }} </template>
|
|
<template #suffix> {{ SelectHttpTimeNameObj[requestIntervalUnit] }} </template>
|
|
|
</n-input>
|
|
</n-input>
|
|
|
</setting-item>
|
|
</setting-item>
|
|
|
|
|
+
|
|
|
|
|
+ <setting-item name="全局间隔(默认)">
|
|
|
|
|
+ <n-input size="small" :placeholder="`${GlobalRequestInterval}` || '暂无'" :disabled="true">
|
|
|
|
|
+ <template #suffix> {{ SelectHttpTimeNameObj[GlobalRequestIntervalUnit] }} </template>
|
|
|
|
|
+ </n-input>
|
|
|
|
|
+ </setting-item>
|
|
|
</setting-item-box>
|
|
</setting-item-box>
|
|
|
|
|
|
|
|
<setting-item-box name="源地址" :alone="true">
|
|
<setting-item-box name="源地址" :alone="true">
|
|
@@ -35,7 +47,7 @@
|
|
|
|
|
|
|
|
<div class="edit-text" @click="requestModelHandle">
|
|
<div class="edit-text" @click="requestModelHandle">
|
|
|
<div class="go-absolute-center">
|
|
<div class="go-absolute-center">
|
|
|
- <n-button type="primary" secondary>点击配置</n-button>
|
|
|
|
|
|
|
+ <n-button type="primary" secondary>查看更多</n-button>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</n-card>
|
|
</n-card>
|
|
@@ -72,14 +84,14 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { ref, toRefs, onBeforeUnmount, watchEffect } from 'vue'
|
|
|
|
|
|
|
+import { ref, toRefs, onBeforeUnmount, watchEffect, toRaw } from 'vue'
|
|
|
import { icon } from '@/plugins'
|
|
import { icon } from '@/plugins'
|
|
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
|
|
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
|
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
|
|
import { ChartDataRequest } from '../ChartDataRequest/index'
|
|
import { ChartDataRequest } from '../ChartDataRequest/index'
|
|
|
-import { RequestHttpEnum, ResultEnum, SelectHttpTimeNameObj } from '@/enums/httpEnum'
|
|
|
|
|
|
|
+import { RequestHttpEnum, ResultEnum, SelectHttpTimeNameObj, RequestContentTypeEnum } from '@/enums/httpEnum'
|
|
|
import { chartDataUrl, rankListUrl, scrollBoardUrl, numberFloatUrl, numberIntUrl, textUrl, imageUrl } from '@/api/mock'
|
|
import { chartDataUrl, rankListUrl, scrollBoardUrl, numberFloatUrl, numberIntUrl, textUrl, imageUrl } from '@/api/mock'
|
|
|
-import { http } from '@/api/http'
|
|
|
|
|
|
|
+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'
|
|
@@ -87,8 +99,14 @@ import { isDev, newFunctionHandle } from '@/utils'
|
|
|
|
|
|
|
|
const { HelpOutlineIcon, FlashIcon, PulseIcon } = icon.ionicons5
|
|
const { HelpOutlineIcon, FlashIcon, PulseIcon } = icon.ionicons5
|
|
|
const { targetData, chartEditStore } = useTargetData()
|
|
const { targetData, chartEditStore } = useTargetData()
|
|
|
-const { requestUrl, requestHttpType, requestInterval, requestIntervalUnit } = toRefs(targetData.value.request)
|
|
|
|
|
-const { requestOriginUrl } = toRefs(chartEditStore.getRequestGlobalConfig)
|
|
|
|
|
|
|
+const { requestUrl, requestHttpType, requestInterval, requestIntervalUnit, requestContentType } = toRefs(
|
|
|
|
|
+ targetData.value.request
|
|
|
|
|
+)
|
|
|
|
|
+const {
|
|
|
|
|
+ requestOriginUrl,
|
|
|
|
|
+ requestInterval: GlobalRequestInterval,
|
|
|
|
|
+ requestIntervalUnit: GlobalRequestIntervalUnit
|
|
|
|
|
+} = toRefs(chartEditStore.getRequestGlobalConfig)
|
|
|
const designStore = useDesignStore()
|
|
const designStore = useDesignStore()
|
|
|
const themeColor = ref(designStore.getAppTheme)
|
|
const themeColor = ref(designStore.getAppTheme)
|
|
|
|
|
|
|
@@ -106,21 +124,19 @@ const requestModelHandle = () => {
|
|
|
// 发送请求
|
|
// 发送请求
|
|
|
const sendHandle = async () => {
|
|
const sendHandle = async () => {
|
|
|
loading.value = true
|
|
loading.value = true
|
|
|
- if (!targetData.value) return
|
|
|
|
|
- const { requestUrl, requestHttpType } = targetData.value.request
|
|
|
|
|
- if (!requestUrl) {
|
|
|
|
|
- window['$message'].warning('请求参数不正确,请检查!')
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- const completePath = requestOriginUrl && requestOriginUrl.value + requestUrl
|
|
|
|
|
- const res = await http(requestHttpType)(completePath || '', {})
|
|
|
|
|
- loading.value = false
|
|
|
|
|
- if (res.status === ResultEnum.SUCCESS) {
|
|
|
|
|
- targetData.value.option.dataset = newFunctionHandle(res.data, targetData.value.filter)
|
|
|
|
|
- showMatching.value = true
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.requestGlobalConfig))
|
|
|
|
|
+ loading.value = false
|
|
|
|
|
+ if (res && res.status === ResultEnum.SUCCESS) {
|
|
|
|
|
+ targetData.value.option.dataset = newFunctionHandle(res.data, targetData.value.filter)
|
|
|
|
|
+ showMatching.value = true
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ window['$message'].warning('数据异常,请检查参数!')
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ loading.value = false
|
|
|
|
|
+ window['$message'].warning('数据异常,请检查参数!')
|
|
|
}
|
|
}
|
|
|
- window['$message'].warning('数据异常,请检查接口数据!')
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
watchEffect(() => {
|
|
@@ -152,7 +168,7 @@ onBeforeUnmount(() => {
|
|
|
top: 0px;
|
|
top: 0px;
|
|
|
left: 0px;
|
|
left: 0px;
|
|
|
width: 325px;
|
|
width: 325px;
|
|
|
- height: 235px;
|
|
|
|
|
|
|
+ height: 292px;
|
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
|
opacity: 0;
|
|
opacity: 0;
|
|
|
transition: all 0.3s;
|
|
transition: all 0.3s;
|