var typeSmall; var id = helper.request.queryString("id"); var CallId = ""; var callRecordType = helper.request.queryString("callRecordType"); $(document).ready(function () { /* 1 通话记录 修改工单 else 工单管理修改工单 */ if (callRecordType === "1") { CallId = helper.request.queryString("CallId"); getWorkOrderCallRecordId(); } else { getWorkOrderDetails(); } // 产品代码 getProductType(); // 问题代码 getProblemCode(); // 重要级别 getDealTimely(); //产品厂家 getProductFactory(); // 省 办事处 LAISHENG($("#source"));//省 CHOUDQ($("#customer_comaddress")); //办事处 //普通工单禁止选择原因 $('#reason').attr("disabled", "disabled"); //保存 $('.customerSubmit').click(function() { saveCustomer(); }); $.ajaxSettings.async = true; //获取专员手机号 $("#vipName").change(function() { $("#vipTel").val($("#vipName option:selected").attr("index")); //$("#areaInps").val($("#vipName option:selected").attr("areaText")); $("#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")); }); }) // 获取工单详情 function getWorkOrderDetails() { $.ajax({ type: "get", url: huayi.config.callcenter_url + "WorkOrder/GetDetails", dataType: 'json', async: true, cache: false, data: { id: id, token: $.cookie("token") }, success: function(result) { if (result.rows.length > 0) { var data = result.rows[0]; CallId = data.F_CallId; $("#workOrderId").val(data.F_WorkOrderId); //工单编号 $("#name").val(data.F_CusName); // 姓名 $("#tel").val(data.F_CusPhone); // 电话 $("#productName").val(data.F_ProductName); // 产品名称 $('#specification').val(data.F_Specifications); // 规格 $("#productDate").val(data.F_ProductDate); // 生产日期 $("#productNumber").val(data.F_BatchNumber); // 产品编码 $("#productFactory").val(data.F_Manufacturer); // 产品厂家 $("#problemCode option:selected").text(data.F_ProblemCode); // 问题代码 $("#problemCode option:selected").val(data.F_ProblemCode); // 问题代码 $("#productType option:selected").text(data.F_ProductType) //产品代码 $("#productType option:selected").val(data.F_ProductType); // 产品代码 $("#qualityProblem").val(data.F_QualityProblem); // 质量问题 $("#remark").val(data.F_Content); // 备注 $("#dealTimely option:selected").text(data.F_DealTimely); //重要级别 $("#dealTimely option:selected").val(data.F_DealTimely); //重要级别 $("#reason option:selected").text(data.F_Reason); //原因 $("#reason option:selected").val(data.F_Reason); //原因 //工单类型 $("#order_isover input[type=radio][name=type][value="+data.F_Type+"]").attr("checked",'checked'); if (data.F_ComplaintType) $("#complainType input[type=radio][name=complainType][value="+data.F_ComplaintType+"]").attr("checked",'checked'); console.log(data.F_ComplaintType, 'data.F_ComplaintType') if (data.F_Type === 1){ $(".isOverWrapper").show(); $(".complaintWorkOrderRequired").hide(); $(".workOrderTypeForm").show(); $(".workOrderTypeSpotCheck").hide(); $("#workOrderSpotCheck").attr("disabled", "disabled"); } else if(data.F_Type === 2) { // 工单类型(投诉) 隐藏立即办理 $(".isOverWrapper").hide(); $(".complaintWorkOrderRequired").show(); $(".workOrderTypeForm").show(); $(".workOrderTypeSpotCheck").hide(); $("#workOrderSpotCheck").attr("disabled", "disabled"); } else if(data.F_Type === 3) { $(".workOrderTypeForm").show(); $(".workOrderTypeSpotCheck").hide(); $("#workOrderSpotCheck").attr("disabled", "disabled"); } else if (data.F_Type === 4) { $(".workOrderTypeForm").hide(); $(".workOrderTypeSpotCheck").show(); $("#workOrderRadioAdvisory").attr("disabled", "disabled"); $("#workOrderRadioComplaint").attr("disabled", "disabled"); $("#workOrderRadioRepeat").attr("disabled", "disabled"); } $("#spotCheckDate").val(data.F_Datecheck); //抽检日期 $("#spotCheckCompany").val(data.F_Company); //抽检单位 $("#spotCheckSamplingtype").val(data.F_Samplingtype); //抽检类型 $("#spotCheckSalesroom").val(data.F_Salesroom); //抽样客户/门店 $("#spotCheckSamplingproducts").val(data.F_Samplingproducts); //抽检产品 $("#spotCheckProductDate").val(data.F_ProductDate); //生产日期 $("#spotCheckFactories").val(data.F_Factories); //涉及工厂 $("#spotCheckCusPhone").val(data.F_CusPhone); //电话 $("#spotCheckRemark").val(data.F_Remark); //备注 //重复工单 $("#duplicate input[type=radio][name=duplicate][value="+data.F_Duplicate+"]").attr("checked",'checked'); // 工单来源 workOrderSourceDisplay(data); // 省市县 provinceCity(data) } } }); } // 通话记录获取工单详情 function getWorkOrderCallRecordId() { $.ajax({ type: "get", url: huayi.config.callcenter_url + "WorkOrder/GetCallidDetails", dataType: 'json', async: true, cache: false, data: { callid: CallId, token: $.cookie("token") }, success: function(result) { if (result.rows.length > 0) { var data = result.rows[0]; $("#workOrderId").val(data.F_WorkOrderId); //工单编号 $("#name").val(data.F_CusName); // 姓名 $("#tel").val(data.F_CusPhone); // 电话 $("#productName").val(data.F_ProductName); // 产品名称 $('#specification').val(data.F_Specifications); // 规格 $("#productDate").val(data.F_ProductDate); // 生产日期 $("#productNumber").val(data.F_BatchNumber); // 产品编码 $("#productFactory").val(data.F_Manufacturer); // 产品厂家 $("#problemCode option:selected").text(data.F_ProblemCode); // 问题代码 $("#problemCode option:selected").val(data.F_ProblemCode); // 问题代码 $("#productType option:selected").text(data.F_ProductType) //产品代码 $("#productType option:selected").val(data.F_ProductType); // 产品代码 $("#qualityProblem").val(data.F_QualityProblem); // 质量问题 $("#remark").val(data.F_Content); // 备注 $("#dealTimely option:selected").text(data.F_DealTimely); //重要级别 $("#dealTimely option:selected").val(data.F_DealTimely); //重要级别 $("#reason option:selected").text(data.F_Reason); //原因 $("#reason option:selected").val(data.F_Reason); //原因 //工单类型 $("#order_isover input[type=radio][name=type][value="+data.F_Type+"]").attr("checked",'checked'); if (data.F_Type === 1){ $(".isOverWrapper").show(); $(".complaintWorkOrderRequired").hide(); $(".workOrderTypeForm").show(); $(".workOrderTypeSpotCheck").hide(); $("#workOrderSpotCheck").attr("disabled", "disabled"); } else if(data.F_Type === 2) { // 工单类型(投诉) 隐藏立即办理 $(".isOverWrapper").hide(); $(".complaintWorkOrderRequired").show(); $(".workOrderTypeForm").show(); $(".workOrderTypeSpotCheck").hide(); $("#workOrderSpotCheck").attr("disabled", "disabled"); } else if(data.F_Type === 3) { $(".workOrderTypeForm").show(); $(".workOrderTypeSpotCheck").hide(); $("#workOrderSpotCheck").attr("disabled", "disabled"); } else if (data.F_Type === 4) { $(".workOrderTypeForm").hide(); $(".workOrderTypeSpotCheck").show(); $("#workOrderRadioAdvisory").attr("disabled", "disabled"); $("#workOrderRadioComplaint").attr("disabled", "disabled"); $("#workOrderRadioRepeat").attr("disabled", "disabled"); } $("#spotCheckDate").val(data.F_Datecheck); //抽检日期 $("#spotCheckCompany").val(data.F_Company); //抽检单位 $("#spotCheckSamplingtype").val(data.F_Samplingtype); //抽检类型 $("#spotCheckSalesroom").val(data.F_Salesroom); //抽样客户/门店 $("#spotCheckSamplingproducts").val(data.F_Samplingproducts); //抽检产品 $("#spotCheckProductDate").val(data.F_ProductDate); //生产日期 $("#spotCheckFactories").val(data.F_Factories); //涉及工厂 $("#spotCheckCusPhone").val(data.F_CusPhone); //电话 $("#spotCheckRemark").val(data.F_Remark); //备注 //重复工单 $("#duplicate input[type=radio][name=duplicate][value="+data.F_Duplicate+"]").attr("checked",'checked'); // 工单来源 workOrderSourceDisplay(data); // 省市县 provinceCity(data) //获取工单id id = data.F_Id; } else { layer.msg('没有查询到工单'); } } }); } // 工单来源显示 function workOrderSourceDisplay(data) { if (data.F_Source === 1) { $("#workOrderSource").val("PC") } else if (data.F_Source === 2){ $("#workOrderSource").val("APP") } else if (data.F_Source === 3) { $("#workOrderSource").val("微信") } else { $("#workOrderSource").val("") } } //省市县回显 function provinceCity(data){ var provinceCityArr = data.F_AddRess.split("-"); $("#source option:selected").text(provinceCityArr[0]); //省 $("#source option:selected").val(provinceCityArr[0]); $("#type option:selected").text(provinceCityArr[1]); //市 $("#type option:selected").val(provinceCityArr[1]); $("#keyid").val(provinceCityArr[2]); //区\县 $("#addressDescription").val(provinceCityArr[3]); //详细地址描述 } //省 市 区/县 //省 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) { obj.empty(); obj.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(obj); }) } }) } //办事处 function CHOUFEN(obj) { obj.empty(); obj.append(''); $.getJSON(huayi.config.callcenter_url + "Department/GetCusAreaList", { "token": $.cookie("token"), F_Layer:2, pid:$("#customer_comaddress").val(), }, function (data) { if (data.state.toLowerCase() == "success") { var content = data.data; $(content).each(function (i, n) { $("").appendTo(obj); }) } }) } // 提交人 function getSubmitter(obj) { obj.empty(); obj.append(''); $.getJSON(huayi.config.callcenter_url + "UserAccount/GetList", { "token": $.cookie("token"), type: 1, dptid: $("#customer_comaddress").val(), }, function (data) { var content = data.rows; $(content).each(function (i, n) { $("").appendTo(obj); }) }) } // 获取提交人 $('#customer_comaddress').on('change',function(){ getSubmitter($('#customer_submitter')); }); //产品代码 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('