panel.vue 2.9 KB

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