| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003 |
- 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: '<span style="color:{point.color}">\u25CF</span> <b> {point.name}</b><br/>' +
- '及时率: <b>{point.y}%</b><br/>'
- },
- 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 ? '<b>' + this.point.name + ':</b> ' + 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 ? '<b>' + this.point.name + ':</b> ' + 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} 制造 <b>{point.y:,.0f}</b>枚弹头'
- // },
- 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;
- $('<li><div class="ranking">' + ranking +
- '</div><img src="' + srcImg +
- '" alt="" /><p><span>工号:</span><span>' + mainmanData[i].usercode +
- '</span></p><p><span>' + mainmanData[i].username +
- '    </span><span>' + age +
- '岁</span></p><p><span>工种:</span><span>' + mainmanData[i].remark +
- '</span></p><p><span>满意度:</span><span>' + mainmanData[i].myrate +
- '</span></p></li>'
- ).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
- }
- $('<li><a title="' + unfinishData[i].faultdescripe +
- '"><dl style="width: 15%; text-align: center; margin-left: 0;">' + repairDataTime +
- '</dl><dl style="width: 10%;">' + unfinishData[i].repairman +
- '</dl><dl style="width: 15%;">' + unfinishData[i].faultdescripe +
- '</dl><dl style="width: 10%;">' + touName + ' ' +
- '</dl><dl style="width: 10%;">' + repairsState +
- '</dl><dl style="width: 14%; text-align: center;">' + totimeDataTime +
- '</dl><dl style="width: 14%; text-align: center;">' + dealtimeDataTime +
- '</dl></a></li>'
- ).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));
- }
- }
- }
- }
|