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.
311 lines
10 KiB
311 lines
10 KiB
define([
|
|
'kefu-assets/api/kefu',
|
|
'text!./index.html',
|
|
'css!./index.css'
|
|
], function (kefuApi, template) {
|
|
return {
|
|
template,
|
|
name: "msgWindow",
|
|
data() {
|
|
return {
|
|
ops: {
|
|
vuescroll: {
|
|
mode: "native",
|
|
enable: false,
|
|
tips: {
|
|
deactive: "Push to Load",
|
|
active: "Release to Load",
|
|
start: "Loading...",
|
|
beforeDeactive: "Load Successfully!",
|
|
},
|
|
auto: false,
|
|
autoLoadDistance: 0,
|
|
pullRefresh: {
|
|
enable: false,
|
|
},
|
|
pushLoad: {
|
|
enable: false,
|
|
auto: true,
|
|
autoLoadDistance: 10,
|
|
},
|
|
},
|
|
bar: {
|
|
background: "#393232",
|
|
opacity: ".5",
|
|
size: "2px",
|
|
},
|
|
},
|
|
isScroll: true,
|
|
page: 1,
|
|
limit: 10,
|
|
tabCur: 1,
|
|
tabList: [
|
|
{
|
|
title: "个人库",
|
|
key: 1,
|
|
},
|
|
{
|
|
title: "公共库",
|
|
key: 0,
|
|
},
|
|
],
|
|
searchTxt: "", // 搜索
|
|
list: [
|
|
{
|
|
isEdit: false,
|
|
},
|
|
], // 列表
|
|
model1: "",
|
|
msgTitle: "", // 填写的标题
|
|
sortList: [], // 分类
|
|
cateId: "", // 选中的id
|
|
addMsg: {
|
|
title: "",
|
|
message: "",
|
|
cateId: "",
|
|
isEdit: false,
|
|
},
|
|
isAddSort: false, // 添加分类
|
|
classTitle: "", // 分类名称
|
|
classSort: "", // 分类排序
|
|
maskTitle: "", // 弹窗标题
|
|
editObj: {}, // 编辑分类对象
|
|
};
|
|
},
|
|
filters: {
|
|
filtersTitle(val) {
|
|
let len = 37;
|
|
if (val.length > len) {
|
|
let data = val.substring(0, len);
|
|
return `${data}...`;
|
|
} else {
|
|
return val;
|
|
}
|
|
},
|
|
filtersCon(val) {
|
|
let len = 113;
|
|
if (val.length > len) {
|
|
let data = val.substring(0, len);
|
|
return `${data}...`;
|
|
} else {
|
|
return val;
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
this.serviceCate();
|
|
},
|
|
methods: {
|
|
// 打开编辑
|
|
editMsg(item) {
|
|
item.isEdit = true;
|
|
this.cateId = item.cate_id;
|
|
},
|
|
// 编辑框
|
|
bindEdit(item, index) {
|
|
// if (index == 0) {
|
|
// return;
|
|
// } else {
|
|
item.isEdit = !item.isEdit;
|
|
// }
|
|
},
|
|
// 头部选择
|
|
bindTab(item) {
|
|
this.tabCur = item.key;
|
|
this.cateId = "";
|
|
this.sortList = [];
|
|
this.isScroll = true;
|
|
this.page = 1;
|
|
this.list = [];
|
|
this.serviceCate();
|
|
},
|
|
// 搜索
|
|
bindSearch() {
|
|
this.isScroll = true;
|
|
this.page = 1;
|
|
this.list = [];
|
|
this.getList();
|
|
},
|
|
// 选择分类
|
|
selectSort(item) {
|
|
if (this.cateId == item.id) {
|
|
return;
|
|
}
|
|
this.sortList.forEach((el, index) => {
|
|
if (el.id != item.id) {
|
|
el.isEdit = false;
|
|
}
|
|
});
|
|
this.cateId = item.id;
|
|
this.isScroll = true;
|
|
this.page = 1;
|
|
this.list = [];
|
|
this.getList();
|
|
},
|
|
// 删除分类
|
|
delSort(row) {
|
|
this.$Modal.confirm({
|
|
title: "确定要删除分类吗?",
|
|
loading: true,
|
|
onOk: () => {
|
|
this.$Modal.remove();
|
|
kefuApi.delSpeechCate(row.id)
|
|
.then(res => {
|
|
this.$Message.success(res.msg);
|
|
this.isScroll = true;
|
|
this.page = 1;
|
|
this.list = [];
|
|
this.cateId = "";
|
|
this.serviceCate();
|
|
})
|
|
.catch(error => {
|
|
this.$Message.error(error.msg);
|
|
});
|
|
}
|
|
});
|
|
},
|
|
// 获取分类
|
|
serviceCate() {
|
|
kefuApi.serviceCate({
|
|
type: this.tabCur,
|
|
}).then((res) => {
|
|
res.data.forEach((el, index) => {
|
|
el.isEdit = false;
|
|
});
|
|
this.sortList = res.data;
|
|
if (this.cateId === "" && res.data.length) {
|
|
this.cateId = res.data[0].id;
|
|
}
|
|
this.getList();
|
|
});
|
|
},
|
|
// 获取列表
|
|
getList() {
|
|
if (!this.isScroll) return;
|
|
kefuApi.speeChcraft({
|
|
page: this.page,
|
|
limit: this.limit,
|
|
title: this.searchTxt,
|
|
cate_id: this.cateId,
|
|
type: this.tabCur,
|
|
}).then((res) => {
|
|
this.isScroll = res.data.length >= this.limit;
|
|
res.data.forEach((el, index) => {
|
|
el.isEdit = false;
|
|
});
|
|
this.page++;
|
|
this.list = this.list.concat(res.data);
|
|
});
|
|
},
|
|
// 修改话术
|
|
updataMsg(item) {
|
|
kefuApi.addSpeeChcraft({
|
|
id: item.id,
|
|
title: item.title,
|
|
cate_id: this.cateId,
|
|
message: item.message,
|
|
})
|
|
.then((res) => {
|
|
this.$Message.success("修改成功");
|
|
item.isEdit = false;
|
|
})
|
|
.catch((error) => {
|
|
this.$Message.error(error.msg);
|
|
item.isEdit = true;
|
|
});
|
|
},
|
|
// 添加框显示
|
|
bindFocus() {
|
|
this.list.forEach((el, item) => {
|
|
el.isEdit = false;
|
|
});
|
|
this.addMsg.isEdit = true;
|
|
},
|
|
// 打开添加窗口
|
|
openAddSort() {
|
|
this.isAddSort = true;
|
|
this.maskTitle = "添加分组";
|
|
this.editObj.id = 0;
|
|
},
|
|
// 添加话术
|
|
bindAdd() {
|
|
kefuApi.addSpeeChcraft({
|
|
title: this.addMsg.title,
|
|
cate_id: this.addMsg.cateId,
|
|
message: this.addMsg.message,
|
|
})
|
|
.then((res) => {
|
|
this.addMsg.title = "";
|
|
this.addMsg.message = "";
|
|
this.addMsg.cateId = "";
|
|
this.addMsg.isEdit = false;
|
|
this.$Message.success(res.msg);
|
|
res.data.isEdit = false;
|
|
this.page = 1;
|
|
this.list = [];
|
|
this.isScroll = true;
|
|
this.serviceCate();
|
|
})
|
|
.catch((error) => {
|
|
this.$Message.error(error.msg);
|
|
});
|
|
},
|
|
// 删除
|
|
delMsg(row, num) {
|
|
this.$Modal.confirm({
|
|
title: "确定要删除话术吗?",
|
|
loading: true,
|
|
onOk: () => {
|
|
this.$Modal.remove();
|
|
kefuApi.delSpeech(row.id)
|
|
.then(res => {
|
|
this.$Message.success(res.msg);
|
|
this.list.splice(num, 1);
|
|
})
|
|
.catch(error => {
|
|
this.$Message.error(error.msg);
|
|
});
|
|
}
|
|
});
|
|
},
|
|
// 添加分类
|
|
addServiceCate() {
|
|
kefuApi.addKefuSpeechCate({
|
|
id: this.editObj.id || '',
|
|
name: this.classTitle,
|
|
sort: this.classSort,
|
|
})
|
|
.then((res) => {
|
|
this.classTitle = "";
|
|
this.classSort = "";
|
|
this.$Message.success(res.msg);
|
|
this.isAddSort = false;
|
|
this.page = 1;
|
|
this.list = [];
|
|
this.isScroll = true;
|
|
this.serviceCate();
|
|
})
|
|
.catch((error) => {
|
|
this.classTitle = "";
|
|
this.classSort = "";
|
|
this.$Message.error(res.msg);
|
|
});
|
|
|
|
},
|
|
// 编辑分类
|
|
editSort(item) {
|
|
this.classSort = item.sort;
|
|
this.classTitle = item.name;
|
|
this.isAddSort = true;
|
|
this.maskTitle = "编辑分组";
|
|
this.editObj = item;
|
|
},
|
|
handleReachBottom() {
|
|
this.getList();
|
|
},
|
|
bindRadio(data) {
|
|
this.$emit("active-txt", data.message);
|
|
},
|
|
},
|
|
};
|
|
}); |