Commit 18094fa72bb157aeb7421b10c4a9474cbe84690f

Authored by fengwotao
1 parent b0951b28

feat(src/hooks/external): 新增联动组件hooks代码注释

@@ -10,7 +10,7 @@ export const useChartInteract = ( @@ -10,7 +10,7 @@ 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 ) => { 14 ) => {
15 const chartEditStore = useChartEditStore() 15 const chartEditStore = useChartEditStore()
16 const { interactEvents } = chartConfig.events 16 const { interactEvents } = chartConfig.events
@@ -30,25 +30,28 @@ export const useChartInteract = ( @@ -30,25 +30,28 @@ export const useChartInteract = (
30 Header.value[key] = param[item.interactFn[key]] 30 Header.value[key] = param[item.interactFn[key]]
31 } 31 }
32 }) 32 })
33 - updateIndex(chartConfig) 33 + setJump(chartConfig)
34 }) 34 })
35 -  
36 - function updateIndex(chart: any) { 35 + function setJump(chart: CreateComponentType) {
  36 + /**
  37 + * 通过页面显示隐藏来模拟页面跳转
  38 + * 当前点击对象和绑定的联动组件(分组或单个)内容隐藏,目标对象和绑定的联动组件(分组或单个)内容显示
  39 + */
37 try { 40 try {
38 const targetId = chart.option.dataset[0].target 41 const targetId = chart.option.dataset[0].target
39 const currentId = chart.option.dataset[0].current 42 const currentId = chart.option.dataset[0].current
40 - const currentButtonId = chart.option.dataset[0].currentButton  
41 const targetButtonId = chart.option.dataset[0].targetButton 43 const targetButtonId = chart.option.dataset[0].targetButton
  44 + const currentButtonId = chart.option.dataset[0].currentButton
42 const targetIndex = chartEditStore.fetchTargetIndex(targetId) 45 const targetIndex = chartEditStore.fetchTargetIndex(targetId)
43 const currentIndex = chartEditStore.fetchTargetIndex(currentId) 46 const currentIndex = chartEditStore.fetchTargetIndex(currentId)
44 - const currentButtonIndex = chartEditStore.fetchTargetIndex(currentButtonId)  
45 const targetButtonIndex = chartEditStore.fetchTargetIndex(targetButtonId) 47 const targetButtonIndex = chartEditStore.fetchTargetIndex(targetButtonId)
  48 + const currentButtonIndex = chartEditStore.fetchTargetIndex(currentButtonId)
46 chartEditStore.componentList[targetIndex].status.hide = false 49 chartEditStore.componentList[targetIndex].status.hide = false
47 chartEditStore.componentList[currentIndex].status.hide = true 50 chartEditStore.componentList[currentIndex].status.hide = true
48 - chartEditStore.componentList[currentButtonIndex].status.hide = true  
49 chartEditStore.componentList[targetButtonIndex].status.hide = false 51 chartEditStore.componentList[targetButtonIndex].status.hide = false
50 - } catch (e) {  
51 - console.error(e) 52 + chartEditStore.componentList[currentButtonIndex].status.hide = true
  53 + } finally {
  54 + console.log()
52 } 55 }
53 } 56 }
54 } 57 }