ckt的看板部分
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.

477 lines
16 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <div class="container">
  3. <div style="width:100%;height: 25%;text-align:center;">
  4. <TimeC></TimeC>
  5. <div style="float: left;width: 25%;height: 100%;text-align:center;margin-left: 37% ">
  6. <div style="height: 40%;width: 100%;text-align: center;margin-top: 3%;">
  7. <label style="font-size: 30px;color: #ffffff">派工单完成情况</label>
  8. </div>
  9. <div style="height: 34%;width: 100%;margin-top: 10%">
  10. <div
  11. style="width: 12%;height: 40%;float: left;margin-left: 5%;border-radius: 10px; background-color: #ec6566;"></div>
  12. <div style="width: 25%;height: 50%;float: left;margin-left: 3%;">
  13. <label style="font-size: 16px;color:#ffffff; ">未完工</label>
  14. </div>
  15. <div
  16. style="width: 12%;height: 40%;float: left;margin-left: 8%;border-radius: 10px; background-color: #90ca75;"></div>
  17. <div style="width: 25%;height: 50%;float: left;margin-left: 3%;">
  18. <label style="font-size: 16px;color:#ffffff; ">已完工</label>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. <div style="width:100%;height: 40%;">
  24. <div id="pie0" style="float:left;margin-left: 0px; margin-top: 0px; width: 33%; height:100%;"></div>
  25. <div id="pie1" style="float:left;margin-left: 0px; margin-top: 0px; width: 33%; height:100%;"></div>
  26. <div id="pie2" style="float:left;margin-left: 0px; margin-top: 0px; width: 33%; height:100%;"></div>
  27. </div>
  28. <div style="width:100%;height: 40%">
  29. <div id="pie3" style="float:left;margin-left: 0px; margin-top: 0px; width: 33%; height:100%;"></div>
  30. <div id="pie4" style="float:left;margin-left: 0px; margin-top: 0px; width: 33%; height:100%;"></div>
  31. <div id="pie5" style="float:left;margin-left: 0px; margin-top: 0px; width: 33%; height:100%;"></div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import TimeC from "./time"
  37. export default {
  38. name: "scheduledBoard",
  39. data() {
  40. return {
  41. currentDate: null,
  42. stringdate: null,
  43. itemNum: null,
  44. myChart0: null,
  45. myChart1: null,
  46. myChart2: null,
  47. myChart3: null,
  48. myChart4: null,
  49. myChart5: null,
  50. countTimer: null,
  51. refreshTime: 30,
  52. loader: null,
  53. timer: null,
  54. handler: null,
  55. nextPage: null,
  56. }
  57. },
  58. components: {
  59. TimeC
  60. },
  61. methods: {
  62. load() {
  63. let that = this;
  64. $.ajax({
  65. url: "/board/getJumpConfig",
  66. type: "post",
  67. data: {"boardName": 'scheduledBoard'},
  68. dataType: "json",
  69. success: (data) => {
  70. if (data.rows2 != "" && data.rows2 != null) {
  71. that.nextPage = data.rows2;
  72. if (data.rows != "" && data.rows != null) {
  73. let jumpTime = Number(data.rows);
  74. if (jumpTime > 0) {
  75. that.countTimer = window.setTimeout(() => {
  76. that.jump()
  77. }, 1000 * jumpTime);
  78. }
  79. }
  80. }
  81. }
  82. }).fail(() => {
  83. this.$router.push("/")
  84. })
  85. },
  86. jump() {
  87. clearTimeout(this.countTimer);
  88. clearInterval(this.loader);
  89. clearInterval(this.timer);
  90. clearInterval(this.handler);
  91. $.ajax({
  92. url: "/board/kanKanYouMeiYouDiaoXian",
  93. type: "post",
  94. data: {},
  95. dataType: "json",
  96. success: (data) => {
  97. this.$router.push(this.nextPage);
  98. }
  99. }).fail(() => {
  100. this.$router.push("/")
  101. })
  102. },
  103. getItemNoNumber() {
  104. let that = this;
  105. $.ajax({
  106. url: "/board/getBoardData",
  107. type: "POST",
  108. contentType: 'application/json;charset=utf-8',
  109. async: false,
  110. data: null,// 你的formid
  111. dataType: "JSON",
  112. success: (data) => {
  113. if (data.success) {
  114. that.itemNum = data.rows.length;
  115. /* console.log(itemNum)*/
  116. } else {
  117. alert(data.msg);
  118. }
  119. }
  120. });
  121. },
  122. load2() {
  123. let that = this;
  124. let timeout;
  125. if (that.itemNum == 0) {
  126. timeout = 1;
  127. } else {
  128. timeout = Math.ceil(that.itemNum / 6);
  129. }
  130. $.ajax({
  131. url: "/board/getRefreshTime",
  132. type: "post",
  133. data: {"boardName": 'scheduledBoard'},
  134. dataType: "json",
  135. success: (data) => {
  136. if (data.rows != "" && data.rows != null) {
  137. that.refreshTime = Number(data.rows);
  138. if(that.refreshTime ==0){
  139. that.refreshTime =5;
  140. }
  141. }
  142. that.loader = window.setInterval(() => {
  143. this.getBoardData()
  144. }, timeout * 1000 * this.refreshTime);
  145. that.getBoardData();
  146. },
  147. })
  148. },
  149. getBoardData() {
  150. $.ajax({
  151. url: "/board/getBoardData",
  152. type: "POST",
  153. contentType: 'application/json;charset=utf-8',
  154. async: false,
  155. data: null,// 你的formid
  156. dataType: "JSON",
  157. success: (data) => {
  158. if (data.success) {
  159. let data_temp = data.rows;
  160. this.boardLoading(data_temp);
  161. } else {
  162. this.jump();
  163. }
  164. },
  165. error: () => {
  166. this.jump();
  167. }
  168. });
  169. },
  170. boardLoading(data_temp) {
  171. let that = this
  172. that.doOne(data_temp);
  173. var x = 0;
  174. that.handler = setInterval(function () {
  175. that.myChart0.dispose();
  176. that.myChart0 = null;
  177. that.myChart1.dispose();
  178. that.myChart1 = null;
  179. that.myChart2.dispose();
  180. that.myChart2 = null;
  181. that.myChart3.dispose();
  182. that.myChart3 = null;
  183. that.myChart4.dispose();
  184. that.myChart4 = null;
  185. that.myChart5.dispose();
  186. that.myChart5 = null;
  187. for (let i = 6; i < 12 && i + x < data_temp.length; i++) {
  188. if (data_temp[i + x].percentage >= 100) {
  189. var color = '#90ca75';
  190. } else {
  191. var color = '#fff300';
  192. }
  193. // if (i == 6) {
  194. //
  195. // that.myChart0.dispose();
  196. // } else if (i == 7) {
  197. // that.myChart1.dispose();
  198. // } else if (i == 8) {
  199. // that.myChart2.dispose();
  200. // } else if (i == 9) {
  201. // that.myChart3.dispose();
  202. // } else if (i == 10) {
  203. // that.myChart4.dispose();
  204. // } else if (i == 11) {
  205. // that.myChart5.dispose();
  206. // }
  207. let option = ({
  208. title: [{
  209. text: '工序:' + data_temp[i + x].itemNo,
  210. // x 设置水平安放位置,默认左对齐,可选值:'center' ¦ 'left' ¦ 'right' ¦ {number}(x坐标,单位px)
  211. x: 'center',
  212. // y 设置垂直安放位置,默认全图顶端,可选值:'top' ¦ 'bottom' ¦ 'center' ¦ {number}(y坐标,单位px)
  213. y: 'bottom',
  214. // itemGap设置主副标题纵向间隔,单位px,默认为10,
  215. backgroundColor: '#EEE',
  216. // 主标题文本样式设置
  217. textStyle: {
  218. fontSize: 16,
  219. fontWeight: 'bolder',
  220. color: '#fff300'
  221. }
  222. },
  223. {
  224. text: data_temp[i + x].percentage + '%',
  225. // x 设置水平安放位置,默认左对齐,可选值:'center' ¦ 'left' ¦ 'right' ¦ {number}(x坐标,单位px)
  226. x: 'center',
  227. // y 设置垂直安放位置,默认全图顶端,可选值:'top' ¦ 'bottom' ¦ 'center' ¦ {number}(y坐标,单位px)
  228. y: 'center',
  229. // itemGap设置主副标题纵向间隔,单位px,默认为10,
  230. backgroundColor: 'rgba(0,0,0,0)',
  231. // 主标题文本样式设置
  232. textStyle: {
  233. fontSize: 18,
  234. fontWeight: 'bolder',
  235. color: color
  236. },
  237. }],
  238. series: [
  239. {
  240. name: '完成数量统计',
  241. type: 'pie', // 设置图表类型为饼图
  242. radius: ['40%', '70%'], // 饼图的半径,外半径为可视区尺寸(容器高宽中较小一项)的 55% 长度。
  243. data: [ // 数据数组,name 为数据项名称,value 为数据项值
  244. {value: data_temp[i + x].approveQty, name: ''},
  245. {value: data_temp[i + x].unapproveQty, name: ''}
  246. ],
  247. color: ['#90ca75', '#ec6566'],
  248. labelLine: {
  249. normal: {
  250. show: false
  251. }
  252. },
  253. label: {
  254. normal: {
  255. position: 'outer', // 设置标签位置,默认在饼状图外 可选值:'outer' ¦ 'inner(饼状图上)'
  256. // formatter: '{a} {b} : {c}个 ({d}%)' 设置标签显示内容 ,默认显示{b}
  257. // {a}指series.name {b}指series.data的name
  258. // {c}指series.data的value {d}%指这一部分占总数的百分比
  259. formatter: '{b}'
  260. }
  261. }
  262. }
  263. ]
  264. });
  265. if (i == 6) {
  266. that.myChart0 = echarts.init(document.getElementById('pie0'));
  267. that.myChart0.setOption(option);
  268. } else if (i == 7) {
  269. that.myChart1 = echarts.init(document.getElementById('pie1'));
  270. that.myChart1.setOption(option);
  271. } else if (i == 8) {
  272. that.myChart2 = echarts.init(document.getElementById('pie2'));
  273. that.myChart2.setOption(option);
  274. } else if (i == 9) {
  275. that.myChart3 = echarts.init(document.getElementById('pie3'));
  276. that.myChart3.setOption(option);
  277. } else if (i == 10) {
  278. that.myChart4 = echarts.init(document.getElementById('pie4'));
  279. that.myChart4.setOption(option);
  280. } else if (i == 11) {
  281. that.myChart5 = echarts.init(document.getElementById('pie5'));
  282. that.myChart5.setOption(option);
  283. }
  284. }
  285. x = Number(x) + 6;
  286. if (x + 6 >= data_temp.length) {
  287. /*console.log(x);*/
  288. clearInterval(that.handler);
  289. }
  290. }, 1000 * that.refreshTime)
  291. },
  292. doOne(data_temp) {
  293. for (let i = 0; i < 6 && i < data_temp.length; i++) {
  294. if (data_temp[i].percentage >= 100) {
  295. var color = '#90ca75';
  296. } else {
  297. var color = '#fff300';
  298. }
  299. if (i == 0) {
  300. if (this.myChart0) {
  301. this.myChart0.dispose();
  302. }
  303. // $("#pie0").removeAttr("_echarts_instance_").empty();
  304. } else if (i == 1) {
  305. if (this.myChart1) {
  306. this.myChart1.dispose();
  307. }
  308. // $("#pie1").removeAttr("_echarts_instance_").empty();
  309. } else if (i == 2) {
  310. if (this.myChart2) {
  311. this.myChart2.dispose();
  312. }
  313. // $("#pie2").removeAttr("_echarts_instance_").empty();
  314. } else if (i == 3) {
  315. if (this.myChart3) {
  316. this.myChart3.dispose();
  317. }
  318. // $("#pie3").removeAttr("_echarts_instance_").empty();
  319. } else if (i == 4) {
  320. if (this.myChart4) {
  321. this.myChart4.dispose();
  322. }
  323. // $("#pie4").removeAttr("_echarts_instance_").empty();
  324. } else if (i == 5) {
  325. if (this.myChart5) {
  326. this.myChart5.dispose();
  327. }
  328. // $("#pie5").removeAttr("_echarts_instance_").empty();
  329. }
  330. let option = ({
  331. title: [{
  332. text: '工序:' + data_temp[i].itemNo,
  333. // x 设置水平安放位置,默认左对齐,可选值:'center' ¦ 'left' ¦ 'right' ¦ {number}(x坐标,单位px)
  334. x: 'center',
  335. // y 设置垂直安放位置,默认全图顶端,可选值:'top' ¦ 'bottom' ¦ 'center' ¦ {number}(y坐标,单位px)
  336. y: 'bottom',
  337. // itemGap设置主副标题纵向间隔,单位px,默认为10,
  338. backgroundColor: '#EEE',
  339. // 主标题文本样式设置
  340. textStyle: {
  341. fontSize: 16,
  342. fontWeight: 'bolder',
  343. color: '#fff300'
  344. }
  345. },
  346. {
  347. text: data_temp[i].percentage + '%',
  348. // x 设置水平安放位置,默认左对齐,可选值:'center' ¦ 'left' ¦ 'right' ¦ {number}(x坐标,单位px)
  349. x: 'center',
  350. // y 设置垂直安放位置,默认全图顶端,可选值:'top' ¦ 'bottom' ¦ 'center' ¦ {number}(y坐标,单位px)
  351. y: 'center',
  352. // itemGap设置主副标题纵向间隔,单位px,默认为10,
  353. backgroundColor: 'rgba(0,0,0,0)',
  354. // 主标题文本样式设置
  355. textStyle: {
  356. fontSize: 18,
  357. fontWeight: 'bolder',
  358. color: color
  359. },
  360. }],
  361. series: [
  362. {
  363. name: '完成数量统计',
  364. type: 'pie', // 设置图表类型为饼图
  365. radius: ['40%', '70%'], // 饼图的半径,外半径为可视区尺寸(容器高宽中较小一项)的 55% 长度。
  366. data: [ // 数据数组,name 为数据项名称,value 为数据项值
  367. {value: data_temp[i].approveQty, name: ''},
  368. {value: data_temp[i].unapproveQty, name: ''}
  369. ],
  370. color: ['#90ca75', '#ec6566'],
  371. labelLine: {
  372. normal: {
  373. show: false
  374. }
  375. },
  376. label: {
  377. normal: {
  378. position: 'outer', // 设置标签位置,默认在饼状图外 可选值:'outer' ¦ 'inner(饼状图上)'
  379. // formatter: '{a} {b} : {c}个 ({d}%)' 设置标签显示内容 ,默认显示{b}
  380. // {a}指series.name {b}指series.data的name
  381. // {c}指series.data的value {d}%指这一部分占总数的百分比
  382. formatter: '{b}'
  383. }
  384. }
  385. }
  386. ]
  387. });
  388. // var myChart = echarts.init(document.getElementById('pie' + i));
  389. //
  390. // myChart.setOption(option);
  391. if (i == 0) {
  392. this.myChart0 = echarts.init(document.getElementById('pie0'));
  393. this.myChart0.setOption(option);
  394. } else if (i == 1) {
  395. this.myChart1 = echarts.init(document.getElementById('pie1'));
  396. this.myChart1.setOption(option);
  397. } else if (i == 2) {
  398. this.myChart2 = echarts.init(document.getElementById('pie2'));
  399. this.myChart2.setOption(option);
  400. } else if (i == 3) {
  401. this.myChart3 = echarts.init(document.getElementById('pie3'));
  402. this.myChart3.setOption(option);
  403. } else if (i == 4) {
  404. this.myChart4 = echarts.init(document.getElementById('pie4'));
  405. this.myChart4.setOption(option);
  406. } else if (i == 5) {
  407. this.myChart5 = echarts.init(document.getElementById('pie5'));
  408. this.myChart5.setOption(option);
  409. }
  410. }
  411. }
  412. },
  413. mounted() {
  414. this.load();
  415. this.getItemNoNumber();
  416. this.load2();
  417. },
  418. beforeDestroy() {
  419. clearInterval(this.handler);
  420. clearTimeout(this.countTimer);
  421. clearInterval(this.loader);
  422. },
  423. destroyed() {
  424. this.myChart0.clear()
  425. this.myChart0.dispose()
  426. this.myChart0 = null
  427. window.removeEventListener('resize', () => { this.myChart0.resize() })
  428. this.myChart1.clear()
  429. this.myChart1.dispose()
  430. this.myChart1 = null
  431. window.removeEventListener('resize', () => { this.myChart1.resize() })
  432. this.myChart2.clear()
  433. this.myChart2.dispose()
  434. this.myChart2 = null
  435. window.removeEventListener('resize', () => { this.myChart2.resize() })
  436. this.myChart3.clear()
  437. this.myChart3.dispose()
  438. this.myChart3 = null
  439. window.removeEventListener('resize', () => { this.myChart3.resize() })
  440. this.myChart4.clear()
  441. this.myChart4.dispose()
  442. this.myChart4 = null
  443. window.removeEventListener('resize', () => { this.myChart4.resize() })
  444. this.myChart5.clear()
  445. this.myChart5.dispose()
  446. this.myChart5 = null
  447. window.removeEventListener('resize', () => { this.myChart5.resize() })
  448. },
  449. }
  450. </script>
  451. <style scoped>
  452. .container {
  453. height: 100%;
  454. }
  455. </style>