var typeSmall;
var CallId = helper.request.queryString("CallId");
$(document).ready(function () {
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "CallInScreen/GetCurrUserDep",
dataType: 'json',
async: false,
data: {
token: $.cookie("token")
},
success: function(data) {
if(data.state.toLowerCase() == 'success') {
if(data.data.groname == '思念组') {
$(".snRmove").remove();
$(".dkRmove").show();
} else {
$(".snRmove").show();
$(".complainDiv2").hide();
$(".dkRmove").remove();
}
}
}
});
var groupcode = $('#groupcode', top.document).val();
if (groupcode == 'SCZ') {
$("#usedate").text("饮用日期:");
$("#vipid").text("对接人:");
$("#vipphone").text("对接人电话:");
}
var id = helper.request.queryString("id");
var phone = helper.request.queryString("phone");
var name = helper.request.queryString("name");
// laydate.render({
// elem: '#productDate',
// theme: '#1ab394',
// calendar: 'true'
// });
// 产品代码
getProductType();
// 问题代码
getProblemCode();
// 重要级别
getDealTimely();
//生产厂家
getProductFactory();
// 省 办事处
LAISHENG($("#source"));//省
CHOUDQ(); //大区
//普通工单禁止选择原因
$('#reason').attr("disabled", "disabled");
//保存
$('.customerSubmit').click(function() {
saveCustomer();
})
//立即办理
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)));
}
}
$('.areaDown').click(function () {
if ($('.treeList1').css('display') == 'block') {
$('.treeList1').css('display', 'none')
} else {
$('.treeList1').css('display', 'block')
}
})
$('#typeclass').click(function () {
$('.treeList1').css('display', 'block')
})
$('.treeList1').mouseleave(function () {
$(this).css('display', 'none')
})
$(".orderType").change(function () {
if ($(".orderType option:selected").text() != "投诉") {
$(".complainDiv2").show();
typeSmall =$(".complaintType2").val();
$(".complainDiv").hide();
} else {
$(".complainDiv2").hide();
$(".complainDiv").show();
typeSmall =$(".complaintType1").val();
}
});
$(".complaintType2").change(function () {
typeSmall=$(".complaintType2").val();
});
$(".complaintType1").change(function () {
typeSmall=$(".complaintType1").val();
});
//获取专员手机号
$("#vipName").change(function () {
$("#vipTel").val($("#vipName option:selected").attr("index"));
if ($("#vipName option:selected").attr("province")==undefined) {
$("#typeclass").val("");
} else {
$("#typeclass").val($("#vipName option:selected").attr("province") + "/" + $("#vipName option:selected").attr("city"));
$(".inps2").val($("#vipName option:selected").attr("province"));
$(".inps3").val($("#vipName option:selected").attr("city"));
}
});
/*
工单类型
1:咨询
2:投诉
3:重复
4:抽查
*/
$("#order_isover").find('input[type="radio"]').on("change", function() {
if ($(this).val() === "1"){
$(".isOverWrapper").show();
$(".complaintWorkOrderRequired").hide();
$(".workOrderTypeForm").show();
$(".workOrderTypeSpotCheck").hide();
} else if(['2', '5', '6', '7', '8', '9', '10', '11', '12'].includes($(this).val())) {
// 工单类型(投诉) 隐藏立即办理
$(".isOverWrapper").hide();
$(".complaintWorkOrderRequired").show();
$(".workOrderTypeForm").show();
$(".workOrderTypeSpotCheck").hide();
} else if ($(this).val() === "3") {
radioRepeat();
$("#order_isover input[name='type'][value='1']").prop("checked","checked"); //咨询
$(".workOrderTypeForm").show();
$(".workOrderTypeSpotCheck").hide();
} else if ($(this).val() === "4") {
$(".complaintWorkOrderRequired").hide();
$(".workOrderTypeForm").hide();
$(".workOrderTypeSpotCheck").show();
}
});
})
//省 市 区/县
//省
function LAISHENG(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
"token": $.cookie("token"),
pid: 0,
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
//市
function LAISHI(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
"token": $.cookie("token"),
pid:$('#source').val(),
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
// 区/县
function LAIQU() {
$("#keyidDataList").empty();
$("#keyidDataList").append('');
$.getJSON(huayi.config.callcenter_url + "RegionCategory/GetCountyList", {
"token": $.cookie("token"),
pid:$('#type').val(),
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("#keyidDataList").append('").appendTo(obj);
})
}
})
}
$('#source').on('change',function(){
LAISHI($("#type"));
});
$('#type').on('change',function(){
LAIQU();
});
//大区
function CHOUDQ(obj) {
$("#customer_comaddress_data_list").empty();
$("#customer_comaddress_data_list").append('');
$.getJSON(huayi.config.callcenter_url + "Department/GetCusAreaList", {
"token": $.cookie("token"),
pid: 1,
F_Layer: 1,
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo($("#customer_comaddress_data_list"));
})
}
})
}
// 提交人
function getSubmitter() {
$("#customer_submitter_data_list").empty();
$("#customer_submitter_data_list").append('');
$.getJSON(huayi.config.callcenter_url + "UserAccount/GetList", {
"token": $.cookie("token"),
type: 1,
dptid: $('#customer_comaddress_data_list').find('option[value="' + $('#customer_comaddress').val() + '"]').attr('data-id'),
pagesize: 100,
}, function (data) {
var content = data.rows;
$(content).each(function (i, n) {
$("").appendTo($("#customer_submitter_data_list"));
})
})
}
// 获取提交人
$('#customer_comaddress').on('change',function(){
getSubmitter();
});
//产品代码
function getProductType() {
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
flag: "CPDM"
},
success: function(data) {
var Count = data.data;
$(Count).each(function(i, n) {
$('').appendTo($("#productType"));
})
}
});
}
// 问题代码
function getProblemCode() {
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
flag: "WTDM"
},
success: function(data) {
var Count = data.data;
$(Count).each(function(i, n) {
$('').appendTo($("#problemCode"));
})
}
});
}
// 重要级别
function getDealTimely() {
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
flag: "GDDJ"
},
success: function(data) {
var Count = data.data;
$(Count).each(function(i, n) {
$('').appendTo($("#dealTimely"));
})
}
});
}
// 重要级别原因(Ⅰ级)
function getReasonOne() {
$("#reason").empty();
$("#reason").append("");
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
flag: "YJYY"
},
success: function(data) {
var Count = data.data;
$(Count).each(function(i, n) {
$('').appendTo($("#reason"));
})
}
});
}
// 重要级别原因(Ⅱ级)
function getReasonTwo() {
$("#reason").empty();
$("#reason").append("");
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
flag: "EJYY"
},
success: function(data) {
var Count = data.data;
$(Count).each(function(i, n) {
$('').appendTo($("#reason"));
})
}
});
}
// 生产厂家
function getProductFactory() {
$("#productFactoryDataList").empty();
$("#productFactoryDataList").append('');
$("#productFactoryDataList").append('');
$("#spotCheckFactoriesDataList").empty();
$("#spotCheckFactoriesDataList").append('');
$("#spotCheckFactoriesDataList").append('');
$.getJSON(huayi.config.callcenter_url + "EquipmentNumber/GetList", {
"token": $.cookie("token"),
keywords: "",
pageindex: "1",
pagesize: "200",
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.rows;
$(content).each(function (i, n) {
$("#productFactoryDataList").append('').appendTo($("#DicValueList"));
})
}
});
}
//客诉专员
function ComplaintVip() {
$.ajax({
type: "get",
url: huayi.config.callcenter_url + "Customer/GetAllList",
dataType: 'json',
async: true,
data: {
token: $.cookie("token"),
type: 2,
province: $('.inps2').val(), //省
city: $('.inps3').val() //市
},
success: function(data) {
$("#vipName").empty();
var Count = data.data;
$('').appendTo($("#vipName"));
$(Count).each(function (i, n) {
$('').appendTo($("#vipName"));
})
}
});
}
//保存
function saveCustomer() {
if($('#order_isover input[name="type"]:checked').val() === "4") {
if(!$("#spotCheckCusPhone").val()) {
layer.confirm('请输入电话!', {
icon: 2,
btn: ['确定']
});
return;
}
if(!$("#spotCheckDate").val()) {
layer.confirm('请输入抽检日期!', {
icon: 2,
btn: ['确定']
});
return;
}
if(!$("#spotCheckCompany").val()) {
layer.confirm('请输入抽检单位!', {
icon: 2,
btn: ['确定']
});
return;
}
if(!$("#spotCheckSamplingtype").val()) {
layer.confirm('请输入抽检类型!', {
icon: 2,
btn: ['确定']
});
return;
}
if(!$("#spotCheckSalesroom").val()) {
layer.confirm('请输入抽样客户/门店!', {
icon: 2,
btn: ['确定']
});
return;
}
if(!$("#spotCheckSamplingproducts").val()) {
layer.confirm('请输入抽检产品!', {
icon: 2,
btn: ['确定']
});
return;
}
if(!$("#spotCheckProductDate").val()) {
layer.confirm('请输入生产日期!', {
icon: 2,
btn: ['确定']
});
return;
}
if(!$("#spotCheckFactories").val()) {
layer.confirm('请输入涉及工厂!', {
icon: 2,
btn: ['确定']
});
return;
}
if(!$("#spotCheckRemark").val()) {
layer.confirm('请输入备注!', {
icon: 2,
btn: ['确定']
});
return;
}
var cusPhone = $("#spotCheckCusPhone").val();
var productDate = $("#spotCheckProductDate").val();
} else {
if (!$('#name').val()) {
layer.confirm('请输入姓名!', {
icon: 2,
btn: ['确定']
});
return;
}
if (!$('#tel').val()) {
layer.confirm('请输入电话!', {
icon: 2,
btn: ['确定']
});
return;
}
if (!$('#qualityProblem').val()) {
layer.confirm('请输入质量问题!', {
icon: 2,
btn: ['确定']
});
return;
}
var cusPhone = $('#tel').val();
var productDate = $('#productDate').val();
}
if ($('#order_isover input[name="type"]:checked').val() === "2") {
if (detailedAddress() === "---") {
layer.confirm('请输入地址!', {
icon: 2,
btn: ['确定']
});
return;
} else if (!$('#productType').val()) {
layer.confirm('请输入产品代码!', {
icon: 2,
btn: ['确定']
});
return;
} else if (!$('#productName').val()) {
layer.confirm('请输入产品名称!', {
icon: 2,
btn: ['确定']
});
return;
} else if (!$('#specification').val()) {
layer.confirm('请输入规格!', {
icon: 2,
btn: ['确定']
});
return;
} else if (!$('#productDate').val()) {
layer.confirm('请输入生产日期!', {
icon: 2,
btn: ['确定']
});
return;
} else if (!$('#productFactory').val()) {
layer.confirm('请输入生产厂家!', {
icon: 2,
btn: ['确定']
});
return;
} else if (!$('#problemCode').val()) {
layer.confirm('请输入问题代码!', {
icon: 2,
btn: ['确定']
});
return;
}
}
$.ajax({
type: "post",
url: huayi.config.callcenter_url + "WorkOrder/AddWorkOrder",
dataType: 'json',
async: true,
beforeSend: function() { //触发ajax请求开始时执行
$('.customerSubmit').attr("disabled", true);
$('.customerSubmit').text('保存中...');
},
data: {
token: $.cookie("token"),
isover: $('#isOver input[name="isOver"]:checked').val(), //立即办理
IsAssign: $('#isAssign input[name="isAssign"]:checked').val(),//是否指派
clbm: $('#customer_submitter_data_list').find('option[value="' + $('#customer_submitter').val() + '"]').attr("deptId"), //提交部门
clid: $('#customer_submitter_data_list').find('option[value="' + $('#customer_submitter').val() + '"]').attr("data-id"), //提交人
// cont: $('#cont').val(), //提交内容
F_Type: $('#order_isover input[name="type"]:checked').val(), //工单类型
F_ComplaintType: $('#complainType input[name="complainType"]:checked').val(), //投诉分类
// F_Area: $('#customer_area').val(), //大区
F_Area: "",
// F_Office: $('#customer_office').val(), //办事处
F_Office: "",
F_DealTimely: $('#dealTimely').val(), //重要级别
F_Reason: $('#reason').val(), //原因
F_CusName: $('#name').val(), //姓名
F_CusPhone: cusPhone, //号码
F_AddRess: detailedAddress(),//地址
F_ProductType: $('#productType').val(), //产品代码
F_ProductName: $('#productName').val(), //产品名称
F_Specifications: $('#specification').val(), //规格
F_ProductDate: productDate, //生产日期
F_BatchNumber: $('#productNumber').val(), //产品编码
F_Manufacturer: $('#productFactory').val(), //生产厂家
F_ProblemCode: $('#problemCode').val(), //问题代码
F_QualityProblem: $('#qualityProblem').val(), //质量问题
F_Content: $('#remark').val(), //备注
F_CallId: CallId, //通话记录id
F_Datecheck: $("#spotCheckDate").val(), //抽检日期
F_Company: $("#spotCheckCompany").val(), //抽检单位
F_Samplingtype: $("#spotCheckSamplingtype").val(), //抽检类型
F_Salesroom: $("#spotCheckSalesroom").val(), //抽样客户/门店
F_Samplingproducts: $("#spotCheckSamplingproducts").val(), //抽检产品
F_Factories: $("#spotCheckFactories").val(), //涉及工厂
F_Remark: $("#spotCheckRemark").val(), //备注
},
success: function(data) {
if(data.state.toLowerCase() == 'success') {
$('.customerSubmit').attr("disabled", false);
$('.customerSubmit').text('保存');
layer.msg("保存成功!");
clear();
// setTimeout("window.location.reload()", 1000); //页面刷新
} else {
$('.customerSubmit').attr("disabled", false);
$('.customerSubmit').text('保存');
}
}
});
}
function clear() {
$('#name').val('');
$('#tel').val(''); //号码
// $('#customer_area').val('');
$('#source').val('');
$('#type').val('');
$('#keyid').val('');
$('#productType').val('');
$('#productName').val('');
$('#specification').val('');
$('#productDate').val('');
$('#productNumber').val('');
$('#productFactory').val('');
$('#problemCode').val('');
$('#qualityProblem').val('');
$('#dealTimely').val('');
$('#reason').val('');
$('#customer_comaddress').val('');
$('#customer_submitter').val('');
// $('#cont').val('');
$('#remark').val('');
$("#order_isover input[name='type'][value='1']").prop("checked","checked"); //工单类型
$(".isOverWrapper").show();
$(".workOrderTypeForm").show();
$(".workOrderTypeSpotCheck").hide();
$("#isAssign input[name='isAssign'][value='1']").prop("checked","checked"); //是否分派
$(".isAssignWrapper").show(); //分派大区 办事处
$('.comaddressTitle').show();
$('.comaddressSelect').show();
$('.submitterTitle').show();
$('.submitterSelect').show();
$("#duplicate input[name='duplicate'][value='0']").prop("checked","checked"); //重复工单
$('#addressDescription').val('');
$("#spotCheckCusPhone").val("");//抽检电话
$("#spotCheckDate").val("");//抽检日期
$("#spotCheckCompany").val("");//抽检单位
$("#spotCheckSamplingtype").val("");//抽检类型
$("#spotCheckSalesroom").val("");//抽样客户/门店
$("#spotCheckSamplingproducts").val("");//抽检产品
$("#spotCheckProductDate").val("");//生产日期
$("#spotCheckFactories").val("");//涉及工厂
$("#spotCheckRemark").val("");//抽检备注
}
// 重复工单
function radioRepeat(){
layer.open({
type: 2,
title: '重复工单',
maxmin: true, //开启最大化最小化按钮
area: ['80%', '90%'],
content: "../WorkOrder/WorkOrderRepeat.html?"
});
}