vdpAdmin 486ceafce1 版本升级到3.0.4:
1. 新增必填校验自定义提示属性requiredHint;
2. 当容器被设置隐藏时,同步清除容器内所有字段的校验规则;
3. 设计器、渲染器新增两个API方法:getFieldWidgets()、getContainerWidgets();
4. field-list-api属性允许传递请求头信息;
5. 修复异步请求时setFormData()函数可能失效的问题;
6. 修复其他部分bug。
2022-03-08 17:59:10 +08:00

99 lines
2.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function _broadcast(componentName, eventName, params) {
this.$children.forEach(function (child) {
let name = child.$options.componentName;
if (name === componentName) {
//child.$emit.apply(child, [eventName].concat(params));
if (!!child.emit$) {
child.emit$.call(child, eventName, params)
}
} else {
_broadcast.apply(child, [componentName, eventName].concat([params]));
}
});
}
export default {
data() {
return {
vfEvents: {}
}
},
methods: {
emit$(eventName, data) {
if (this.vfEvents[eventName]) {
this.vfEvents[eventName].forEach((fn) => {
fn(data);
});
}
},
on$(eventName, fn) {
this.vfEvents[eventName] = this.vfEvents[eventName] || [];
this.vfEvents[eventName].push(fn);
},
off$(eventName, fn) {
if (this.vfEvents[eventName]) {
if ((fn === undefined) || (fn === null)) {
this.vfEvents[eventName].length = 0
return
}
for (let i = 0; i < this.vfEvents[eventName].length; i++) {
if (this.vfEvents[eventName][i] === fn) {
this.vfEvents[eventName].splice(i, 1)
break
}
}
}
},
dispatch: function dispatch(componentName, eventName, params) {
//debugger
let parent = this.$parent || this.$root;
let name = parent.$options.componentName;
while (parent && (!name || name !== componentName)) {
parent = parent.$parent;
if (parent) {
name = parent.$options.componentName;
}
}
if (parent) {
//parent.$emit.apply(parent, [eventName].concat(params));
if (!!parent.emit$) {
parent.emit$.call(parent, eventName, params)
}
}
},
broadcast: function broadcast(componentName, eventName, params) {
/* Vue3移除了$children属性_broadcast方法已不能使用 */
//_broadcast.call(this, componentName, eventName, params);
if (!!this.widgetRefList) { //FormRender只需遍历自身的widgetRefList属性
Object.keys(this.widgetRefList).forEach(refName => {
let cmpName = this.widgetRefList[refName].$options.componentName
if (cmpName === componentName) {
let foundRef = this.widgetRefList[refName]
foundRef.emit$.call(foundRef, eventName, params)
}
})
}
if (!!this.refList) { //其他组件遍历inject的refList属性
Object.keys(this.refList).forEach(refName => {
let cmpName = this.refList[refName].$options.componentName
if (cmpName === componentName) {
let foundRef = this.refList[refName]
foundRef.emit$.call(foundRef, eventName, params)
}
})
}
}
}
};