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.

175 lines
4.0 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="excel_container">
  3. <div class="common_grid" v-for="item in 14 * 14" :key="item">
  4. <div v-if="isTableHeader(item)" class="table_header_box">
  5. {{ getHeaderText(item) }}
  6. </div>
  7. <div :class="getClass(item)" v-else @click="showCoreDetail(item)">
  8. <p class="line1">{{ getLine(item, 1) }}</p>
  9. <p class="line2">{{ getLine(item, 2) }}</p>
  10. </div>
  11. </div>
  12. </div>
  13. </template>
  14. <script setup>
  15. import { useImageStore, useTaskStore, useCheckStore } from '@/store'
  16. const imageStore = useImageStore()
  17. const taskStore = useTaskStore()
  18. const checkStore = useCheckStore()
  19. const props = defineProps({
  20. excelData: {
  21. type: Array,
  22. default: [],
  23. },
  24. })
  25. const showCoreDetail = index => {
  26. const arr = props.excelData.filter(item => item.num == index)
  27. if (checkStore.manualCheck) {
  28. if (arr?.length > 0) {
  29. const item = arr[0]
  30. checkStore.updateCheckNumber(item.serialNumber)
  31. }
  32. }
  33. // 只有正确或者错误的才可以点击出详情
  34. if (arr?.length > 0) {
  35. const item = arr[0]
  36. if ([1, 2].includes(item.result)) {
  37. // 将item存入store中
  38. imageStore.updateShowImage(true)
  39. imageStore.updateCoreInfo(item)
  40. }
  41. }
  42. }
  43. const getClass = index => {
  44. // 需要用item 获取真正实体
  45. const arr = props.excelData.filter(item => item.num == index)
  46. if (arr?.length > 0) {
  47. const item = arr[0]
  48. if (item.result == 1) {
  49. // 检测正确
  50. return 'box success'
  51. } else if (item.result == 2) {
  52. // 检测错误
  53. return 'box fail'
  54. } else if (
  55. checkStore.manualCheck &&
  56. checkStore.checkNumber == item.serialNumber
  57. ) {
  58. return 'box process'
  59. } else if (
  60. taskStore.currentCoord == item.serialNumber &&
  61. taskStore.taskStatus == 1
  62. ) {
  63. // 正在检测
  64. return 'box process'
  65. } else {
  66. // 待检测
  67. if (canClick(index)) {
  68. return 'box cur'
  69. } else {
  70. return 'box'
  71. }
  72. }
  73. }
  74. }
  75. const canClick = item => {
  76. if (getLine(item, 1) && getLine(item, 2)) {
  77. return true
  78. }
  79. return false
  80. }
  81. const getLine = (index, position) => {
  82. const arr = props.excelData.filter(item => item.num == index)
  83. if (arr?.length > 0) {
  84. const obj = arr[0]
  85. if (obj.secondSign && obj.firstSign) {
  86. if (position == 1) {
  87. // 截取后4位
  88. return obj.firstSign.substr(-4)
  89. } else {
  90. // 截取后4位
  91. return obj.secondSign.substr(-4)
  92. }
  93. }
  94. }
  95. return ''
  96. }
  97. const isTableHeader = index => {
  98. return index <= 14 || index % 14 == 1
  99. }
  100. const getHeaderText = index => {
  101. if (index <= 14 && index > 1) {
  102. return index - 1
  103. }
  104. const arr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N']
  105. if (index % 14 == 1) {
  106. return arr[parseInt(index / 14) - 1]
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .excel_container {
  112. display: grid;
  113. grid-template-columns: repeat(14, 1fr);
  114. grid-template-rows: repeat(14, 1fr);
  115. border: 1px solid #ebebeb;
  116. box-sizing: border-box;
  117. border-radius: 6px;
  118. overflow: hidden;
  119. .common_grid {
  120. border: 1px solid #ebebeb;
  121. margin-left: -1px;
  122. margin-top: -1px;
  123. .box {
  124. width: 100%;
  125. height: 100%;
  126. padding: 7px;
  127. background: #ffffff;
  128. font-size: 18px;
  129. font-weight: 500;
  130. color: #b3b3b3;
  131. box-sizing: border-box;
  132. display: flex;
  133. flex-direction: column;
  134. align-items: center;
  135. justify-content: space-between;
  136. }
  137. .success {
  138. cursor: pointer;
  139. background: #e1fff1;
  140. color: #01ff82;
  141. }
  142. .fail {
  143. cursor: pointer;
  144. background: #fee2e2;
  145. color: #fe0c0c;
  146. }
  147. .process {
  148. cursor: pointer;
  149. background: #4350dc;
  150. color: #ffffff;
  151. }
  152. .cur {
  153. cursor: pointer;
  154. }
  155. .table_header_box {
  156. background: #f1f1f1;
  157. box-sizing: border-box;
  158. font-size: 26px;
  159. font-weight: bold;
  160. color: #3d3d3d;
  161. display: flex;
  162. align-items: center;
  163. justify-content: center;
  164. height: 100%;
  165. }
  166. }
  167. }
  168. </style>