Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setvalue(trigger) {
let value = this.dispose();
this.$emit('input', value);
this.$emit('change', utils.copy(this.multiple ? this.objects : this.object));
if (trigger != 'clear') {
this.valueBak = value;
}
let event = document.createEvent('CustomEvent');
event.initCustomEvent('setvalue', true, true, value);
this.$el.dispatchEvent(event);
this.dropdownUpdate();
},
initCategoryDatas() {
this.$nextTick(() => {
this.$emit(
'change',
utils.copy(this.multiple ? this.objects : this.object)
);
});
},
setvalue() {
let value = this.dispose();
this.$emit('input', value);
this.$emit('change', utils.copy(this.multiple ? this.objects : this.object));
let event = document.createEvent('CustomEvent');
event.initCustomEvent('setvalue', true, true, value);
this.$el.dispatchEvent(event);
},
initCascaderDatas() {
initDatas(datas) {
let list = utils.copy(datas);
if (this.param.dataMode == 'list' && datas.length > 0) {
list = utils.generateTree(list, this.param);
}
let isWait = utils.isFunction(this.param.getDatas);
this.categoryDatas = this.initTreeModeData(list, null, isWait, 0);
this.list = this.categoryDatas;
this.parse();
},
initTreeModeData(list, parentKey, isWait, level) {
this.$nextTick(() => {
if (this.multiple) {
this.objects = this.$refs.tree.getChoose();
} else {
this.object = this.$refs.tree.getSelect();
}
});
} else {
if (this.multiple) {
this.valuebak = (this.value || []).map(
item => item[this.param.keyName]
);
this.objects = utils.copy(this.value);
} else {
this.valuebak = this.value ? this.value[this.param.keyName] : null;
this.object = utils.copy(this.value);
}
}
},
dispose() {
add() {
if (this.wordlimit < this.tagvalue.length) {
Message.error(this.t('h.wordlimit.warn', [this.wordlimit]));
return false;
}
if (this.limit <= this.values.length) {
Message.error(this.t('h.taginput.limitWords'));
return false;
}
if (this.readonly) return false;
if (this.tagvalue === '') return false;
let value = utils.copy(this.values);
value.push(this.tagvalue);
this.setvalue(value);
},
setvalue(value) {
openPicker() {
let that = this;
if (this.disabled) return;
Modal({
width: 600,
hasDivider: true,
component: {
vue: categoryModal,
data: {
param: this.param,
objects: [...this.objects],
object: utils.copy(this.object),
categoryDatas: this.categoryDatas,
categoryObj: this.categoryObj,
multiple: this.multiple,
limit: this.limit,
filterable: this.filterable
}
},
events: {
setvalue(modal, data) {
that.objects = data.objects;
that.object = data.object;
that.setvalue();
},
load: (modal, { data, callback }) => {
if (data.status.loading) return;
data.status.loading = true;
remove(index) {
if (this.readonly) return;
let value = utils.copy(this.values);
value.splice(index, 1);
this.setvalue(value);
},
add() {