pestDiscern.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="pest-discern" v-if="pests.length">
  3. <view class="pest-discern__header">
  4. <view class="pest-discern__title">
  5. 虫害识别
  6. </view>
  7. </view>
  8. <view class="pest-discern__content">
  9. <view class="pest-discern__item" v-for="(item,index) in pests" :key="index">
  10. <view class="pest-discern__item-title">
  11. {{ item.name }}
  12. </view>
  13. <view class="pest-discern__item-content">
  14. <u-line-progress :active-color="item.color" :percent="item.percent" :show-percent="false" height="8"></u-line-progress>
  15. </view>
  16. <view class="pest-discern__item-count">
  17. {{ item.count }}
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. props: {
  26. total: {
  27. type: Number,
  28. default: 0
  29. },
  30. pest_order: {
  31. type: Object,
  32. default: () => ({})
  33. }
  34. },
  35. watch:{
  36. pest_order:{
  37. handler(val){
  38. this.pests = [];
  39. let index = 0;
  40. for(let key in val){
  41. index++;
  42. this.pests.push({
  43. color: this.colors[index],
  44. name: key,
  45. count: val[key] || 0,
  46. percent: (val[key] / this.total) * 100
  47. })
  48. }
  49. },
  50. deep: true
  51. }
  52. },
  53. data() {
  54. return {
  55. colors:[
  56. '#FF5951',
  57. '#66EDED',
  58. '#E67B3E',
  59. '#6DE28B',
  60. '#FFC97A',
  61. '#E7EB4B',
  62. '#1561F3',
  63. '#FA73F5',
  64. '#159AFF',
  65. '#FA73F5'
  66. ],
  67. pests: []
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .pest-discern {
  74. width: 100%;
  75. padding: 32rpx;
  76. box-sizing: border-box;
  77. background: #fff;
  78. border-radius: 16rpx;
  79. }
  80. .pest-discern__header {
  81. padding: 0rpx 0rpx 20rpx 0rpx;
  82. font-size: 32rpx;
  83. color: #042118;
  84. font-family: 'Source Han Sans CN VF';
  85. font-weight: 700;
  86. }
  87. .pest-discern__title {
  88. font-size: 28rpx;
  89. color: #042118;
  90. font-family: 'Source Han Sans CN VF';
  91. font-weight: 500;
  92. }
  93. .pest-discern__item {
  94. display: flex;
  95. width: 100%;
  96. margin-bottom: 20rpx;
  97. align-items: center;
  98. .pest-discern__item-title{
  99. width: 120rpx;
  100. font-size: 28rpx;
  101. color: #042118;
  102. font-family: 'Source Han Sans CN VF';
  103. font-weight: 400;
  104. // 超出隐藏
  105. overflow: hidden;
  106. text-overflow: ellipsis;
  107. white-space: nowrap;
  108. }
  109. .pest-discern__item-content{
  110. flex: 1;
  111. margin: 0 20rpx;
  112. }
  113. .pest-discern__item-count{
  114. width: 80rpx;
  115. font-size: 28rpx;
  116. color: #042118;
  117. text-align: right;
  118. }
  119. }
  120. </style>