Merge branch 'dev'
This commit is contained in:
commit
1688c6bf38
@ -9,7 +9,6 @@ import { isPreview, newFunctionHandle } from '@/utils'
|
|||||||
// 获取类型
|
// 获取类型
|
||||||
type ChartEditStoreType = typeof useChartEditStore
|
type ChartEditStoreType = typeof useChartEditStore
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setdata 数据监听与更改
|
* setdata 数据监听与更改
|
||||||
* @param targetComponent
|
* @param targetComponent
|
||||||
@ -30,7 +29,12 @@ export const useChartDataFetch = (
|
|||||||
// 组件类型
|
// 组件类型
|
||||||
const { chartFrame } = targetComponent.chartConfig
|
const { chartFrame } = targetComponent.chartConfig
|
||||||
// 请求配置
|
// 请求配置
|
||||||
const { requestDataType, requestHttpType, requestUrl } = toRefs(targetComponent.data)
|
const {
|
||||||
|
requestDataType,
|
||||||
|
requestHttpType,
|
||||||
|
requestUrl,
|
||||||
|
requestInterval: targetInterval
|
||||||
|
} = toRefs(targetComponent.request)
|
||||||
// 非请求类型
|
// 非请求类型
|
||||||
if (requestDataType.value !== RequestDataTypeEnum.AJAX) return
|
if (requestDataType.value !== RequestDataTypeEnum.AJAX) return
|
||||||
// 处理地址
|
// 处理地址
|
||||||
@ -65,12 +69,13 @@ export const useChartDataFetch = (
|
|||||||
|
|
||||||
// 立即调用
|
// 立即调用
|
||||||
fetchFn()
|
fetchFn()
|
||||||
|
|
||||||
// 开启定时
|
// 开启定时
|
||||||
fetchInterval = setInterval(fetchFn, requestInterval.value * 1000)
|
const time = targetInterval && targetInterval.value ? targetInterval.value : requestInterval.value
|
||||||
|
fetchInterval = setInterval(fetchFn, time * 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isPreview() && requestIntervalFn()
|
isPreview() && requestIntervalFn()
|
||||||
|
|
||||||
return { vChartRef }
|
return { vChartRef }
|
||||||
}
|
}
|
||||||
|
4
src/packages/index.d.ts
vendored
4
src/packages/index.d.ts
vendored
@ -27,9 +27,7 @@ export type ConfigType = {
|
|||||||
|
|
||||||
// 数据请求
|
// 数据请求
|
||||||
interface requestConfig {
|
interface requestConfig {
|
||||||
data: RequestConfigType,
|
request: RequestConfigType,
|
||||||
// 暂时约定为数据存储区域(未使用)
|
|
||||||
requestData: any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Echarts 数据类型
|
// Echarts 数据类型
|
||||||
|
@ -7,7 +7,8 @@ import { chartInitConfig } from '@/settings/designSetting'
|
|||||||
const requestConfig: RequestConfigType = {
|
const requestConfig: RequestConfigType = {
|
||||||
requestDataType: RequestDataTypeEnum.STATIC,
|
requestDataType: RequestDataTypeEnum.STATIC,
|
||||||
requestHttpType: RequestHttpEnum.GET,
|
requestHttpType: RequestHttpEnum.GET,
|
||||||
requestUrl: ''
|
requestUrl: '',
|
||||||
|
requestInterval: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export class publicConfig implements PublicConfigType {
|
export class publicConfig implements PublicConfigType {
|
||||||
@ -41,10 +42,8 @@ export class publicConfig implements PublicConfigType {
|
|||||||
// 动画
|
// 动画
|
||||||
animations: []
|
animations: []
|
||||||
}
|
}
|
||||||
// 数据
|
// 请求
|
||||||
public data = { ...requestConfig }
|
public request = { ...requestConfig }
|
||||||
// 数据获取
|
|
||||||
public requestData = []
|
|
||||||
// 数据过滤
|
// 数据过滤
|
||||||
public filter = undefined
|
public filter = undefined
|
||||||
|
|
||||||
|
@ -134,9 +134,10 @@ export enum ChartEditStoreEnum {
|
|||||||
export type RequestGlobalConfigType = {
|
export type RequestGlobalConfigType = {
|
||||||
// 请求源地址
|
// 请求源地址
|
||||||
requestOriginUrl?: string
|
requestOriginUrl?: string
|
||||||
// 轮询时间
|
// 全局默认轮询时间
|
||||||
requestInterval: number
|
requestInterval: number
|
||||||
}
|
}
|
||||||
|
|
||||||
// 单个图表请求配置
|
// 单个图表请求配置
|
||||||
export type RequestConfigType = {
|
export type RequestConfigType = {
|
||||||
// 获取数据的方式
|
// 获取数据的方式
|
||||||
@ -145,6 +146,8 @@ export type RequestConfigType = {
|
|||||||
requestHttpType: RequestHttpEnum
|
requestHttpType: RequestHttpEnum
|
||||||
// 源后续的 url
|
// 源后续的 url
|
||||||
requestUrl?: string
|
requestUrl?: string
|
||||||
|
// 组件定制轮询时间
|
||||||
|
requestInterval?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store 类型
|
// Store 类型
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
placeholder="源地址如: http://127.0.0.1"
|
placeholder="源地址如: http://127.0.0.1"
|
||||||
></n-input>
|
></n-input>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
<setting-item-box name="更新间隔">
|
<setting-item-box name="更新间隔" :alone="true">
|
||||||
<n-input-number
|
<n-input-number
|
||||||
v-model:value.trim="chartEditStore.getRequestGlobalConfig.requestInterval"
|
v-model:value.trim="chartEditStore.getRequestGlobalConfig.requestInterval"
|
||||||
min="5"
|
min="5"
|
||||||
:show-button="false"
|
:show-button="false"
|
||||||
placeholder="为 0 不更新"
|
placeholder="将应用全局组件"
|
||||||
>
|
>
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
秒
|
秒
|
||||||
|
@ -1,7 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="go-chart-configurations-data-ajax">
|
<div class="go-chart-configurations-data-ajax">
|
||||||
<setting-item-box name="类型" :alone="true">
|
<setting-item-box name="配置">
|
||||||
<n-select v-model:value="targetData.data.requestHttpType" :options="selectOptions" />
|
<setting-item name="类型">
|
||||||
|
<n-select v-model:value="targetData.request.requestHttpType" :options="selectOptions" />
|
||||||
|
</setting-item>
|
||||||
|
<setting-item name="默认使用全局间隔">
|
||||||
|
<n-input-number
|
||||||
|
v-model:value.trim="targetData.request.requestInterval"
|
||||||
|
min="5"
|
||||||
|
:show-button="false"
|
||||||
|
placeholder="可以为空"
|
||||||
|
>
|
||||||
|
<template #suffix> 秒 </template>
|
||||||
|
</n-input-number>
|
||||||
|
</setting-item>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
|
|
||||||
<setting-item-box name="源地址:" :alone="true">
|
<setting-item-box name="源地址:" :alone="true">
|
||||||
@ -25,9 +37,8 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</n-tooltip>
|
</n-tooltip>
|
||||||
</template>
|
</template>
|
||||||
<n-input v-model:value.trim="targetData.data.requestUrl" :min="1" placeholder="请输入地址(去除源)" />
|
<n-input v-model:value.trim="targetData.request.requestUrl" :min="1" placeholder="请输入地址(去除源)" />
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
|
|
||||||
<setting-item-box :alone="true">
|
<setting-item-box :alone="true">
|
||||||
<template #name>
|
<template #name>
|
||||||
测试
|
测试
|
||||||
@ -60,7 +71,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, toRefs, onBeforeUnmount, watchEffect } from 'vue'
|
import { ref, toRefs, onBeforeUnmount, watchEffect } from 'vue'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
import { SettingItemBox } from '@/components/Pages/ChartItemSetting'
|
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||||
import { RequestHttpEnum, ResultEnum } from '@/enums/httpEnum'
|
import { RequestHttpEnum, ResultEnum } 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 } from '@/api/http'
|
||||||
@ -116,8 +127,8 @@ const selectOptions: SelectHttpType[] = [
|
|||||||
// 发送请求
|
// 发送请求
|
||||||
const sendHandle = async () => {
|
const sendHandle = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
if(!targetData.value) return
|
if (!targetData.value) return
|
||||||
const { requestUrl, requestHttpType } = targetData.value.data
|
const { requestUrl, requestHttpType } = targetData.value.request
|
||||||
if (!requestUrl) {
|
if (!requestUrl) {
|
||||||
window['$message'].warning('请求参数不正确,请检查!')
|
window['$message'].warning('请求参数不正确,请检查!')
|
||||||
return
|
return
|
||||||
|
@ -118,7 +118,7 @@ const { uploadFileListRef, customRequest, beforeUpload, download } = useFile(tar
|
|||||||
|
|
||||||
// 是否展示过滤器
|
// 是否展示过滤器
|
||||||
const filterShow = computed(() => {
|
const filterShow = computed(() => {
|
||||||
return targetData.value.data.requestDataType === RequestDataTypeEnum.AJAX
|
return targetData.value.request.requestDataType === RequestDataTypeEnum.AJAX
|
||||||
})
|
})
|
||||||
|
|
||||||
// 是图表类型
|
// 是图表类型
|
||||||
|
@ -109,7 +109,7 @@ import cloneDeep from 'lodash/cloneDeep'
|
|||||||
const { DocumentTextIcon } = icon.ionicons5
|
const { DocumentTextIcon } = icon.ionicons5
|
||||||
const { FilterIcon, FilterEditIcon } = icon.carbon
|
const { FilterIcon, FilterEditIcon } = icon.carbon
|
||||||
const { targetData, chartEditStore } = useTargetData()
|
const { targetData, chartEditStore } = useTargetData()
|
||||||
const { requestDataType } = toRefs(targetData.value.data)
|
const { requestDataType } = toRefs(targetData.value.request)
|
||||||
const { requestOriginUrl } = toRefs(chartEditStore.getRequestGlobalConfig)
|
const { requestOriginUrl } = toRefs(chartEditStore.getRequestGlobalConfig)
|
||||||
|
|
||||||
// 受控弹窗
|
// 受控弹窗
|
||||||
@ -124,7 +124,7 @@ const sourceData = ref<any>('')
|
|||||||
// 动态获取数据
|
// 动态获取数据
|
||||||
const fetchTargetData = async () => {
|
const fetchTargetData = async () => {
|
||||||
try {
|
try {
|
||||||
const { requestUrl, requestHttpType } = targetData.value.data
|
const { requestUrl, requestHttpType } = targetData.value.request
|
||||||
if (!requestUrl) {
|
if (!requestUrl) {
|
||||||
window['$message'].warning('请求参数不正确,请检查!')
|
window['$message'].warning('请求参数不正确,请检查!')
|
||||||
sourceData.value = '请求参数不正确,请检查!'
|
sourceData.value = '请求参数不正确,请检查!'
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="go-chart-configurations-data" v-if="targetData">
|
<div class="go-chart-configurations-data" v-if="targetData">
|
||||||
<setting-item-box name="请求方式" :alone="true">
|
<setting-item-box name="请求方式" :alone="true">
|
||||||
<n-select
|
<n-select
|
||||||
v-model:value="targetData.data.requestDataType"
|
v-model:value="targetData.request.requestDataType"
|
||||||
:options="selectOptions"
|
:options="selectOptions"
|
||||||
/>
|
/>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<!-- 静态 -->
|
<!-- 静态 -->
|
||||||
<chart-data-static
|
<chart-data-static
|
||||||
v-if="targetData.data.requestDataType === RequestDataTypeEnum.STATIC"
|
v-if="targetData.request.requestDataType === RequestDataTypeEnum.STATIC"
|
||||||
></chart-data-static>
|
></chart-data-static>
|
||||||
|
|
||||||
<!-- 动态 -->
|
<!-- 动态 -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user