data-progress.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view class="column">
  3. <view v-for="(item,index) in progressList" :key="index" :class="['row','font-small','progress',padMiddle?'paddingMiddle':'']">
  4. <text class="title">{{item.name}}</text>
  5. <view class="body">
  6. <view class="number">{{item.now?item.now+"/":""}}{{item.expect}} [{{item.value}}%]</view>
  7. <progress :percent="item.value" backgroundColor="#C9C9C9"
  8. :border-radius="borderRadius?borderRadius+'rpx':'0px'"
  9. :color="time"
  10. stroke-width="16" />
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. name:'data-progress',
  18. props: {
  19. progressList: {
  20. type: Array,
  21. default: ()=> {
  22. return []
  23. }
  24. },
  25. borderRadius:{
  26. type:Number,
  27. default:0
  28. },
  29. padMiddle:{
  30. type:String,
  31. default:"false"
  32. }
  33. },
  34. data() {
  35. return {
  36. time:0
  37. }
  38. },
  39. watch:{
  40. "progressList":{
  41. deep: true,
  42. handler: function(newVal, oldVal) {
  43. this.time = newVal.filter(x=>x.name=="时间进度")[0].value;
  44. }
  45. }
  46. },
  47. created() {
  48. this.time = this.progressList.filter(x=>x.name=="时间进度")[0].value;
  49. }
  50. }
  51. </script>
  52. <style lang="scss">
  53. .paddingMiddle{
  54. padding: 18rpx 10rpx;
  55. }
  56. .progress{
  57. .title{
  58. font-size: 28rpx;
  59. width: 170rpx;
  60. display: flex;
  61. align-items: center;
  62. }
  63. .body{
  64. position: relative;
  65. flex: 1;
  66. .number{
  67. color: #fff;
  68. position: absolute;
  69. z-index: 2;
  70. left: 26rpx;
  71. height: 100%;
  72. display: flex;
  73. align-items: center;
  74. text-overflow: ellipsis;
  75. white-space: nowrap;
  76. overflow: hidden;
  77. height: 44rpx;
  78. }
  79. progress{
  80. padding: 6rpx 0;
  81. }
  82. }
  83. }
  84. </style>