You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zhishifufei_php/public/kefu-assets/components/pc/user-label/index.js

75 lines
2.1 KiB

define([
'kefu-assets/api/kefu',
'text!./index.html',
'css!./index.css'
], function (kefuApi, template) {
return {
template,
name: "userLabel",
props: {
uid: {
type:[ String, Number],
default: ''
}
},
data() {
return {
labelList: [],
activeIds: []
}
},
mounted() {
this.getList()
},
methods: {
getList() {
kefuApi.userLabel(this.uid).then(res => {
res.data.map(el => {
el.label.map(label => {
if (label.disabled) {
this.activeIds.push(label.id)
}
})
})
this.labelList = res.data
})
},
selectLabel(label) {
if (label.disabled) {
let index = this.activeIds.indexOf(label.id)
this.activeIds.splice(index, 1)
label.disabled = false
} else {
this.activeIds.push(label.id)
label.disabled = true
}
},
// 确定
subBtn() {
let unLaberids = [];
this.labelList.map(item => {
item.label.map(i => {
if (i.disabled == false) {
unLaberids.push(i.id);
}
});
});
kefuApi.userLabelPut({
uid: this.uid,
label_ids: this.activeIds,
un_label_ids: unLaberids
}).then(res => {
this.$Message.success(res.msg)
this.$emit('editLabel')
}).catch(error => {
this.$Message.error(error.msg)
})
},
cancel() {
this.$emit('close')
}
}
};
});