panel.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <div class="my-panel">
  3. <el-button v-show="reIdentify" class="resetPest" @click="resetPest" size="small" type="primary"
  4. >重新识别</el-button
  5. >
  6. <el-tabs type="border-card" class="infoCard">
  7. <el-tab-pane label="图像识别">
  8. <div class="info title">
  9. <span>{{ title }}</span>
  10. <span>数量</span>
  11. </div>
  12. <div class="info" v-for="(value, key) in pestObj" :key="key">
  13. <span>{{ key }}</span>
  14. <span>{{ value }}</span>
  15. </div>
  16. </el-tab-pane>
  17. </el-tabs>
  18. </div>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'Panel',
  23. props: {
  24. rectangles: {
  25. type: Array,
  26. default: () => []
  27. },
  28. reIdentify: {
  29. type: Boolean,
  30. default: true
  31. },
  32. title: {
  33. type: String,
  34. default: '目录'
  35. }
  36. },
  37. data() {
  38. return {}
  39. },
  40. computed: {
  41. pestObj() {
  42. let obj = {}
  43. this.rectangles.forEach(item => {
  44. if (obj[item.text]) {
  45. obj[item.text]++
  46. } else {
  47. obj[item.text] = 1
  48. }
  49. })
  50. return obj
  51. }
  52. },
  53. created() {},
  54. mounted() {
  55. let obj = {}
  56. this.rectangles.forEach(item => {
  57. if (obj[item.text]) {
  58. obj[item.text]++
  59. } else {
  60. obj[item.text] = 0
  61. }
  62. })
  63. console.log('子组件mounted', obj)
  64. },
  65. watch: {},
  66. methods: {
  67. resetPest() {
  68. // 通知业务上层处理逻辑
  69. this.$emit('resetPest')
  70. }
  71. },
  72. components: {}
  73. }
  74. </script>
  75. <style scoped lang="less">
  76. /deep/ .custom-ffffff .el-tabs--border-card {
  77. box-shadow: none;
  78. }
  79. .my-panel {
  80. position: relative;
  81. height: 100%;
  82. }
  83. .resetPest {
  84. position: absolute;
  85. top: 4px;
  86. right: 9px;
  87. z-index: 1;
  88. }
  89. .infoCard {
  90. position: relative;
  91. height: 100%;
  92. overflow: auto;
  93. box-sizing: border-box;
  94. // box-shadow: none !important;
  95. border: 1px solid #e4e7ed;
  96. /deep/ .el-tabs__content {
  97. height: calc(100% - 70px);
  98. overflow: auto;
  99. padding: 14px 0 !important;
  100. &::-webkit-scrollbar {
  101. width: 8px; /* 滚动条宽度 */
  102. }
  103. /* 滚动条轨道 */
  104. &::-webkit-scrollbar-track {
  105. background: #f6f6f6; /* 轨道背景 */
  106. border-radius: 8px; /* 圆角 */
  107. }
  108. /* 滚动条滑块 */
  109. &::-webkit-scrollbar-thumb {
  110. background: #b6b6b6; /* 滑块颜色 */
  111. border-radius: 8px; /* 圆角 */
  112. }
  113. /* 鼠标悬停时的滑块样式 */
  114. &::-webkit-scrollbar-thumb:hover {
  115. background: #555; /* 悬停时颜色 */
  116. }
  117. }
  118. .info {
  119. display: flex;
  120. padding: 10px;
  121. align-items: center;
  122. font-weight: 600;
  123. justify-content: space-between;
  124. height: 40px;
  125. box-sizing: border-box;
  126. color: #333;
  127. // margin-top: 16px;
  128. font-size: 14px;
  129. border-bottom: 1px solid #e4e7ed;
  130. }
  131. .title {
  132. background: #ebedf0;
  133. margin-top: 0;
  134. }
  135. }
  136. .infoCard.el-tabs--border-card {
  137. box-shadow: none !important;
  138. }
  139. </style>