vxe-table-demonic
Version:
一个基于 vue 的 PC 端表单/表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、JSON 配置式...
55 lines (54 loc) • 1.85 kB
JavaScript
import XEUtils from 'xe-utils';
import { warnLog } from '../../tools/log';
var VXECommandsStore = /** @class */ (function () {
function VXECommandsStore() {
this.store = {};
}
VXECommandsStore.prototype.mixin = function (options) {
var _this = this;
XEUtils.each(options, function (item, key) {
_this.add(key, item);
});
return this;
};
VXECommandsStore.prototype.has = function (name) {
return !!this.get(name);
};
VXECommandsStore.prototype.get = function (name) {
return this.store[name];
};
VXECommandsStore.prototype.add = function (name, render) {
var conf = this.store[name];
// 兼容
if (XEUtils.isFunction(render)) {
if (process.env.NODE_ENV === 'development') {
warnLog('vxe.error.delProp', ['commands -> callback', 'commandMethod']);
}
render = {
commandMethod: render
};
}
// 检测是否覆盖
if (process.env.NODE_ENV === 'development') {
var confKeys_1 = XEUtils.keys(conf);
XEUtils.each(render, function (item, key) {
if (confKeys_1.includes(key)) {
warnLog('vxe.error.coverProp', [name, key]);
}
});
}
this.store[name] = conf ? XEUtils.merge(conf, render) : render;
return this;
};
VXECommandsStore.prototype.delete = function (name) {
delete this.store[name];
};
VXECommandsStore.prototype.forEach = function (callback) {
XEUtils.objectEach(this.store, callback);
};
return VXECommandsStore;
}());
export var commands = new VXECommandsStore();
if (process.env.NODE_ENV === 'development') {
Object.assign(commands, { _name: 'Commands' });
}