Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
emit.forEach(config => {
let inject, eventName = config;
if (isPlainObject(config)) {
eventName = config.name;
inject = config.inject;
}
if (!eventName) return;
const emitKey = emitPrefix ? emitPrefix : field;
const fieldKey = toLine(`${emitKey}-${eventName}`).replace('_', '-');
const fn = (...arg) => {
this.vm.$emit(fieldKey, ...arg);
};
fn.__emit = true;
event[eventName] = (this.options.injectEvent || config.inject !== undefined) ? this.inject(rule, fn, inject) : fn;
});
setValue(field, value) {
let formData = field;
if (!isPlainObject(field))
formData = {[field]: value};
Object.keys(formData).forEach(key => {
this.changeValue(key, formData[key]);
});
},
changeValue(field, value) {
setValue(field, value) {
let formData = field;
if (!isPlainObject(field))
formData = {[field]: value};
Object.keys(formData).forEach(key => {
const parser = h.fieldList[key];
if (!parser) return;
parser.rule.value = formData[key];
});
},
changeValue(field, value) {
class(classList, status = true) {
if (isUndef(classList)) return this;
if (Array.isArray(classList)) {
classList.forEach((cls) => {
$set(this._data.class, toString(cls), true);
});
} else if (isPlainObject(classList)) {
$set(this._data, 'class', extend(this._data.class, classList));
} else {
$set(this._data.class, toString(classList), status === undefined ? true : status);
}
return this;
}
VData.prototype[key] = function (obj, val) {
if (isUndef(obj)) return this;
if (isPlainObject(obj)) {
$set(this._data, key, extend(this._data[key], obj));
} else {
$set(this._data[key], toString(obj), val);
}
return this;
};
});
function install(Vue, options) {
if (Vue._installedFormCreate === true) return;
Vue._installedFormCreate = true;
if (options && isPlainObject(options))
margeGlobal(globalConfig, options);
Vue.use(FormCreate);
}
Creator.prototype.event = function (key, value) {
let event;
if (!isPlainObject(key)) {
event = {[key]: value}
} else {
event = key;
}
Object.keys(event).forEach((eventName) => {
const name = toString(eventName).indexOf('on-') === 0 ? eventName : `on-${eventName}`;
this.on(name, event[eventName]);
});
return this;
};
function parse(rule, toMaker = false) {
if (isString(rule)) rule = parseJson(rule);
if (rule instanceof Creator) return toMaker ? rule : rule.getRule();
if (isPlainObject(rule)) {
const maker = ruleToMaker(rule);
return toMaker ? maker : maker.getRule();
} else if (!Array.isArray(rule)) return rule;
else {
const rules = rule.map(r => parse(r, toMaker));
Object.defineProperties(rules, {
find: enumerable(findField),
model: enumerable(model)
});
return rules;
}
}
class(classList, status = true) {
if (isUndef(classList)) return this;
if (Array.isArray(classList)) {
classList.forEach((cls) => {
$set(this._data.class, toString(cls), true);
});
} else if (isPlainObject(classList)) {
$set(this._data, 'class', extend(this._data.class, classList));
} else {
$set(this._data.class, toString(classList), status === undefined ? true : status);
}
return this;
}