efficiencyFrm.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
  6. <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  7. <title>生产数据</title>
  8. <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
  9. <!--<link rel="stylesheet" type="text/css" href="../../css/aui.css"/>-->
  10. <link rel="stylesheet" type="text/css" href="../../css/popoPicker.css"/>
  11. <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
  12. <link rel="stylesheet" href="../../css/projeck.css">
  13. <style>
  14. body,html{
  15. background: #F3F3F3;
  16. }
  17. .api_layout{
  18. /*border-top: 1px solid #37b0e9;*/
  19. padding: 13px 10px;
  20. -webkit-box-sizing: border-box;
  21. -moz-box-sizing: border-box;
  22. box-sizing: border-box;
  23. }
  24. .navs_item{
  25. padding:0;
  26. }
  27. .nav_title{
  28. padding: 0 5px;
  29. background: #F3F6FA;
  30. }
  31. .nav_title li{
  32. text-align: center;
  33. font-size: 14px;
  34. padding: 9px 0 ;
  35. color: #232627;
  36. }
  37. .li-box{
  38. height: 39px;
  39. line-height: 39px;
  40. font-size: 14px;
  41. color: #232627;
  42. }
  43. .selectData{
  44. margin-left: 10px;
  45. }
  46. #coalCuttings .li-box{
  47. height: auto;
  48. line-height: normal;
  49. padding: 11px 0;
  50. font-size: 12px;
  51. }
  52. </style>
  53. </head>
  54. <body>
  55. <div class="api_layout">
  56. <!-- 时间 -->
  57. <div class="Notice borderRa Stitle">
  58. <span class="time-box"></span>
  59. </div>
  60. <!--今日产量-->
  61. <div class="Notice borderRa beforS">
  62. <p class="Stitle centertT">今日产量</p>
  63. <div class="" style="width:100%">
  64. <canvas id="downWell" style="width: 100%;margin-top:10px;height:210px"></canvas>
  65. </div>
  66. </div>
  67. <!-- 一周产量 -->
  68. <div class="Notice borderRa">
  69. <div class="Chart">
  70. <div class="flex-start">
  71. <div class="relative Sharebox screen">
  72. <input id="button-value" class="js-picker" value="周产量趋势">
  73. <i class="lower"></i>
  74. </div>
  75. <div class=" selectTime hide">
  76. <input class="button-value startYear" value="">
  77. </div>
  78. <div class="selectTime1 hide">
  79. <input class="button-value startTime" value="">
  80. </div>
  81. </div>
  82. <div class="" style="width:100%">
  83. <canvas id="weekYield" style="width: 100%;margin-top:10px;height:210px"></canvas>
  84. </div>
  85. </div>
  86. <!--列表-->
  87. <nav>
  88. <ul class="nav_title flex-wrap">
  89. <li class="flex-con">日期</li>
  90. <li class="flex-con">晚班</li>
  91. <li class="flex-con">早班</li>
  92. <li class="flex-con">中班</li>
  93. <li class="flex-con">日产量</li>
  94. </ul>
  95. </nav>
  96. <ul class="downWellPersonnal" id="downWellPersonnal">
  97. </ul>
  98. </div>
  99. <!-- 皮带秤 产量 -->
  100. <div class="Notice borderRa beforS">
  101. <p class="Stitle centertT">皮带秤小时产量</p>
  102. <div class="" style="width:100%">
  103. <canvas id="Belt" style="width: 100%;margin-top:10px;height:210px"></canvas>
  104. </div>
  105. </div>
  106. <!-- 周割煤刀数 -->
  107. <div class="Notice borderRa">
  108. <div class="Chart">
  109. <div class="flex-start">
  110. <div class="relative Sharebox screen">
  111. <input id="button-value" class="js-coalCutting" readonly value="日割煤刀数">
  112. <i class="lower"></i>
  113. </div>
  114. <div class=" selectData hide">
  115. <input class="button-value startData" value="">
  116. </div>
  117. </div>
  118. <div class="" style="width:100%">
  119. <canvas id="coalCutting" style="width: 100%;margin-top:10px;height:210px"></canvas>
  120. </div>
  121. </div>
  122. <!--列表-->
  123. <nav>
  124. <ul class="nav_title flex-wrap">
  125. <li class="flex-con">工作面名称</li>
  126. <li class="flex-con">区队名称</li>
  127. <li class="flex-con">实际刀数</li>
  128. <li class="flex-con">计划刀数</li>
  129. </ul>
  130. </nav>
  131. <ul class="downWellPersonnal" id="coalCuttings">
  132. </ul>
  133. </div>
  134. </div>
  135. <script type="text/template" id="downWellTemplate">
  136. {{~it:value}}
  137. <li class="flex-wrap li-box centertT relative after-border">
  138. <span class="flex-con">{{=value.CurDT}}</span>
  139. <span class="flex-con">{{=getInteger(value.BanTotal1)}}吨</span>
  140. <span class="flex-con">{{=getInteger(value.BanTotal2)}}吨</span>
  141. <span class="flex-con">{{=getInteger(value.BanTotal3)}}吨</span>
  142. <span class="flex-con">{{=getInteger(value.BanTotal2) + getInteger(value.BanTotal3) + getInteger(value.BanTotal1)}}吨</span>
  143. </li>
  144. {{~}}
  145. </script>
  146. <script type="text/template" id="coalCuttingsTemplate">
  147. {{~it:value}}
  148. <li class="flex-wrap li-box centertT relative after-border">
  149. <span class="flex-con">{{=value.work}}</span>
  150. <span class="flex-con">{{=value.team}}</span>
  151. <span class="flex-con">{{=value.value}}刀</span>
  152. <span class="flex-con">{{=value.plan_value}}刀</span>
  153. </li>
  154. {{~}}
  155. </script>
  156. <script src="../../script/api.js"></script>
  157. <script src="../../script/popoPicker.js"></script>
  158. <script src="../../script/doT.min.js"></script>
  159. <script src="../../script/f2.js"></script>
  160. <script src="../../script/config.js"></script>
  161. <script>
  162. var headers;
  163. var apiToast = new apiToast();
  164. apiready = function () {
  165. var info = $api.getStorage('data'),
  166. user = JSON.parse(info).data.user;
  167. token = JSON.parse(info).data.access_token;
  168. $api.html($api.dom('.time-box'), getNowFormatDate());
  169. setInterval(function () {
  170. $api.html($api.dom('.time-box'), getNowFormatDate());
  171. }, 1000)
  172. headers = {
  173. "Authorization": "Bearer " + token
  174. };
  175. openSharebox();//选择器
  176. // 图表权限
  177. chartsJurisdiction();
  178. // 监听切换tab标签,刷新页面
  179. api.addEventListener({
  180. name: 'refreshProduction'
  181. }, function(ret, err) {
  182. // 图表
  183. chartsJurisdiction();
  184. });
  185. };
  186. // 图表
  187. function chartsJurisdiction() {
  188. $api.val($api.dom('#button-value'), '周产量趋势');
  189. $api.addCls($api.dom('.selectTime1'), 'hide');
  190. $api.addCls($api.dom('.selectTime'), 'hide');
  191. getThreeyield();
  192. // 今日产量
  193. downWell()
  194. //一周的产量
  195. weekYield(false,210);
  196. // 皮带称
  197. getBeltData();
  198. // 割煤刀数
  199. coalCutting('day',false,210,'');
  200. }
  201. // 今日产量
  202. function downWell() {
  203. $http.fnReuestDataNologing(UrlRouter.getBanNowDayAllTotal,'','get','',function (ret,err) {
  204. if (ret.status === 20000) {
  205. var data = ret.data;
  206. var map = {};
  207. data.map(function(obj) {
  208. map[obj.devName] = getInteger(obj.total) + '吨';
  209. });
  210. var chart = new F2.Chart({
  211. id: 'downWell',
  212. pixelRatio: window.devicePixelRatio,
  213. padding: [20, 'auto']
  214. });
  215. chart.source(data, {
  216. percent: {
  217. formatter: function formatter(val) {
  218. return val + '吨';
  219. }
  220. }
  221. });
  222. chart.tooltip(false);
  223. chart.legend({
  224. position: 'right',
  225. itemFormatter: function itemFormatter(val) {
  226. return val + ' ' + map[val];
  227. }
  228. });
  229. chart.coord('polar', {
  230. transposed: true,
  231. innerRadius: 0.7,
  232. radius: 0.85
  233. });
  234. chart.axis(false);
  235. chart.interval().position('conts*total').color('devName', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0', '#3436C7', '#223273']).adjust('stack');
  236. chart.guide().html({
  237. position: ['50%', '45%'],
  238. html: '<div style="width: 250px;height: 40px;text-align: center;">' + '<div style="font-size: 16px">总产量</div>' + '<div style="font-size: 18px">'+getInteger(ret.data[0].count)+' 吨</div>' + '</div>'
  239. });
  240. chart.render();
  241. }
  242. })
  243. }
  244. //一周的产量
  245. function weekYield(transposed,height,type,startTime,endTime) {
  246. if(type != '年产量趋势'){
  247. var data = {
  248. dateTime:startTime,
  249. endTime:endTime
  250. };
  251. $http.fnReuestDataNologing(UrlRouter.getBanDayList,'','get',data,function(ret,err){
  252. if (ret && ret.status === 20000) {
  253. var data = ret.data;
  254. var chart = new F2.Chart({
  255. id: 'weekYield',
  256. height: height,
  257. pixelRatio: window.devicePixelRatio
  258. });
  259. chart.source(data, {
  260. 'banTotal2': {
  261. tickCount: 5
  262. }
  263. });
  264. chart.coord({
  265. transposed: transposed
  266. });
  267. chart.tooltip({
  268. custom: false, // 自定义 tooltip 内容框
  269. });
  270. chart.interval().position('curDT*total').color('devName').adjust('stack');
  271. chart.render();
  272. }
  273. });
  274. }else {
  275. $http.fnReuestDataNologing(UrlRouter.getMonthSumByYear,'','get',{year:startTime},function(ret,err){
  276. if (ret && ret.status === 20000) {
  277. var data = ret.data;
  278. var chart = new F2.Chart({
  279. id: 'weekYield',
  280. height: height,
  281. pixelRatio: window.devicePixelRatio
  282. });
  283. chart.source(data, {
  284. 'banTotal2': {
  285. tickCount: 5
  286. }
  287. });
  288. chart.coord({
  289. transposed: transposed
  290. });
  291. chart.axis('total', {
  292. line: null,
  293. grid: F2.Global._defaultAxis.grid,
  294. label: function label(text, index, total) {
  295. var textCfg = {
  296. text: text / 10000 + '万吨'
  297. };
  298. if (index === 0) {
  299. textCfg.textAlign = 'right';
  300. } else if (index === total - 1) {
  301. textCfg.textAlign = 'right';
  302. }else {
  303. textCfg.textAlign = 'right';
  304. }
  305. return textCfg;
  306. }
  307. });
  308. chart.interval().position('month*total').color('devName').adjust('stack');
  309. chart.render();
  310. }
  311. });
  312. }
  313. }
  314. // 选择时间
  315. function openSharebox() {
  316. var myDate = new Date();
  317. var tYear = myDate.getFullYear();
  318. var tmonth = myDate.getMonth()+1
  319. $api.val($api.dom('.startYear'), tYear+'年');
  320. $api.val($api.dom('.startTime'), tYear+'-'+ (tmonth<10? 0+""+tmonth:tmonth));
  321. $api.val($api.dom('.startData'), tYear+'-'+ (tmonth<10? 0+""+tmonth:tmonth));
  322. new popoPicker('.js-picker',{
  323. container:'.screen',
  324. wheels: [{
  325. infinite: false,
  326. //selected: 3,
  327. data:[
  328. {value:0,display:'周产量趋势'},
  329. {value:1,display:'月产量趋势'},
  330. {value:2,display:'年产量趋势'}
  331. ]
  332. }],
  333. background:'light',
  334. save:function (data) {
  335. switch (data.result[0].display) {
  336. case '周产量趋势':
  337. $api.addCls($api.dom('.selectTime1'), 'hide');
  338. $api.addCls($api.dom('.selectTime'), 'hide');
  339. weekYield(false,210);
  340. break;
  341. case '月产量趋势':
  342. $api.removeCls($api.dom('.selectTime1'), 'hide');
  343. $api.addCls($api.dom('.selectTime'), 'hide');
  344. weekYield(true,700,'',tYear+'-'+ (tmonth<10? 0+""+tmonth+'-'+0+""+1:tmonth),tYear+'-'+ (tmonth<10? 0+""+tmonth+'-'+31:tmonth),'');
  345. break;
  346. case '年产量趋势':
  347. $api.addCls($api.dom('.selectTime1'), 'hide');
  348. $api.removeCls($api.dom('.selectTime'), 'hide');
  349. weekYield(false,300,data.result[0].display,tYear)
  350. break;
  351. default:
  352. }
  353. }
  354. });
  355. new popoDate('.startTime',{
  356. container:'.selectTime1',
  357. background:'light',
  358. save:function (data) {
  359. weekYield(true,700,'',data+'-'+0+""+1,data+'-'+31);
  360. }
  361. });
  362. new popoYear('.startYear',{
  363. container:'.selectTime',
  364. background:'light',
  365. save:function (data) {
  366. $api.val($api.dom('.startYear'), data+'年');
  367. weekYield(false,300,'年产量趋势',data)
  368. }
  369. });
  370. new popoPicker('.js-coalCutting',{
  371. container:'.screen',
  372. wheels: [{
  373. infinite: false,
  374. //selected: 3,
  375. data:[
  376. {value:'day',display:'日割煤刀数'},
  377. {value:'week',display:'周割煤刀数'},
  378. {value:'month',display:'月割煤刀数'}
  379. ]
  380. }],
  381. background:'light',
  382. save:function (data) {
  383. switch (data.result[0].display) {
  384. case '日割煤刀数':
  385. $api.addCls($api.dom('.selectData'), 'hide');
  386. coalCutting(data.result[0].value,false,210,'');
  387. break;
  388. case '周割煤刀数':
  389. $api.addCls($api.dom('.selectData'), 'hide');
  390. coalCutting(data.result[0].value,false,210,'');
  391. break;
  392. case '月割煤刀数':
  393. $api.removeCls($api.dom('.selectData'), 'hide');
  394. coalCutting('month',false,210,'');
  395. break;
  396. default:
  397. }
  398. }
  399. });
  400. new popoDate('.startData',{
  401. container:'.selectData',
  402. background:'light',
  403. save:function (data) {
  404. coalCutting('month',false,210,data);
  405. }
  406. });
  407. }
  408. // 皮带称数据
  409. function getBeltData() {
  410. $http.fnReuestDataNologing(UrlRouter.getDayHourTotal,'','get','',function (ret,err) {
  411. if (ret.status === 20000) {
  412. var data = ret.data;
  413. var chart = new F2.Chart({
  414. id: 'Belt',
  415. pixelRatio: window.devicePixelRatio
  416. });
  417. chart.source(data, {
  418. time: {
  419. type: 'timeCat',
  420. mask: 'hh:mm',
  421. tickCount: 5,
  422. range: [0, 1]
  423. }
  424. });
  425. chart.tooltip({
  426. showCrosshairs: true,
  427. showItemMarker: false,
  428. onShow: function onShow(ev) {
  429. var items = ev.items;
  430. items[0].name = null;
  431. items[0].value = items[0].value +'吨';
  432. }
  433. });
  434. chart.axis('day', {
  435. label: function label(text, index, total) {
  436. var textCfg = {};
  437. if (index === 0) {
  438. textCfg.textAlign = 'left';
  439. } else if (index === total - 1) {
  440. textCfg.textAlign = 'right';
  441. }
  442. return textCfg;
  443. }
  444. });
  445. if (ret.data.length != 0) {
  446. chart.legend({
  447. custom: true,
  448. itemWidth: null,
  449. nameStyle: {
  450. textAlign: 'middle',
  451. fontSize: '14',
  452. textBaseline: 'middle'
  453. },
  454. items: [{
  455. name: '皮带秤',
  456. marker: {
  457. symbol:'circle',
  458. radius: 5,
  459. fill: ret.data[ret.data.length-1].runState === 'Stop'? '#E74C3C':'#2ECC71'
  460. }
  461. }]
  462. });
  463. }
  464. chart.line().position('time*total').shape('smooth');
  465. chart.point().position('time*total').shape('smooth').style({
  466. stroke: '#fff',
  467. lineWidth: 1
  468. });
  469. chart.render();
  470. }
  471. })
  472. }
  473. // 周割煤刀数
  474. function coalCutting(type,transposed,height,date) {
  475. var param = {
  476. type:type,
  477. date:date
  478. }
  479. $http.fnReuestDataNologing(UrlRouter.getEfficacyCutMerge,'','post',param,function (ret,err) {
  480. if (ret.code === 0) {
  481. // 图表
  482. var data = ret.data['total'];
  483. var chart = new F2.Chart({
  484. id: 'coalCutting',
  485. height: height,
  486. pixelRatio: window.devicePixelRatio
  487. });
  488. chart.source(data);
  489. chart.coord({
  490. transposed: transposed
  491. });
  492. chart.interval().position('label*value').color('type').adjust({
  493. type: 'dodge',
  494. marginRatio: 0.05 // 设置分组间柱子的间距
  495. });
  496. chart.render();
  497. // 周割煤刀数列表
  498. $apis.html(coalCuttings,'#coalCuttingsTemplate',ret.data['info']);
  499. }
  500. })
  501. }
  502. // 前三天的产量
  503. function getThreeyield() {
  504. var curTime = new Date().getTime();
  505. var endDate = curTime - (3 * 3600 * 24 * 1000);
  506. var dateTime = curTime - (1 * 3600 * 24 * 1000);
  507. var data = {
  508. dateTime:formatDateTime(endDate),
  509. endTime:formatDateTime(dateTime)
  510. };
  511. $http.fnReuestDataNologing(UrlRouter.getBanDayThree,'','get',data,function(ret,err){
  512. if (ret.status === 20000) {
  513. $apis.html(downWellPersonnal,'#downWellTemplate',ret.data);
  514. }
  515. });
  516. }
  517. // 取整数
  518. function getInteger(data) {
  519. return Math.floor(data/1)
  520. }
  521. </script>
  522. </body>
  523. </html>