var typeSmall; var id = helper.request.queryString("id"); $(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(); $(".ns-2").remove(); } } } }); var groupcode = $('#groupcode', top.document).val(); if (groupcode == 'SCZ') { $("#usedate").text("饮用日期:"); $("#vipid").text("对接人:"); $("#vipphone").text("对接人电话:"); } // laydate.render({ // elem: '.userDate', // theme: '#1ab394', // calendar: 'true' // }); // laydate.render({ // elem: '.buyDate', // theme: '#1ab394', // calendar: 'true' // }); // laydate.render({ // elem: '#productDate', // theme: '#1ab394', // calendar: 'true' // }); $.ajaxSettings.async = false; // 产品代码 getProductType(); // 问题代码 getProblemCode(); // 重要级别 getDealTimely(); //产品厂家 getProductFactory(); // 省 办事处 LAISHENG($("#source"));//省 CHOUDQ($("#customer_comaddress")); //办事处 //普通工单禁止选择原因 $('#reason').attr("disabled", "disabled"); //客诉专员 ComplaintVip(); //保存 $('.customerSubmit').click(function() { saveCustomer(); }); $.ajaxSettings.async = true; var id = helper.request.queryString("id"); $.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]; $("#workOrderId").val(data.F_WorkOrderId); //工单编号 // $("#order_isover").val(data.F_Type); // 工单类别 $("#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); // 质量问题 $("#duplicate").val(data.F_Duplicate); // 重复工单 $("#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'); //重复工单 $("#duplicate input[type=radio][name=duplicate][value="+data.duplicate+"]").attr("checked",'checked'); // 工单来源 workOrderSourceDisplay(data); // 省市县 provinceCity(data) } } }); //获取专员手机号 $("#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 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 option:selected").text(provinceCityArr[2]); $("#keyid option:selected").val(provinceCityArr[2]); } //省 市 区/县 //省 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(obj) { obj.empty(); obj.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) { $("").appendTo(obj); }) } }) } $('#source').on('change',function(){ LAISHI($("#type")); }); $('#type').on('change',function(){ LAIQU($("#keyid")); }); //办事处 提交人 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() { $("#productFactory").empty(); $("#productFactory").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) { $("").appendTo("#productFactory"); }) } }) } // 重要级别显示原因 $('#dealTimely').on('change',function(){ if ($('#dealTimely').val() === 'Ⅰ级'){ $('#reason').val(''); $('#reason').removeAttr("disabled"); getReasonOne(); } else if ($('#dealTimely').val() === 'Ⅱ级' ){ $('#reason').val(''); $('#reason').removeAttr("disabled"); getReasonTwo(); } else { $('#reason').val(''); $('#reason').attr("disabled", "disabled"); } }) // 指派事件 $('#isAssign').on('change', function(){ if($('#isAssign input[name="isAssign"]:checked').val() === '1'){ $('.comaddressTitle').show(); $('.comaddressSelect').show(); $('.submitterTitle').show(); $('.submitterSelect').show(); } else if ($('#isAssign input[name="isAssign"]:checked').val() === '2'){ $('.comaddressTitle').hide(); $('.comaddressSelect').hide(); $('.submitterTitle').hide(); $('.submitterSelect').hide(); } }) // 地址(省+市+区/县) function detailedAddress() { if($('#source').val() === ""){ var province = ''; } else { var province = $('#source').find("option:selected").text() } if($('#type').val() === ""){ var city = ''; } else { var city = $('#type').find("option:selected").text() } if($('#keyid').val() === ""){ var county = ''; } else { var county = $('#keyid').find("option:selected").text() } var address = province + '-' + city + '-' + county; return address; } //处理状态 dealState(); function dealState() { $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', { "token": $.cookie("token"), flag: "CLZT" }, function(result) { result = $.parseJSON(result); var Count = result.data; $(Count).each(function(i, n) { $('').appendTo($(".disposeST")); }) $('.disposeST input:radio:first').attr('checked', 'checked'); }); } //响应状态 responseState(); function responseState() { $.get(huayi.config.callcenter_url + 'Dictionary/GetDicValueListByFlag', { "token": $.cookie("token"), flag: "XYZT" }, function(result) { result = $.parseJSON(result); var Count = result.data; $(Count).each(function(i, n) { $('').appendTo($(".responseST")); }) $('.responseST input:radio:first').attr('checked', 'checked'); }); } var setting = { data: { key: { name: "F_AreaName" }, simpleData: { enable: true, idKey: "F_Id", pIdKey: "F_ParentId", rootPId: 0 } }, callback: { onClick: changeTreeClick } } function changeTreeClick(event, treeId, treeNode) { var areaParent = treeNode.getPath(); if (areaParent[1]) { areaParent1 = areaParent[0].F_AreaName areaParent2 = areaParent[1].F_AreaName $('#typeclass').val(areaParent1 + "/" + areaParent2); $('.inps2').val(areaParent1); $('.inps3').val(areaParent2); ComplaintVip(); } else { layer.msg("请选择最下级菜单"); } $('.addTree1').hide(); }; //客诉专员 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() { var val = $("input[name='ltype']:checked").val(); var valRes = $("input[name='response']:checked").val(); var dealCost; if (isNaN($("#dealCost").val())) { dealCost=""; }else{ dealCost=$("#dealCost").val(); } 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; } $.ajax({ type: "post", url: huayi.config.callcenter_url + "WorkOrder/UpdateWorkOrder", dataType: 'json', async: true, beforeSend: function() { //触发ajax请求开始时执行 $('.customerSubmit').attr("disabled", true); $('.customerSubmit').text('保存中...'); }, data: { token: $.cookie("token"), F_Id: id, F_Type: $('#order_isover input[name="type"]:checked').val(), //工单类型 F_DealTimely: $('#dealTimely').val(), //重要级别 F_Reason: $('#reason').val(), //原因 F_CusName: $('#name').val(), //姓名 F_CusPhone: $('#tel').val(), //号码 F_AddRess: detailedAddress(),//地址 F_ProductType: $('#productType').val(), //产品代码 F_ProductName: $('#productName').val(), //产品名称 F_Specifications: $('#specification').val(), //规格 F_ProductDate: $('#productDate').val(), //生产日期 F_BatchNumber: $('#productNumber').val(), //产品编码 F_Manufacturer: $('#productFactory').val(), //产品厂家 F_ProblemCode: $('#problemCode').val(), //问题代码 F_QualityProblem: $('#qualityProblem').val(), //质量问题 F_Content: $('#remark').val(), //备注 F_Duplicate: $('#duplicate input[name="duplicate"]:checked').val(), //重复工单 }, success: function(data) { if (data.state.toLowerCase() == 'success') { $('.customerSubmit').attr("disabled", false); $('.customerSubmit').text('保存'); var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引 parent.layer.close(index); //再执行关闭 parent.layer.msg("保存成功!"); parent.$('#workorderlist').bootstrapTable('refresh'); parent.$('#orderlist').bootstrapTable('refresh'); } else { $('.customerSubmit').attr("disabled", false); $('.customerSubmit').text('保存'); } } }); }