index_v2.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. var listIndex = 0;
  2. //人员大数据统计
  3. function personnel() {
  4. $.get('/api/Project_v2/personnel',{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:['#fdd100','#ec5400','#40ebff','#ff4874'],
  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 : [20, 70],
  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/complaint',{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>' + list[i]['COMPLAIN_ID'] + '</td>';
  81. str += '<td class="table-project-name">' + list[i]['CONTENT'] + '</td>';
  82. str += '<td>' + list[i]['CREATTE_TIME'].replace(/(\d{4}).(\d{1,2}).(\d{1,2}).+/mg, '$1-$2-$3') + '</td>';
  83. str += '</tr>';
  84. }
  85. $('#complaintList').html(str);
  86. }
  87. if (list.length > 5) {
  88. $(function(){
  89. var text=$("#complaintList:first");
  90. var clear;
  91. text.hover(function(){
  92. clearInterval(clear);
  93. },function(){
  94. clear=setInterval(function(){
  95. var field=text.find("tr:first");
  96. var high=field.height();
  97. text.animate({ marginTop:-high+"px"},600,function(){
  98. field.css("marginTop",0).appendTo(text);
  99. text.css("marginTop",0);
  100. })
  101. },2000)//滚动间隔时间
  102. }).trigger("mouseleave");//自动滚动
  103. });
  104. }
  105. }
  106. })
  107. }
  108. //网格化
  109. function taskList() {
  110. $.get('/api/Project_v2/task',{orgid:orgid},function (res) {
  111. if(res.status == 0) {
  112. let list = res.data.data;
  113. if (list.length > 0) {
  114. var str = '';
  115. for (var i in list){
  116. str += '<tr>';
  117. // str += '<td>' + list[i]['PATROL_RECORD_ID'] + '</td>';
  118. str += '<td data-show>' + list[i]['TITLE'] + '</td>';
  119. str += '<td class="table-project-name data-show">' + list[i]['REAL_NAME'] + '</td>';
  120. str += '<td data-show>' + list[i]['CREATE_TIME'] + '</td>';
  121. str += '</tr>';
  122. }
  123. $('#taskList').html(str);
  124. }
  125. if (list.length > 13) {
  126. $(function(){
  127. var text=$("#taskList:first");
  128. var clear;
  129. text.hover(function(){
  130. clearInterval(clear);
  131. },function(){
  132. clear=setInterval(function(){
  133. var field=text.find("tr:first");
  134. var high=field.height();
  135. text.animate({ marginTop:-high+"px"},600,function(){
  136. field.css("marginTop",0).appendTo(text);
  137. text.css("marginTop",0);
  138. })
  139. },5000)//滚动间隔时间
  140. }).trigger("mouseleave");//自动滚动
  141. });
  142. }
  143. }
  144. })
  145. }
  146. //安保
  147. function hiddenDangerChart() {
  148. $.get('/api/Project_v2/hiddenDangerChart',{orgid:orgid},function (data) {
  149. if(data.status == 0){
  150. if(data.data.x.length > 0){
  151. var hiddenDanger = echarts.init(document.getElementById('hidden-danger'));
  152. hiddenDangerOption = {
  153. color:['#04F4CD','#429AEC'],
  154. tooltip : {
  155. trigger: 'axis',
  156. axisPointer : {
  157. type : 'shadow'
  158. }
  159. },
  160. grid: {
  161. top: '30%',
  162. left: '6%',
  163. right: '6%',
  164. bottom: '2%',
  165. containLabel: true
  166. },
  167. legend: {
  168. icon:"circle",
  169. data:['隐患数量','转工单量'],
  170. textStyle: {
  171. color: '#fff',
  172. fontSize: 12,
  173. }
  174. },
  175. xAxis: {
  176. axisLine: {
  177. lineStyle: {
  178. color: '#fff',
  179. width: 1,
  180. }
  181. },
  182. data: data.data.x,
  183. },
  184. yAxis: {
  185. type: 'value',
  186. axisLabel:{
  187. show:true,
  188. inside:false,
  189. rotate:0,
  190. margin: 8,
  191. color:'#fff',
  192. },
  193. },
  194. series: [
  195. {
  196. name:'隐患数量',
  197. type:'bar',
  198. label: {
  199. normal: {
  200. show: true,
  201. position: 'top',
  202. color: '#fff'
  203. }
  204. },
  205. data: data.data.y1
  206. },
  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.y2
  218. }
  219. ]
  220. };
  221. hiddenDanger.setOption(hiddenDangerOption);
  222. }
  223. }
  224. });
  225. }
  226. // 安保表单
  227. function hiddenDangerList() {
  228. $.get('/api/Project_v2/hiddenDanger',{orgid:orgid},function (res) {
  229. if(res.status == 0) {
  230. let list = [];
  231. let hiddenlist = res.data.data;
  232. if (hiddenlist.length < 5) {
  233. list = hiddenlist;
  234. } else {
  235. for (var i=0;i<5;i++){
  236. if(listIndex >= hiddenlist.length){
  237. listIndex = 0;
  238. }
  239. list.push(hiddenlist[listIndex]);
  240. listIndex++;
  241. }
  242. }
  243. if (list.length > 0) {
  244. var str = '';
  245. var status = '';
  246. for (var i in list){
  247. str += '<tr>';
  248. str += '<td>' + list[i]['ORDER_ID'] +'</td>';
  249. str += '<td class="table-project-name">' + list[i]['TITLE'] + list[i]['NAME'] +'</td>';
  250. str += '<td>' + list[i]['CREATTE_TIME'] + '</td>';
  251. str += '<td class="table-project-name">' + list[i]['REAL_NAME'] + '</td>';
  252. str += '<td class="table-project-name">' + list[i]['CONTENT'] + '</td>';
  253. if (list[i]['CURR_ORDER_MODE'] == 9 || list[i]['CURR_ORDER_MODE'] == 11) {
  254. status = '已完成';
  255. str += '<td class="status-yes">' + status + '</td>';
  256. } else {
  257. status = '未完成';
  258. str += '<td class="status-no">' + status + '</td>';
  259. }
  260. str += '</tr>';
  261. }
  262. }
  263. $('#hiddenDangerList').html(str);
  264. list.shift();
  265. if(listIndex >= hiddenlist.length){
  266. listIndex = 0;
  267. }
  268. list.push(hiddenlist[listIndex]);
  269. listIndex++;
  270. }
  271. })
  272. }
  273. // patrol-task
  274. function patrolTask() {
  275. $.get('/api/Orders/patrol',{org_id:orgid},function (res) {
  276. if(res.status === 0) {
  277. let list = [];
  278. let tasklist = res.data.data;
  279. if (tasklist.length < 5) {
  280. list = tasklist;
  281. } else {
  282. for (var i=0;i<5;i++){
  283. if(listIndex >= tasklist.length){
  284. listIndex = 0;
  285. }
  286. list.push(tasklist[listIndex]);
  287. listIndex++;
  288. }
  289. }
  290. if(list.length > 0){
  291. var str = '';
  292. var status = '';
  293. for (i in list){
  294. str += '<tr>';
  295. str += '<td>'+list[i]['PATROL_TASK_ID']+'</td>';
  296. // str += '<td>'+list[i]['TITLE']+'</td>';
  297. str += '<td>'+list[i]['NAME']+'</td>';
  298. str += '<td class="table-project-name">'+list[i]['USERS']+'</td>';
  299. str += '<td>'+list[i]['START_TIME']+'</td>';
  300. str += '<td>'+list[i]['END_TIME']+'</td>';
  301. if (list[i]['STATUS'] == 2) {
  302. status = '已完成';
  303. str += '<td class="status-yes">' + status + '</td>';
  304. } else if (list[i]['STATUS'] == 3) {
  305. status = '未完成';
  306. str += '<td class="status-no">' + status + '</td>';
  307. } else if (list[i]['STATUS'] == 1) {
  308. status = '执行中';
  309. str += '<td style="color: #FDD100;">' + status + '</td>';
  310. } else {
  311. status = '未执行';
  312. str += '<td>' + status + '</td>';
  313. }
  314. str += '</tr>';
  315. }
  316. }
  317. $('#patrol-task').html(str);
  318. list.shift();
  319. if(listIndex >= tasklist.length){
  320. listIndex = 0;
  321. }
  322. list.push(tasklist[listIndex]);
  323. listIndex++;
  324. }
  325. })
  326. }
  327. // 巡更
  328. function patrol() {
  329. $.get('/api/Project_v2/patrol',{orgid:orgid},function (res) {
  330. if(res.status == 0) {
  331. var list = res.data.data;
  332. if (list != '') {
  333. var str = '';
  334. str += '<tr>';
  335. str += '<td>' + list['NAME'] +'地点' + '</td>';
  336. str += '<td>' + list['TITLE'] + '</td>';
  337. str += '</tr>';
  338. str += '<tr>';
  339. str += '<td>' + list['NAME'] +'时间' + '</td>';
  340. str += '<td>' + list['CREATE_TIME'].replace(/(\d{4}).(\d{1,2}).(\d{1,2}).+/mg, '$1-$2-$3') + '</td>';
  341. str += '</tr>';
  342. str += '<tr>';
  343. str += '<td>' + list['NAME'] +'人员' + '</td>';
  344. str += '<td>' + list['USER_NAME'] + '</td>';
  345. str += '</tr>';
  346. str += '<tr>';
  347. str += '<td>' + list['NAME'] +'内容' + '</td>';
  348. str += '<td>' + list['TASK_NAME'] + '</td>';
  349. str += '</tr>';
  350. $('#patrol').html(str);
  351. $('#patrol-addr').html(list['TITLE']);
  352. $('#patrol-report').html('汇报内容:' + list['CONTENT']);
  353. var oImg = document.getElementById('patrol-img');
  354. var arr = list['IMAGES'];
  355. var num = 0;
  356. num++;
  357. if (num == arr.length) {
  358. num = 0;
  359. }
  360. oImg.src = arr[num];
  361. }
  362. setTimeout("patrol()", 15000);
  363. }
  364. })
  365. }
  366. function chunk(arr, size) {
  367. var arrs=[];
  368. for(var i=0; i<arr.length; i=i+size) {
  369. arrs.push(arr.slice(i,i+size));
  370. }
  371. return arrs;
  372. }
  373. var timer = 1000*60*15;
  374. personnel();
  375. duty();
  376. taskList();
  377. complaintList();
  378. hiddenDangerList();
  379. hiddenDangerChart();
  380. patrolTask();
  381. patrol(); //巡更
  382. setInterval(function(){
  383. personnel();
  384. duty();
  385. taskList();
  386. complaintList();
  387. hiddenDangerList();
  388. hiddenDangerChart();
  389. patrolTask();
  390. // patrol();
  391. }, timer);
  392. setInterval(function(){
  393. hiddenDangerList();
  394. patrolTask();
  395. }, 10000);
  396. function locationIicon() {
  397. var id = document.getElementById("location-icon");
  398. var photo=$(".location-icon img");
  399. var imgs = [
  400. '/public/data/img/bannertips/1.png',
  401. '/public/data/img/bannertips/2.png',
  402. '/public/data/img/bannertips/3.png',
  403. '/public/data/img/bannertips/4.png',
  404. '/public/data/img/bannertips/5.png',
  405. '/public/data/img/bannertips/6.png',
  406. '/public/data/img/bannertips/7.png',
  407. '/public/data/img/bannertips/8.png',
  408. ];
  409. for(var i=0; photo.eq(i).val()==0;i++){
  410. // var left = Math.floor( Math.random() * 100 + 200 );
  411. // var top = Math.floor( Math.random() * 100 + 80);
  412. var left = getRandomInt(100, 350);
  413. var top = getRandomInt(30, 180);
  414. let index = left%8;
  415. photo.attr('src',imgs[index]);
  416. photo.eq(i).css({
  417. 'position': 'absolute',
  418. 'left':left +'px',
  419. 'top' :top +'px',
  420. });
  421. }
  422. }
  423. function getRandomInt(min, max) {
  424. min = Math.ceil(min);
  425. max = Math.floor(max);
  426. return Math.floor(Math.random() * (max - min)) + min; //不含最大值,含最小值
  427. }
  428. setInterval(function () {
  429. locationIicon();
  430. },5000);