scanboard.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  1. $(function(){
  2. //页面淡入效果
  3. $(".animsition").animsition({
  4. inClass : 'fade-in',
  5. outClass : 'fade-out',
  6. inDuration : 300,
  7. outDuration : 1000,
  8. // e.g. linkElement : 'a:not([target="_blank"]):not([href^=#])'
  9. loading : false,
  10. loadingParentElement : 'body', //animsition wrapper element
  11. loadingClass : 'animsition-loading',
  12. unSupportCss : [ 'animation-duration',
  13. '-webkit-animation-duration',
  14. '-o-animation-duration'
  15. ],
  16. //"unSupportCss" option allows you to disable the "animsition" in case the css property in the array is not supported by your browser.
  17. //The default setting is to disable the "animsition" in a browser that does not support "animation-duration".
  18. overlay : false,
  19. overlayClass : 'animsition-overlay-slide',
  20. overlayParentElement : 'body'
  21. });
  22. document.onreadystatechange = subSomething;
  23. function subSomething()
  24. {
  25. if(document.readyState == "complete"){
  26. $('#loader').hide();
  27. }
  28. }
  29. //顶部时间
  30. function getTime(){
  31. var myDate = new Date();
  32. var myYear = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
  33. var myMonth = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  34. var myToday = myDate.getDate(); //获取当前日(1-31)
  35. var myDay = myDate.getDay(); //获取当前星期X(0-6,0代表星期天)
  36. var myHour = myDate.getHours(); //获取当前小时数(0-23)
  37. var myMinute = myDate.getMinutes(); //获取当前分钟数(0-59)
  38. var mySecond = myDate.getSeconds(); //获取当前秒数(0-59)
  39. var week = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
  40. var nowTime;
  41. nowTime = myYear+'-'+fillZero(myMonth)+'-'+fillZero(myToday)+'  '+week[myDay]+'  '+fillZero(myHour)+':'+fillZero(myMinute)+':'+fillZero(mySecond);
  42. $('.topTime').html(nowTime);
  43. };
  44. function fillZero(str){
  45. var realNum;
  46. if(str<10){
  47. realNum = '0'+str;
  48. }else{
  49. realNum = str;
  50. }
  51. return realNum;
  52. }
  53. setInterval(getTime,1000);
  54. function totalNum(obj,speed){
  55. var singalNum = 0;
  56. var timer;
  57. var totalNum = obj.attr('total');
  58. if(totalNum){
  59. timer = setInterval(function(){
  60. singalNum+=speed;
  61. if(singalNum>=totalNum){
  62. singalNum=totalNum;
  63. clearInterval(timer);
  64. }
  65. obj.html(singalNum);
  66. },1);
  67. }
  68. }
  69. //高德地图
  70. var myMap = new AMap.Map('myMap',{
  71. resizeEnable: true,
  72. zoom: 14,
  73. mapStyle: 'amap://styles/darkblue',
  74. center: [103.752171,36.068716],
  75. });
  76. var point = [
  77. [103.752171,36.068716],
  78. [103.759037,36.072046],
  79. [103.73788,36.061257]
  80. ]
  81. var maker;
  82. for (var i = 0; i < point.length; i += 1) {
  83. var marker = new AMap.Marker({
  84. position: point[i],
  85. map: myMap,
  86. icon:'images/s_ico4.png',
  87. });
  88. marker.content='<p>ZC1712120023</p>'+
  89. '<p>起点:配件A厂</p>'+
  90. '<p>终点:美的冰箱公司</p>'+
  91. '<p>满载率:95%</p>'+
  92. '<p>已使用时间:2小时15分</p>';
  93. marker.on('click', markerClick);
  94. //map.setFitView();
  95. }
  96. var infoWindow = new AMap.InfoWindow({
  97. offset: new AMap.Pixel(16, -36)
  98. });
  99. function markerClick(e){
  100. infoWindow.setContent(e.target.content);
  101. infoWindow.open(myMap,e.target.getPosition());
  102. }
  103. myMap.on('click',function(){
  104. infoWindow.close();
  105. });
  106. //月运单量统计图
  107. var myChart1 = echarts.init(document.getElementById('myChart1'));
  108. var option1 = {
  109. tooltip: {
  110. trigger: 'item',
  111. formatter: function(params) {
  112. var res = '本月'+params.name+'号运单数:'+params.data;
  113. return res;
  114. }
  115. },
  116. grid: {
  117. top: '5%',
  118. left: '0%',
  119. width: '100%',
  120. height: '95%',
  121. containLabel: true
  122. },
  123. xAxis: {
  124. data: ['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31'],
  125. axisLabel: {
  126. show: true,
  127. textStyle: {
  128. fontSize: '12px',
  129. color: '#fff',
  130. }
  131. },
  132. axisLine:{
  133. lineStyle:{
  134. color:'#fff',
  135. width:1,
  136. }
  137. }
  138. },
  139. yAxis: {
  140. axisLabel: {
  141. show: true,
  142. textStyle: {
  143. fontSize: '12px',
  144. color: '#fff',
  145. }
  146. },
  147. axisLine:{
  148. lineStyle:{
  149. color:'#fff',
  150. width:1,
  151. }
  152. },
  153. splitLine:{
  154. show:false,
  155. }
  156. },
  157. series :{
  158. name: '',
  159. type: 'bar',
  160. barWidth : 10,
  161. data: ['5','14','3','6','8','18','11','4','8','7','16','13','6','10','11','9','19','13','4','20','12','7','13','15','8','3','9','16','11','16','8'],
  162. itemStyle: {
  163. normal: {
  164. barBorderRadius:[5, 5, 5, 5],
  165. color: new echarts.graphic.LinearGradient(
  166. 0, 0, 0, 1,
  167. [
  168. {offset: 0, color: '#3876cd'},
  169. {offset: 0.5, color: '#45b4e7'},
  170. {offset: 1, color: '#54ffff'}
  171. ]
  172. ),
  173. },
  174. },
  175. },
  176. }
  177. //运单状态文字滚动
  178. $('#FontScroll').FontScroll({time: 3000,num: 1});
  179. setTimeout(function(){
  180. $('.progress').each(function(i,ele){
  181. var PG = $(ele).attr('progress');
  182. var PGNum = parseInt(PG);
  183. var zero = 0;
  184. var speed = 50;
  185. var timer;
  186. $(ele).find('h4').html(zero+'%');
  187. if(PGNum<10){
  188. $(ele).find('.progressBar span').addClass('bg-red');
  189. $(ele).find('h3 i').addClass('color-red');
  190. }else if(PGNum>=10 && PGNum<50){
  191. $(ele).find('.progressBar span').addClass('bg-yellow');
  192. $(ele).find('h3 i').addClass('color-yellow');
  193. }else if(PGNum>=50 && PGNum<100){
  194. $(ele).find('.progressBar span').addClass('bg-blue');
  195. $(ele).find('h3 i').addClass('color-blue');
  196. }else{
  197. $(ele).find('.progressBar span').addClass('bg-green');
  198. $(ele).find('h3 i').addClass('color-green');
  199. }
  200. $(ele).find('.progressBar span').animate({width: PG},PGNum*speed);
  201. timer = setInterval(function(){
  202. zero++;
  203. $(ele).find('h4').html(zero+'%');
  204. if(zero==PGNum){
  205. clearInterval(timer);
  206. }
  207. },speed);
  208. });
  209. //基本信息
  210. totalNum($('#indicator1'),1);
  211. totalNum($('#indicator2'),1);
  212. totalNum($('#indicator3'),1);
  213. //总计运单数
  214. totalNum($('#totalNum'),1000);
  215. myChart1.setOption(option1);
  216. },500);
  217. var summaryPie1,summaryPie2,summaryPie3,summaryBar,summaryLine;
  218. var pieData;
  219. function setSummary(){
  220. summaryPie1 = echarts.init(document.getElementById('summaryPie1'));
  221. summaryPie2 = echarts.init(document.getElementById('summaryPie2'));
  222. summaryPie3 = echarts.init(document.getElementById('summaryPie3'));
  223. var ww = $(window).width();
  224. var pieData;
  225. if(ww>1600){
  226. pieData = {
  227. pieTop: '40%',
  228. pieTop2: '36%',
  229. titleSize: 20,
  230. pieRadius: [80, 85],
  231. itemSize: 32
  232. }
  233. }else{
  234. pieData = {
  235. pieTop: '30%',
  236. pieTop2: '26%',
  237. titleSize: 16,
  238. pieRadius: [60, 64],
  239. itemSize: 28
  240. }
  241. };
  242. //弹出框调用ECharts饼图
  243. var pieOption1 = {
  244. title: {
  245. x: 'center',
  246. y: pieData.pieTop,
  247. text: '司机',
  248. textStyle: {
  249. fontWeight: 'normal',
  250. color: '#ffd325',
  251. fontSize: pieData.titleSize,
  252. },
  253. subtext: '总数:100人\n今日工作:25人',
  254. subtextStyle:{
  255. color: '#fff',
  256. }
  257. },
  258. tooltip: {
  259. show: false,
  260. },
  261. toolbox: {
  262. show: false,
  263. },
  264. series: [{
  265. type: 'pie',
  266. clockWise: false,
  267. radius: pieData.pieRadius,
  268. hoverAnimation: false,
  269. center: ['50%', '50%'],
  270. data: [{
  271. value: 25,
  272. label: {
  273. normal: {
  274. formatter: '{d}%',
  275. position: 'outside',
  276. show: true,
  277. textStyle: {
  278. fontSize: pieData.itemSize,
  279. fontWeight: 'normal',
  280. color: '#ffd325'
  281. }
  282. }
  283. },
  284. itemStyle: {
  285. normal: {
  286. color: '#ffd325',
  287. shadowColor: '#ffd325',
  288. shadowBlur: 10
  289. }
  290. }
  291. }, {
  292. value: 75,
  293. name: '未工作',
  294. itemStyle: {
  295. normal: {
  296. color: 'rgba(44,59,70,1)', // 未完成的圆环的颜色
  297. label: {
  298. show: false
  299. },
  300. labelLine: {
  301. show: false
  302. }
  303. },
  304. emphasis: {
  305. color: 'rgba(44,59,70,1)' // 未完成的圆环的颜色
  306. }
  307. },
  308. itemStyle: {
  309. normal: {
  310. color: '#11284e',
  311. shadowColor: '#11284e',
  312. }
  313. },
  314. }]
  315. }]
  316. }
  317. var pieOption2 = {
  318. title: {
  319. x: 'center',
  320. y: pieData.pieTop,
  321. text: '车辆',
  322. textStyle: {
  323. fontWeight: 'normal',
  324. color: '#32ffc7',
  325. fontSize: pieData.titleSize
  326. },
  327. subtext: '总数:100辆\n今日工作:75辆人',
  328. subtextStyle:{
  329. color: '#fff',
  330. }
  331. },
  332. tooltip: {
  333. show: false,
  334. },
  335. toolbox: {
  336. show: false,
  337. },
  338. series: [{
  339. type: 'pie',
  340. clockWise: false,
  341. radius: pieData.pieRadius,
  342. hoverAnimation: false,
  343. center: ['50%', '50%'],
  344. data: [{
  345. value: 75,
  346. label: {
  347. normal: {
  348. formatter: '{d}%',
  349. position: 'outside',
  350. show: true,
  351. textStyle: {
  352. fontSize: pieData.itemSize,
  353. fontWeight: 'normal',
  354. color: '#32ffc7'
  355. }
  356. }
  357. },
  358. itemStyle: {
  359. normal: {
  360. color: '#32ffc7',
  361. shadowColor: '#32ffc7',
  362. shadowBlur: 10
  363. }
  364. }
  365. }, {
  366. value: 25,
  367. name: '未工作',
  368. itemStyle: {
  369. normal: {
  370. color: 'rgba(44,59,70,1)', // 未完成的圆环的颜色
  371. label: {
  372. show: false
  373. },
  374. labelLine: {
  375. show: false
  376. }
  377. },
  378. emphasis: {
  379. color: 'rgba(44,59,70,1)' // 未完成的圆环的颜色
  380. }
  381. },
  382. itemStyle: {
  383. normal: {
  384. color: '#11284e',
  385. shadowColor: '#11284e',
  386. }
  387. },
  388. }]
  389. }]
  390. }
  391. var pieOption3 = {
  392. title: {
  393. x: 'center',
  394. y: pieData.pieTop2,
  395. text: '运单',
  396. textStyle: {
  397. fontWeight: 'normal',
  398. color: '#1eb6fe',
  399. fontSize: pieData.titleSize
  400. },
  401. subtext: '总数:100单\n正常单:50单\n异常单:50单',
  402. subtextStyle:{
  403. color: '#fff',
  404. }
  405. },
  406. tooltip: {
  407. show: false,
  408. },
  409. toolbox: {
  410. show: false,
  411. },
  412. series: [{
  413. type: 'pie',
  414. clockWise: false,
  415. radius: pieData.pieRadius,
  416. hoverAnimation: false,
  417. center: ['50%', '50%'],
  418. data: [{
  419. value: 50,
  420. label: {
  421. normal: {
  422. formatter: '{d}%',
  423. position: 'outside',
  424. show: true,
  425. textStyle: {
  426. fontSize: pieData.itemSize,
  427. fontWeight: 'normal',
  428. color: '#1eb6fe'
  429. }
  430. }
  431. },
  432. itemStyle: {
  433. normal: {
  434. color: '#1eb6fe',
  435. shadowColor: '#1eb6fe',
  436. shadowBlur: 10
  437. }
  438. }
  439. }, {
  440. value: 50,
  441. name: '未工作',
  442. itemStyle: {
  443. normal: {
  444. color: 'rgba(44,59,70,1)', // 未完成的圆环的颜色
  445. label: {
  446. show: false
  447. },
  448. labelLine: {
  449. show: false
  450. }
  451. },
  452. emphasis: {
  453. color: 'rgba(44,59,70,1)' // 未完成的圆环的颜色
  454. }
  455. },
  456. itemStyle: {
  457. normal: {
  458. color: '#11284e',
  459. shadowColor: '#11284e',
  460. }
  461. },
  462. }]
  463. }]
  464. }
  465. //弹出框调用ECharts柱状图
  466. summaryBar = echarts.init(document.getElementById('summaryBar'));
  467. var barOption = {
  468. tooltip: {
  469. trigger: 'item',
  470. formatter: function(params) {
  471. var res = '本月'+params.name+'号运单数:'+params.data;
  472. return res;
  473. }
  474. },
  475. grid: {
  476. top: '20%',
  477. left: '15%',
  478. width: '80%',
  479. height: '80%',
  480. containLabel: true
  481. },
  482. xAxis: {
  483. data: ['美的南沙分厂','美的商业空调事业部','佛山信华'],
  484. axisLabel: {
  485. show: true,
  486. textStyle: {
  487. fontSize: '12px',
  488. color: '#fff',
  489. }
  490. },
  491. axisLine:{
  492. lineStyle:{
  493. color:'#fff',
  494. width:1,
  495. }
  496. }
  497. },
  498. yAxis: {
  499. axisLabel: {
  500. show: true,
  501. textStyle: {
  502. fontSize: '12px',
  503. color: '#fff',
  504. }
  505. },
  506. axisLine:{
  507. lineStyle:{
  508. color:'#fff',
  509. width:1,
  510. }
  511. },
  512. splitLine:{
  513. show:false,
  514. }
  515. },
  516. series :{
  517. name: '',
  518. type: 'bar',
  519. barWidth : 20,
  520. data: ['15','13','17'],
  521. itemStyle: {
  522. normal: {
  523. color: new echarts.graphic.LinearGradient(
  524. 0, 0, 0, 1,
  525. [
  526. {offset: 0, color: '#3876cd'},
  527. {offset: 0.5, color: '#45b4e7'},
  528. {offset: 1, color: '#54ffff'}
  529. ]
  530. ),
  531. },
  532. },
  533. },
  534. }
  535. //弹出框调用ECharts折线图
  536. summaryLine = echarts.init(document.getElementById('summaryLine'));
  537. var lineOption = {
  538. tooltip: {
  539. trigger: 'item',
  540. formatter: function(params) {
  541. var res = '本月'+params.name+'号运单数:'+params.data;
  542. return res;
  543. }
  544. },
  545. grid: {
  546. top: '20%',
  547. left: '0%',
  548. width: '100%',
  549. height: '80%',
  550. containLabel: true
  551. },
  552. xAxis: {
  553. data: ['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31'],
  554. axisLabel: {
  555. show: true,
  556. textStyle: {
  557. fontSize: '12px',
  558. color: '#3e70b0',
  559. }
  560. },
  561. axisLine:{
  562. lineStyle:{
  563. color:'#0e2c52',
  564. width:1,
  565. }
  566. }
  567. },
  568. yAxis: {
  569. axisLabel: {
  570. show: true,
  571. textStyle: {
  572. fontSize: '12px',
  573. color: '#3e70b0',
  574. }
  575. },
  576. axisLine:{
  577. lineStyle:{
  578. color:'#0e2c52',
  579. width:1,
  580. }
  581. },
  582. splitLine:{
  583. show:true,
  584. lineStyle:{
  585. color:'#0e2c52',
  586. width:1,
  587. }
  588. }
  589. },
  590. series :{
  591. name: '',
  592. type: 'line',
  593. data: ['5','14','3','6','8','18','11','4','8','7','16','13','6','10','11','9','19','13','4','20','12','7','13','15','8','3','9','16','11','16','8'],
  594. areaStyle: {
  595. normal:{
  596. color: 'rgba(79,237,247,0.3)',
  597. }
  598. },
  599. itemStyle: {
  600. normal: {
  601. lineStyle: {
  602. color: '#00dafb',
  603. width: 1,
  604. },
  605. color: '#00dafb',
  606. },
  607. },
  608. },
  609. }
  610. summaryPie1.setOption(pieOption1);
  611. summaryPie2.setOption(pieOption2);
  612. summaryPie3.setOption(pieOption3);
  613. summaryBar.setOption(barOption);
  614. summaryLine.setOption(lineOption);
  615. }
  616. //弹窗
  617. $('.summaryBtn').on('click',function(){
  618. $('.filterbg').show();
  619. $('.popup').show();
  620. $('.popup').width('3px');
  621. $('.popup').animate({height: '76%'},400,function(){
  622. $('.popup').animate({width: '82%'},400);
  623. });
  624. setTimeout(summaryShow,800);
  625. });
  626. $('.popupClose').on('click',function(){
  627. $('.popupClose').css('display','none');
  628. $('.summary').hide();
  629. summaryPie1.clear();
  630. summaryPie2.clear();
  631. summaryPie3.clear();
  632. summaryBar.clear();
  633. summaryLine.clear();
  634. $('.popup').animate({width: '3px'},400,function(){
  635. $('.popup').animate({height: 0},400);
  636. });
  637. setTimeout(summaryHide,800);
  638. });
  639. function summaryShow(){
  640. $('.popupClose').css('display','block');
  641. $('.summary').show();
  642. setSummary();
  643. };
  644. function summaryHide(){
  645. $('.filterbg').hide();
  646. $('.popup').hide();
  647. $('.popup').width(0);
  648. };
  649. $(window).resize(function(){
  650. myChart1.resize();
  651. try{
  652. summaryPie1.resize();
  653. summaryPie2.resize();
  654. summaryPie3.resize();
  655. summaryBar.resize();
  656. summaryLine.resize();
  657. }catch(err){
  658. return false;
  659. }
  660. });
  661. /***************2018-01-03增加js****************/
  662. //地图上的搜索
  663. $('.searchBtn').on('click',function(){
  664. $(this).hide();
  665. $('.searchInner').addClass('open');
  666. setTimeout(function(){
  667. $('.searchInner').find('form').show();
  668. },400);
  669. });
  670. $('.search').on('click',function(event){
  671. event.stopPropagation();
  672. });
  673. $('body').on('click',function(){
  674. $('.searchInner').find('form').hide();
  675. $('.searchInner').removeClass('open');
  676. setTimeout(function(){
  677. $('.searchBtn').show();
  678. },400);
  679. });
  680. //车辆状态滚动条样式
  681. $('.stateUl').niceScroll({
  682. cursorcolor: "#045978",//#CC0071 光标颜色
  683. cursoropacitymax: 0.6, //改变不透明度非常光标处于活动状态(scrollabar“可见”状态),范围从1到0
  684. touchbehavior: false, //使光标拖动滚动像在台式电脑触摸设备
  685. cursorwidth: "4px", //像素光标的宽度
  686. cursorborder: "0", // 游标边框css定义
  687. cursorborderradius: "4px",//以像素为光标边界半径
  688. autohidemode: false //是否隐藏滚动条
  689. });
  690. //车辆信息工作时间表
  691. //模拟数据
  692. var carData = [
  693. {
  694. dateLable: "2018-01-01 星期一",
  695. data: {
  696. workTime: [
  697. {start: "07:30",end: "13:15"},
  698. {start: "14:40",end: "21:50"}
  699. ],
  700. standard: [
  701. {start: "00:00",end: "05:00"},
  702. {start: "08:00",end: "12:00"},
  703. {start: "14:00",end: "19:00"}
  704. ]
  705. }
  706. },
  707. {
  708. dateLable: "2018-01-02 星期二",
  709. data: {
  710. workTime: [
  711. {start: "03:10",end: "09:40"}
  712. ],
  713. standard: [
  714. {start: "00:00",end: "05:00"},
  715. {start: "08:00",end: "12:00"},
  716. {start: "14:00",end: "19:00"}
  717. ]
  718. }
  719. },
  720. {
  721. dateLable: "2018-01-03 星期三",
  722. data: {
  723. workTime: [
  724. {start: "06:15",end: "14:08"},
  725. {start: "15:53",end: "24:00"}
  726. ],
  727. standard: [
  728. {start: "00:00",end: "05:00"},
  729. {start: "08:00",end: "12:00"},
  730. {start: "14:00",end: "19:00"}
  731. ]
  732. }
  733. },
  734. {
  735. dateLable: "2018-01-04 星期四",
  736. data: {
  737. workTime: [
  738. {start: "00:00",end: "07:32"},
  739. {start: "12:20",end: "19:50"}
  740. ],
  741. standard: [
  742. {start: "00:00",end: "05:00"},
  743. {start: "08:00",end: "12:00"},
  744. {start: "14:00",end: "19:00"}
  745. ]
  746. }
  747. },
  748. {
  749. dateLable: "2018-01-05 星期五",
  750. data: {
  751. workTime: [
  752. {start: "06:15",end: "17:20"}
  753. ],
  754. standard: [
  755. {start: "00:00",end: "05:00"},
  756. {start: "08:00",end: "12:00"},
  757. {start: "14:00",end: "19:00"}
  758. ]
  759. }
  760. },
  761. {
  762. dateLable: "2018-01-06 星期六",
  763. data: {
  764. workTime: [
  765. {start: "14:40",end: "22:38"}
  766. ],
  767. standard: [
  768. {start: "00:00",end: "05:00"},
  769. {start: "08:00",end: "12:00"},
  770. {start: "14:00",end: "19:00"}
  771. ]
  772. }
  773. },
  774. {
  775. dateLable: "2018-01-07 星期天",
  776. data: {
  777. workTime: [
  778. {start: "06:30",end: "12:20"},
  779. {start: "14:25",end: "20:33"}
  780. ],
  781. standard: [
  782. {start: "00:00",end: "05:00"},
  783. {start: "08:00",end: "12:00"},
  784. {start: "14:00",end: "19:00"}
  785. ]
  786. }
  787. }
  788. ];
  789. function Schedule(){
  790. var Item = $('.dataBox');
  791. var Size = Item.eq(0).width();
  792. var oDay = 24*60;
  793. function getMin(timeStr){
  794. var timeArray = timeStr.split(":");
  795. var Min = parseInt(timeArray[0])*60+parseInt(timeArray[1]);
  796. return Min;
  797. }
  798. //在时间轴上添加工作时间数据
  799. Item.each(function(i,ele){
  800. var ItemData = carData[i];
  801. function addData(obj,dataParam){
  802. for(var j=0;j<dataParam.length;j++){
  803. var pos,wid,workCeil,sDate,sStart,sEnd,sConsume;
  804. pos = getMin(dataParam[j].start)/oDay*100+'%';
  805. wid = (getMin(dataParam[j].end)-getMin(dataParam[j].start))/oDay*100+'%';
  806. sDate = ItemData.dateLable;
  807. sStart = dataParam[j].start;
  808. sEnd = dataParam[j].end;
  809. sConsume = getMin(dataParam[j].end)-getMin(dataParam[j].start);
  810. workCeil = '<span style="width: '+wid+';left: '+pos+'" sDate="'+sDate+'" sStart="'+sStart+'" sEnd="'+sEnd+'" sConsume="'+sConsume+'"></span>';
  811. obj.append(workCeil);
  812. }
  813. }
  814. addData($(ele).find('.workTime'),ItemData.data.workTime);
  815. addData($(ele).find('.standard'),ItemData.data.standard);
  816. });
  817. //添加总用时与总单数
  818. var Total = $('.totalItem');
  819. Total.each(function(i,ele){
  820. var ItemData = carData[i].data.workTime;
  821. var timeUsed = 0;
  822. for(var j=0;j<ItemData.length;j++){
  823. timeUsed+= getMin(ItemData[j].end)-getMin(ItemData[j].start);
  824. }
  825. var realHour = Math.floor(timeUsed/60);
  826. $(ele).find('span').eq(0).html(realHour+':'+(timeUsed-realHour*60));
  827. $(ele).find('span').eq(1).html(ItemData.length);
  828. });
  829. };
  830. Schedule();
  831. //鼠标移入运单显示信息框
  832. $('.workTime').on('mouseenter','span',function(ev){
  833. var x = ev.clientX;
  834. var y = ev.clientY;
  835. var sDate,sStart,sEnd,sConsume,infos,sHour,sMin;
  836. sDate = $(this).attr("sDate");
  837. sStart = $(this).attr("sStart");
  838. sEnd = $(this).attr("sEnd");
  839. sConsume = $(this).attr("sConsume");
  840. sHour = Math.floor(sConsume/60);
  841. sMin = sConsume-sHour*60;
  842. infos = '<div class="workTimeInfo" style="left:'+x+'px;top:'+y+'px"><p>日期:'+sDate+'</p><p>开始时间:'+sStart+'</p><p>结束时间:'+sEnd+'</p><p>总用时:'+sHour+'小时'+sMin+'分钟</p></div>';
  843. $('body').append(infos);
  844. });
  845. $('.workTime').on('mouseout',function(){
  846. $('.workTimeInfo').remove();
  847. });
  848. //车辆信息弹出框的显示隐藏效果
  849. $('.infoBtn').on('click',function(){
  850. $('.filterbg').show();
  851. $('.carInfo').show();
  852. $('.carInfo').width('3px');
  853. $('.carInfo').animate({height: '76%'},400,function(){
  854. $('.carInfo').animate({width: '82%'},400);
  855. });
  856. setTimeout(function(){
  857. $('.infoBox').show();
  858. $('.carClose').css('display','block');
  859. },800);
  860. });
  861. $('.carClose').on('click',function(){
  862. $('.carClose').css('display','none');
  863. $('.infoBox').hide();
  864. $('.carInfo').animate({width: '3px'},400,function(){
  865. $('.carInfo').animate({height: 0},400);
  866. });
  867. setTimeout(function(){
  868. $('.filterbg').hide();
  869. $('.carInfo').hide();
  870. $('.carInfo').width(0);
  871. },800);
  872. });
  873. });