Browse Source

更新问题

master
zhang_li 5 months ago
parent
commit
520e68c92b
  1. 9
      src/hooks/useChartDataFetch.hook.ts
  2. 18
      src/packages/components/Charts/Bars/BarCommon/index.vue
  3. 3
      src/utils/utils.ts

9
src/hooks/useChartDataFetch.hook.ts

@ -39,7 +39,7 @@ export const useChartDataFetch = (
}
}
const requestIntervalFn = () => {
const requestIntervalFn =async () => {
const chartEditStore = useChartEditStore()
// 全局数据
@ -75,10 +75,11 @@ export const useChartDataFetch = (
if (res) {
try {
const filter = targetComponent.filter
res.data = res.source
echartsUpdateHandle(newFunctionHandle(res?.data, res, filter))
// 更新回调函数
if (updateCallback) {
updateCallback(newFunctionHandle(res?.data, res, filter))
updateCallback(newFunctionHandle(res?.data, res, filter),res)
}
} catch (error) {
console.error(error)
@ -87,7 +88,9 @@ export const useChartDataFetch = (
}
// 立即调用
fetchFn()
await fetchFn()
// fetchFn()
// 定时时间
const time = targetInterval && targetInterval.value ? targetInterval.value : globalRequestInterval.value
// 单位

18
src/packages/components/Charts/Bars/BarCommon/index.vue

@ -7,6 +7,7 @@
:update-options="{
replaceMerge: replaceMergeArr
}"
:key="key"
autoresize
></v-chart>
</template>
@ -45,8 +46,16 @@ use([DatasetComponent, CanvasRenderer, BarChart, GridComponent, TooltipComponent
const replaceMergeArr = ref<string[]>()
const dataset1 = ref()
const dataset2 = ref(props.chartConfig.option)
const key = ref(0)
const option = computed(() => {
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
if(dataset1.value){
dataset2.value.dataset = dataset1.value
}
console.log(3444, mergeTheme(dataset2.value, props.themeSetting, includes))
key.value++
return mergeTheme(dataset2.value, props.themeSetting, includes)
})
// dataset
@ -74,6 +83,11 @@ watch(
deep: false
}
)
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore,(dataset,res)=>{
dataset1.value = {
source : res.source,
dimensions : res.dimensions,
}
})
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
</script>

3
src/utils/utils.ts

@ -193,7 +193,8 @@ export const newFunctionHandle = (
try {
if (!funcStr) return data
const fn = new Function('data', 'res', funcStr)
const fnRes = fn(cloneDeep(data), cloneDeep(res))
const fnRes = fn(res,data)
// const fnRes = fn(cloneDeep(data), cloneDeep(res))
const resHandle = isToString ? toString(fnRes) : fnRes
// 成功回调
successCallBack && successCallBack(resHandle)

Loading…
Cancel
Save