郑州第一人民医院UI

RepairStatistic.js 26KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. var channelDateType = 0,
  2. maintainDateType = 0,
  3. sevrDateType = 0,
  4. ssatiDateType = 0,
  5. repairsDateTye = 0,
  6. mainManType = 0,
  7. mainManPopDateType = 2;
  8. // 工单渠道占比
  9. $(function() {
  10. //按钮点击事件
  11. $('.btns').click(function() {
  12. $(this).addClass('active').siblings().removeClass('active');
  13. });
  14. // 工单渠道占比
  15. $(".channel_btn").click(function() {
  16. var index = $(this).attr("index");
  17. channelDateType = index;
  18. orderSource(index);
  19. })
  20. // 维修及时率统计
  21. $(".maintain_btn").click(function() {
  22. var index = $(this).attr("index");
  23. maintainDateType = index;
  24. mainTimely(index);
  25. })
  26. //维修工单数据
  27. $(".sevr_btn").click(function() {
  28. var index = $(this).attr("index");
  29. sevrDateType = index;
  30. servOrder(index);
  31. })
  32. //综合满意度统计
  33. $(".ssati_btn").click(function() {
  34. var index = $(this).attr("index");
  35. ssatiDateType = index;
  36. satisfaction(index);
  37. })
  38. //24小时报修统计
  39. $(".repairs_btn").click(function() {
  40. var index = $(this).attr("index");
  41. repairsDateTye = index;
  42. repairsNum(index);
  43. })
  44. //维修工满意度统计弹框
  45. // $(".mainManPop_btn").click(function() {
  46. // var index = $(this).attr("index");
  47. // mainManPopDateType = index;
  48. // mainteManPop(index);
  49. // })
  50. Ajax();
  51. autoChange();//按钮调用
  52. //维修工满意度统计
  53. mainteMan()
  54. .then(function(){
  55. var timer = null;
  56. //维修自动轮播
  57. var satiNum = 12;
  58. var satiNumTo = -184 * finshLength;
  59. function autoCaro() {
  60. satiNum -= 1;
  61. if (satiNum == satiNumTo) {
  62. satiNum = 0;
  63. };
  64. $(".contentBottom_content_right .posi").css({
  65. left: satiNum
  66. });
  67. }
  68. if(timer){
  69. window.clearInterval(timer);
  70. }
  71. //设置滚动速度;
  72. timer = window.setInterval(autoCaro, 30);
  73. //设置鼠标经过时滚动停止
  74. $(".contentBottom_content_right").hover(function() {
  75. window.clearInterval(timer);
  76. },
  77. function() {
  78. timer = window.setInterval(autoCaro, 30);
  79. })
  80. });
  81. window.setInterval("mainteMan()", 30 * 60 * 1000);//维修工满意度统计
  82. window.setInterval("autoChange()", huayi.config.timeBtnTime); //按钮调用
  83. });
  84. //图标轮播
  85. var num = 0;
  86. var num1 = 0;
  87. var num2 = 0;
  88. var num3 = 0;
  89. //获取缓存数据
  90. function Ajax() {
  91. accumOrder(); //累计数量
  92. unFinish(); //未完成工单
  93. }
  94. //切换项目
  95. function projectTab() {
  96. orderSource(channelDateType);//维修工接单量
  97. mainTimely(channelDateType);// 维修及时率统计
  98. servOrder(channelDateType);//维修工单数据点击
  99. satisfaction(ssatiDateType); //综合满意度
  100. repairsNum(channelDateType); //24小时保修统计
  101. accumOrder(); //累计数量
  102. mainteMan(); //维修工满意度
  103. unFinish();//未完成工单
  104. }
  105. function autoChange() {
  106. $(".channel_btn:eq(" + num + ")").addClass('active').siblings().removeClass('active');
  107. $(".maintain_btn:eq(" + num + ")").addClass('active').siblings().removeClass('active');
  108. $(".repairs_btn:eq(" + num + ")").addClass('active').siblings().removeClass('active');
  109. $(".sevr_btn:eq(" + num + ")").addClass('active').siblings().removeClass('active');
  110. $(".ssati_btn:eq(" + num2 + ")").addClass('active').siblings().removeClass('active');
  111. // 日月年
  112. if (num == 0) {
  113. channelDateType = 0;
  114. } else if (num == 1) {
  115. channelDateType = 2;
  116. } else if (num == 2) {
  117. channelDateType = 3;
  118. };
  119. num++; //显示的图片的----下一张
  120. if (num >= 3) {
  121. num = 0;
  122. } //判断合理性!!!
  123. // 判断年月
  124. if (num2 == 0) {
  125. ssatiDateType = 2;
  126. } else if (num2 == 1) {
  127. ssatiDateType = 3;
  128. }
  129. num2++; //显示的图片的----下一张
  130. if (num2 >= 2) {
  131. num2 = 0;
  132. } //判断合理性!!!
  133. orderSource(channelDateType); //工单渠道
  134. mainTimely(channelDateType); //维修及时率
  135. servOrder(channelDateType); //维修工单数据
  136. satisfaction(ssatiDateType); //综合满意度
  137. repairsNum(channelDateType); //24小时保修统计
  138. };
  139. //window.setInterval("autoChange()",10000);
  140. //维修工接单量
  141. function orderSource(datetype) {
  142. $.ajax({
  143. type: "get",
  144. url: huayi.config.callcenter_url + 'equipmentapi/api/RunningChart/getuseracceptcount',
  145. async: true,
  146. dataType: 'json',
  147. data: {
  148. datetype: datetype,
  149. projectid: $("#projectID").text()
  150. },
  151. success: function(result) {
  152. if (result.state.toLowerCase() == "success") {
  153. // 工单渠道
  154. $('#orderSource').highcharts({
  155. chart: {
  156. type: 'column',
  157. backgroundColor: 'transparent',
  158. marginRight: 25,
  159. marginTop: 25
  160. },
  161. title: false,
  162. credits: {
  163. enabled: false // 禁用版权信息
  164. },
  165. exporting: {
  166. enabled: false
  167. }, //隐藏导出图片
  168. legend: {
  169. enabled: false
  170. },
  171. xAxis: {
  172. categories: (function() {
  173. var xAxised = [];
  174. var dpartLength = result.data;
  175. var dapLe = dpartLength.length;
  176. // if (dpartLength.length<5) {
  177. // dapLe=dpartLength.length;
  178. // }else{
  179. // dapLe=5;
  180. // }
  181. for (var i = 0; i < dapLe; i++) {
  182. xAxised.push(dpartLength[i].username)
  183. }
  184. return xAxised
  185. })(),
  186. crosshair: true,
  187. title: {
  188. text: "姓名",
  189. align: 'high',
  190. offset: 0,
  191. x: 25,
  192. y: 8,
  193. style: {
  194. color: '#266cf8'
  195. }
  196. },
  197. lineColor: "#45599d",
  198. tickColor: 'transparent',
  199. labels: {
  200. style: {
  201. color: '#fff'
  202. }
  203. }
  204. },
  205. yAxis: {
  206. min: 0,
  207. title: {
  208. text: '数量',
  209. align: 'high',
  210. offset: 0,
  211. rotation: 0,
  212. y: -10,
  213. x: -10,
  214. style: {
  215. color: '#266cf8'
  216. },
  217. },
  218. gridLineDashStyle: 'longdash', //图表内网格线样式
  219. gridLineColor: '#242f5d', //图表内网格线颜色
  220. labels: {
  221. style: {
  222. color: '#fff'
  223. },
  224. step: 1
  225. },
  226. lineColor: '#45599d',
  227. lineWidth: 1
  228. },
  229. plotOptions: {
  230. column: {
  231. borderWidth: 0,
  232. pointWidth: 15 //柱子之间的距离值
  233. }
  234. },
  235. series: [{
  236. name: '数量',
  237. data: (function() {
  238. var seriesData = [];
  239. var dpartLength = result.data
  240. var dapLe = dpartLength.length;
  241. // if (dpartLength.length<5) {
  242. // dapLe=dpartLength.length;
  243. // }else{
  244. // dapLe=5;
  245. // }
  246. for (var i = 0; i < dapLe; i++) {
  247. seriesData.push(dpartLength[i].acceptcount)
  248. }
  249. // console.log(seriesData)
  250. return seriesData.map(s => +s)
  251. })(),
  252. color: "#7787ff",
  253. dataLabels: {
  254. enabled: true,
  255. format: '{y}',
  256. style: {
  257. color: '#fff'
  258. }
  259. }
  260. }]
  261. });
  262. }
  263. }
  264. });
  265. }
  266. // 维修及时率统计
  267. function mainTimely(datetype) {
  268. $.ajax({
  269. type: "get",
  270. url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getrepairtime",
  271. async: true,
  272. dataType: 'json',
  273. data: {
  274. datetype: datetype,
  275. projectid: $("#projectID").text()
  276. },
  277. success: function(result) {
  278. if (result.state.toLowerCase() == "success") {
  279. var rate = result.data.timerate;
  280. $('#repairTimely').highcharts({
  281. chart: {
  282. type: 'pie',
  283. backgroundColor: 'transparent'
  284. },
  285. title: false,
  286. credits: {
  287. enabled: false // 禁用版权信息
  288. },
  289. exporting: {
  290. enabled: false
  291. }, //隐藏导出图片
  292. legend: {
  293. enabled: true,
  294. symbolRadius: 2,
  295. symbolPadding: 10,
  296. symbolWidth: 20,
  297. y: 10,
  298. itemStyle: {
  299. color: '#fff',
  300. 'fontSize': '14px'
  301. },
  302. itemHoverStyle: {
  303. color: '#fff'
  304. },
  305. layout: 'horizontal', // default
  306. itemDistance: 10
  307. },
  308. plotOptions: {
  309. pie: {
  310. shadow: false,
  311. center: ['50%', '50%'],
  312. borderWidth: 0,
  313. showInLegend: true
  314. }
  315. },
  316. tooltip: {
  317. headerFormat: '',
  318. pointFormat: '<span style="color:{point.color}">\u25CF</span> <b> {point.name}</b><br/>' +
  319. '及时率: <b>{point.y}%</b><br/>'
  320. },
  321. series: [{
  322. innerSize: '0',
  323. zMin: 0,
  324. data: [{
  325. name: '2小时',
  326. y: rate.twohourrate - 0,
  327. z: 220.5,
  328. color: "#1fc7cd"
  329. }, {
  330. name: '4小时',
  331. y: rate.fourhourrate - 0,
  332. z: 90.5,
  333. color: "#afa9ff"
  334. }, {
  335. name: '8小时',
  336. y: rate.eighthourrate - 0,
  337. z: 95.5,
  338. color: "#28d88b"
  339. }, {
  340. name: '24小时',
  341. y: rate.tfourhourrate - 0,
  342. z: 120.5,
  343. color: "#ffc65d"
  344. }, {
  345. name: '大于24小时',
  346. y: rate.tfouruphourrate - 0,
  347. z: 100.5,
  348. color: "#fe8081"
  349. }],
  350. dataLabels: {
  351. softConnector: false, // 是否使用曲线
  352. connectorColor: '#3a62b8', // 连接线颜色,默认是扇区颜色
  353. distance: 20, // 数据标签与扇区距离
  354. connectorPadding: 20, // 数据标签与连接线的距离
  355. formatter: function() {
  356. // 通过函数判断是否显示数据标签,为了防止数据标签过于密集
  357. // return this.y > 1 ? '<b>' + this.point.name + ':</b> ' + this.y + '%' : null;
  358. return this.y > 1 ? this.y + '%' : null;
  359. },
  360. style: {
  361. color: '#4f84ef',
  362. fontSize: '14px',
  363. textOutline: '0 0 contras',
  364. fontFamily: "DigifaceWide"
  365. }
  366. }
  367. }]
  368. });
  369. }
  370. }
  371. });
  372. }
  373. //维修工单数据点击
  374. function servOrder(datetype) {
  375. $.ajax({
  376. type: "get",
  377. url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getrepairstatecount",
  378. async: true,
  379. dataType: 'json',
  380. data: {
  381. datetype: datetype,
  382. projectid: $("#projectID").text()
  383. },
  384. success: function(result) {
  385. if (result.state.toLowerCase() == "success") {
  386. var servdata = result.data
  387. $('#orderRepairCount').highcharts({
  388. chart: {
  389. type: 'column',
  390. backgroundColor: 'transparent',
  391. marginRight: 25,
  392. marginTop: 25
  393. },
  394. title: false,
  395. credits: {
  396. enabled: false // 禁用版权信息
  397. },
  398. exporting: {
  399. enabled: false
  400. }, //隐藏导出图片
  401. legend: {
  402. enabled: false
  403. },
  404. xAxis: {
  405. categories: [
  406. '报修', '已处理', '未处理', '已评价'
  407. ],
  408. crosshair: true,
  409. lineColor: "#45599d",
  410. tickColor: 'transparent',
  411. labels: {
  412. style: {
  413. color: '#fff',
  414. 'fontSize': '14px'
  415. }
  416. }
  417. },
  418. yAxis: {
  419. min: 0,
  420. title: false,
  421. gridLineDashStyle: 'longdash', //图表内网格线样式
  422. gridLineColor: '#242f5d', //图表内网格线颜色
  423. labels: {
  424. style: {
  425. color: '#fff'
  426. },
  427. step: 1
  428. },
  429. lineColor: '#45599d',
  430. lineWidth: 1
  431. },
  432. plotOptions: {
  433. column: {
  434. borderWidth: 0,
  435. pointWidth: 20 //柱子之间的距离值
  436. }
  437. },
  438. series: [{
  439. name: '数量',
  440. data: [{
  441. 'color': '#2374c0',
  442. 'y': servdata.bxnum - 0
  443. }, {
  444. 'color': '#29b988',
  445. 'y': servdata.yclnum - 0
  446. }, {
  447. // + servdata.cjnum
  448. 'color': '#747ad6',
  449. 'y': servdata.wclnum - 0
  450. }, {
  451. 'color': '#e8d370',
  452. 'y': servdata.ypjnum - 0
  453. }],
  454. dataLabels: {
  455. enabled: true,
  456. format: '{y}',
  457. style: {
  458. color: '#fff'
  459. }
  460. }
  461. }]
  462. });
  463. }
  464. }
  465. });
  466. }
  467. //综合满意度统计
  468. function satisfaction(datetype) {
  469. $.ajax({
  470. type: "get",
  471. url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getrepairscore",
  472. async: true,
  473. dataType: 'json',
  474. data: {
  475. datetype: datetype,
  476. projectid: $("#projectID").text()
  477. },
  478. success: function(result) {
  479. if (result.state.toLowerCase() == "success") {
  480. var satisdata = result.data.scorerate;
  481. $('#Satisfaction').highcharts({
  482. chart: {
  483. type: 'pie',
  484. backgroundColor: 'transparent'
  485. },
  486. title: false,
  487. credits: {
  488. enabled: false // 禁用版权信息
  489. },
  490. exporting: {
  491. enabled: false
  492. }, //隐藏导出图片
  493. legend: {
  494. enabled: true,
  495. symbolRadius: 2,
  496. symbolPadding: 0,
  497. symbolWidth: 30,
  498. y: 10,
  499. itemStyle: {
  500. color: '#fff',
  501. 'fontSize': '14px'
  502. },
  503. itemHoverStyle: {
  504. color: '#fff'
  505. },
  506. layout: 'horizontal', // default
  507. itemDistance: 10
  508. },
  509. plotOptions: {
  510. pie: {
  511. shadow: false,
  512. center: ['50%', '50%'],
  513. borderWidth: 0,
  514. showInLegend: true
  515. }
  516. },
  517. // tooltip: {
  518. //// valueSuffix: '%'
  519. // },
  520. series: [{
  521. name: '应巡检',
  522. data: [{
  523. name: "",
  524. y: result.data.complexrate * 1,
  525. color: "transparent"
  526. }],
  527. size: '38%',
  528. dataLabels: {
  529. formatter: function() {
  530. // return this.y > 5 ? this.point.name : null;
  531. return this.y > 5 ? this.point.y + '%' : null;
  532. },
  533. style: {
  534. color: '#4f84ef',
  535. fontSize: '16px',
  536. textOutline: '0 0 contras',
  537. fontFamily: "DigifaceWide"
  538. },
  539. distance: -48 // 距离值为负时显示在在扇区里面
  540. }
  541. }, {
  542. name: '数量占比',
  543. data: [{
  544. name: '差',
  545. y: satisdata.onestarrate - 0,
  546. color: "#f87373"
  547. }, {
  548. name: '不满意',
  549. y: satisdata.twostarrate - 0,
  550. color: "#f46b95"
  551. }, {
  552. name: '一般',
  553. y: satisdata.threestarrate - 0,
  554. color: "#ffffff"
  555. }, {
  556. name: '满意',
  557. y: satisdata.fourstarrate - 0,
  558. color: "#48f1c7"
  559. }, {
  560. name: '很满意',
  561. y: satisdata.fivestarrate - 0,
  562. color: "#4deb7e"
  563. }],
  564. size: '80%',
  565. innerSize: '60%',
  566. dataLabels: {
  567. softConnector: false, // 是否使用曲线
  568. connectorColor: '#3a62b8', // 连接线颜色,默认是扇区颜色
  569. distance: 20, // 数据标签与扇区距离
  570. connectorPadding: 20, // 数据标签与连接线的距离
  571. formatter: function() {
  572. // 通过函数判断是否显示数据标签,为了防止数据标签过于密集
  573. // return this.y > 1 ? '<b>' + this.point.name + ':</b> ' + this.y + '%' : null;
  574. return this.y > 1 ? this.y + '%' : null;
  575. },
  576. style: {
  577. color: '#4f84ef',
  578. fontSize: '14px',
  579. textOutline: '0 0 contras',
  580. fontFamily: "DigifaceWide"
  581. }
  582. }
  583. }]
  584. });
  585. }
  586. }
  587. });
  588. }
  589. //24小时报修统计
  590. function repairsNum(datetype) {
  591. $.ajax({
  592. type: "get",
  593. url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/get24hourrepaircount",
  594. async: true,
  595. dataType: 'json',
  596. data: {
  597. datetype: datetype,
  598. projectid: $("#projectID").text()
  599. },
  600. success: function(result) {
  601. if (result.state.toLowerCase() == "success") {
  602. var repairsdata = result.data.bxcounts
  603. $('#hoursRepairStatistics').highcharts({
  604. chart: {
  605. type: 'area',
  606. backgroundColor: 'transparent'
  607. },
  608. title: false,
  609. credits: {
  610. enabled: false // 禁用版权信息
  611. },
  612. exporting: {
  613. enabled: false
  614. }, //隐藏导出图片
  615. legend: {
  616. enabled: false
  617. },
  618. xAxis: {
  619. categories: [
  620. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
  621. ],
  622. lineColor: "#45599d",
  623. tickColor: 'transparent',
  624. labels: {
  625. style: {
  626. color: '#fff'
  627. }
  628. }
  629. },
  630. yAxis: {
  631. title: false,
  632. gridLineDashStyle: 'longdash', //图表内网格线样式
  633. gridLineColor: '#242f5d', //图表内网格线颜色
  634. labels: {
  635. style: {
  636. color: '#fff'
  637. },
  638. step: 1
  639. }
  640. },
  641. // tooltip: {
  642. // pointFormat: '{series.name} 制造 <b>{point.y:,.0f}</b>枚弹头'
  643. // },
  644. plotOptions: {
  645. area: {
  646. fillOpacity: 0, // 指定所有面积图的透明度
  647. //pointStart: 1940,
  648. marker: {
  649. enabled: false,
  650. symbol: 'circle',
  651. radius: 2,
  652. states: {
  653. hover: {
  654. enabled: true
  655. }
  656. }
  657. }
  658. }
  659. },
  660. series: [{
  661. name: '报修数量',
  662. // data: (function() {
  663. // var repairsdata= result.data.bxcounts
  664. // var arrs = [];
  665. // for(var k = 0; k < repairsdata.length; k++) {
  666. // var objs = {};
  667. // objs= repairsdata[k];
  668. // arrs.push(objs);
  669. // }
  670. // return arrs;
  671. // })(),
  672. data: [
  673. repairsdata[0], repairsdata[1], repairsdata[2], repairsdata[3], repairsdata[4], repairsdata[5],
  674. repairsdata[6], repairsdata[7], repairsdata[8], repairsdata[9],
  675. repairsdata[10], repairsdata[11], repairsdata[12], repairsdata[13], repairsdata[14], repairsdata[15],
  676. repairsdata[16], repairsdata[17], repairsdata[18], repairsdata[19],
  677. repairsdata[20], repairsdata[21], repairsdata[22], repairsdata[23],
  678. ],
  679. color: '#306cdd'
  680. }]
  681. });
  682. }
  683. }
  684. });
  685. }
  686. //累计数量
  687. function accumOrder() {
  688. $.ajax({
  689. type: "get",
  690. url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getrepairstatecount",
  691. async: true,
  692. dataType: 'json',
  693. data: {
  694. datetype: 4,
  695. projectid: $("#projectID").text()
  696. },
  697. success: function(result) {
  698. if (result.state.toLowerCase() == "success") {
  699. var servdata = result.data
  700. $(".Pink").text(servdata.bxnum); //报修
  701. $(".purple").text(servdata.yclnum); //已处理
  702. // + servdata.cjnum
  703. $(".Ashen").text(servdata.wclnum); //未处理
  704. $(".green").text(servdata.ypjnum); //已评价
  705. }
  706. }
  707. });
  708. }
  709. //维修工满意度统计
  710. function mainteMan() {
  711. var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
  712. $.ajax({
  713. type: "get",
  714. url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getuserrepaireval",
  715. async: true,
  716. dataType: 'json',
  717. data: {
  718. datetype: 2,
  719. projectid: $("#projectID").text()
  720. },
  721. success: function(result) {
  722. if (result.state.toLowerCase() == "success") {
  723. $('.OA_main').empty();
  724. var mainmanData = result.data;
  725. var mainLength = mainmanData.length;
  726. var mainLgthWd = mainLength * 183 * 2;
  727. finshLength = mainLength;
  728. $(".contentBottom_content_right .posi").css("width", mainLgthWd);
  729. for (var i = 0; i < mainmanData.length; i++) {
  730. var srcImg = mainmanData[i].head_img
  731. if (srcImg == "") {
  732. srcImg = "images/img.png"
  733. } else {
  734. srcImg = mainmanData[i].head_img
  735. }
  736. var UUserCard = mainmanData[i].idcardno;
  737. var myDate = new Date();
  738. // var age=myDate.getFullYear() - UUserCard.substring(6, 10);
  739. // alert(age);
  740. if (UUserCard == null) {
  741. age = 0;
  742. } else {
  743. age = myDate.getFullYear() - UUserCard.substring(6, 10);
  744. }
  745. // alert(age);
  746. var ranking = i - 0 + 1;
  747. $('<li><div class="ranking">' + ranking +
  748. '</div><img src="' + srcImg +
  749. '" alt="" /><p><span>工号:</span><span>' + mainmanData[i].usercode +
  750. '</span></p><p><span>' + mainmanData[i].username +
  751. '&nbsp&nbsp&nbsp&nbsp</span><span>' + age +
  752. '岁</span></p><p><span>工种:</span><span>' + mainmanData[i].remark +
  753. '</span></p><p><span>满意度:</span><span>' + mainmanData[i].myrate +
  754. '</span></p></li>'
  755. ).appendTo('.OA_main');
  756. };
  757. dtd.resolve(); // 改变Deferred对象的执行状态
  758. }
  759. },
  760. });
  761. return dtd.promise(); // 返回promise对象
  762. }
  763. //未完成工单
  764. function unFinish() {
  765. $.ajax({
  766. type: "get",
  767. url: huayi.config.callcenter_url + "equipmentapi/api/RunningChart/getnodeallist",
  768. async: true,
  769. dataType: 'json',
  770. data: {
  771. datetype: 0,
  772. projectid: $("#projectID").text()
  773. },
  774. success: function(result) {
  775. if (result.state.toLowerCase() == "success") {
  776. $('.unfinish').empty();
  777. var unfinishData = result.data;
  778. var listLg = unfinishData.length;
  779. var aListlg = listLg * 38;
  780. // 格式化时间
  781. //var $("p").css("background-color","yellow");
  782. if (unfinishData.length > 0) {
  783. var lenghData
  784. if (unfinishData.length < 11) {
  785. lenghData = unfinishData.length;
  786. } else {
  787. lenghData = 11
  788. }
  789. for (var i = 0; i < lenghData; i++) {
  790. var repairsState,repairsTime,receivTime,dealTime
  791. //报修时间
  792. if (unfinishData[i].repairtime) {
  793. repairsTime = unfinishData[i].repairtime;
  794. var repairMonth = repairsTime.split('-')[1]; //月
  795. var repairdayTime = repairsTime.split('-')[2].split(' ')[0]; //日
  796. var repairhour = repairsTime.split('-')[2].split(' ')[1].split(':')[0]; //时
  797. var repairminute = repairsTime.split('-')[2].split(' ')[1].split(':')[1]; //时
  798. var repairDataTime= repairMonth + "-" + repairdayTime + " " + repairhour + ":" + repairminute;
  799. }else{
  800. var repairDataTime="-";
  801. }
  802. //接单时间
  803. if (unfinishData[i].totime) {
  804. receivTime = unfinishData[i].totime
  805. var totimeMonth = repairsTime.split('-')[1]; //月
  806. var totimedayTime = repairsTime.split('-')[2].split(' ')[0]; //日
  807. var totimehour = repairsTime.split('-')[2].split(' ')[1].split(':')[0]; //时
  808. var totimeminute = repairsTime.split('-')[2].split(' ')[1].split(':')[1]; //时
  809. var totimeDataTime= totimeMonth + "-" + totimedayTime + " " + totimehour + ":" + totimeminute;
  810. }else{
  811. var totimeDataTime="-";
  812. }
  813. // 处理时间
  814. if (unfinishData[i].dealtime) {
  815. dealTime = unfinishData[i].dealtime
  816. var dealtimeMonth = dealTime.split('-')[1]; //月
  817. var dealtimedayTime = dealTime.split('-')[2].split(' ')[0]; //日
  818. var dealtimehour = dealTime.split('-')[2].split(' ')[1].split(':')[0]; //时
  819. var dealtimeminute = dealTime.split('-')[2].split(' ')[1].split(':')[1]; //时
  820. var dealtimeDataTime= dealtimeMonth + "-" + dealtimedayTime + " " + dealtimehour + ":" + dealtimeminute;
  821. }else{
  822. var dealtimeDataTime="-";
  823. }
  824. if (unfinishData[i].wostate == 0) {
  825. repairsState = "待接单";
  826. //判断是否是新的工单 播放语音
  827. if (isNewOrderHandler(unfinishData[i])) {
  828. playSaveHandler(unfinishData[i]);
  829. }
  830. } else if (unfinishData[i].wostate == 1) {
  831. repairsState = "待处理";
  832. deleteCacheData(unfinishData[i]);
  833. } else if (unfinishData[i].wostate == 7) {
  834. repairsState = "挂起";
  835. deleteCacheData(unfinishData[i]);
  836. } else if (unfinishData[i].wostate == 2) {
  837. repairsState = "已处理";
  838. deleteCacheData(unfinishData[i]);
  839. } else if (unfinishData[i].wostate == 3) {
  840. repairsState = "已完结";
  841. deleteCacheData(unfinishData[i]);
  842. }
  843. var touName
  844. if (unfinishData[i].tousername == "") {
  845. touName = "无"
  846. } else {
  847. touName = unfinishData[i].tousername
  848. }
  849. $('<li><a title="' + unfinishData[i].faultdescripe +
  850. '"><dl style="width: 15%; text-align: center; margin-left: 0;">' + repairDataTime +
  851. '</dl><dl style="width: 10%;">' + unfinishData[i].repairman +
  852. '</dl><dl style="width: 15%;">' + unfinishData[i].faultdescripe +
  853. '</dl><dl style="width: 10%;">' + touName + ' ' +
  854. '</dl><dl style="width: 10%;">' + repairsState +
  855. '</dl><dl style="width: 14%; text-align: center;">' + totimeDataTime +
  856. '</dl><dl style="width: 14%; text-align: center;">' + dealtimeDataTime +
  857. '</dl></a></li>'
  858. ).appendTo('.unfinish');
  859. }
  860. }
  861. }
  862. }
  863. });
  864. }
  865. /**
  866. * 判断是否是新的工单 播放语音
  867. * @cuData 当前信息
  868. * @return boolean false(缓存中有这个工单,不是新工单) true(缓存中没有这工单,是新工单)
  869. */
  870. function isNewOrderHandler(cuData) {
  871. var oldLocalDatas = window.localStorage.getItem('newOrderData');
  872. var isTrue = [];
  873. if (oldLocalDatas) {
  874. oldLocalDatas = JSON.parse(oldLocalDatas);
  875. for (var j = 0, len = oldLocalDatas.length; j < len; j++) {
  876. if (oldLocalDatas[j].wocode === cuData.wocode && oldLocalDatas[j].time === cuData.repairtime) {
  877. isTrue.push(false); // 缓存中有这个工单
  878. }
  879. }
  880. } else {
  881. isTrue.push(true); // 缓存中没有这工单
  882. }
  883. return isTrue.indexOf(false) === -1 ? true : false;
  884. }
  885. /**
  886. * 播放语音 存储数据
  887. * @cuData 当前信息
  888. */
  889. function playSaveHandler(cuData) {
  890. //播放语音
  891. var promise = $('#btn_audio')[0].play();
  892. if (promise !== undefined) {
  893. promise.then(function() {
  894. $('#btn_audio')[0].play();
  895. }).catch(function(error) {
  896. var context = new(window.AudioContext || window.webkitAudioContext)();
  897. playAudio(context, 'audio/orderTips.wav');
  898. });
  899. }
  900. //缓存当前信息
  901. var oldLocalDatas = window.localStorage.getItem('newOrderData');
  902. var newOrderData = oldLocalDatas === null ? [] : JSON.parse(oldLocalDatas);
  903. newOrderData.unshift({
  904. "time": cuData.repairtime,
  905. "wocode": cuData.wocode
  906. });
  907. window.localStorage.setItem('newOrderData', JSON.stringify(newOrderData));
  908. }
  909. //requestAudio play playAudio处理 Chrome 69 70 不能自动播放的问题;
  910. function requestAudio(url) {
  911. var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
  912. var xhr = new XMLHttpRequest();
  913. xhr.open('GET', url);
  914. // 这里需要设置xhr response的格式为arraybuffer
  915. // 否则默认是二进制的文本格式
  916. xhr.responseType = 'arraybuffer';
  917. xhr.onreadystatechange = function() {
  918. // 请求完成,并且成功
  919. if (xhr.readyState === 4 && xhr.status === 200) {
  920. dtd.resolve(xhr.response); // 改变Deferred对象的执行状态
  921. }
  922. };
  923. xhr.send();
  924. return dtd.promise(); // 返回promise对象
  925. }
  926. function play(context, decodeBuffer) {
  927. // 调用resume恢复播放
  928. context.resume();
  929. var source = context.createBufferSource();
  930. source.buffer = decodeBuffer;
  931. source.connect(context.destination);
  932. source.start(0);
  933. return false;
  934. }
  935. function playAudio(context, url) {
  936. requestAudio(url).then(function(audioMedia) {
  937. context.decodeAudioData(audioMedia, function(decode) {
  938. play(context, decode);
  939. });
  940. });
  941. }
  942. /**
  943. * 清除缓存数据
  944. * @cuData 当前信息
  945. */
  946. function deleteCacheData(cuData) {
  947. var oldLocalDatas = window.localStorage.getItem('newOrderData');
  948. oldLocalDatas = oldLocalDatas === null ? [] : JSON.parse(oldLocalDatas);
  949. if (oldLocalDatas.length > 0) {
  950. for (var i = 0; i < oldLocalDatas.length; i++) {
  951. if (oldLocalDatas[i].wocode === cuData.wocode && oldLocalDatas[i].time === cuData.repairtime) {
  952. oldLocalDatas.splice(i, 1);
  953. window.localStorage.setItem('newOrderData', JSON.stringify(oldLocalDatas));
  954. }
  955. }
  956. }
  957. }