fix:修复数据联动存在的问题
parent
71cc292763
commit
a733617e36
@ -1,26 +1,34 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
export const EventBus = new Vue()
|
|
||||||
|
|
||||||
export function dataInit (_this) {
|
// 创建全局唯一的 EventBus 实例
|
||||||
|
export const EventBus = new Vue();
|
||||||
|
|
||||||
|
// 创建唯一的事件处理函数
|
||||||
|
function dataInitHandler(_this, formData, bindComponents) {
|
||||||
|
bindComponents?.forEach(com => {
|
||||||
|
const maps = com.maps;
|
||||||
|
const filterList = maps?.map(param => ({
|
||||||
|
column: param.targetField,
|
||||||
|
operator: param.queryRule,
|
||||||
|
value: formData[param.sourceField],
|
||||||
|
}));
|
||||||
|
|
||||||
|
_this.$nextTick(() => {
|
||||||
|
if (_this.$refs[com.componentKey] && _this.$refs[com.componentKey].dataInit) {
|
||||||
|
_this.$refs[com.componentKey].dataInit(filterList);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注册事件监听器
|
||||||
|
export function dataInit(_this) {
|
||||||
EventBus.$on('dataInit', (formData, bindComponents) => {
|
EventBus.$on('dataInit', (formData, bindComponents) => {
|
||||||
// eslint-disable-next-line no-unused-expressions
|
// 在回调中调用处理函数并传递组件实例
|
||||||
bindComponents?.forEach(com => {
|
dataInitHandler(_this, formData, bindComponents);
|
||||||
const maps = com.maps
|
});
|
||||||
const filterList = maps?.map(param => ({
|
|
||||||
column: param.targetField,
|
|
||||||
operator: param.queryRule,
|
|
||||||
value: formData[param.sourceField]
|
|
||||||
}))
|
|
||||||
_this.$nextTick(() => {
|
|
||||||
if (_this.$refs[com.componentKey]) {
|
|
||||||
if (_this.$refs[com.componentKey].dataInit) {
|
|
||||||
_this.$refs[com.componentKey].dataInit(filterList)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
export function destroyedEvent () {
|
|
||||||
EventBus.$off('dataInit')
|
export function destroyedEvent() {
|
||||||
|
EventBus.$off('dataInit', dataInitHandler);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue