Showing
4 changed files
with
20 additions
and
28 deletions
@@ -10,12 +10,13 @@ export const useChartInteract = ( | @@ -10,12 +10,13 @@ export const useChartInteract = ( | ||
10 | chartConfig: CreateComponentType, | 10 | chartConfig: CreateComponentType, |
11 | useChartEditStore: ChartEditStoreType, | 11 | useChartEditStore: ChartEditStoreType, |
12 | param: { [T: string]: any }, | 12 | param: { [T: string]: any }, |
13 | - interactEventOn: string | 13 | + interactEventOn: string, |
14 | + status: boolean | ||
14 | ) => { | 15 | ) => { |
15 | const chartEditStore = useChartEditStore() | 16 | const chartEditStore = useChartEditStore() |
16 | const { interactEvents } = chartConfig.events | 17 | const { interactEvents } = chartConfig.events |
17 | - const { selectCurrentItems } = chartConfig.option | ||
18 | const { selectTargetItems } = chartConfig.option | 18 | const { selectTargetItems } = chartConfig.option |
19 | + const { data } = param | ||
19 | const fnOnEvent = interactEvents.filter(item => { | 20 | const fnOnEvent = interactEvents.filter(item => { |
20 | return item.interactOn === interactEventOn | 21 | return item.interactOn === interactEventOn |
21 | }) | 22 | }) |
@@ -32,19 +33,24 @@ export const useChartInteract = ( | @@ -32,19 +33,24 @@ export const useChartInteract = ( | ||
32 | Header.value[key] = param[item.interactFn[key]] | 33 | Header.value[key] = param[item.interactFn[key]] |
33 | } | 34 | } |
34 | }) | 35 | }) |
35 | - setJump(selectCurrentItems, selectTargetItems) | 36 | + setJump(selectTargetItems) |
36 | }) | 37 | }) |
37 | - function setJump(selectCurrentItems: string[], selectTargetItems: string[]) { | 38 | + function setJump(selectTargetItems: string[]) { |
39 | + console.log('当前选择的关联项', selectTargetItems) | ||
38 | try { | 40 | try { |
41 | + console.log('当前页面所有的组件列表', chartEditStore.componentList) | ||
39 | //优化循环性能 | 42 | //优化循环性能 |
40 | for (let i = 0, len = chartEditStore.componentList.length; i < len; i++) { | 43 | for (let i = 0, len = chartEditStore.componentList.length; i < len; i++) { |
41 | const compId = chartEditStore.componentList[i].id | 44 | const compId = chartEditStore.componentList[i].id |
42 | const compItem = chartEditStore.componentList[i] | 45 | const compItem = chartEditStore.componentList[i] |
43 | - if (selectCurrentItems.includes(compId)) { | ||
44 | - compItem.status.hide = true | ||
45 | - } | ||
46 | - if (selectTargetItems.includes(compId)) { | ||
47 | - compItem.status.hide = false | 46 | + if (status) { |
47 | + if (compItem.key !== 'Button') { | ||
48 | + if (selectTargetItems.includes(compId)) { | ||
49 | + compItem.status.hide = false | ||
50 | + } else { | ||
51 | + compItem.status.hide = true | ||
52 | + } | ||
53 | + } | ||
48 | } | 54 | } |
49 | } | 55 | } |
50 | } finally { | 56 | } finally { |
@@ -18,7 +18,6 @@ export const option = { | @@ -18,7 +18,6 @@ export const option = { | ||
18 | buttonColor: '', | 18 | buttonColor: '', |
19 | buttonTextColor: 'white', | 19 | buttonTextColor: 'white', |
20 | buttonTextSize: '16', | 20 | buttonTextSize: '16', |
21 | - selectCurrentItems: [], | ||
22 | selectTargetItems: [] | 21 | selectTargetItems: [] |
23 | } | 22 | } |
24 | 23 |
@@ -44,17 +44,6 @@ | @@ -44,17 +44,6 @@ | ||
44 | <n-input v-model:value="optionData.dataset" size="small" placeholder="按钮文字"></n-input> | 44 | <n-input v-model:value="optionData.dataset" size="small" placeholder="按钮文字"></n-input> |
45 | </setting-item> | 45 | </setting-item> |
46 | </setting-item-box> | 46 | </setting-item-box> |
47 | - <setting-item-box name="当前项"> | ||
48 | - <setting-item name="当前项" :alone="true"> | ||
49 | - <n-select | ||
50 | - placeholder="请选择当前项" | ||
51 | - multiple | ||
52 | - size="small" | ||
53 | - v-model:value="optionData.selectCurrentItems" | ||
54 | - :options="selectCurrentItemOptions" | ||
55 | - /> | ||
56 | - </setting-item> | ||
57 | - </setting-item-box> | ||
58 | <setting-item-box name="目标项"> | 47 | <setting-item-box name="目标项"> |
59 | <setting-item name="目标项" :alone="true"> | 48 | <setting-item name="目标项" :alone="true"> |
60 | <n-select | 49 | <n-select |
@@ -120,8 +109,6 @@ const buttonTypeOptions = [ | @@ -120,8 +109,6 @@ const buttonTypeOptions = [ | ||
120 | } | 109 | } |
121 | ] | 110 | ] |
122 | 111 | ||
123 | -const selectCurrentItemOptions = ref<{ label: string; value: string }[]>([]) | ||
124 | - | ||
125 | const selectTargetItemOptions = ref<{ label: string; value: string }[]>([]) | 112 | const selectTargetItemOptions = ref<{ label: string; value: string }[]>([]) |
126 | 113 | ||
127 | onMounted(() => { | 114 | onMounted(() => { |
@@ -129,7 +116,6 @@ onMounted(() => { | @@ -129,7 +116,6 @@ onMounted(() => { | ||
129 | label: item.chartConfig?.title, | 116 | label: item.chartConfig?.title, |
130 | value: item.id | 117 | value: item.id |
131 | })) | 118 | })) |
132 | - selectCurrentItemOptions.value = componentList | ||
133 | selectTargetItemOptions.value = componentList | 119 | selectTargetItemOptions.value = componentList |
134 | }) | 120 | }) |
135 | </script> | 121 | </script> |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | :dashed="buttonDashed" | 5 | :dashed="buttonDashed" |
6 | :ghost="buttonGhost" | 6 | :ghost="buttonGhost" |
7 | :color="buttonColor" | 7 | :color="buttonColor" |
8 | - @click="onClick(option.value.dataset)" | 8 | + @click="onClick(option.value.selectTargetItems, true)" |
9 | > | 9 | > |
10 | <span class="button-text-color">{{ dataset }}</span> | 10 | <span class="button-text-color">{{ dataset }}</span> |
11 | </n-button> | 11 | </n-button> |
@@ -35,17 +35,18 @@ const option = shallowReactive({ | @@ -35,17 +35,18 @@ const option = shallowReactive({ | ||
35 | value: cloneDeep(props.chartConfig.option) | 35 | value: cloneDeep(props.chartConfig.option) |
36 | }) | 36 | }) |
37 | 37 | ||
38 | -const onClick = (v: any) => { | 38 | +const onClick = (v: any, status: boolean) => { |
39 | useChartInteract( | 39 | useChartInteract( |
40 | props.chartConfig, | 40 | props.chartConfig, |
41 | useChartEditStore, | 41 | useChartEditStore, |
42 | { [ComponentInteractParamsEnum.DATA]: v }, | 42 | { [ComponentInteractParamsEnum.DATA]: v }, |
43 | - InteractEventOn.CHANGE | 43 | + InteractEventOn.CHANGE, |
44 | + status | ||
44 | ) | 45 | ) |
45 | } | 46 | } |
46 | 47 | ||
47 | onMounted(() => { | 48 | onMounted(() => { |
48 | - onClick(option.value.dataset) | 49 | + onClick(option.value.selectTargetItems, false) |
49 | }) | 50 | }) |
50 | 51 | ||
51 | // 手动更新 | 52 | // 手动更新 |