var channelDateType = 0, maintainDateType = 0, sevrDateType = 0, ssatiDateType = 0, repairsDateTye = 0, mainManType = 0, mainManPopDateType = 2; // 工单渠道占比 $(function() { //按钮点击事件 $('.btns').click(function() { $(this).addClass('active').siblings().removeClass('active'); }); // 工单渠道占比 $(".channel_btn").click(function() { var index = $(this).attr("index"); channelDateType = index; orderSource(index); }) // 维修及时率统计 $(".maintain_btn").click(function() { var index = $(this).attr("index"); maintainDateType = index; mainTimely(index); }) //维修工单数据 $(".sevr_btn").click(function() { var index = $(this).attr("index"); sevrDateType = index; servOrder(index); }) //综合满意度统计 $(".ssati_btn").click(function() { var index = $(this).attr("index"); ssatiDateType = index; satisfaction(index); }) //24小时报修统计 $(".repairs_btn").click(function() { var index = $(this).attr("index"); repairsDateTye = index; repairsNum(index); }) //维修工满意度统计弹框 // $(".mainManPop_btn").click(function() { // var index = $(this).attr("index"); // mainManPopDateType = index; // mainteManPop(index); // }) Ajax(); autoChange();//按钮调用 //维修工满意度统计 mainteMan() .then(function(){ var timer = null; //维修自动轮播 var satiNum = 12; var satiNumTo = -184 * finshLength; function autoCaro() { satiNum -= 1; if (satiNum == satiNumTo) { satiNum = 0; }; $(".contentBottom_content_right .posi").css({ left: satiNum }); } if(timer){ window.clearInterval(timer); } //设置滚动速度; timer = window.setInterval(autoCaro, 30); //设置鼠标经过时滚动停止 $(".contentBottom_content_right").hover(function() { window.clearInterval(timer); }, function() { timer = window.setInterval(autoCaro, 30); }) }); window.setInterval("mainteMan()", 30 * 60 * 1000);//维修工满意度统计 window.setInterval("autoChange()", huayi.config.timeBtnTime); //按钮调用 }); //图标轮播 var num = 0; var num1 = 0; var num2 = 0; var num3 = 0; //获取缓存数据 function Ajax() { accumOrder(); //累计数量 unFinish(); //未完成工单 } //切换项目 function projectTab() { orderSource(channelDateType);//维修工接单量 mainTimely(channelDateType);// 维修及时率统计 servOrder(channelDateType);//维修工单数据点击 satisfaction(ssatiDateType); //综合满意度 repairsNum(channelDateType); //24小时保修统计 accumOrder(); //累计数量 mainteMan(); //维修工满意度 unFinish();//未完成工单 } function autoChange() { $(".channel_btn:eq(" + num + ")").addClass('active').siblings().removeClass('active'); $(".maintain_btn:eq(" + num + ")").addClass('active').siblings().removeClass('active'); $(".repairs_btn:eq(" + num + ")").addClass('active').siblings().removeClass('active'); $(".sevr_btn:eq(" + num + ")").addClass('active').siblings().removeClass('active'); $(".ssati_btn:eq(" + num2 + ")").addClass('active').siblings().removeClass('active'); // 日月年 if (num == 0) { channelDateType = 0; } else if (num == 1) { channelDateType = 2; } else if (num == 2) { channelDateType = 3; }; num++; //显示的图片的----下一张 if (num >= 3) { num = 0; } //判断合理性!!! // 判断年月 if (num2 == 0) { ssatiDateType = 2; } else if (num2 == 1) { ssatiDateType = 3; } num2++; //显示的图片的----下一张 if (num2 >= 2) { num2 = 0; } //判断合理性!!! orderSource(channelDateType); //工单渠道 mainTimely(channelDateType); //维修及时率 servOrder(channelDateType); //维修工单数据 satisfaction(ssatiDateType); //综合满意度 repairsNum(channelDateType); //24小时保修统计 }; //window.setInterval("autoChange()",10000); //维修工接单量 function orderSource(datetype) { $.ajax({ type: "get", url: huayi.config.callcenter_url + 'equipmentapi/api/RunningChart/getuseracceptcount', async: true, dataType: 'json', data: { datetype: datetype, projectid: $("#projectID").text() }, success: function(result) { if (result.state.toLowerCase() == "success") { // 工单渠道 $('#orderSource').highcharts({ chart: { type: 'column', backgroundColor: 'transparent', marginRight: 25, marginTop: 25 }, title: false, credits: { enabled: false // 禁用版权信息 }, exporting: { enabled: false }, //隐藏导出图片 legend: { enabled: false }, xAxis: { categories: (function() { var xAxised = []; var dpartLength = result.data; var dapLe = dpartLength.length; // if (dpartLength.length<5) { // dapLe=dpartLength.length; // }else{ // dapLe=5; // } for (var i = 0; i < dapLe; i++) { xAxised.push(dpartLength[i].username) } return xAxised })(), crosshair: true, title: { text: "姓名", align: 'high', offset: 0, x: 25, y: 8, style: { color: '#266cf8' } }, lineColor: "#45599d", tickColor: 'transparent', labels: { style: { color: '#fff' } } }, yAxis: { min: 0, title: { text: '数量', align: 'high', offset: 0, rotation: 0, y: -10, x: -10, style: { color: '#266cf8' }, }, gridLineDashStyle: 'longdash', //图表内网格线样式 gridLineColor: '#242f5d', //图表内网格线颜色 labels: { style: { color: '#fff' }, step: 1 }, lineColor: '#45599d', lineWidth: 1 }, plotOptions: { column: { borderWidth: 0, pointWidth: 15 //柱子之间的距离值 } }, series: [{ name: '数量', data: (function() { var seriesData = []; var dpartLength = result.data var dapLe = dpartLength.length; // if (dpartLength.length<5) { // dapLe=dpartLength.length; // }else{ // dapLe=5; // } for (var i = 0; i < dapLe; i++) { seriesData.push(dpartLength[i].acceptcount) } // console.log(seriesData) return seriesData.map(s => +s) })(), color: "#7787ff", dataLabels: { enabled: true, format: '{y}', style: { color: '#fff' } } }] }); } } }); } // 维修及时率统计 function mainTimely(datetype) { $.ajax({ type: "get", url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getrepairtime", async: true, dataType: 'json', data: { datetype: datetype, projectid: $("#projectID").text() }, success: function(result) { if (result.state.toLowerCase() == "success") { var rate = result.data.timerate; $('#repairTimely').highcharts({ chart: { type: 'pie', backgroundColor: 'transparent' }, title: false, credits: { enabled: false // 禁用版权信息 }, exporting: { enabled: false }, //隐藏导出图片 legend: { enabled: true, symbolRadius: 2, symbolPadding: 10, symbolWidth: 20, y: 10, itemStyle: { color: '#fff', 'fontSize': '14px' }, itemHoverStyle: { color: '#fff' }, layout: 'horizontal', // default itemDistance: 10 }, plotOptions: { pie: { shadow: false, center: ['50%', '50%'], borderWidth: 0, showInLegend: true } }, tooltip: { headerFormat: '', pointFormat: '\u25CF {point.name}
' + '及时率: {point.y}%
' }, series: [{ innerSize: '0', zMin: 0, data: [{ name: '2小时', y: rate.twohourrate - 0, z: 220.5, color: "#1fc7cd" }, { name: '4小时', y: rate.fourhourrate - 0, z: 90.5, color: "#afa9ff" }, { name: '8小时', y: rate.eighthourrate - 0, z: 95.5, color: "#28d88b" }, { name: '24小时', y: rate.tfourhourrate - 0, z: 120.5, color: "#ffc65d" }, { name: '大于24小时', y: rate.tfouruphourrate - 0, z: 100.5, color: "#fe8081" }], dataLabels: { softConnector: false, // 是否使用曲线 connectorColor: '#3a62b8', // 连接线颜色,默认是扇区颜色 distance: 20, // 数据标签与扇区距离 connectorPadding: 20, // 数据标签与连接线的距离 formatter: function() { // 通过函数判断是否显示数据标签,为了防止数据标签过于密集 // return this.y > 1 ? '' + this.point.name + ': ' + this.y + '%' : null; return this.y > 1 ? this.y + '%' : null; }, style: { color: '#4f84ef', fontSize: '14px', textOutline: '0 0 contras', fontFamily: "DigifaceWide" } } }] }); } } }); } //维修工单数据点击 function servOrder(datetype) { $.ajax({ type: "get", url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getrepairstatecount", async: true, dataType: 'json', data: { datetype: datetype, projectid: $("#projectID").text() }, success: function(result) { if (result.state.toLowerCase() == "success") { var servdata = result.data $('#orderRepairCount').highcharts({ chart: { type: 'column', backgroundColor: 'transparent', marginRight: 25, marginTop: 25 }, title: false, credits: { enabled: false // 禁用版权信息 }, exporting: { enabled: false }, //隐藏导出图片 legend: { enabled: false }, xAxis: { categories: [ '报修', '已处理', '未处理', '已评价' ], crosshair: true, lineColor: "#45599d", tickColor: 'transparent', labels: { style: { color: '#fff', 'fontSize': '14px' } } }, yAxis: { min: 0, title: false, gridLineDashStyle: 'longdash', //图表内网格线样式 gridLineColor: '#242f5d', //图表内网格线颜色 labels: { style: { color: '#fff' }, step: 1 }, lineColor: '#45599d', lineWidth: 1 }, plotOptions: { column: { borderWidth: 0, pointWidth: 20 //柱子之间的距离值 } }, series: [{ name: '数量', data: [{ 'color': '#2374c0', 'y': servdata.bxnum - 0 }, { 'color': '#29b988', 'y': servdata.yclnum - 0 }, { // + servdata.cjnum 'color': '#747ad6', 'y': servdata.wclnum - 0 }, { 'color': '#e8d370', 'y': servdata.ypjnum - 0 }], dataLabels: { enabled: true, format: '{y}', style: { color: '#fff' } } }] }); } } }); } //综合满意度统计 function satisfaction(datetype) { $.ajax({ type: "get", url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getrepairscore", async: true, dataType: 'json', data: { datetype: datetype, projectid: $("#projectID").text() }, success: function(result) { if (result.state.toLowerCase() == "success") { var satisdata = result.data.scorerate; $('#Satisfaction').highcharts({ chart: { type: 'pie', backgroundColor: 'transparent' }, title: false, credits: { enabled: false // 禁用版权信息 }, exporting: { enabled: false }, //隐藏导出图片 legend: { enabled: true, symbolRadius: 2, symbolPadding: 0, symbolWidth: 30, y: 10, itemStyle: { color: '#fff', 'fontSize': '14px' }, itemHoverStyle: { color: '#fff' }, layout: 'horizontal', // default itemDistance: 10 }, plotOptions: { pie: { shadow: false, center: ['50%', '50%'], borderWidth: 0, showInLegend: true } }, // tooltip: { //// valueSuffix: '%' // }, series: [{ name: '应巡检', data: [{ name: "", y: result.data.complexrate * 1, color: "transparent" }], size: '38%', dataLabels: { formatter: function() { // return this.y > 5 ? this.point.name : null; return this.y > 5 ? this.point.y + '%' : null; }, style: { color: '#4f84ef', fontSize: '16px', textOutline: '0 0 contras', fontFamily: "DigifaceWide" }, distance: -48 // 距离值为负时显示在在扇区里面 } }, { name: '数量占比', data: [{ name: '差', y: satisdata.onestarrate - 0, color: "#f87373" }, { name: '不满意', y: satisdata.twostarrate - 0, color: "#f46b95" }, { name: '一般', y: satisdata.threestarrate - 0, color: "#ffffff" }, { name: '满意', y: satisdata.fourstarrate - 0, color: "#48f1c7" }, { name: '很满意', y: satisdata.fivestarrate - 0, color: "#4deb7e" }], size: '80%', innerSize: '60%', dataLabels: { softConnector: false, // 是否使用曲线 connectorColor: '#3a62b8', // 连接线颜色,默认是扇区颜色 distance: 20, // 数据标签与扇区距离 connectorPadding: 20, // 数据标签与连接线的距离 formatter: function() { // 通过函数判断是否显示数据标签,为了防止数据标签过于密集 // return this.y > 1 ? '' + this.point.name + ': ' + this.y + '%' : null; return this.y > 1 ? this.y + '%' : null; }, style: { color: '#4f84ef', fontSize: '14px', textOutline: '0 0 contras', fontFamily: "DigifaceWide" } } }] }); } } }); } //24小时报修统计 function repairsNum(datetype) { $.ajax({ type: "get", url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/get24hourrepaircount", async: true, dataType: 'json', data: { datetype: datetype, projectid: $("#projectID").text() }, success: function(result) { if (result.state.toLowerCase() == "success") { var repairsdata = result.data.bxcounts $('#hoursRepairStatistics').highcharts({ chart: { type: 'area', backgroundColor: 'transparent' }, title: false, credits: { enabled: false // 禁用版权信息 }, exporting: { enabled: false }, //隐藏导出图片 legend: { enabled: false }, xAxis: { categories: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 ], lineColor: "#45599d", tickColor: 'transparent', labels: { style: { color: '#fff' } } }, yAxis: { title: false, gridLineDashStyle: 'longdash', //图表内网格线样式 gridLineColor: '#242f5d', //图表内网格线颜色 labels: { style: { color: '#fff' }, step: 1 } }, // tooltip: { // pointFormat: '{series.name} 制造 {point.y:,.0f}枚弹头' // }, plotOptions: { area: { fillOpacity: 0, // 指定所有面积图的透明度 //pointStart: 1940, marker: { enabled: false, symbol: 'circle', radius: 2, states: { hover: { enabled: true } } } } }, series: [{ name: '报修数量', // data: (function() { // var repairsdata= result.data.bxcounts // var arrs = []; // for(var k = 0; k < repairsdata.length; k++) { // var objs = {}; // objs= repairsdata[k]; // arrs.push(objs); // } // return arrs; // })(), data: [ repairsdata[0], repairsdata[1], repairsdata[2], repairsdata[3], repairsdata[4], repairsdata[5], repairsdata[6], repairsdata[7], repairsdata[8], repairsdata[9], repairsdata[10], repairsdata[11], repairsdata[12], repairsdata[13], repairsdata[14], repairsdata[15], repairsdata[16], repairsdata[17], repairsdata[18], repairsdata[19], repairsdata[20], repairsdata[21], repairsdata[22], repairsdata[23], ], color: '#306cdd' }] }); } } }); } //累计数量 function accumOrder() { $.ajax({ type: "get", url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getrepairstatecount", async: true, dataType: 'json', data: { datetype: 4, projectid: $("#projectID").text() }, success: function(result) { if (result.state.toLowerCase() == "success") { var servdata = result.data $(".Pink").text(servdata.bxnum); //报修 $(".purple").text(servdata.yclnum); //已处理 // + servdata.cjnum $(".Ashen").text(servdata.wclnum); //未处理 $(".green").text(servdata.ypjnum); //已评价 } } }); } //维修工满意度统计 function mainteMan() { var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象 $.ajax({ type: "get", url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getuserrepaireval", async: true, dataType: 'json', data: { datetype: 2, projectid: $("#projectID").text() }, success: function(result) { if (result.state.toLowerCase() == "success") { $('.OA_main').empty(); var mainmanData = result.data; var mainLength = mainmanData.length; var mainLgthWd = mainLength * 183 * 2; finshLength = mainLength; $(".contentBottom_content_right .posi").css("width", mainLgthWd); for (var i = 0; i < mainmanData.length; i++) { var srcImg = mainmanData[i].head_img if (srcImg == "") { srcImg = "images/img.png" } else { srcImg = mainmanData[i].head_img } var UUserCard = mainmanData[i].idcardno; var myDate = new Date(); // var age=myDate.getFullYear() - UUserCard.substring(6, 10); // alert(age); if (UUserCard == null) { age = 0; } else { age = myDate.getFullYear() - UUserCard.substring(6, 10); } // alert(age); var ranking = i - 0 + 1; $('
  • ' + ranking + '

    工号:' + mainmanData[i].usercode + '

    ' + mainmanData[i].username + '    ' + age + '岁

    工种:' + mainmanData[i].remark + '

    满意度:' + mainmanData[i].myrate + '

  • ' ).appendTo('.OA_main'); }; dtd.resolve(); // 改变Deferred对象的执行状态 } }, }); return dtd.promise(); // 返回promise对象 } //未完成工单 function unFinish() { $.ajax({ type: "get", url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getnodeallist", async: true, dataType: 'json', data: { datetype: 0, projectid: $("#projectID").text() }, success: function(result) { if (result.state.toLowerCase() == "success") { $('.unfinish').empty(); var unfinishData = result.data; var listLg = unfinishData.length; var aListlg = listLg * 38; // 格式化时间 //var $("p").css("background-color","yellow"); if (unfinishData.length > 0) { var lenghData if (unfinishData.length < 11) { lenghData = unfinishData.length; } else { lenghData = 11 } for (var i = 0; i < lenghData; i++) { var repairsState,repairsTime,receivTime,dealTime //报修时间 if (unfinishData[i].repairtime) { repairsTime = unfinishData[i].repairtime; var repairMonth = repairsTime.split('-')[1]; //月 var repairdayTime = repairsTime.split('-')[2].split(' ')[0]; //日 var repairhour = repairsTime.split('-')[2].split(' ')[1].split(':')[0]; //时 var repairminute = repairsTime.split('-')[2].split(' ')[1].split(':')[1]; //时 var repairDataTime= repairMonth + "-" + repairdayTime + " " + repairhour + ":" + repairminute; }else{ var repairDataTime="-"; } //接单时间 if (unfinishData[i].totime) { receivTime = unfinishData[i].totime var totimeMonth = repairsTime.split('-')[1]; //月 var totimedayTime = repairsTime.split('-')[2].split(' ')[0]; //日 var totimehour = repairsTime.split('-')[2].split(' ')[1].split(':')[0]; //时 var totimeminute = repairsTime.split('-')[2].split(' ')[1].split(':')[1]; //时 var totimeDataTime= totimeMonth + "-" + totimedayTime + " " + totimehour + ":" + totimeminute; }else{ var totimeDataTime="-"; } // 处理时间 if (unfinishData[i].dealtime) { dealTime = unfinishData[i].dealtime var dealtimeMonth = dealTime.split('-')[1]; //月 var dealtimedayTime = dealTime.split('-')[2].split(' ')[0]; //日 var dealtimehour = dealTime.split('-')[2].split(' ')[1].split(':')[0]; //时 var dealtimeminute = dealTime.split('-')[2].split(' ')[1].split(':')[1]; //时 var dealtimeDataTime= dealtimeMonth + "-" + dealtimedayTime + " " + dealtimehour + ":" + dealtimeminute; }else{ var dealtimeDataTime="-"; } if (unfinishData[i].wostate == 0) { repairsState = "待接单"; //判断是否是新的工单 播放语音 if (isNewOrderHandler(unfinishData[i])) { playSaveHandler(unfinishData[i]); } } else if (unfinishData[i].wostate == 1) { repairsState = "待处理"; deleteCacheData(unfinishData[i]); } else if (unfinishData[i].wostate == 7) { repairsState = "挂起"; deleteCacheData(unfinishData[i]); } else if (unfinishData[i].wostate == 2) { repairsState = "已处理"; deleteCacheData(unfinishData[i]); } else if (unfinishData[i].wostate == 3) { repairsState = "已完结"; deleteCacheData(unfinishData[i]); } var touName if (unfinishData[i].tousername == "") { touName = "无" } else { touName = unfinishData[i].tousername } $('
  • ' + repairDataTime + '
    ' + unfinishData[i].repairman + '
    ' + unfinishData[i].faultdescripe + '
    ' + touName + ' ' + '
    ' + repairsState + '
    ' + totimeDataTime + '
    ' + dealtimeDataTime + '
  • ' ).appendTo('.unfinish'); } } } } }); } /** * 判断是否是新的工单 播放语音 * @cuData 当前信息 * @return boolean false(缓存中有这个工单,不是新工单) true(缓存中没有这工单,是新工单) */ function isNewOrderHandler(cuData) { var oldLocalDatas = window.localStorage.getItem('newOrderData'); var isTrue = []; if (oldLocalDatas) { oldLocalDatas = JSON.parse(oldLocalDatas); for (var j = 0, len = oldLocalDatas.length; j < len; j++) { if (oldLocalDatas[j].wocode === cuData.wocode && oldLocalDatas[j].time === cuData.repairtime) { isTrue.push(false); // 缓存中有这个工单 } } } else { isTrue.push(true); // 缓存中没有这工单 } return isTrue.indexOf(false) === -1 ? true : false; } /** * 播放语音 存储数据 * @cuData 当前信息 */ function playSaveHandler(cuData) { //播放语音 var promise = $('#btn_audio')[0].play(); if (promise !== undefined) { promise.then(function() { $('#btn_audio')[0].play(); }).catch(function(error) { var context = new(window.AudioContext || window.webkitAudioContext)(); playAudio(context, 'audio/orderTips.wav'); }); } //缓存当前信息 var oldLocalDatas = window.localStorage.getItem('newOrderData'); var newOrderData = oldLocalDatas === null ? [] : JSON.parse(oldLocalDatas); newOrderData.unshift({ "time": cuData.repairtime, "wocode": cuData.wocode }); window.localStorage.setItem('newOrderData', JSON.stringify(newOrderData)); } //requestAudio play playAudio处理 Chrome 69 70 不能自动播放的问题; function requestAudio(url) { var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象 var xhr = new XMLHttpRequest(); xhr.open('GET', url); // 这里需要设置xhr response的格式为arraybuffer // 否则默认是二进制的文本格式 xhr.responseType = 'arraybuffer'; xhr.onreadystatechange = function() { // 请求完成,并且成功 if (xhr.readyState === 4 && xhr.status === 200) { dtd.resolve(xhr.response); // 改变Deferred对象的执行状态 } }; xhr.send(); return dtd.promise(); // 返回promise对象 } function play(context, decodeBuffer) { // 调用resume恢复播放 context.resume(); var source = context.createBufferSource(); source.buffer = decodeBuffer; source.connect(context.destination); source.start(0); return false; } function playAudio(context, url) { requestAudio(url).then(function(audioMedia) { context.decodeAudioData(audioMedia, function(decode) { play(context, decode); }); }); } /** * 清除缓存数据 * @cuData 当前信息 */ function deleteCacheData(cuData) { var oldLocalDatas = window.localStorage.getItem('newOrderData'); oldLocalDatas = oldLocalDatas === null ? [] : JSON.parse(oldLocalDatas); if (oldLocalDatas.length > 0) { for (var i = 0; i < oldLocalDatas.length; i++) { if (oldLocalDatas[i].wocode === cuData.wocode && oldLocalDatas[i].time === cuData.repairtime) { oldLocalDatas.splice(i, 1); window.localStorage.setItem('newOrderData', JSON.stringify(oldLocalDatas)); } } } }