Commit b68ec315647e10feb02dfaac9944bcb2dd5fe3d3
Merge branch 'ft' into 'main_dev'
feat(packages/external): 新增自定义按钮,点击跳转 See merge request yunteng/thingskit-view!67
Showing
18 changed files
with
393 additions
and
33 deletions
src/hooks/external/useButtonInteract.hook.ts
0 → 100644
1 | +import { toRefs, ref } from 'vue' | ||
2 | +import { CreateComponentType } from '@/packages/index.d' | ||
3 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | ||
4 | + | ||
5 | +// 获取类型 | ||
6 | +type ChartEditStoreType = typeof useChartEditStore | ||
7 | + | ||
8 | +// Params 参数修改触发 api 更新图表请求 | ||
9 | +export const useChartInteract = ( | ||
10 | + chartConfig: CreateComponentType, | ||
11 | + useChartEditStore: ChartEditStoreType, | ||
12 | + param: { [T: string]: any }, | ||
13 | + interactEventOn: string, | ||
14 | + target: string, | ||
15 | + status: boolean | ||
16 | +) => { | ||
17 | + const chartEditStore = useChartEditStore() | ||
18 | + const { interactEvents } = chartConfig.events | ||
19 | + const fnOnEvent = interactEvents.filter(item => { | ||
20 | + return item.interactOn === interactEventOn | ||
21 | + }) | ||
22 | + if (fnOnEvent.length === 0) return | ||
23 | + fnOnEvent.forEach(item => { | ||
24 | + const index = chartEditStore.fetchTargetIndex(item.interactComponentId) | ||
25 | + if (index === -1) return | ||
26 | + const { Params, Header } = toRefs(chartEditStore.componentList[index].request.requestParams) | ||
27 | + Object.keys(item.interactFn).forEach(key => { | ||
28 | + if (Params.value[key]) { | ||
29 | + Params.value[key] = param[item.interactFn[key]] | ||
30 | + } | ||
31 | + if (Header.value[key]) { | ||
32 | + Header.value[key] = param[item.interactFn[key]] | ||
33 | + } | ||
34 | + }) | ||
35 | + updateIndex(chartConfig) | ||
36 | + }) | ||
37 | + | ||
38 | + function updateIndex(chart: any) { | ||
39 | + try { | ||
40 | + const targetId = chart.option.dataset[0].target | ||
41 | + const currentId = chart.option.dataset[0].current | ||
42 | + const currentButtonId = chart.option.dataset[0].currentButton | ||
43 | + const targetButtonId = chart.option.dataset[0].targetButton | ||
44 | + const targetIndex = chartEditStore.fetchTargetIndex(targetId) | ||
45 | + const currentIndex = chartEditStore.fetchTargetIndex(currentId) | ||
46 | + const currentButtonIndex = chartEditStore.fetchTargetIndex(currentButtonId) | ||
47 | + const targetButtonIndex = chartEditStore.fetchTargetIndex(targetButtonId) | ||
48 | + chartEditStore.componentList[targetIndex].status.hide = false | ||
49 | + chartEditStore.componentList[currentIndex].status.hide = true | ||
50 | + chartEditStore.componentList[currentButtonIndex].status.hide = true | ||
51 | + chartEditStore.componentList[targetButtonIndex].status.hide = false | ||
52 | + } catch (e) { | ||
53 | + console.error(e) | ||
54 | + } | ||
55 | + } | ||
56 | +} | ||
57 | + | ||
58 | +// 联动事件触发的 type 变更时,清除当前绑定内容 | ||
59 | +// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
60 | +export const clearInteractEvent = (chartConfig: CreateComponentType) => {} |
@@ -19,11 +19,9 @@ export const useChartInteract = ( | @@ -19,11 +19,9 @@ export const useChartInteract = ( | ||
19 | interactEventOn: string | 19 | interactEventOn: string |
20 | ) => { | 20 | ) => { |
21 | /**新增代码 */ | 21 | /**新增代码 */ |
22 | - let combineData: any = null | ||
23 | const { | 22 | const { |
24 | option: { dataset } | 23 | option: { dataset } |
25 | } = chartConfig | 24 | } = chartConfig |
26 | - combineData = dataset | ||
27 | const { data } = param | 25 | const { data } = param |
28 | /**新增代码 */ | 26 | /**新增代码 */ |
29 | const chartEditStore = useChartEditStore() | 27 | const chartEditStore = useChartEditStore() |
@@ -46,7 +44,8 @@ export const useChartInteract = ( | @@ -46,7 +44,8 @@ export const useChartInteract = ( | ||
46 | } | 44 | } |
47 | }) | 45 | }) |
48 | /**新增代码 */ | 46 | /**新增代码 */ |
49 | - combineData.forEach((combinItem: any, combinIndex: number) => { | 47 | + if (!Array.isArray(dataset)) return |
48 | + dataset.forEach((combinItem: any, combinIndex: number) => { | ||
50 | if (itemIndex === combinIndex) { | 49 | if (itemIndex === combinIndex) { |
51 | combinItem.targetItem = chartEditStore.componentList[index] | 50 | combinItem.targetItem = chartEditStore.componentList[index] |
52 | } | 51 | } |
@@ -54,14 +53,15 @@ export const useChartInteract = ( | @@ -54,14 +53,15 @@ export const useChartInteract = ( | ||
54 | /**新增代码 */ | 53 | /**新增代码 */ |
55 | }) | 54 | }) |
56 | /**新增代码 */ | 55 | /**新增代码 */ |
57 | - combineData.forEach((item: any) => { | 56 | + if (!Array.isArray(dataset)) return |
57 | + dataset.forEach((item: any) => { | ||
58 | try { | 58 | try { |
59 | if (item.value === data) item.targetItem.status.hide = false | 59 | if (item.value === data) item.targetItem.status.hide = false |
60 | else { | 60 | else { |
61 | item.targetItem.status.hide = true | 61 | item.targetItem.status.hide = true |
62 | } | 62 | } |
63 | } catch (e) { | 63 | } catch (e) { |
64 | - console.log(`useChartInteract.hook.ts:${e}`) | 64 | + console.log(`Error: useChartInteract.hook.ts:${e}`) |
65 | } | 65 | } |
66 | }) | 66 | }) |
67 | /**新增代码 */ | 67 | /**新增代码 */ |
@@ -31,7 +31,7 @@ import { isPreview } from '@/utils' | @@ -31,7 +31,7 @@ import { isPreview } from '@/utils' | ||
31 | import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components' | 31 | import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components' |
32 | import isObject from 'lodash/isObject' | 32 | import isObject from 'lodash/isObject' |
33 | import dataJson from './data.json' | 33 | import dataJson from './data.json' |
34 | -import { isFullScreen } from '../../utls/isFullScreen' | 34 | +import { useFullScreen } from '../../utls/fullScreen' |
35 | 35 | ||
36 | const props = defineProps({ | 36 | const props = defineProps({ |
37 | themeSetting: { | 37 | themeSetting: { |
@@ -68,9 +68,9 @@ const toolBoxOption = { | @@ -68,9 +68,9 @@ const toolBoxOption = { | ||
68 | icon: 'path://M733.549304 0l116.434359 116.23452-226.402521 226.40252 57.053835 57.068109 226.459617-226.445342 120.616689 120.41685V0H733.549304zM689.513507 619.855586l-57.068108 57.068109 224.232847 224.232847-122.64362 122.843458h293.676657V729.838022l-114.007751 114.207588-224.190025-224.190024zM338.197775 404.144414l57.068109-57.068109L171.033037 122.843458 293.676657 0H0v294.161978l114.022025-114.207588 224.17575 224.190024zM347.076305 624.294851L120.616689 850.754468 0 730.323343v293.676657h294.161978l-116.420084-116.23452 226.40252-226.40252-57.068109-57.068109z', | 68 | icon: 'path://M733.549304 0l116.434359 116.23452-226.402521 226.40252 57.053835 57.068109 226.459617-226.445342 120.616689 120.41685V0H733.549304zM689.513507 619.855586l-57.068108 57.068109 224.232847 224.232847-122.64362 122.843458h293.676657V729.838022l-114.007751 114.207588-224.190025-224.190024zM338.197775 404.144414l57.068109-57.068109L171.033037 122.843458 293.676657 0H0v294.161978l114.022025-114.207588 224.17575 224.190024zM347.076305 624.294851L120.616689 850.754468 0 730.323343v293.676657h294.161978l-116.420084-116.23452 226.40252-226.40252-57.068109-57.068109z', |
69 | onclick: () => { | 69 | onclick: () => { |
70 | const getEchartDom = vChartRef.value?.getDom() | 70 | const getEchartDom = vChartRef.value?.getDom() |
71 | - const domName = document.getElementById(getEchartDom.id) as any | ||
72 | - const htmlName = document.querySelector('html') as any | ||
73 | - isFullScreen(domName, htmlName) | 71 | + const domName = document.getElementById(getEchartDom.id) as HTMLElement |
72 | + const htmlName = document.querySelector('html') as HTMLHtmlElement | ||
73 | + useFullScreen(domName, htmlName) | ||
74 | } | 74 | } |
75 | } | 75 | } |
76 | } | 76 | } |
@@ -30,7 +30,7 @@ import { isPreview } from '@/utils' | @@ -30,7 +30,7 @@ import { isPreview } from '@/utils' | ||
30 | import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components' | 30 | import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components' |
31 | import isObject from 'lodash/isObject' | 31 | import isObject from 'lodash/isObject' |
32 | import dataJson from './data.json' | 32 | import dataJson from './data.json' |
33 | -import { isFullScreen } from '../../utls/isFullScreen' | 33 | +import { useFullScreen } from '../../utls/fullScreen' |
34 | 34 | ||
35 | const props = defineProps({ | 35 | const props = defineProps({ |
36 | themeSetting: { | 36 | themeSetting: { |
@@ -67,9 +67,9 @@ const toolBoxOption = { | @@ -67,9 +67,9 @@ const toolBoxOption = { | ||
67 | icon: 'path://M733.549304 0l116.434359 116.23452-226.402521 226.40252 57.053835 57.068109 226.459617-226.445342 120.616689 120.41685V0H733.549304zM689.513507 619.855586l-57.068108 57.068109 224.232847 224.232847-122.64362 122.843458h293.676657V729.838022l-114.007751 114.207588-224.190025-224.190024zM338.197775 404.144414l57.068109-57.068109L171.033037 122.843458 293.676657 0H0v294.161978l114.022025-114.207588 224.17575 224.190024zM347.076305 624.294851L120.616689 850.754468 0 730.323343v293.676657h294.161978l-116.420084-116.23452 226.40252-226.40252-57.068109-57.068109z', | 67 | icon: 'path://M733.549304 0l116.434359 116.23452-226.402521 226.40252 57.053835 57.068109 226.459617-226.445342 120.616689 120.41685V0H733.549304zM689.513507 619.855586l-57.068108 57.068109 224.232847 224.232847-122.64362 122.843458h293.676657V729.838022l-114.007751 114.207588-224.190025-224.190024zM338.197775 404.144414l57.068109-57.068109L171.033037 122.843458 293.676657 0H0v294.161978l114.022025-114.207588 224.17575 224.190024zM347.076305 624.294851L120.616689 850.754468 0 730.323343v293.676657h294.161978l-116.420084-116.23452 226.40252-226.40252-57.068109-57.068109z', |
68 | onclick: () => { | 68 | onclick: () => { |
69 | const getEchartDom = vChartRef.value?.getDom() | 69 | const getEchartDom = vChartRef.value?.getDom() |
70 | - const domName = document.getElementById(getEchartDom.id) as any | ||
71 | - const htmlName = document.querySelector('html') as any | ||
72 | - isFullScreen(domName, htmlName) | 70 | + const domName = document.getElementById(getEchartDom.id) as HTMLElement |
71 | + const htmlName = document.querySelector('html') as HTMLHtmlElement | ||
72 | + useFullScreen(domName, htmlName) | ||
73 | } | 73 | } |
74 | } | 74 | } |
75 | } | 75 | } |
@@ -26,7 +26,7 @@ import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } fr | @@ -26,7 +26,7 @@ import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } fr | ||
26 | import { useChartDataFetch } from '@/hooks' | 26 | import { useChartDataFetch } from '@/hooks' |
27 | import { isPreview, colorGradientCustomMerge } from '@/utils' | 27 | import { isPreview, colorGradientCustomMerge } from '@/utils' |
28 | import dataJson from './data.json' | 28 | import dataJson from './data.json' |
29 | -import { isFullScreen } from '../../utls/isFullScreen' | 29 | +import { useFullScreen } from '../../utls/fullScreen' |
30 | 30 | ||
31 | const props = defineProps({ | 31 | const props = defineProps({ |
32 | themeSetting: { | 32 | themeSetting: { |
@@ -61,9 +61,9 @@ const toolBoxOption = { | @@ -61,9 +61,9 @@ const toolBoxOption = { | ||
61 | icon: 'path://M733.549304 0l116.434359 116.23452-226.402521 226.40252 57.053835 57.068109 226.459617-226.445342 120.616689 120.41685V0H733.549304zM689.513507 619.855586l-57.068108 57.068109 224.232847 224.232847-122.64362 122.843458h293.676657V729.838022l-114.007751 114.207588-224.190025-224.190024zM338.197775 404.144414l57.068109-57.068109L171.033037 122.843458 293.676657 0H0v294.161978l114.022025-114.207588 224.17575 224.190024zM347.076305 624.294851L120.616689 850.754468 0 730.323343v293.676657h294.161978l-116.420084-116.23452 226.40252-226.40252-57.068109-57.068109z', | 61 | icon: 'path://M733.549304 0l116.434359 116.23452-226.402521 226.40252 57.053835 57.068109 226.459617-226.445342 120.616689 120.41685V0H733.549304zM689.513507 619.855586l-57.068108 57.068109 224.232847 224.232847-122.64362 122.843458h293.676657V729.838022l-114.007751 114.207588-224.190025-224.190024zM338.197775 404.144414l57.068109-57.068109L171.033037 122.843458 293.676657 0H0v294.161978l114.022025-114.207588 224.17575 224.190024zM347.076305 624.294851L120.616689 850.754468 0 730.323343v293.676657h294.161978l-116.420084-116.23452 226.40252-226.40252-57.068109-57.068109z', |
62 | onclick: () => { | 62 | onclick: () => { |
63 | const getEchartDom = vChartRef.value?.getDom() | 63 | const getEchartDom = vChartRef.value?.getDom() |
64 | - const domName = document.getElementById(getEchartDom.id) as any | ||
65 | - const htmlName = document.querySelector('html') as any | ||
66 | - isFullScreen(domName, htmlName) | 64 | + const domName = document.getElementById(getEchartDom.id) as HTMLElement |
65 | + const htmlName = document.querySelector('html') as HTMLHtmlElement | ||
66 | + useFullScreen(domName, htmlName) | ||
67 | } | 67 | } |
68 | } | 68 | } |
69 | } | 69 | } |
src/packages/components/external/Charts/utls/fullScreen.ts
renamed from
src/packages/components/external/Charts/utls/isFullScreen.ts
1 | -export const isFullScreen = (domName: any, htmlName: any) => { | 1 | +export const useFullScreen = (domName: any, htmlName: HTMLHtmlElement) => { |
2 | const isFullScreen = document.fullscreenElement | 2 | const isFullScreen = document.fullscreenElement |
3 | const currentDatkTheme = htmlName.getAttribute('data-theme') | 3 | const currentDatkTheme = htmlName.getAttribute('data-theme') |
4 | 4 | ||
5 | if (isFullScreen) { | 5 | if (isFullScreen) { |
6 | - console.log('退出全屏') | ||
7 | if (document.exitFullscreen) { | 6 | if (document.exitFullscreen) { |
8 | document.exitFullscreen() | 7 | document.exitFullscreen() |
9 | - domName.style.background = '' | ||
10 | } | 8 | } |
11 | } else { | 9 | } else { |
12 | - console.log('进入全屏') | ||
13 | if (domName.requestFullscreen) { | 10 | if (domName.requestFullscreen) { |
14 | domName.requestFullscreen() | 11 | domName.requestFullscreen() |
15 | domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c' | 12 | domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c' |
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | import { toRefs } from 'vue' | 2 | import { toRefs } from 'vue' |
3 | import SelectCity from './SelectCity.vue' | 3 | import SelectCity from './SelectCity.vue' |
4 | import { useUtils } from '../hooks/useUtils' | 4 | import { useUtils } from '../hooks/useUtils' |
5 | +import weatherBg from '@/assets/external/weather/bg.png' | ||
5 | 6 | ||
6 | const props = defineProps({ | 7 | const props = defineProps({ |
7 | data: { | 8 | data: { |
@@ -27,7 +28,7 @@ const onHandleSelectValues = (values: any) => { | @@ -27,7 +28,7 @@ const onHandleSelectValues = (values: any) => { | ||
27 | content: true, | 28 | content: true, |
28 | footer: 'soft' | 29 | footer: 'soft' |
29 | }" | 30 | }" |
30 | - :style="{ backgroundImage: `url('src/assets/external/weather/bg.png')` }" | 31 | + :style="{ backgroundImage: `url('${weatherBg}')` }" |
31 | class="n-card" | 32 | class="n-card" |
32 | > | 33 | > |
33 | <template #header> | 34 | <template #header> |
@@ -3,6 +3,10 @@ import { CreateComponentType } from '@/packages/index.d' | @@ -3,6 +3,10 @@ import { CreateComponentType } from '@/packages/index.d' | ||
3 | import { WeatherConfig } from './index' | 3 | import { WeatherConfig } from './index' |
4 | import cloneDeep from 'lodash/cloneDeep' | 4 | import cloneDeep from 'lodash/cloneDeep' |
5 | import { chartInitConfig } from '@/settings/designSetting' | 5 | import { chartInitConfig } from '@/settings/designSetting' |
6 | +import clearDay from '@/assets/external/weather/clearDay.png' | ||
7 | +import cloudy from '@/assets/external/weather/cloudy.png' | ||
8 | +import cloudyDay from '@/assets/external/weather/cloudyDay.png' | ||
9 | +import lightRain from '@/assets/external/weather/lightRain.png' | ||
6 | 10 | ||
7 | //第三方 天气接口key值和api配置(高德) | 11 | //第三方 天气接口key值和api配置(高德) |
8 | export class ThirdPartyWeatherConnfig { | 12 | export class ThirdPartyWeatherConnfig { |
@@ -23,22 +27,23 @@ export const enum areaEnum { | @@ -23,22 +27,23 @@ export const enum areaEnum { | ||
23 | export const weatherTextMapImg = [ | 27 | export const weatherTextMapImg = [ |
24 | { | 28 | { |
25 | text: '晴', | 29 | text: '晴', |
26 | - img: 'src/assets/external/weather/clearDay.png' | 30 | + img: clearDay |
27 | }, | 31 | }, |
28 | { | 32 | { |
29 | text: '多云', | 33 | text: '多云', |
30 | - img: 'src/assets/external/weather/cloudy.png' | 34 | + img: cloudy |
31 | }, | 35 | }, |
32 | { | 36 | { |
33 | text: '阴', | 37 | text: '阴', |
34 | - img: 'src/assets/external/weather/cloudyDay.png' | 38 | + img: cloudyDay |
35 | }, | 39 | }, |
36 | { | 40 | { |
37 | text: '小雨', | 41 | text: '小雨', |
38 | - img: 'src/assets/external/weather/lightRain.png' | 42 | + img: lightRain |
39 | } | 43 | } |
40 | ] | 44 | ] |
41 | 45 | ||
46 | +console.log(clearDay, cloudy) | ||
42 | //风力等级文字映射 | 47 | //风力等级文字映射 |
43 | export const weatherSpeedMapText = [ | 48 | export const weatherSpeedMapText = [ |
44 | { | 49 | { |
1 | import { weatherSpeedMapText, weatherTextMapImg } from '../config' | 1 | import { weatherSpeedMapText, weatherTextMapImg } from '../config' |
2 | +import clearDay from '@/assets/external/weather/clearDay.png' | ||
2 | 3 | ||
3 | export const useUtils = () => { | 4 | export const useUtils = () => { |
4 | const loadWeatherImg = (text: string) => { | 5 | const loadWeatherImg = (text: string) => { |
5 | - return ( | ||
6 | - weatherTextMapImg.find((item: any) => item.text === text)?.img || | ||
7 | - '/src/assets/external/weather/clearDay.png' | ||
8 | - ) | 6 | + return weatherTextMapImg.find((item: any) => item.text === text)?.img || clearDay |
9 | } | 7 | } |
10 | 8 | ||
11 | //风力等级 ≤3 3 | 9 | //风力等级 ≤3 3 |
1 | +import cloneDeep from 'lodash/cloneDeep' | ||
2 | +import { PublicConfigClass } from '@/packages/public' | ||
3 | +import { CreateComponentType } from '@/packages/index.d' | ||
4 | +import { chartInitConfig } from '@/settings/designSetting' | ||
5 | +import { COMPONENT_INTERACT_EVENT_KET } from '@/enums/eventEnum' | ||
6 | +import { interactActions, ComponentInteractEventEnum } from './interact' | ||
7 | +import { ButtonConfig } from './index' | ||
8 | + | ||
9 | +export const option = { | ||
10 | + // 时间组件展示类型,必须和 interactActions 中定义的数据一致 | ||
11 | + [COMPONENT_INTERACT_EVENT_KET]: ComponentInteractEventEnum.DATA, | ||
12 | + // 暴露配置内容给用户 | ||
13 | + dataset: [ | ||
14 | + { | ||
15 | + label: '', | ||
16 | + current: '', | ||
17 | + target: '', | ||
18 | + currentButton: '', | ||
19 | + targetButton: '' | ||
20 | + } | ||
21 | + ], | ||
22 | + buttonType:'primary' | ||
23 | +} | ||
24 | + | ||
25 | +export default class Config extends PublicConfigClass implements CreateComponentType { | ||
26 | + public key = ButtonConfig.key | ||
27 | + public attr = { ...chartInitConfig, w: 460, h: 32, zIndex: -1 } | ||
28 | + public chartConfig = cloneDeep(ButtonConfig) | ||
29 | + public interactActions = interactActions | ||
30 | + public option = cloneDeep(option) | ||
31 | +} |
1 | +<template> | ||
2 | + <collapse-item name="按钮配置" :expanded="true"> | ||
3 | + <setting-item-box name="默认值" :alone="true"> | ||
4 | + <n-select size="small" v-model:value="optionData.buttonType" :options="buttonTypeOptions" /> | ||
5 | + </setting-item-box> | ||
6 | + <setting-item-box name="跳转配置项" :alone="true"> | ||
7 | + <setting-item v-for="(item, index) in optionData.dataset" :key="index"> | ||
8 | + <n-input v-model:value="item.label" size="small" placeholder="按钮文字"></n-input> | ||
9 | + <div style="height: 5px"></div> | ||
10 | + <n-input v-model:value="item.currentButton" size="small" placeholder="当前按钮"></n-input> | ||
11 | + <div style="height: 5px"></div> | ||
12 | + <n-input v-model:value="item.targetButton" size="small" placeholder="目标按钮"></n-input> | ||
13 | + <div style="height: 5px"></div> | ||
14 | + <n-input v-model:value="item.current" size="small" placeholder="当前页面"></n-input> | ||
15 | + <div style="height: 5px"></div> | ||
16 | + <n-input v-model:value="item.target" size="small" placeholder="目标页面"></n-input> | ||
17 | + <div style="height: 5px"></div> | ||
18 | + </setting-item> | ||
19 | + </setting-item-box> | ||
20 | + </collapse-item> | ||
21 | +</template> | ||
22 | + | ||
23 | +<script lang="ts" setup> | ||
24 | +import { PropType } from 'vue' | ||
25 | +import { CollapseItem, SettingItemBox } from '@/components/Pages/ChartItemSetting' | ||
26 | +import { option } from './config' | ||
27 | + | ||
28 | +defineProps({ | ||
29 | + optionData: { | ||
30 | + type: Object as PropType<typeof option>, | ||
31 | + required: true | ||
32 | + } | ||
33 | +}) | ||
34 | + | ||
35 | +const buttonTypeOptions = [ | ||
36 | + { | ||
37 | + label: 'default', | ||
38 | + value: 'default' | ||
39 | + }, | ||
40 | + { | ||
41 | + label: 'primary', | ||
42 | + value: 'primary' | ||
43 | + }, | ||
44 | + { | ||
45 | + label: 'tertiary', | ||
46 | + value: 'tertiary' | ||
47 | + }, | ||
48 | + { | ||
49 | + label: 'info', | ||
50 | + value: 'info' | ||
51 | + }, | ||
52 | + { | ||
53 | + label: 'success', | ||
54 | + value: 'success' | ||
55 | + }, | ||
56 | + { | ||
57 | + label: 'warning', | ||
58 | + value: 'warning' | ||
59 | + }, | ||
60 | + { | ||
61 | + label: 'error', | ||
62 | + value: 'error' | ||
63 | + } | ||
64 | +] | ||
65 | +</script> |
1 | +import { ConfigType, PackagesCategoryEnum, ChartFrameEnum } from '@/packages/index.d' | ||
2 | +import { ChatCategoryEnum, ChatCategoryEnumName } from '@/packages/components/Informations/index.d' | ||
3 | +import { useWidgetKey } from '@/packages/external/useWidgetKey' | ||
4 | + | ||
5 | +const { key, conKey, chartKey } = useWidgetKey('Button', true) | ||
6 | + | ||
7 | +export const ButtonConfig: ConfigType = { | ||
8 | + key, | ||
9 | + chartKey, | ||
10 | + conKey, | ||
11 | + title: '自定义按钮', | ||
12 | + category: ChatCategoryEnum.MORE, | ||
13 | + categoryName: ChatCategoryEnumName.MORE, | ||
14 | + package: PackagesCategoryEnum.INFORMATIONS, | ||
15 | + chartFrame: ChartFrameEnum.STATIC, | ||
16 | + image: 'inputs_tab.png' | ||
17 | +} |
1 | +<template> | ||
2 | + <n-button | ||
3 | + :style="{ width: `${w}px`, height: `${h}px` }" | ||
4 | + :type="buttonType" | ||
5 | + @click="onClick(option.value.dataset[0],true)" | ||
6 | + >{{ option.value.dataset[0].label }}</n-button | ||
7 | + > | ||
8 | +</template> | ||
9 | + | ||
10 | +<script setup lang="ts"> | ||
11 | +import { PropType, toRefs, shallowReactive, watch, onMounted } from 'vue' | ||
12 | +import cloneDeep from 'lodash/cloneDeep' | ||
13 | +import { CreateComponentType } from '@/packages/index.d' | ||
14 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | ||
15 | +import { useChartInteract } from '@/hooks/external/useButtonInteract.hook' | ||
16 | +import { InteractEventOn } from '@/enums/eventEnum' | ||
17 | +import { ComponentInteractParamsEnum } from './interact' | ||
18 | + | ||
19 | +const props = defineProps({ | ||
20 | + chartConfig: { | ||
21 | + type: Object as PropType<CreateComponentType>, | ||
22 | + required: true | ||
23 | + } | ||
24 | +}) | ||
25 | + | ||
26 | +const { w, h } = toRefs(props.chartConfig.attr) | ||
27 | +const { buttonType } = toRefs(props.chartConfig.option) | ||
28 | +const option = shallowReactive({ | ||
29 | + value: cloneDeep(props.chartConfig.option) | ||
30 | +}) | ||
31 | + | ||
32 | +const onClick = (v: any, s: boolean) => { | ||
33 | + useChartInteract( | ||
34 | + props.chartConfig, | ||
35 | + useChartEditStore, | ||
36 | + { [ComponentInteractParamsEnum.DATA]: v?.current }, | ||
37 | + InteractEventOn.CHANGE, | ||
38 | + v?.target, | ||
39 | + s | ||
40 | + ) | ||
41 | +} | ||
42 | + | ||
43 | +onMounted(() => { | ||
44 | + onClick(option.value.dataset[0], false) | ||
45 | +}) | ||
46 | + | ||
47 | +// 手动更新 | ||
48 | +watch( | ||
49 | + () => props.chartConfig.option, | ||
50 | + (newData: any) => { | ||
51 | + option.value = newData | ||
52 | + // onClick(newData.tabValue, true) | ||
53 | + }, | ||
54 | + { | ||
55 | + immediate: true, | ||
56 | + deep: true | ||
57 | + } | ||
58 | +) | ||
59 | +</script> |
1 | +import { InteractEventOn, InteractActionsType } from '@/enums/eventEnum' | ||
2 | + | ||
3 | +// 时间组件类型 | ||
4 | +export enum ComponentInteractEventEnum { | ||
5 | + DATA = 'data' | ||
6 | +} | ||
7 | + | ||
8 | +// 联动参数 | ||
9 | +export enum ComponentInteractParamsEnum { | ||
10 | + DATA = 'data' | ||
11 | +} | ||
12 | + | ||
13 | +// 定义组件触发回调事件 | ||
14 | +export const interactActions: InteractActionsType[] = [ | ||
15 | + { | ||
16 | + interactType: InteractEventOn.CHANGE, | ||
17 | + interactName: '选择完成', | ||
18 | + componentEmitEvents: { | ||
19 | + [ComponentInteractEventEnum.DATA]: [ | ||
20 | + { | ||
21 | + value: ComponentInteractParamsEnum.DATA, | ||
22 | + label: '选择项' | ||
23 | + } | ||
24 | + ] | ||
25 | + } | ||
26 | + } | ||
27 | +] |
@@ -27,7 +27,16 @@ export const option = { | @@ -27,7 +27,16 @@ export const option = { | ||
27 | label: '选项3', | 27 | label: '选项3', |
28 | value: '3' | 28 | value: '3' |
29 | } | 29 | } |
30 | - ] | 30 | + ], |
31 | + //自定义样式 | ||
32 | + tabStyleOptions: { | ||
33 | + textColor: 'green', | ||
34 | + textActiveColor: 'black', | ||
35 | + textBackgroundColor: '#ffffff', | ||
36 | + tabBarColor: 'green', | ||
37 | + segmentBackgroundColor: 'grey', | ||
38 | + segmentActiveColor: 'white' | ||
39 | + } | ||
31 | } | 40 | } |
32 | 41 | ||
33 | export default class Config extends PublicConfigClass implements CreateComponentType { | 42 | export default class Config extends PublicConfigClass implements CreateComponentType { |
1 | <template> | 1 | <template> |
2 | <collapse-item name="标签页配置" :expanded="true"> | 2 | <collapse-item name="标签页配置" :expanded="true"> |
3 | <setting-item-box name="默认值" :alone="true"> | 3 | <setting-item-box name="默认值" :alone="true"> |
4 | - <n-select size="small" v-model:value="optionData.tabType" :options="tabTypeOptions" /> | 4 | + <n-select @change="handleSelect" size="small" v-model:value="optionData.tabType" :options="tabTypeOptions" /> |
5 | + </setting-item-box> | ||
6 | + <setting-item-box name="未激活文字颜色" :alone="true"> | ||
7 | + <SettingItem name="颜色"> | ||
8 | + <n-color-picker | ||
9 | + size="small" | ||
10 | + :modes="['hex']" | ||
11 | + v-model:value="optionData.tabStyleOptions.textColor" | ||
12 | + ></n-color-picker> | ||
13 | + </SettingItem> | ||
14 | + <SettingItem> | ||
15 | + <n-button size="small" @click="optionData.tabStyleOptions.textColor = 'green'"> 恢复默认 </n-button> | ||
16 | + </SettingItem> | ||
17 | + </setting-item-box> | ||
18 | + <setting-item-box name="激活文字颜色" :alone="true"> | ||
19 | + <SettingItem name="颜色"> | ||
20 | + <n-color-picker | ||
21 | + size="small" | ||
22 | + :modes="['hex']" | ||
23 | + v-model:value="optionData.tabStyleOptions.textActiveColor" | ||
24 | + ></n-color-picker> | ||
25 | + </SettingItem> | ||
26 | + <SettingItem> | ||
27 | + <n-button size="small" @click="optionData.tabStyleOptions.textActiveColor = 'black'"> 恢复默认 </n-button> | ||
28 | + </SettingItem> | ||
29 | + </setting-item-box> | ||
30 | + <setting-item-box v-if="optionData.tabType === 'bar'" name="导航条颜色" :alone="true"> | ||
31 | + <SettingItem name="颜色"> | ||
32 | + <n-color-picker | ||
33 | + size="small" | ||
34 | + :modes="['hex']" | ||
35 | + v-model:value="optionData.tabStyleOptions.tabBarColor" | ||
36 | + ></n-color-picker> | ||
37 | + </SettingItem> | ||
38 | + <SettingItem> | ||
39 | + <n-button size="small" @click="optionData.tabStyleOptions.tabBarColor = 'green'"> 恢复默认 </n-button> | ||
40 | + </SettingItem> | ||
41 | + </setting-item-box> | ||
42 | + <setting-item-box v-if="optionData.tabType === 'segment'" name="分段背景色" :alone="true"> | ||
43 | + <SettingItem name="颜色"> | ||
44 | + <n-color-picker | ||
45 | + size="small" | ||
46 | + :modes="['hex']" | ||
47 | + v-model:value="optionData.tabStyleOptions.segmentBackgroundColor" | ||
48 | + ></n-color-picker> | ||
49 | + </SettingItem> | ||
50 | + <SettingItem> | ||
51 | + <n-button size="small" @click="optionData.tabStyleOptions.segmentBackgroundColor = 'grey'"> 恢复默认 </n-button> | ||
52 | + </SettingItem> | ||
53 | + </setting-item-box> | ||
54 | + <setting-item-box v-if="optionData.tabType === 'segment'" name="分段激活背景色" :alone="true"> | ||
55 | + <SettingItem name="颜色"> | ||
56 | + <n-color-picker | ||
57 | + size="small" | ||
58 | + :modes="['hex']" | ||
59 | + v-model:value="optionData.tabStyleOptions.segmentActiveColor" | ||
60 | + ></n-color-picker> | ||
61 | + </SettingItem> | ||
62 | + <SettingItem> | ||
63 | + <n-button size="small" @click="optionData.tabStyleOptions.segmentActiveColor = 'white'"> 恢复默认 </n-button> | ||
64 | + </SettingItem> | ||
5 | </setting-item-box> | 65 | </setting-item-box> |
6 | </collapse-item> | 66 | </collapse-item> |
7 | </template> | 67 | </template> |
@@ -11,7 +71,7 @@ import { PropType } from 'vue' | @@ -11,7 +71,7 @@ import { PropType } from 'vue' | ||
11 | import { CollapseItem, SettingItemBox } from '@/components/Pages/ChartItemSetting' | 71 | import { CollapseItem, SettingItemBox } from '@/components/Pages/ChartItemSetting' |
12 | import { option } from './config' | 72 | import { option } from './config' |
13 | 73 | ||
14 | -defineProps({ | 74 | +const props = defineProps({ |
15 | optionData: { | 75 | optionData: { |
16 | type: Object as PropType<typeof option>, | 76 | type: Object as PropType<typeof option>, |
17 | required: true | 77 | required: true |
@@ -28,4 +88,11 @@ const tabTypeOptions = [ | @@ -28,4 +88,11 @@ const tabTypeOptions = [ | ||
28 | value: 'segment' | 88 | value: 'segment' |
29 | } | 89 | } |
30 | ] | 90 | ] |
91 | + | ||
92 | +const handleSelect = (e: string) => { | ||
93 | + if (e === 'bar') { | ||
94 | + props.optionData.tabStyleOptions.segmentActiveColor = '' | ||
95 | + props.optionData.tabStyleOptions.segmentBackgroundColor = '' | ||
96 | + } | ||
97 | +} | ||
31 | </script> | 98 | </script> |
@@ -21,6 +21,9 @@ const props = defineProps({ | @@ -21,6 +21,9 @@ const props = defineProps({ | ||
21 | }) | 21 | }) |
22 | 22 | ||
23 | const { w, h } = toRefs(props.chartConfig.attr) | 23 | const { w, h } = toRefs(props.chartConfig.attr) |
24 | + | ||
25 | +const { tabStyleOptions } = toRefs(props.chartConfig.option) | ||
26 | + | ||
24 | const option = shallowReactive({ | 27 | const option = shallowReactive({ |
25 | value: cloneDeep(props.chartConfig.option) | 28 | value: cloneDeep(props.chartConfig.option) |
26 | }) | 29 | }) |
@@ -57,3 +60,22 @@ watch( | @@ -57,3 +60,22 @@ watch( | ||
57 | } | 60 | } |
58 | ) | 61 | ) |
59 | </script> | 62 | </script> |
63 | + | ||
64 | +<style lang="scss" scoped> | ||
65 | +@include deep() { | ||
66 | + .n-tabs-tab { | ||
67 | + color: v-bind('tabStyleOptions.textColor') !important; | ||
68 | + background: v-bind('tabStyleOptions.segmentBackgroundColor') !important; | ||
69 | + } | ||
70 | + .n-tabs-tab--active { | ||
71 | + color: v-bind('tabStyleOptions.textActiveColor') !important; | ||
72 | + background: v-bind('tabStyleOptions.segmentActiveColor') !important; | ||
73 | + } | ||
74 | + .n-tabs-bar { | ||
75 | + background-color: v-bind('tabStyleOptions.tabBarColor') !important; | ||
76 | + } | ||
77 | + .n-tabs-tab-wrapper { | ||
78 | + background-color: v-bind('tabStyleOptions.segmentBackgroundColor') !important; | ||
79 | + } | ||
80 | +} | ||
81 | +</style> |
@@ -9,6 +9,7 @@ import { OverrideSelectConfig } from '@/packages/components/external/Information | @@ -9,6 +9,7 @@ import { OverrideSelectConfig } from '@/packages/components/external/Information | ||
9 | import { OverrideInputsDateConfig } from '@/packages/components/external/Informations/Mores/OverrideInputsDate' | 9 | import { OverrideInputsDateConfig } from '@/packages/components/external/Informations/Mores/OverrideInputsDate' |
10 | import { OverrideInputsTabConfig } from '@/packages/components/external/Informations/Mores/OverrideInputsTab' | 10 | import { OverrideInputsTabConfig } from '@/packages/components/external/Informations/Mores/OverrideInputsTab' |
11 | import { OverrideTextCommonConfig } from '@/packages/components/external/Informations/Mores/OverrideTextCommon' | 11 | import { OverrideTextCommonConfig } from '@/packages/components/external/Informations/Mores/OverrideTextCommon' |
12 | +import { ButtonConfig } from '@/packages/components/external/Informations/Mores/Button' | ||
12 | import { OverrideBarCommonConfig } from '@/packages/components/external/Charts/Bars/OverrideBarCommon' | 13 | import { OverrideBarCommonConfig } from '@/packages/components/external/Charts/Bars/OverrideBarCommon' |
13 | import { OverrideLineCommonConfig } from '@/packages/components/external/Charts/Lines/OverrideLineCommon' | 14 | import { OverrideLineCommonConfig } from '@/packages/components/external/Charts/Lines/OverrideLineCommon' |
14 | import { OverrideLineGradientsConfig } from '@/packages/components/external/Charts/Lines/OverrideLineGradients' | 15 | import { OverrideLineGradientsConfig } from '@/packages/components/external/Charts/Lines/OverrideLineGradients' |
@@ -25,6 +26,7 @@ export function useInjectLib(packagesList: EPackagesType) { | @@ -25,6 +26,7 @@ export function useInjectLib(packagesList: EPackagesType) { | ||
25 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsDateConfig) | 26 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsDateConfig) |
26 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsTabConfig) | 27 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideInputsTabConfig) |
27 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideTextCommonConfig) | 28 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, OverrideTextCommonConfig) |
29 | + addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.INFORMATIONS, ButtonConfig) | ||
28 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideBarCommonConfig) | 30 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideBarCommonConfig) |
29 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideLineCommonConfig) | 31 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideLineCommonConfig) |
30 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideLineGradientsConfig) | 32 | addWidgetToCategoryByCategoryName(packagesList, PackagesCategoryEnum.CHARTS, OverrideLineGradientsConfig) |