work in home

pull/1/head
saeid_01 5 years ago
parent 86f1b962a8
commit b6240cd008

@ -1,6 +1,6 @@
{
"/js/vue/Authentication/app.js": "/js/vue/Authentication/app.js?id=586f299c24bf749d2f3c",
"/js/vue/Home/app.js": "/js/vue/Home/app.js?id=f4ad28357a5e94487801",
"/js/vue/Modules/CRM/app.js": "/js/vue/Modules/CRM/app.js?id=c4391f11fc4c91ba84a6",
"/js/vue/User/app.js": "/js/vue/User/app.js?id=9169814f6c1ee0c82078"
"/js/vue/Authentication/app.js": "/js/vue/Authentication/app.js?id=979ca3cbe3ae6f2f6648",
"/js/vue/Home/app.js": "/js/vue/Home/app.js?id=952eba47f3c87b27c8e4",
"/js/vue/Modules/CRM/app.js": "/js/vue/Modules/CRM/app.js?id=2438d0b19611c164de10",
"/js/vue/User/app.js": "/js/vue/User/app.js?id=90b3808d13f34c14baac"
}

@ -21,6 +21,7 @@
export default {
props: {
itemValue: { default: null },
itemSlug: { default: 'id' },
itemText: { default: null },
text: { default: " " },
item: { default: {} },
@ -30,15 +31,21 @@ export default {
data: function() {
return {
IconClass: "WMi-" + this.Icon,
rand: Math.random()
rand: Math.random(),
values: this.computedValues(this.value)
};
},
computed: {
valueSelected() {
if (this.itemValue) {
return this.item[this.itemValue];
if (typeof this.item == 'object') {
if (this.itemValue) {
return this.item[this.itemValue];
} else {
return this.item[this.itemSlug];
}
} else {
return this.item;
}
return this.item;
},
showText() {
if (this.itemText) {
@ -46,43 +53,51 @@ export default {
}
return this.text;
},
values: {
get() {
if (this.itemValue) {
let newval = [];
for (const val of this.value) {
newval.push(val[this.itemValue]);
}
return newval;
}
return this.value;
},
set() {}
}
},
methods: {
changeValue($event) {
if (this.value) {
if ($event.target.checked) {
this.value.push(this.valueSelected);
if (this.itemValue) {
this.value.push(this.valueSelected);
} else {
this.value.push(this.item);
}
} else {
let index = this.value.findIndex(
x => x == this.valueSelected
);
if (typeof this.item == 'object' && !this.itemValue) {
var index = this.value.findIndex(
x => x[this.itemSlug] == this.item[this.itemSlug]
);
} else {
var index = this.value.findIndex(
x => x == this.valueSelected
);
}
this.value.splice(index, 1);
}
}
this.$emit("change", this.item, $event.target.checked);
},
computedValues(value) {
if (Array.isArray(value)) {
let newArray = [];
for (const val of value) {
if (typeof val == "object") {
newArray.push(val[this.itemSlug]);
} else {
newArray.push(val);
}
}
return newArray;
} else {
return value;
}
}
},
watch: {
value(value) {
if (this.itemValue) {
this.values = value[this.itemValue];
} else {
this.values = value;
}
}
this.values = this.computedValues(value);
},
}
};
</script>

Loading…
Cancel
Save