var ns;
var id = helper.request.queryString("id");
console.log(id)
var phone = helper.request.queryString("phone");
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 == '客服组') {
$('.customerService').show();
ns = 1;
} else {
$('.market').show();
ns = 2;
}
}
}
});
if(id) {
$("#tel").val(phone);
$("#tel_market").val(phone);
$("#CallID").val(id);
}
GDLY();
State();
//工单类型
getOrderType();
//来电单位
getAccount('#comeCall_dep');
// getAccount('#comeCall_dep_market');
getAccount('#feedbackDep');
// getAccount('#feedbackDep_market');
//保存
$('.customerSubmit').click(function() {
saveCustomer();
})
$('.marketSubmit').click(function() {
saveMarket();
})
// })
//编辑器配置
KindEditor.ready(function(K) {
window.changeEditor = K.create('#feedBackCon');//修改弹出框编辑器
})
XQ()
//工单状态
function State(){
$.ajax({
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
type: 'get',
async: true,
cache: false,
data: {
flag: 'GDZT',
token: $.cookie("token")
},
dataType: "json",
success: function(res) {
if(res.state == "success") {
console.log(res.data);
$(res.data).each(function(i, n) {
$('').appendTo($("#State"));
})
//
}
}
})
}
//工单来源
function GDLY(){
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
dataType: 'json',
async: true,
cache: false,
data: {
token: $.cookie("token"),
flag: "GDLY"
},
success: function(data) {
var Count = data.data;
$(Count).each(function(i, n) {
$('').appendTo($("#DicValueList"));
})
}
});
}
//获取详情
function XQ(){
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "WorkOrder/GetWorkOrder",
dataType: 'json',
async: true,
cache: false,
data: {
"orderid": id,
"token": $.cookie("token")
},
success: function(result) {
if(result.data.data.length > 0) {
var data = result.data.data[0];
var state = data.State;
var state_;
$("#xq_gdlx").text(data.GDLXName);
$("#xq_cjsj").text(data.CreateTime);
// $("#xq_gdzt").html(GetStateName(data.State));
$("#name").val(data.Customer);
$("#name_market").val(data.Customer);
$("#tel_market").val(data.CustomerTel);
$("#tel").val(data.CustomerTel);
//
$("#testInput1").val(data.Address);
$("#testInput2").val(data.Source);
$("#testInput3").val(data.Address);
$("#testInput4").val(data.Source);
$("#typeclass").val(data.GDLXName);
// $("#feedBackCon").text(decodeURIComponent(data.Detail));
changeEditor.html(decodeURIComponent(data.Detail));
$("#remark_market").text(data.Detail);
$("#express").text(data.Files);
$("#remark1").text(data.City);
$("#remark2").text(data.Province);
$("#remark3").text(data.County);
if(state == 0) {
state_ = 471;
} else {
state_ = 472;
}
console.log(state_)
$("#State").val(state_);
$("#States").val(data.State);
$("#DicValueList").val(data.Type);
console.log(data.GDLYName)
$("#typeclassId").val(data.TypeClass);
}
}
});
}
//工单类型
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();
};
$('.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 getAccount(obj) {
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Customer/BindLDdep",
dataType: 'json',
async: true,
data: {
token: $.cookie("token")
},
success: function(data) {
var Count = data.data.dep;
$(Count).each(function(i, n) {
$("").appendTo($(obj));
})
// $(obj).selectpicker('refresh');
}
});
}
function saveCustomer() {
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "WorkOrder/EditWorkOrderDetail",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
orderid: id,
customer: $('#name').val(), //姓名
lddep: $('#testInput1').val(), //来电单位
fkdep: $('#testInput2').val(), //反馈单位
type: $('#DicValueList').val(), //工单来源
typeclass: $('#typeclassId').val(), //工单类型id
gdzt: $('#State').val(), //工单状态id
detail: encodeURIComponent(changeEditor.html()), //反馈内容
files: $('#express').val(), //快递信息
remark1: $('#remark1').val(), //备注一
remark2: $('#remark2').val(), //备注二
remark3: $('#remark3').val() //备注三 callid:$("#CallID").val()
},
success: function(data) {
if(data.state.toLowerCase() == 'success') {
layer.msg("保存成功!");
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
parent.initTable();
parent.layer.msg("修改成功!");
clear();
}
}
});
}
function saveMarket() {
if($('#name_market').val() == '') {
layer.confirm('请输入姓名!', {
icon: 2,
btn: ['确定']
});
return;
}
if($('#tel_market').val() == '') {
layer.confirm('请输入电话!', {
icon: 2,
btn: ['确定']
});
return;
}
if($('#testInput3').val() == '') {
layer.confirm('请选择来电单位!', {
icon: 2,
btn: ['确定']
});
return;
}
$.ajax({
type: "post",
url: huayi.config.callcenter_url + "WorkOrder/EditWorkOrderDetail",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
callCustomer: $('#name_market').val(), //姓名
tel: $('#tel_market').val(), //号码
lddep: $('#testInput3').val(), //来电单位
fkdep: $('#testInput4').val(), //反馈单位
fkcont: encodeURIComponent(changeEditor.html()), //反馈内容
callid: $("#CallID").val()
},
success: function(data) {
if(data.state.toLowerCase() == 'success') {
layer.msg("保存成功!");
clear();
}
}
});
}
function clear() {
if(ns == 1) {
$('#name').val('');
$('#tel').val(''); //号码
$('#testInput1').val(''); //来电单位
$('#testInput2').val(''); //反馈单位
$('#orderSource').val(''); //工单来源
$('#typeclassId').val(''); //工单类型id
$('#State').val(''); //工单状态id
$('#feedBackCon').val(''); //反馈内容
$('#express').val(''); //快递信息
$('#remark1').val(''); //备注一
$('#remark2').val(''); //备注二
$('#remark3').val(''); //备注三
} else {
$('#name_market').val('');
$('#tel_market').val(''); //号码
$('#testInput3').val(''); //来电单位
$('#testInput4').val(''); //反馈单位
$('#remark_market').val(''); //备注内容
}
}