index_lycenter.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. var listIndex = 0;
  2. //人员大数据统计
  3. function personnel() {
  4. $.get('/api/Project_v2/personnel_ly',{orgid:orgid},function (data) {
  5. if(data.status == 0){
  6. if(data.data.length > 0){
  7. var personnel = echarts.init(document.getElementById('personnel'));
  8. personnelOption = {
  9. color:['#7DACFA','#3FECFF','#114FEC'],
  10. tooltip : {
  11. trigger: 'item',
  12. formatter: "{a} <br/>{b} : {c} ({d}%)"
  13. },
  14. legend: {
  15. x : 'left',
  16. y : 'center',
  17. left: 50,
  18. textStyle: {
  19. color: '#fff',
  20. fontSize: 12,
  21. },
  22. orient: 'vertical',
  23. data:['保洁','维修','运送']
  24. },
  25. calculable : true,
  26. series : [
  27. {
  28. name:'人员大数据统计',
  29. type:'pie',
  30. radius : 50,
  31. center : ['60%', '50%'],
  32. // roseType : 'radius',
  33. data:data.data,
  34. // data:[
  35. // {value:30, name:'保洁'},
  36. // {value:25, name:'保安'},
  37. // {value:20, name:'维修'},
  38. // {value:25, name:'运送'}
  39. // ],
  40. label: {
  41. formatter: '{b}{d}%',
  42. color: '#fff'
  43. }
  44. }
  45. ]
  46. };
  47. personnel.setOption(personnelOption);
  48. }
  49. }
  50. });
  51. }
  52. function duty() {
  53. $.get('/api/Project_v2/duty',{orgid:orgid},function (res) {
  54. if(res.status == 0) {
  55. let list = res.data.data;
  56. if (list.length > 0) {
  57. var str = '';
  58. for (var i in list){
  59. str += '<tr>';
  60. str += '<td>' + list[i]['ID'] + '</td>';
  61. str += '<td>' + list[i]['DEP'] + '</td>';
  62. str += '<td>' + list[i]['NAME'] + '</td>';
  63. str += '<td>' + list[i]['PHONE'] + '</td>';
  64. str += '</tr>';
  65. }
  66. $('#duty').html(str);
  67. }
  68. }
  69. })
  70. }
  71. //运送工单数据
  72. function complaintList() {
  73. $.get('/api/Project_v2/convey',{orgid:orgid},function (res) {
  74. if(res.status == 0) {
  75. let list = res.data.data;
  76. if (list.length > 0) {
  77. var str = '';
  78. for (var i in list){
  79. str += '<tr>';
  80. str += '<td class="table-project-name">' + list[i]['START_TITLE'] + '</td>';
  81. str += '<td class="table-project-name">' + list[i]['END_TITLE'] + '</td>';
  82. str += '<td class="table-project-name">' + list[i]['CREATE_TIME'] + '</td>';
  83. str += '<td class="table-project-name">' + list[i]['REAL_NAME'] + '</td>';
  84. if (list[i]['TODO_MODE'] == 3) {
  85. str += '<td class="status-yes">已完成</td>';
  86. }else{
  87. str += '<td class="status-no">未完成</td>';
  88. }
  89. // str += '<td class="table-project-name">' + list[i]['CONTENT'] + '</td>';
  90. // str += '<td>' + list[i]['CREATTE_TIME'].replace(/(\d{4}).(\d{1,2}).(\d{1,2}).+/mg, '$1-$2-$3') + '</td>';
  91. str += '</tr>';
  92. }
  93. $('#complaintList').html(str);
  94. }
  95. if (list.length > 5) {
  96. $(function(){
  97. var text=$("#complaintList:first");
  98. var clear;
  99. text.hover(function(){
  100. clearInterval(clear);
  101. },function(){
  102. clear=setInterval(function(){
  103. var field=text.find("tr:first");
  104. var high=field.height();
  105. text.animate({ marginTop:-high+"px"},600,function(){
  106. field.css("marginTop",0).appendTo(text);
  107. text.css("marginTop",0);
  108. })
  109. },2000)//滚动间隔时间
  110. }).trigger("mouseleave");//自动滚动
  111. });
  112. }
  113. }
  114. })
  115. }
  116. //报修工单展示
  117. function taskList() {
  118. $.get('/api/Project_v2/repairs',{orgid:orgid},function (res) {
  119. if(res.status == 0) {
  120. let list = res.data.data;
  121. if (list.length > 0) {
  122. var str = '';
  123. for (var i in list){
  124. str += '<tr>';
  125. str += '<td>' + list[i]['DEP_TITLE'] + '</td>';
  126. str += '<td class="table-project-name">' + list[i]['CREATE_TIME'] + '</td>';
  127. str += '<td class="table-project-name">' + list[i]['REAL_NAME'] + '</td>';
  128. if(list[i]['STATUS'] == 3){
  129. str += '<td class="status-yes">已完成</td>';
  130. }else{
  131. str += '<td class="status-no">未完成</td>';
  132. }
  133. str += '</tr>';
  134. }
  135. $('#taskList').html(str);
  136. }
  137. if (list.length > 13) {
  138. $(function(){
  139. var text=$("#taskList:first");
  140. var clear;
  141. text.hover(function(){
  142. clearInterval(clear);
  143. },function(){
  144. clear=setInterval(function(){
  145. var field=text.find("tr:first");
  146. var high=field.height();
  147. text.animate({ marginTop:-high+"px"},600,function(){
  148. field.css("marginTop",0).appendTo(text);
  149. text.css("marginTop",0);
  150. })
  151. },5000)//滚动间隔时间
  152. }).trigger("mouseleave");//自动滚动
  153. });
  154. }
  155. }
  156. })
  157. }
  158. //近7天运送订单分析
  159. function hiddenDangerChart() {
  160. $.get('/api/Project_v2/conveyChart',{orgid:orgid,mode: 3},function (data) {
  161. if(data.status == 0){
  162. if(data.data.x.length > 0){
  163. var hiddenDanger = echarts.init(document.getElementById('hidden-danger'));
  164. hiddenDangerOption = {
  165. color:['#429AEC'],
  166. tooltip : {
  167. trigger: 'axis',
  168. axisPointer : {
  169. type : 'shadow'
  170. }
  171. },
  172. grid: {
  173. top: '30%',
  174. left: '6%',
  175. right: '6%',
  176. bottom: '2%',
  177. containLabel: true
  178. },
  179. legend: {
  180. icon:"circle",
  181. data:['运送工单数量'],
  182. textStyle: {
  183. color: '#fff',
  184. fontSize: 12,
  185. }
  186. },
  187. xAxis: {
  188. axisLine: {
  189. lineStyle: {
  190. color: '#fff',
  191. width: 1,
  192. }
  193. },
  194. data: data.data.x,
  195. },
  196. yAxis: {
  197. type: 'value',
  198. axisLabel:{
  199. show:true,
  200. inside:false,
  201. rotate:0,
  202. margin: 8,
  203. color:'#fff',
  204. },
  205. },
  206. series: [
  207. {
  208. name:'运送工单数量',
  209. type:'bar',
  210. label: {
  211. normal: {
  212. show: true,
  213. position: 'top',
  214. color: '#fff'
  215. }
  216. },
  217. data: data.data.y1
  218. },
  219. // {
  220. // name:'转工单量',
  221. // type:'bar',
  222. // label: {
  223. // normal: {
  224. // show: true,
  225. // position: 'top',
  226. // color: '#fff'
  227. // }
  228. // },
  229. // data: data.data.y2
  230. // }
  231. ]
  232. };
  233. hiddenDanger.setOption(hiddenDangerOption);
  234. }
  235. }
  236. });
  237. }
  238. // 设备维护记录
  239. function hiddenDangerList() {
  240. $.get('/api/Project_v2/device',{orgid:orgid},function (res) {
  241. if(res.status == 0) {
  242. let list = [];
  243. let hiddenlist = res.data.data;
  244. if (hiddenlist.length < 5) {
  245. list = hiddenlist;
  246. } else {
  247. for (var i=0;i<5;i++){
  248. if(listIndex >= hiddenlist.length){
  249. listIndex = 0;
  250. }
  251. list.push(hiddenlist[listIndex]);
  252. listIndex++;
  253. }
  254. }
  255. if (list.length > 0) {
  256. var str = '';
  257. var status = '';
  258. for (var i in list){
  259. str += '<tr>';
  260. str += '<td>' + (parseInt(i)+1) +'</td>';
  261. str += '<td class="table-project-name">' + list[i]['TITLE'] +'</td>';
  262. str += '<td>' + list[i]['CREATE_TIME'] + '</td>';
  263. str += '<td class="table-project-name">' + list[i]['REAL_NAME'] + '</td>';
  264. str += '<td class="table-project-name">' + list[i]['CONTENT'] + '</td>';
  265. str += '</tr>';
  266. }
  267. }
  268. $('#hiddenDangerList').html(str);
  269. list.shift();
  270. if(listIndex >= hiddenlist.length){
  271. listIndex = 0;
  272. }
  273. list.push(hiddenlist[listIndex]);
  274. listIndex++;
  275. }
  276. })
  277. }
  278. // patrol-task
  279. function patrolTask() {
  280. $.get('/api/Orders/patrol',{org_id:orgid},function (res) {
  281. if(res.status === 0) {
  282. let list = [];
  283. let tasklist = res.data.data;
  284. if (tasklist.length < 5) {
  285. list = tasklist;
  286. } else {
  287. for (var i=0;i<5;i++){
  288. if(listIndex >= tasklist.length){
  289. listIndex = 0;
  290. }
  291. list.push(tasklist[listIndex]);
  292. listIndex++;
  293. }
  294. }
  295. if(list.length > 0){
  296. var str = '';
  297. var status = '';
  298. for (i in list){
  299. str += '<tr>';
  300. str += '<td>'+list[i]['PATROL_TASK_ID']+'</td>';
  301. // str += '<td>'+list[i]['TITLE']+'</td>';
  302. str += '<td>'+list[i]['NAME']+'</td>';
  303. str += '<td class="table-project-name">'+list[i]['USERS']+'</td>';
  304. str += '<td>'+list[i]['START_TIME']+'</td>';
  305. str += '<td>'+list[i]['END_TIME']+'</td>';
  306. if (list[i]['STATUS'] == 2) {
  307. status = '已完成';
  308. str += '<td class="status-yes">' + status + '</td>';
  309. } else if (list[i]['STATUS'] == 3) {
  310. status = '未完成';
  311. str += '<td class="status-no">' + status + '</td>';
  312. } else if (list[i]['STATUS'] == 1) {
  313. status = '执行中';
  314. str += '<td style="color: #FDD100;">' + status + '</td>';
  315. } else {
  316. status = '未执行';
  317. str += '<td>' + status + '</td>';
  318. }
  319. str += '</tr>';
  320. }
  321. }
  322. $('#patrol-task').html(str);
  323. list.shift();
  324. if(listIndex >= tasklist.length){
  325. listIndex = 0;
  326. }
  327. list.push(tasklist[listIndex]);
  328. listIndex++;
  329. }
  330. })
  331. }
  332. // 巡更
  333. function patrol() {
  334. $.get('/api/Project_v2/patrol',{orgid:orgid},function (res) {
  335. if(res.status == 0) {
  336. var list = res.data.data;
  337. if (list != '') {
  338. var str = '';
  339. str += '<tr>';
  340. str += '<td>' + list['NAME'] +'地点' + '</td>';
  341. str += '<td>' + list['TITLE'] + '</td>';
  342. str += '</tr>';
  343. str += '<tr>';
  344. str += '<td>' + list['NAME'] +'时间' + '</td>';
  345. str += '<td>' + list['CREATE_TIME'].replace(/(\d{4}).(\d{1,2}).(\d{1,2}).+/mg, '$1-$2-$3') + '</td>';
  346. str += '</tr>';
  347. str += '<tr>';
  348. str += '<td>' + list['NAME'] +'人员' + '</td>';
  349. str += '<td>' + list['USER_NAME'] + '</td>';
  350. str += '</tr>';
  351. str += '<tr>';
  352. str += '<td>' + list['NAME'] +'内容' + '</td>';
  353. str += '<td>' + list['TASK_NAME'] + '</td>';
  354. str += '</tr>';
  355. $('#patrol').html(str);
  356. $('#patrol-addr').html(list['TITLE']);
  357. $('#patrol-report').html('汇报内容:' + list['CONTENT']);
  358. var oImg = document.getElementById('patrol-img');
  359. var arr = list['IMAGES'];
  360. var num = 0;
  361. num++;
  362. if (num == arr.length) {
  363. num = 0;
  364. }
  365. oImg.src = arr[num];
  366. }
  367. setTimeout("patrol()", 15000);
  368. }
  369. })
  370. }
  371. //近7天运送订单分析
  372. function repairTodoChart() {
  373. $.get('/api/Project_v2/conveyChart',{orgid:orgid,mode: 1},function (data) {
  374. if(data.status == 0){
  375. if(data.data.x.length > 0){
  376. var hiddenDanger = echarts.init(document.getElementById('repair-todo-order'));
  377. hiddenDangerOption = {
  378. color:['#429AEC'],
  379. tooltip : {
  380. trigger: 'axis',
  381. axisPointer : {
  382. type : 'shadow'
  383. }
  384. },
  385. grid: {
  386. top: '30%',
  387. left: '6%',
  388. right: '6%',
  389. bottom: '2%',
  390. containLabel: true
  391. },
  392. legend: {
  393. icon:"circle",
  394. data:['报修工单数量'],
  395. textStyle: {
  396. color: '#fff',
  397. fontSize: 12,
  398. }
  399. },
  400. xAxis: {
  401. axisLine: {
  402. lineStyle: {
  403. color: '#fff',
  404. width: 1,
  405. }
  406. },
  407. data: data.data.x,
  408. },
  409. yAxis: {
  410. type: 'value',
  411. axisLabel:{
  412. show:true,
  413. inside:false,
  414. rotate:0,
  415. margin: 8,
  416. color:'#fff',
  417. },
  418. },
  419. series: [
  420. {
  421. name:'报修工单数量',
  422. type:'bar',
  423. label: {
  424. normal: {
  425. show: true,
  426. position: 'top',
  427. color: '#fff'
  428. }
  429. },
  430. data: data.data.y1
  431. },
  432. ]
  433. };
  434. hiddenDanger.setOption(hiddenDangerOption);
  435. }
  436. }
  437. });
  438. }
  439. function chunk(arr, size) {
  440. var arrs=[];
  441. for(var i=0; i<arr.length; i=i+size) {
  442. arrs.push(arr.slice(i,i+size));
  443. }
  444. return arrs;
  445. }
  446. var timer = 1000*60*5;
  447. personnel();
  448. duty();
  449. taskList();
  450. complaintList();
  451. hiddenDangerList();
  452. hiddenDangerChart();
  453. patrolTask();
  454. patrol(); //巡更
  455. repairTodoChart();
  456. setInterval(function(){
  457. personnel();
  458. duty();
  459. taskList();
  460. complaintList();
  461. hiddenDangerList();
  462. hiddenDangerChart();
  463. patrolTask();
  464. repairTodoChart();
  465. // patrol();
  466. }, timer);
  467. setInterval(function(){
  468. hiddenDangerList();
  469. patrolTask();
  470. }, 10000);
  471. function locationIiconold() {
  472. // var id = document.getElementById("location-icon");
  473. // var photo=$(".location-icon img");
  474. // var imgs = [
  475. // '/public/data/img/bannertips/1.png',
  476. // '/public/data/img/bannertips/2.png',
  477. // '/public/data/img/bannertips/3.png',
  478. // '/public/data/img/bannertips/4.png',
  479. // '/public/data/img/bannertips/5.png',
  480. // '/public/data/img/bannertips/6.png',
  481. // '/public/data/img/bannertips/7.png',
  482. // '/public/data/img/bannertips/8.png',
  483. // ];
  484. // for(var i=0; photo.eq(i).val()==0;i++){
  485. // // var left = Math.floor( Math.random() * 100 + 200 );
  486. // // var top = Math.floor( Math.random() * 100 + 80);
  487. //
  488. // var left = getRandomInt(100, 350);
  489. // var top = getRandomInt(30, 180);
  490. //
  491. // let index = left%8;
  492. // photo.attr('src',imgs[index]);
  493. // photo.eq(i).css({
  494. // 'position': 'absolute',
  495. // 'left':left +'px',
  496. // 'top' :top +'px',
  497. // });
  498. // }
  499. }
  500. var orders = [];
  501. var orderindex = 0;
  502. getNewOrders();
  503. setInterval(function () {
  504. getNewOrders();
  505. },60000*5);
  506. function getNewOrders() {
  507. $.get('/api/Project_v2/neworders',{orgid:orgid},function (res) {
  508. if(res.status == 0) {
  509. orders = res.data?res.data:[];
  510. orderindex = 0;
  511. }
  512. })
  513. }
  514. function locationIicon() {
  515. if(orders.length == 0){
  516. $('#location-icon1').hide();
  517. return false;
  518. }
  519. //预设随机位置
  520. var locations = [
  521. [94,322],
  522. [133,345],
  523. [177,375],
  524. [196,303],
  525. [179,415],
  526. [209,457],
  527. [245,470],
  528. [274,387],
  529. [305,459],
  530. [370,425],
  531. [323,303],
  532. [332,247]
  533. ];
  534. let orderinfo = orders[orderindex];
  535. $('#order-title').html(orderinfo.TITLE);
  536. if(orderinfo.DEP_NAME){
  537. $('#order-dep').html('科室:'+orderinfo.DEP_NAME);
  538. }else{
  539. $('#order-dep').html('');
  540. }
  541. if(orderinfo.DEP_CONTENT){
  542. $('#order-addr').html('地点:'+orderinfo.DEP_CONTENT);
  543. }else{
  544. $('#order-addr').html('');
  545. }
  546. orderindex++;
  547. if(orderindex >= orders.length){
  548. orderindex = 0;
  549. }
  550. let rand = getRandomInt(0,locations.length);
  551. let top = locations[rand][0];
  552. let left = locations[rand][1];
  553. $('#location-icon1').show().css({
  554. 'left':left +'px',
  555. 'top' :top +'px',
  556. });
  557. }
  558. function getRandomInt(min, max) {
  559. min = Math.ceil(min);
  560. max = Math.floor(max);
  561. return Math.floor(Math.random() * (max - min)) + min; //不含最大值,含最小值
  562. }
  563. setInterval(function () {
  564. locationIicon();
  565. },5000);