var ns;
var id = helper.request.queryString("id");
var phone = helper.request.queryString("phone");
var depName = helper.request.queryString("depName");
var name = helper.request.queryString("name");
var objs = {};
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "CallInScreen/GetCurrUserDep",
dataType: 'json',
async: true,
data: {
token: $.cookie("token")
},
success: function(data) {
if(data.state.toLowerCase() == 'success') {
if(data.data.groname == '客服组') {
//console.log(data.data.groname)
$('.customerService').show();
ns = 1;
} else {
$('.market').show();
ns = 2;
}
}
}
});
$(document).ready(function() {
//工单来源
getOrderSource('#orderSource');
//工单类型
getOrderType();
//工单状态
getOrderState();
//来电单位
// getAccount('#comeCall_dep');
// getAccount('#feedbackDep');
//编辑器配置 客服部
KindEditor.ready(function(K) {
window.changeEditor = K.create('#feedBackCon'); //修改弹出框编辑器
})
//编辑器配置 市场部 备注
KindEditor.ready(function(K) {
window.marketEditor = K.create('#remark_market');
})
//保存
$('.customerSubmit').click(function() {
saveCustomer();
})
$('.marketSubmit').click(function() {
saveMarket();
})
BindLDdep($("#testInput1"),$("#testInput2"),$("#testInput3"),$("#testInput4"));
if(id) {
$("#CallID").val(id);
$("#tel").val(phone);
$("#tel_market").val(phone);
if(unescape(decodeURI(name)) != 'null' && unescape(decodeURI(name)) != 'undefined') {
$("#name_market").val(unescape(decodeURI(name)));
$("#name").val(unescape(decodeURI(name)));
}
if(unescape(decodeURI(depName)) != 'null' && unescape(decodeURI(depName)) != 'undefined') {
$("#testInput1_input").val(unescape(decodeURI(depName)));
$("#testInput3_input").val(unescape(decodeURI(depName)));
}
}
})
//工单类型
function getOrderType() {
$.get(huayi.config.callcenter_url + 'WorkType/GetTreeList', {
"token": $.cookie("token"),
}, function(result) {
result = $.parseJSON(result);
$.fn.zTree.init($("#TreeDemo"), setting3, result.data); //实例化树形图
});
}
var setting3 = {
data: {
key: {
name: "text"
},
simpleData: {
enable: true,
idKey: "id",
rootPId: 0
}
},
callback: {
onClick: changeTreeClick
}
}
function changeTreeClick(event, treeId, treeNode) {
var chanId = treeNode.id;
var changeName = treeNode.text;
$('#typeclass').val(changeName);
$('#typeclassId').val(chanId);
var pidnode = treeNode.getParentNode();
$('.addTree').hide();
};
$('.down').click(function() {
if($('.treeList').css('display') == 'block') {
$('.treeList').css('display', 'none')
} else {
$('.treeList').css('display', 'block')
}
})
$('#typeclass').click(function() {
$('.treeList').css('display', 'block')
})
$('.treeList').mouseleave(function() {
$(this).css('display', 'none')
})
//工单状态
function getOrderState() {
$.ajax({
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
type: 'get',
async: true,
data: {
flag: 'GDZT',
token: $.cookie("token")
},
dataType: "json",
success: function(res) {
if(res.state == "success") {
//console.log(res.data);
$('').appendTo($("#State"));
$(res.data).each(function(i, n) {
if(n.F_DictionaryValueId == '472') {
$('').appendTo($("#State"));
} else {
$('').appendTo($("#State"));
}
})
//
}
}
})
}
//工单来源
function getOrderSource(obj) {
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
flag: "GDLY"
},
success: function(data) {
var Count = data.data;
$('').appendTo($("#DicValueList"));
$(Count).each(function(i, n) {
if(n.F_DictionaryValueId == "468") {
$('').appendTo($("#DicValueList"));
} else {
$('').appendTo($("#DicValueList"));
}
})
}
});
}
//来电单位
$('#testInput1').comboSelect();
$('#testInput2').comboSelect();
$('#testInput3').comboSelect();
$('#testInput4').comboSelect();
function BindLDdep(obj1,obj2,obj3,obj4,) {
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Customer/BindLDdep",
dataType: 'json',
async: false,
data: {
// keypara: str,
token: $.cookie("token")
},
success: function(data) {
var Count = data.data.dep;
var html = '';
$(Count).each(function(i, n) {
html = "";
$(html).appendTo(obj1);
$(html).appendTo(obj2);
$(html).appendTo(obj3);
$(html).appendTo(obj4);
});
obj1.comboSelect();
obj2.comboSelect();
obj3.comboSelect();
obj4.comboSelect();
}
});
};
function saveCustomer() {
if($('#name').val() == '') {
layer.confirm('请输入姓名!', {
icon: 2,
btn: ['确定']
});
return;
}
if($('#tel').val() == '') {
layer.confirm('请输入电话!', {
icon: 2,
btn: ['确定']
});
return;
}
if($.trim($('#testInput1_input').val()) == '') {
layer.confirm('请选择来电单位!', {
icon: 2,
btn: ['确定']
});
return;
}
if($.trim($('#testInput2_input').val()) == '') {
layer.confirm('请选择反馈单位!', {
icon: 2,
btn: ['确定']
});
return;
}
if($('#orderSource').val() == '') {
layer.confirm('请选择工单来源!', {
icon: 2,
btn: ['确定']
});
return;
}
if($('#State').val() == '') {
layer.confirm('请选择工单状态!', {
icon: 2,
btn: ['确定']
});
return;
}
if($('#typeclassId').val() == '') {
layer.confirm('请选择工单类型!', {
icon: 2,
btn: ['确定']
});
return;
}
$.ajax({
type: "post",
url: huayi.config.callcenter_url + "CallInScreen/AddWorkOrder",
dataType: 'json',
async: true,
beforeSend: function() { //触发ajax请求开始时执行
$('.customerSubmit').attr("disabled", true);
$('.customerSubmit').text('保存中...');
},
data: {
token: $.cookie("token"),
callCustomer: $('#name').val(), //姓名
tel: $('#tel').val(), //号码
lddep: $('#testInput1_input').val(), //来电单位
fkdep: $('#testInput2_input').val(), //反馈单位
gdly: $('#DicValueList').val(), //工单来源
gdlx: $('#typeclassId').val(), //工单类型id
gdzt: $('#State').val(), //工单状态id
province: $("#Province").val(),
fkcont: encodeURIComponent(changeEditor.html()), //反馈内容
sendmsg: $('#express').val(), //快递信息
note1: $('#remark1').val(), //备注一
note2: $('#remark2').val(), //备注二
note3: $('#remark3').val(), //备注三
callid: $("#CallID").val()
},
success: function(data) {
if(data.state.toLowerCase() == 'success') {
layer.msg("保存成功!");
clear();
$('.customerSubmit').attr("disabled", false);
$('.customerSubmit').text('保存');
}
}
});
}
function saveMarket() {
if($('#name_market').val() == '') {
layer.confirm('请输入姓名!', {
icon: 2,
btn: ['确定']
});
return;
}
if($('#tel_market').val() == '') {
layer.confirm('请输入电话!', {
icon: 2,
btn: ['确定']
});
return;
}
if($.trim($('#testInput3_input').val()) == '') {
layer.confirm('请选择来电单位!', {
icon: 2,
btn: ['确定']
});
return;
}
$.ajax({
type: "post",
url: huayi.config.callcenter_url + "CallInScreen/AddWorkOrder",
dataType: 'json',
async: true,
beforeSend: function() { //触发ajax请求开始时执行
$('.marketSubmit').attr("disabled", true);
$('.marketSubmit').text('保存中...');
},
data: {
token: $.cookie("token"),
callCustomer: $('#name_market').val(), //姓名
tel: $('#tel_market').val(), //号码
lddep: $('#LDunit_').val(), //来电单位
fkdep: $('#FKunit_').val(), //反馈单位
fkcont: encodeURIComponent(marketEditor.html()), //反馈内容
callid: $("#CallID").val()
},
success: function(data) {
if(data.state.toLowerCase() == 'success') {
layer.msg("保存成功!");
clear();
$('.marketSubmit').attr("disabled", false);
$('.marketSubmit').text('保存');
}
}
});
}
function clear() {
if(ns == 1) {
$('#name').val('');
$('#tel').val(''); //号码
$('#testInput1_input').val(''); //来电单位
$('#testInput2_input').val(''); //反馈单位
$('#orderSource').val(''); //工单来源
$('#typeclassId').val(''); //工单类型id
$('#State').val(''); //工单状态id
$('#feedBackCon').val(''); //反馈内容
$('#express').val(''); //快递信息
$('#remark1').val(''); //备注一
$('#remark2').val(''); //备注二
$('#remark3').val(''); //备注三
$('#typeclass').val('');
changeEditor.html('');
} else {
$('#name_market').val('');
$('#tel_market').val(''); //号码
$('#testInput3_input').val(''); //来电单位
$('#testInput4_input').val(''); //反馈单位
$('#remark_market').val(''); //备注内容
marketEditor.html('');
}
}