mirror of
https://gitee.com/dromara/go-view.git
synced 2025-10-13 22:12:11 +08:00
Merge branch 'dev' of https://gitee.com/tanhao8/go-view into dev
This commit is contained in:
commit
3425328b21
@ -90,12 +90,12 @@ export const useChartDataFetch = (
|
|||||||
|
|
||||||
// 普通初始化与组件交互处理监听
|
// 普通初始化与组件交互处理监听
|
||||||
watch(
|
watch(
|
||||||
() => targetComponent.request,
|
() => targetComponent.request.requestParams,
|
||||||
() => {
|
() => {
|
||||||
fetchFn()
|
fetchFn()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: false,
|
||||||
deep: true
|
deep: true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -105,7 +105,11 @@ export const useChartDataFetch = (
|
|||||||
// 单位
|
// 单位
|
||||||
const unit = targetInterval && targetInterval.value ? targetUnit.value : globalUnit.value
|
const unit = targetInterval && targetInterval.value ? targetUnit.value : globalUnit.value
|
||||||
// 开启轮询
|
// 开启轮询
|
||||||
if (time) fetchInterval = setInterval(fetchFn, intervalUnitHandle(time, unit))
|
if (time) {
|
||||||
|
fetchInterval = setInterval(fetchFn, intervalUnitHandle(time, unit))
|
||||||
|
} else {
|
||||||
|
fetchFn()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-empty
|
// eslint-disable-next-line no-empty
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -114,10 +118,11 @@ export const useChartDataFetch = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isPreview()) {
|
if (isPreview()) {
|
||||||
// 判断是否是数据池类型
|
|
||||||
targetComponent.request.requestDataType === RequestDataTypeEnum.Pond
|
targetComponent.request.requestDataType === RequestDataTypeEnum.Pond
|
||||||
? addGlobalDataInterface(targetComponent, useChartEditStore, updateCallback || echartsUpdateHandle)
|
? addGlobalDataInterface(targetComponent, useChartEditStore, updateCallback || echartsUpdateHandle)
|
||||||
: requestIntervalFn()
|
: requestIntervalFn()
|
||||||
|
} else {
|
||||||
|
requestIntervalFn()
|
||||||
}
|
}
|
||||||
return { vChartRef }
|
return { vChartRef }
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { toRaw } from 'vue'
|
import { toRaw, watch, computed, ComputedRef } from 'vue'
|
||||||
import { customizeHttp } from '@/api/http'
|
import { customizeHttp } from '@/api/http'
|
||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
@ -20,7 +20,7 @@ const mittDataPondMap = new Map<string, DataPondMapType[]>()
|
|||||||
// 创建单个数据项轮询接口
|
// 创建单个数据项轮询接口
|
||||||
const newPondItemInterval = (
|
const newPondItemInterval = (
|
||||||
requestGlobalConfig: RequestGlobalConfigType,
|
requestGlobalConfig: RequestGlobalConfigType,
|
||||||
requestDataPondItem: RequestDataPondItemType,
|
requestDataPondItem: ComputedRef<RequestDataPondItemType>,
|
||||||
dataPondMapItem?: DataPondMapType[]
|
dataPondMapItem?: DataPondMapType[]
|
||||||
) => {
|
) => {
|
||||||
if (!dataPondMapItem) return
|
if (!dataPondMapItem) return
|
||||||
@ -31,8 +31,7 @@ const newPondItemInterval = (
|
|||||||
// 请求
|
// 请求
|
||||||
const fetchFn = async () => {
|
const fetchFn = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await customizeHttp(toRaw(requestDataPondItem.dataPondRequestConfig), toRaw(requestGlobalConfig))
|
const res = await customizeHttp(toRaw(requestDataPondItem.value.dataPondRequestConfig), toRaw(requestGlobalConfig))
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
try {
|
try {
|
||||||
// 遍历更新回调函数
|
// 遍历更新回调函数
|
||||||
@ -49,19 +48,32 @@ const newPondItemInterval = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => requestDataPondItem.value.dataPondRequestConfig.requestParams.Params,
|
||||||
|
() => {
|
||||||
|
fetchFn()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: false,
|
||||||
|
deep: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
// 立即调用
|
// 立即调用
|
||||||
fetchFn()
|
fetchFn()
|
||||||
|
|
||||||
const targetInterval = requestDataPondItem.dataPondRequestConfig.requestInterval
|
|
||||||
const targetUnit = requestDataPondItem.dataPondRequestConfig.requestIntervalUnit
|
const targetInterval = requestDataPondItem.value.dataPondRequestConfig.requestInterval
|
||||||
|
const targetUnit = requestDataPondItem.value.dataPondRequestConfig.requestIntervalUnit
|
||||||
|
|
||||||
const globalRequestInterval = requestGlobalConfig.requestInterval
|
const globalRequestInterval = requestGlobalConfig.requestInterval
|
||||||
const globalUnit = requestGlobalConfig.requestIntervalUnit
|
const globalUnit = requestGlobalConfig.requestIntervalUnit
|
||||||
|
|
||||||
// 定时时间
|
// 定时时间
|
||||||
const time = targetInterval ? targetInterval : globalRequestInterval
|
const time = targetInterval ? targetInterval : globalRequestInterval
|
||||||
// 单位
|
// 单位
|
||||||
const unit = targetInterval ? targetUnit : globalUnit
|
const unit = targetInterval ? targetUnit : globalUnit
|
||||||
// 开启轮询
|
// 开启轮询
|
||||||
if (time) fetchInterval = setInterval(fetchFn, intervalUnitHandle(time, unit))
|
if (time) fetchInterval = setInterval(fetchFn, intervalUnitHandle(time, unit))
|
||||||
}
|
}
|
||||||
@ -96,13 +108,16 @@ export const useChartDataPondFetch = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化数据池
|
// 初始化数据池
|
||||||
const initDataPond = (requestGlobalConfig: RequestGlobalConfigType) => {
|
const initDataPond = (useChartEditStore: ChartEditStoreType) => {
|
||||||
const { requestDataPond } = requestGlobalConfig
|
const { requestGlobalConfig } = useChartEditStore()
|
||||||
|
const chartEditStore = useChartEditStore()
|
||||||
// 根据 mapId 查找对应的数据池配置
|
// 根据 mapId 查找对应的数据池配置
|
||||||
for (let pondKey of mittDataPondMap.keys()) {
|
for (let pondKey of mittDataPondMap.keys()) {
|
||||||
const requestDataPondItem = requestDataPond.find(item => item.dataPondId === pondKey)
|
const requestDataPondItem = computed(() => {
|
||||||
|
return requestGlobalConfig.requestDataPond.find(item => item.dataPondId === pondKey)
|
||||||
|
}) as ComputedRef<RequestDataPondItemType>
|
||||||
if (requestDataPondItem) {
|
if (requestDataPondItem) {
|
||||||
newPondItemInterval(requestGlobalConfig, requestDataPondItem, mittDataPondMap.get(pondKey))
|
newPondItemInterval(chartEditStore.requestGlobalConfig, requestDataPondItem, mittDataPondMap.get(pondKey))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { toRefs } from 'vue'
|
import { toRefs } from 'vue'
|
||||||
|
import { isPreview } from '@/utils'
|
||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ export const useChartInteract = (
|
|||||||
param: { [T: string]: any },
|
param: { [T: string]: any },
|
||||||
interactEventOn: string
|
interactEventOn: string
|
||||||
) => {
|
) => {
|
||||||
|
if (!isPreview()) return
|
||||||
const chartEditStore = useChartEditStore()
|
const chartEditStore = useChartEditStore()
|
||||||
const { interactEvents } = chartConfig.events
|
const { interactEvents } = chartConfig.events
|
||||||
const fnOnEvent = interactEvents.filter(item => {
|
const fnOnEvent = interactEvents.filter(item => {
|
||||||
@ -20,20 +22,37 @@ export const useChartInteract = (
|
|||||||
|
|
||||||
if (fnOnEvent.length === 0) return
|
if (fnOnEvent.length === 0) return
|
||||||
fnOnEvent.forEach(item => {
|
fnOnEvent.forEach(item => {
|
||||||
const index = chartEditStore.fetchTargetIndex(item.interactComponentId)
|
|
||||||
if (index === -1) return
|
const globalConfigPindAprndex = chartEditStore.requestGlobalConfig.requestDataPond.findIndex(cItem =>
|
||||||
const { Params, Header } = toRefs(chartEditStore.componentList[index].request.requestParams)
|
cItem.dataPondId === item.interactComponentId
|
||||||
Object.keys(item.interactFn).forEach(key => {
|
)
|
||||||
if (Params.value[key]) {
|
if (globalConfigPindAprndex !== -1) {
|
||||||
Params.value[key] = param[item.interactFn[key]]
|
const { Params, Header } = toRefs(chartEditStore.requestGlobalConfig.requestDataPond[globalConfigPindAprndex].dataPondRequestConfig.requestParams)
|
||||||
}
|
|
||||||
if (Header.value[key]) {
|
Object.keys(item.interactFn).forEach(key => {
|
||||||
Header.value[key] = param[item.interactFn[key]]
|
if (Params.value[key]) {
|
||||||
}
|
Params.value[key] = param[item.interactFn[key]]
|
||||||
})
|
}
|
||||||
|
if (Header.value[key]) {
|
||||||
|
Header.value[key] = param[item.interactFn[key]]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const index = chartEditStore.fetchTargetIndex(item.interactComponentId)
|
||||||
|
if (index === -1) return
|
||||||
|
const { Params, Header } = toRefs(chartEditStore.componentList[index].request.requestParams)
|
||||||
|
|
||||||
|
Object.keys(item.interactFn).forEach(key => {
|
||||||
|
if (Params.value[key]) {
|
||||||
|
Params.value[key] = param[item.interactFn[key]]
|
||||||
|
}
|
||||||
|
if (Header.value[key]) {
|
||||||
|
Header.value[key] = param[item.interactFn[key]]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 联动事件触发的 type 变更时,清除当前绑定内容
|
// 联动事件触发的 type 变更时,清除当前绑定内容
|
||||||
export const clearInteractEvent = (chartConfig: CreateComponentType) => {
|
export const clearInteractEvent = (chartConfig: CreateComponentType) => {
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
create_btn: 'Creat',
|
create_btn: 'Create',
|
||||||
create_tip: 'Please select a content for development',
|
create_tip: 'Please select a content for development',
|
||||||
project: 'Project',
|
project: 'Project',
|
||||||
my: 'My',
|
my: 'My',
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
<help-outline-icon></help-outline-icon>
|
<help-outline-icon></help-outline-icon>
|
||||||
</n-icon>
|
</n-icon>
|
||||||
</template>
|
</template>
|
||||||
<n-text>不支持「静态组件」</n-text>
|
<n-text>不支持「静态组件」支持「组件」「公共APi」</n-text>
|
||||||
</n-tooltip>
|
</n-tooltip>
|
||||||
</template>
|
</template>
|
||||||
<n-select
|
<n-select
|
||||||
@ -89,7 +89,7 @@
|
|||||||
</n-table>
|
</n-table>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
|
|
||||||
<n-tag :bordered="false" type="primary"> 关联目标组件请求参数 </n-tag>
|
<n-tag :bordered="false" type="primary"> 关联目标请求参数 </n-tag>
|
||||||
|
|
||||||
<setting-item-box
|
<setting-item-box
|
||||||
:name="requestParamsItem"
|
:name="requestParamsItem"
|
||||||
@ -125,7 +125,7 @@ import { VNodeChild, computed } from 'vue'
|
|||||||
import { SelectOption, SelectGroupOption } from 'naive-ui'
|
import { SelectOption, SelectGroupOption } from 'naive-ui'
|
||||||
import { SettingItemBox, SettingItem, CollapseItem } from '@/components/Pages/ChartItemSetting'
|
import { SettingItemBox, SettingItem, CollapseItem } from '@/components/Pages/ChartItemSetting'
|
||||||
import { CreateComponentType, CreateComponentGroupType, ChartFrameEnum } from '@/packages/index.d'
|
import { CreateComponentType, CreateComponentGroupType, ChartFrameEnum } from '@/packages/index.d'
|
||||||
import { RequestParamsTypeEnum } from '@/enums/httpEnum'
|
import { RequestParamsTypeEnum, RequestDataTypeEnum } from '@/enums/httpEnum'
|
||||||
import { InteractEventOn, COMPONENT_INTERACT_EVENT_KET } from '@/enums/eventEnum'
|
import { InteractEventOn, COMPONENT_INTERACT_EVENT_KET } from '@/enums/eventEnum'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
import noData from '@/assets/images/canvas/noData.png'
|
import noData from '@/assets/images/canvas/noData.png'
|
||||||
@ -154,6 +154,11 @@ const option = computed(() => {
|
|||||||
// 绑定组件数据 request
|
// 绑定组件数据 request
|
||||||
const fnGetRequest = (id: string | undefined, key: RequestParamsTypeEnum) => {
|
const fnGetRequest = (id: string | undefined, key: RequestParamsTypeEnum) => {
|
||||||
if (!id) return {}
|
if (!id) return {}
|
||||||
|
const globalConfigPindApr = chartEditStore.requestGlobalConfig.requestDataPond.find(item => {
|
||||||
|
return item.dataPondId === id
|
||||||
|
})?.dataPondRequestConfig.requestParams
|
||||||
|
|
||||||
|
if (globalConfigPindApr) return globalConfigPindApr[key]
|
||||||
return chartEditStore.componentList[chartEditStore.fetchTargetIndex(id)]?.request.requestParams[key]
|
return chartEditStore.componentList[chartEditStore.fetchTargetIndex(id)]?.request.requestParams[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,12 +183,10 @@ const fnEventsOptions = (): Array<SelectOption | SelectGroupOption> => {
|
|||||||
iter: Array<CreateComponentType | CreateComponentGroupType>,
|
iter: Array<CreateComponentType | CreateComponentGroupType>,
|
||||||
val: CreateComponentType | CreateComponentGroupType
|
val: CreateComponentType | CreateComponentGroupType
|
||||||
) => {
|
) => {
|
||||||
if (val.groupList && val.groupList.length > 0) {
|
if (!val.groupList && val.request.requestDataType === RequestDataTypeEnum.AJAX && val.request.requestUrl) {
|
||||||
iter.push(val)
|
|
||||||
} else {
|
|
||||||
iter.push(val)
|
iter.push(val)
|
||||||
}
|
}
|
||||||
return val.groupList ? [...iter, ...fnFlattern(val.groupList)] : iter
|
return val.groupList && val.groupList.length > 0 ? [...iter, ...fnFlattern(val.groupList)] : iter
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
@ -203,18 +206,26 @@ const fnEventsOptions = (): Array<SelectOption | SelectGroupOption> => {
|
|||||||
const mapOptionList = filterOptionList.map(item => ({
|
const mapOptionList = filterOptionList.map(item => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
title: item.chartConfig.title,
|
title: item.chartConfig.title,
|
||||||
disabled: false
|
disabled: false,
|
||||||
|
type: 'componentList'
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
const requestDataPond = chartEditStore.requestGlobalConfig.requestDataPond.map(item => ({
|
||||||
|
id: item.dataPondId,
|
||||||
|
title: item.dataPondName,
|
||||||
|
disabled: false,
|
||||||
|
type: 'requestDataPond'
|
||||||
|
}))
|
||||||
|
const tarArr = requestDataPond.concat(mapOptionList)
|
||||||
targetData.value.events.interactEvents?.forEach(iaItem => {
|
targetData.value.events.interactEvents?.forEach(iaItem => {
|
||||||
mapOptionList.forEach(optionItem => {
|
tarArr.forEach(optionItem => {
|
||||||
if (optionItem.id === iaItem.interactComponentId) {
|
if (optionItem.id === iaItem.interactComponentId) {
|
||||||
optionItem.disabled = true
|
optionItem.disabled = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return mapOptionList
|
return tarArr
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增模块
|
// 新增模块
|
||||||
|
@ -74,7 +74,7 @@ const themeColor = computed(() => {
|
|||||||
// 组件渲染结束初始化数据池
|
// 组件渲染结束初始化数据池
|
||||||
clearMittDataPondMap()
|
clearMittDataPondMap()
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initDataPond(chartEditStore.requestGlobalConfig)
|
initDataPond(useChartEditStore)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
3
types/shims-vue.d.ts
vendored
3
types/shims-vue.d.ts
vendored
@ -5,4 +5,5 @@ declare module '*.vue' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare module 'lodash/*'
|
declare module 'lodash/*'
|
||||||
declare module 'dom-helpers'
|
declare module 'dom-helpers'
|
||||||
|
declare module '@iconify/vue'
|
Loading…
x
Reference in New Issue
Block a user