Commit 051a08bb77687ded7b61cb474e01f3b58729df27
1 parent
46c57d3f
fix(src/hooks/): 修复自定义日期选择器和图表或其他组件一起分组,联动失效问题
Showing
1 changed file
with
13 additions
and
17 deletions
| 1 | 1 | /** |
| 2 | 2 | * 重写select下拉框联动 |
| 3 | 3 | */ |
| 4 | -import {toRaw, toRefs} from 'vue' | |
| 5 | -import {CreateComponentType} from '@/packages/index.d' | |
| 4 | +import {toRefs} from 'vue' | |
| 5 | +import {CreateComponentGroupType, CreateComponentType} from '@/packages/index.d' | |
| 6 | 6 | import {useChartEditStore} from '@/store/modules/chartEditStore/chartEditStore' |
| 7 | -import {customRequest} from "@/api/external/customRequest"; | |
| 8 | -import {useFilterFn} from "@/hooks/external/useFilterFn"; | |
| 9 | 7 | |
| 10 | 8 | // 获取类型 |
| 11 | 9 | type ChartEditStoreType = typeof useChartEditStore |
| ... | ... | @@ -27,26 +25,24 @@ export const useChartInteract = ( |
| 27 | 25 | fnOnEvent.forEach(async (item) => { |
| 28 | 26 | const index = chartEditStore.fetchTargetIndex(item.interactComponentId) |
| 29 | 27 | if (index === -1) return |
| 30 | - const {Params, Header} = toRefs(chartEditStore.componentList[index].request.requestParams) | |
| 31 | - Object.keys(item.interactFn).forEach(key => { | |
| 28 | + //支持分组 | |
| 29 | + const target = chartEditStore.getComponentList?.reduce((prev: Array<CreateComponentType | CreateComponentGroupType>, acc) => { | |
| 30 | + acc?.isGroup ? (prev = [...(acc?.groupList as CreateComponentGroupType[])]) : prev?.push(acc) | |
| 31 | + return prev | |
| 32 | + }, []) | |
| 33 | + target?.forEach((targetItem)=>{ | |
| 34 | + if(targetItem.id!==chartConfig.id){ | |
| 35 | + const {Params, Header} = toRefs(targetItem.request.requestParams) | |
| 36 | + Object.keys(item.interactFn).forEach(key => { | |
| 32 | 37 | if (Params.value[key]) { |
| 33 | 38 | Params.value[key] = param[item.interactFn[key]] |
| 34 | 39 | } |
| 35 | 40 | if (Header.value[key]) { |
| 36 | 41 | Header.value[key] = param[item.interactFn[key]] |
| 37 | 42 | } |
| 38 | - }) | |
| 39 | - const res = await customRequest(toRaw(chartEditStore.componentList[index].request)) | |
| 40 | - if (res) { | |
| 41 | - try { | |
| 42 | - const filter = chartEditStore.componentList[index].filter | |
| 43 | - const {value} = useFilterFn(filter, res) | |
| 44 | - if (!value) return | |
| 45 | - chartEditStore.componentList[index].option.dataset = value | |
| 46 | - } finally { | |
| 47 | - console.log | |
| 43 | + }) | |
| 48 | 44 | } |
| 49 | - } | |
| 45 | + }) | |
| 50 | 46 | }) |
| 51 | 47 | } |
| 52 | 48 | ... | ... |