From 495d93a835f37c59aacc31240480a0da47556220 Mon Sep 17 00:00:00 2001
From: Min <39849555+MinGlizz@users.noreply.github.com>
Date: Wed, 8 Mar 2023 15:10:33 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8E=A7=E4=BB=B6=E4=B8=8E=E7=BB=84?=
=?UTF-8?q?=E4=BB=B6=E4=BA=A4=E4=BA=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/hooks/events.hook.ts | 23 +++
src/hooks/index.ts | 3 +-
src/hooks/useChartDataFetch.hook.ts | 9 +-
.../components/ChartEvebtInteraction/index.ts | 3 +
.../ChartEvebtInteraction/index.vue | 159 ++++++++++++++++++
5 files changed, 195 insertions(+), 2 deletions(-)
create mode 100644 src/hooks/events.hook.ts
create mode 100644 src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEvebtInteraction/index.ts
create mode 100644 src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEvebtInteraction/index.vue
diff --git a/src/hooks/events.hook.ts b/src/hooks/events.hook.ts
new file mode 100644
index 00000000..669f5668
--- /dev/null
+++ b/src/hooks/events.hook.ts
@@ -0,0 +1,23 @@
+import { computed, toRefs } from 'vue'
+import { CreateComponentType } from '@/packages/index.d'
+import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
+
+// 获取类型
+type ChartEditStoreType = typeof useChartEditStore
+
+// Params 参数修改触发api更新图表请求
+export const eventsCreate = (chartConfig: CreateComponentType, useChartEditStore: ChartEditStoreType, param: { [name: string]: string }, onEvevnt: string) => {
+ const chartEditStore = useChartEditStore()
+ const { eventsFn } = chartConfig.events
+ const fnOnEvevnt = eventsFn.filter((item) => {
+ return item.on === onEvevnt
+ }) || []
+ if (fnOnEvevnt.length === 0) return
+ fnOnEvevnt.forEach((item) => {
+ const index = chartEditStore.fetchTargetIndex(item.components)
+ const { Params } = toRefs(chartEditStore.componentList[index].request.requestParams)
+ Object.keys(item.fn).forEach((key) => {
+ Params.value[key] = param[item.fn[key]]
+ })
+ })
+}
\ No newline at end of file
diff --git a/src/hooks/index.ts b/src/hooks/index.ts
index b5ab7ef8..902d76ef 100644
--- a/src/hooks/index.ts
+++ b/src/hooks/index.ts
@@ -4,4 +4,5 @@ export * from '@/hooks/useCode.hook'
export * from '@/hooks/useChartDataFetch.hook'
export * from '@/hooks/useChartDataPondFetch.hook'
export * from '@/hooks/useLifeHandler.hook'
-export * from '@/hooks/useLang.hook'
\ No newline at end of file
+export * from '@/hooks/useLang.hook'
+export * from '@/hooks/events.hook'
\ No newline at end of file
diff --git a/src/hooks/useChartDataFetch.hook.ts b/src/hooks/useChartDataFetch.hook.ts
index ed82edf5..6cbbdee4 100644
--- a/src/hooks/useChartDataFetch.hook.ts
+++ b/src/hooks/useChartDataFetch.hook.ts
@@ -1,4 +1,4 @@
-import { ref, toRefs, toRaw } from 'vue'
+import { ref, toRefs, toRaw, watch } from 'vue'
import type VChart from 'vue-echarts'
import { customizeHttp } from '@/api/http'
import { useChartDataPondFetch } from '@/hooks/'
@@ -89,6 +89,13 @@ export const useChartDataFetch = (
// 立即调用
fetchFn()
+
+
+ watch(() => targetComponent.request, () => {
+ fetchFn()
+ }, {
+ deep: true
+ })
// 定时时间
const time = targetInterval && targetInterval.value ? targetInterval.value : globalRequestInterval.value
// 单位
diff --git a/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEvebtInteraction/index.ts b/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEvebtInteraction/index.ts
new file mode 100644
index 00000000..d4c2031d
--- /dev/null
+++ b/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEvebtInteraction/index.ts
@@ -0,0 +1,3 @@
+import ChartEvebtInteraction from './index.vue'
+
+export { ChartEvebtInteraction }
\ No newline at end of file
diff --git a/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEvebtInteraction/index.vue b/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEvebtInteraction/index.vue
new file mode 100644
index 00000000..0526f50d
--- /dev/null
+++ b/src/views/chart/ContentConfigurations/components/ChartEvent/components/ChartEvebtInteraction/index.vue
@@ -0,0 +1,159 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item }} |
+
+
+
+
+ {{ cItem.value }} |
+ {{ cItem.label }} |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 添加交互
+
+
+
+
+