right.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div id="right" >
  3. <div class="bg-color-black">
  4. <div class="plan-header">
  5. <div class="d-flex pt-1 pl-2 jc-center">
  6. <span class="text mx-2 fw-b">各车间达成进度</span>
  7. </div>
  8. </div>
  9. <div class="plan-body">
  10. <dv-scroll-board
  11. :config="config"
  12. ref="scrollBoard"
  13. class="scroll-board"
  14. />
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: 'ProductionPlan',
  22. data() {
  23. return {
  24. config: {
  25. header: ['车间', '计划数', '完成数', '达成比例%'],
  26. data: [],
  27. rowNum: 20,
  28. headerHeight: 35,
  29. headerBGC: 'rgba(15,19,37,0.1)',
  30. oddRowBGC: 'rgba(15,19,37,0.1)',
  31. evenRowBGC: 'rgba(23,28,51,0.1)',
  32. columnWidth: [200, 190, 150],
  33. align: ['center', 'center', 'center', 'center']
  34. },
  35. refreshInterval: null,
  36. apiCaller: 'KB!ALLWC!PROCESS'
  37. }
  38. },
  39. mounted() {
  40. this.initDataRefresh()
  41. },
  42. beforeDestroy() {
  43. this.clearRefreshInterval()
  44. },
  45. methods: {
  46. initDataRefresh() {
  47. this.fetchData()
  48. this.refreshInterval = setInterval(this.fetchData, 10000)
  49. },
  50. clearRefreshInterval() {
  51. if (this.refreshInterval) {
  52. clearInterval(this.refreshInterval)
  53. this.refreshInterval = null
  54. }
  55. },
  56. async fetchData() {
  57. try {
  58. const response = await this.$http.get("kanban/datalist.action", {
  59. params: {
  60. caller: this.apiCaller,
  61. _noc: 1,
  62. page: 1,
  63. pageSize: 100,
  64. condition: "1=1"
  65. }
  66. })
  67. this.processResponseData(response.data.data)
  68. } catch (error) {
  69. console.error('数据获取失败:', error)
  70. }
  71. },
  72. processResponseData(rawData) {
  73. try {
  74. const dataList = JSON.parse(rawData)
  75. const formattedData = dataList.map(item => this.formatRowData(item))
  76. this.$refs.scrollBoard.updateRows(formattedData)
  77. } catch (error) {
  78. console.error('数据处理失败:', error)
  79. }
  80. },
  81. formatRowData(item) {
  82. const rowClass = 'colorGrass';
  83. return [
  84. this.createCell(item.v_wccode, rowClass),
  85. this.createCell(item.v_planqty, rowClass),
  86. this.createCell(item.v_madeqty, rowClass),
  87. this.createCell(item.v_rate, rowClass)
  88. ]
  89. },
  90. createCell(content, className) {
  91. return `<span class="${className} fs-xxl">${content || ''}</span>`
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. $box-height: 950px;
  98. $box-width: 944px;
  99. #right {
  100. padding: 13px;
  101. height: $box-height;
  102. width: $box-width;
  103. border-radius: 5px;
  104. .bg-color-black {
  105. height: $box-height - 25px;
  106. border-radius: 10px;
  107. padding: 5px;
  108. display: flex;
  109. flex-direction: column;
  110. }
  111. .plan-header {
  112. .text {
  113. color: #c3cbde;
  114. font-size: 25px;
  115. }
  116. .header-content {
  117. border-radius: 10px;
  118. padding: 5px;
  119. background-color: rgba(15, 19, 37, 0.1);
  120. .header-title {
  121. color: #c3cbde;
  122. font-weight: bold;
  123. display: flex;
  124. justify-content: center;
  125. align-items: center;
  126. padding: 5px 10px;
  127. }
  128. }
  129. }
  130. .plan-body {
  131. margin-top: 5px;
  132. .scroll-board {
  133. height: 920px;
  134. border-radius: 10px;
  135. ::v-deep .header {
  136. font-size: 23px;
  137. }
  138. }
  139. }
  140. }
  141. </style>