You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

589 lines
22 KiB

3 years ago
  1. <template>
  2. <div class="container" >
  3. <div style="width:100%;height: 19%;text-align:center;">
  4. <div style="float: left;width: 25%;height: 100%;text-align:left; ">
  5. <div style="height: 60%;width: 100%;text-align: left;margin-top: 1%">
  6. <label style="font-size: 40px;color: #9c0202;margin-left: 2%">Jtem 江天电子</label>
  7. </div>
  8. </div>
  9. <TimeC></TimeC>
  10. <!-- <div style="font-size: 26px;float: right;color: #ffffff;height: 100%" v-html="clock"></div>-->
  11. <div style="float: left;width: 35%;height: 100%;text-align:center;margin-left: 7% ">
  12. <div style="height: 45%;width: 100%;text-align: center;margin-top: 3%;">
  13. <label style="font-size: 30px;color: #ffffff">生产情况看板<br>Production Board</label>
  14. </div>
  15. </div>
  16. </div>
  17. <div style="width:100%;height: 79%;">
  18. <!-- <div style="float: left;height: 100%;width: 35%; ">-->
  19. <!-- <div style="height: 12%;width: 100%;margin-top: 1%">-->
  20. <!-- <div-->
  21. <!-- style="width: 12%;height: 40%;float: left;margin-left: 18%;border-radius: 10px; background-color: #ec6566;"></div>-->
  22. <!-- <div style="width: 25%;height: 50%;float: left;margin-left: 3%;">-->
  23. <!-- <label style="font-size: 16px;color:#ffffff; ">未完成</label>-->
  24. <!-- </div>-->
  25. <!-- <div-->
  26. <!-- style="width: 12%;height: 40%;float: left;margin-left: 1%;border-radius: 10px; background-color: #90ca75;"></div>-->
  27. <!-- <div style="width: 25%;height: 50%;float: left;margin-left: 3%;">-->
  28. <!-- <label style="font-size: 16px;color:#ffffff; ">已完成</label>-->
  29. <!-- </div>-->
  30. <!-- </div>-->
  31. <!-- <div style="height: 88%;width: 100%;">-->
  32. <!-- <div id="pie" style="float:left;margin-left: 0px; margin-top: 0%; width: 100%; height:80%;"></div>-->
  33. <!-- </div>-->
  34. <!-- </div>-->
  35. <div style="float: left;height: 100%;width: 38%; ">
  36. <div style="height: 28%;width: 100%;margin-top: 0.5%" class="board2">
  37. <el-table
  38. height="150"
  39. :data="tableList2"
  40. :cell-style="board2Function"
  41. style="width: 100%">
  42. <el-table-column
  43. prop="qty1"
  44. header-align="center"
  45. align="center"
  46. min-width="40"
  47. label="派工数/PlanQty"
  48. :render-header="renderHeader"
  49. >
  50. </el-table-column>
  51. <el-table-column
  52. prop="qty2"
  53. header-align="center"
  54. align="center"
  55. min-width="63"
  56. label="合格数/ApproveQty"
  57. :render-header="renderHeader">
  58. </el-table-column>
  59. <el-table-column
  60. prop="qty3"
  61. header-align="center"
  62. align="center"
  63. min-width="60"
  64. label="不合格数/UnApproveQty"
  65. :render-header="renderHeader">
  66. </el-table-column>
  67. <el-table-column
  68. prop="qty4"
  69. header-align="center"
  70. align="center"
  71. min-width="62"
  72. label="未完成/UnReportedQty"
  73. :render-header="renderHeader">
  74. </el-table-column>
  75. </el-table>
  76. </div>
  77. <div style="height: 72%;width: 100%;">
  78. <div id="pie" style="float:left;margin-left: 0px; margin-top: -3%; width: 100%; height:100%;"></div>
  79. </div>
  80. </div>
  81. <div style="float: left;height: 53%;width: 53%;margin-left:3% " class="board">
  82. <el-table
  83. height="250"
  84. :data="tableList"
  85. style="width: 100%">
  86. <el-table-column
  87. prop="resourceDesc"
  88. header-align="center"
  89. align="center"
  90. min-width="72"
  91. label="生产线/ProduceLine"
  92. :render-header="renderHeader"
  93. >
  94. </el-table-column>
  95. <el-table-column
  96. prop="qtyRequired"
  97. header-align="center"
  98. align="center"
  99. min-width="100"
  100. label="派工数量/PlanQty"
  101. :render-header="renderHeader">
  102. </el-table-column>
  103. <el-table-column
  104. prop="qtyReported"
  105. header-align="center"
  106. align="center"
  107. min-width="90"
  108. label="完成数量/ReportedQty"
  109. :render-header="renderHeader">
  110. </el-table-column>
  111. <el-table-column
  112. prop="qtyApprove"
  113. header-align="center"
  114. align="center"
  115. min-width="108"
  116. label="合格数量/ApproveQty"
  117. :render-header="renderHeader">
  118. </el-table-column>
  119. <el-table-column
  120. prop="qtyUnReported"
  121. header-align="center"
  122. align="center"
  123. min-width="100"
  124. label="未完成数量/UnReportedQty"
  125. :render-header="renderHeader">>
  126. </el-table-column>
  127. </el-table>
  128. </div>
  129. <div style="float: left;height: 47%;width: 62%; ">
  130. <div id="main" style="width: 100%;height: 100%;margin-top: 0px"></div>
  131. </div>
  132. </div>
  133. </div>
  134. </template>
  135. <script>
  136. import {getNewScheduledTableData,
  137. getRefreshTime,
  138. getScheduledData
  139. } from '@/api/production/board.js'
  140. import TimeC from "@/views/modules/board/newTime.vue"
  141. export default {
  142. name: "newScheduledBoard",
  143. data() {
  144. return {
  145. myChart: null,
  146. number1:0,
  147. number2:0,
  148. option:null,
  149. chartDom:null,
  150. option2:null,
  151. tableList:null,
  152. pieData:null,
  153. barList:null,
  154. resourceId:'',
  155. height:200,
  156. // ip:'',
  157. refreshTime:5,
  158. tableList2:[],
  159. }
  160. },
  161. components: {
  162. TimeC
  163. },
  164. methods: {
  165. getRefresh(){
  166. getRefreshTime('scheduledBoard').then(({data}) => {
  167. if (data.rows != "" && data.rows != null) {
  168. this.refreshTime = Number(data.rows);
  169. if(this.refreshTime ==0){
  170. this.refreshTime =5;
  171. }
  172. }else {
  173. this.refreshTime =5;
  174. }
  175. })
  176. },
  177. searchData(){
  178. this.getRefresh();
  179. getScheduledData().then(({data}) => {
  180. this.pieData=data.pieData;
  181. this.barList=data.barList;
  182. this.tableList2=[],
  183. this.tableList2.push(this.pieData);
  184. let pieData2={
  185. qty1: '-',
  186. qty2: this.pieData.per2 +'%',
  187. qty3: this.pieData.per3 +'%',
  188. qty4: this.pieData.per4 +'%',
  189. }
  190. this.tableList2.push(pieData2)
  191. this.draw();
  192. this.draw2()
  193. this.getTableData();
  194. // window.setTimeout(() => {
  195. // this.getTableData();
  196. // }, 1000* Number(this.refreshTime));
  197. // window.setTimeout(() => {
  198. // this.getTableData();
  199. // }, 2000*Number(this.refreshTime));
  200. // window.setTimeout(() => {
  201. // this.getTableData();
  202. // }, 3000*Number(this.refreshTime));
  203. })
  204. },
  205. draw(){
  206. // if (data_temp[i].percentage >= 100) {
  207. if (true) {
  208. var color = '#90ca75';
  209. } else {
  210. var color = '#fff300';
  211. }
  212. if (this.myChart!=null) {
  213. this.myChart.clear()
  214. }
  215. this.option = ({
  216. title: [{
  217. text: '总生产情况\nProduction State' ,
  218. // text: '工序:' + data_temp[i + x].itemNo,
  219. // x 设置水平安放位置,默认左对齐,可选值:'center' ¦ 'left' ¦ 'right' ¦ {number}(x坐标,单位px)
  220. x: 'center',
  221. // y 设置垂直安放位置,默认全图顶端,可选值:'top' ¦ 'bottom' ¦ 'center' ¦ {number}(y坐标,单位px)
  222. y: '264px',
  223. // itemGap设置主副标题纵向间隔,单位px,默认为10,
  224. backgroundColor: '#EEE',
  225. // 主标题文本样式设置
  226. textStyle: {
  227. fontSize: 18,
  228. fontWeight: 'bolder',
  229. color: '#fff300'
  230. }
  231. },
  232. // {
  233. // text: this.pieData.qtyPercent + '%',
  234. // // text: data_temp[i + x].percentage + '%',
  235. // // x 设置水平安放位置,默认左对齐,可选值:'center' ¦ 'left' ¦ 'right' ¦ {number}(x坐标,单位px)
  236. // x: 'center',
  237. // // y 设置垂直安放位置,默认全图顶端,可选值:'top' ¦ 'bottom' ¦ 'center' ¦ {number}(y坐标,单位px)
  238. // y: 'center',
  239. // // itemGap设置主副标题纵向间隔,单位px,默认为10,
  240. // backgroundColor: 'rgba(0,0,0,0)',
  241. // // 主标题文本样式设置
  242. // textStyle: {
  243. // fontSize: 20,
  244. // fontWeight: 'bolder',
  245. // color: color
  246. // },
  247. // }
  248. ],
  249. // legend: {
  250. // orient: 'vertical',
  251. // left: 10,
  252. // data: ['直接访问', '邮件营销'],
  253. // color: ['#90ca75', '#ec6566'],
  254. // },
  255. series: [
  256. {
  257. name: '报工数量统计',
  258. type: 'pie', // 设置图表类型为饼图
  259. radius: ['45%', '75%'], // 饼图的半径,外半径为可视区尺寸(容器高宽中较小一项)的 55% 长度。
  260. data: [ // 数据数组,name 为数据项名称,value 为数据项值
  261. // {value: data_temp[i + x].approveQty, name: ''},
  262. // {value: data_temp[i + x].unapproveQty, name: ''}
  263. {value: this.pieData.qty2, name: ''},
  264. {value: this.pieData.qty3, name: ''},
  265. {value: this.pieData.qty4, name: ''}
  266. ],
  267. color: ['#90ca75','#dbd81a', '#ec6566'],
  268. labelLine: {
  269. normal: {
  270. show: false
  271. }
  272. },
  273. label: {
  274. normal: {
  275. position: 'inner', // 设置标签位置,默认在饼状图外 可选值:'outer' ¦ 'inner(饼状图上)'
  276. // formatter: '{a} {b} : {c}个 ({d}%)' 设置标签显示内容 ,默认显示{b}
  277. // {a}指series.name {b}指series.data的name
  278. // {c}指series.data的value {d}%指这一部分占总数的百分比
  279. // formatter: '{d}'+'%',
  280. formatter:function(data){
  281. return data.percent.toFixed(1)+"%";
  282. }
  283. }
  284. },
  285. }
  286. ]
  287. });
  288. this.myChart = echarts.init(document.getElementById('pie'));
  289. this.myChart.setOption(this.option);
  290. },
  291. getTableData() {
  292. getNewScheduledTableData(this.number2).then(({data}) => {
  293. this.tableList=data.rows;
  294. this.number2=data.num;
  295. })
  296. },
  297. draw2(){
  298. if (this.myChart2!=null) {
  299. this.myChart2.clear()
  300. }
  301. let barData=[];
  302. let valueData=[];
  303. let valueApproveData=[];
  304. for (let a = 0; a <this.barList.length ; a++) {
  305. let resourceData={
  306. value: this.barList[a].resourceDesc,
  307. textStyle: {
  308. color: '#EEE'
  309. }
  310. }
  311. barData.push(resourceData);
  312. valueData[a]=this.barList[a].qtyPercent;
  313. valueApproveData[a]=this.barList[a].approvePercent;
  314. }
  315. this.myChart2 = echarts.init(document.getElementById('main'));
  316. // document.getElementById('main').style.height="300px";
  317. // if(this.option2!=null){
  318. // document.getElementById('main').removeAttribute('_echarts_instance_')
  319. // this.option2 = null
  320. // }
  321. this.option2 = {
  322. color:["#90ca75", "#00a7ff"],
  323. legend: {
  324. textStyle: { //图例文字的样式
  325. color: '#fff',
  326. // fontSize: 12
  327. },
  328. },
  329. tooltip: {},
  330. xAxis:[
  331. {
  332. type: 'category',
  333. // data: xAxisData
  334. data:barData,
  335. axisLine:{
  336. lineStyle: {
  337. color:'#eee'
  338. }
  339. },
  340. axisTick: {
  341. lineStyle: {
  342. color:'#eee'
  343. }
  344. },
  345. },
  346. ],
  347. yAxis:[
  348. {
  349. type: 'value',
  350. min: 0,
  351. max: 100,
  352. axisLabel: {
  353. formatter: '{value} %'
  354. },
  355. axisLine:{
  356. lineStyle: {
  357. color:'#eee'
  358. }
  359. },
  360. axisTick: {
  361. lineStyle: {
  362. color:'#eee'
  363. }
  364. },
  365. // splitLine:{
  366. // show:false,
  367. // }
  368. }
  369. ],
  370. series: [
  371. {
  372. 'name': '当日完成率',
  373. 'type': 'bar',
  374. 'emphasis': {
  375. focus: 'series'
  376. },
  377. // data: seriesData1
  378. 'data': valueData,
  379. // [this.barList[6].num1, this.barList[5].num1, this.barList[4].num1, this.barList[3].num1, this.barList[2].num1, this.barList[1].num1, this.barList[0].num1],
  380. 'label':{
  381. show:true,
  382. position:'top',
  383. textStyle: {
  384. color: '#fff300',
  385. fontSize: 11
  386. }
  387. },
  388. },
  389. {
  390. 'name': '当日良品率',
  391. 'type': 'bar',
  392. 'emphasis': {
  393. focus: 'series'
  394. },
  395. // data: seriesData1
  396. 'data': valueApproveData,
  397. // [this.barList[6].num1, this.barList[5].num1, this.barList[4].num1, this.barList[3].num1, this.barList[2].num1, this.barList[1].num1, this.barList[0].num1],
  398. 'label':{
  399. show:true,
  400. position:'top',
  401. textStyle: {
  402. color: '#fff300',
  403. fontSize: 11
  404. }
  405. },
  406. },
  407. ]
  408. };
  409. this.option2 && this.myChart2.setOption(this.option2);
  410. },
  411. getDate(value) {
  412. var date = value.substring(5, 10);
  413. return date;
  414. },
  415. timeDo(){
  416. let that=this;
  417. getRefreshTime('scheduledBoard').then(({data}) => {
  418. if (data.rows != "" && data.rows != null) {
  419. that.refreshTime = Number(data.rows);
  420. if(that.refreshTime ==0){
  421. that.refreshTime =5;
  422. }
  423. }else {
  424. that.refreshTime =5;
  425. }
  426. window.setInterval(() => {
  427. this.searchData();
  428. // }, 4000*Number(that.refreshTime));
  429. }, 1000*that.refreshTime);
  430. })
  431. // $.ajax({
  432. // url: "/board/getRefreshTime",
  433. // type: "post",
  434. // data: {"boardName": 'newScheduledBoard'},
  435. // dataType: "json",
  436. // success: (data) => {
  437. // if (data.rows != "" && data.rows != null) {
  438. // that.refreshTime = Number(data.rows);
  439. // if(that.refreshTime ==0){
  440. // that.refreshTime =5;
  441. // }
  442. // }else {
  443. // that.refreshTime =5;
  444. // }
  445. // window.setInterval(() => {
  446. // this.searchData();
  447. // }, 4000*Number(that.refreshTime));
  448. // },
  449. // })
  450. },
  451. renderHeader(h, { column, $index }) {
  452. return h("span", {}, [
  453. h("span", {}, column.label.split("/")[0]),
  454. h("br"),
  455. h("span", {}, column.label.split("/")[1])
  456. ]);
  457. },
  458. board2Function({row, column, rowIndex, columnIndex}){
  459. if(columnIndex==1){
  460. return 'background-color: #90ca75;'
  461. }
  462. if(columnIndex==2){
  463. return 'background-color: #dbd81a;'
  464. }
  465. if(columnIndex==3){
  466. return 'background-color: #ec6566;'
  467. }
  468. }
  469. },
  470. created(){
  471. this.getRefresh();
  472. },
  473. mounted() {
  474. this.$nextTick(()=>{
  475. this.height = window.innerHeight *0.36;
  476. })
  477. // this.getTableData();
  478. this.timeDo();
  479. this.searchData();
  480. }
  481. }
  482. </script>
  483. <style >
  484. .container {
  485. height: 109%;
  486. position: fixed;
  487. top: 0;
  488. left: 0;
  489. z-index: -1;
  490. width: 100%;
  491. height: 100%;
  492. content: "";
  493. background-image: url(~@/assets/img/factory.jpg);
  494. background-size: cover;
  495. }
  496. .board .el-table .cell {
  497. line-height: 20px;
  498. font-size: 20px;
  499. height: 20px;
  500. padding: 0px;
  501. color: yellow;
  502. }
  503. /* 表格内背景颜色 */
  504. .board .el-table th, .el-table tr,.el-table td{
  505. border: 0;
  506. background-color: transparent;
  507. }
  508. /* 使表格背景透明 */
  509. .board .el-table th, .el-table tr {
  510. background-color: transparent;
  511. }
  512. /* 删除表格下横线 */
  513. .board .el-table::before {
  514. left: 0;
  515. bottom: 0;
  516. width: 100%;
  517. height: 0px;
  518. }
  519. /* 表格表头字体颜色 */
  520. .board .el-table, .el-table__expanded-cell {
  521. background-color: transparent;
  522. }
  523. .el-table thead {
  524. background-color: transparent;
  525. }
  526. .board .el-table th .cell {
  527. line-height: 20px;
  528. font-size: 15px;
  529. height: 40px;
  530. padding: 0px;
  531. color: yellow;
  532. }
  533. .board2 .el-table .cell {
  534. line-height: 18px;
  535. font-size: 18px;
  536. height: 18px;
  537. padding: 0px;
  538. color: white;
  539. }
  540. /* 表格内背景颜色 */
  541. .board2 .el-table th, .el-table tr,.el-table td{
  542. border: 0;
  543. background-color: transparent;
  544. }
  545. /* 使表格背景透明 */
  546. .board2 .el-table th, .el-table tr {
  547. background-color: transparent;
  548. }
  549. /* 删除表格下横线 */
  550. .board2 .el-table::before {
  551. left: 0;
  552. bottom: 0;
  553. width: 100%;
  554. height: 0px;
  555. }
  556. /* 表格表头字体颜色 */
  557. .board2 .el-table, .el-table__expanded-cell {
  558. background-color: transparent;
  559. }
  560. .board2 .el-table th .cell {
  561. line-height: 18px;
  562. font-size: 13px;
  563. height: 36px;
  564. padding: 0px;
  565. color: white;
  566. }
  567. </style>