pestDiscern.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="pest-discern">
  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. {{ total }}
  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. percent: (val[key] / this.total) * 100
  46. })
  47. }
  48. },
  49. deep: true
  50. }
  51. },
  52. data() {
  53. return {
  54. colors:[
  55. '#FF5951',
  56. '#66EDED',
  57. '#E67B3E',
  58. '#6DE28B',
  59. '#FFC97A',
  60. '#E7EB4B',
  61. '#1561F3',
  62. '#FA73F5',
  63. '#159AFF',
  64. '#FA73F5'
  65. ],
  66. pests: []
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .pest-discern {
  73. width: 100%;
  74. padding: 32rpx;
  75. box-sizing: border-box;
  76. background: #fff;
  77. border-radius: 16rpx;
  78. }
  79. .pest-discern__header {
  80. padding: 20rpx 0rpx;
  81. font-size: 32rpx;
  82. color: #042118;
  83. font-family: 'Source Han Sans CN VF';
  84. font-weight: 700;
  85. }
  86. .pest-discern__title {
  87. font-size: 32rpx;
  88. color: #042118;
  89. font-family: 'Source Han Sans CN VF';
  90. font-weight: 700;
  91. }
  92. .pest-discern__item {
  93. display: flex;
  94. width: 100%;
  95. margin-bottom: 20rpx;
  96. align-items: center;
  97. .pest-discern__item-title{
  98. width: 120rpx;
  99. font-size: 28rpx;
  100. color: #042118;
  101. font-family: 'Source Han Sans CN VF';
  102. font-weight: 400;
  103. // 超出隐藏
  104. overflow: hidden;
  105. text-overflow: ellipsis;
  106. white-space: nowrap;
  107. }
  108. .pest-discern__item-content{
  109. flex: 1;
  110. margin: 0 20rpx;
  111. }
  112. .pest-discern__item-count{
  113. width: 80rpx;
  114. font-size: 28rpx;
  115. color: #042118;
  116. text-align: right;
  117. }
  118. }
  119. </style>