teaPlan.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view class="plan-tea">
  3. <view class="plan-tea-left">
  4. <view :style="`color:${titleColor(item)} ;`" v-for="(item,index) in list" :key="index"
  5. class="plan-tea-left-item">
  6. <view class="plan-tea-left-item-title">
  7. {{item.dateTitle}}
  8. </view>
  9. <view v-if="item.open" class="">
  10. <view :style="`color:${color(item1)} ;`" v-for="(item1,index1) in item.child" :key="index1"
  11. class="child-item">
  12. {{item1.date}}
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="plan-tea-right">
  18. <view class="plan-tea-right-item" v-for="(item,index) in list" :key="index">
  19. <view @click.stop="open(item)" class="plan-tea-right-item-top">
  20. <text>{{item.title}}</text>
  21. <text>
  22. <uni-icons v-if="item.open" color="#999" type="top" size="16"></uni-icons>
  23. <uni-icons v-else color="#999" type="bottom" size="16"></uni-icons>
  24. </text>
  25. <view @click.stop="open(item)" :style="`width:${titleWidth(item)} ;`"
  26. class="plan-tea-right-item-top-color">
  27. </view>
  28. </view>
  29. <uni-transition ref="ani" custom-class="transition" :mode-class="modeClass" :show="item.open">
  30. <view @click="openPop(item)" :style="`background-color:${bgcColor(item1)} ;`"
  31. v-for="(item1,index1) in item.child" :key="index1" class="children-item">
  32. {{item1.title}}
  33. </view>
  34. </uni-transition>
  35. </view>
  36. </view>
  37. <uni-popup ref="alertDialog" type="dialog">
  38. <uni-popup-dialog :type="msgType" cancelText="关闭" confirmText="确定" content="确认该课时已完成?"
  39. @confirm="dialogConfirm"></uni-popup-dialog>
  40. </uni-popup>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. name: "teaPlan",
  46. props: {
  47. list: {
  48. type: Array,
  49. default: () => []
  50. }
  51. },
  52. data() {
  53. return {
  54. modeClass: ['fade', 'zoom-in'],
  55. msgType: '',
  56. item: {}
  57. };
  58. },
  59. methods: {
  60. color(item1) {
  61. if (item1.flag) {
  62. return '#05cca1'
  63. }
  64. },
  65. titleColor(item) {
  66. let color = ' '
  67. item.child.forEach(it => {
  68. if (it.flag) {
  69. color = '#05cca1'
  70. }
  71. })
  72. return color
  73. },
  74. bgcColor(item1) {
  75. if (item1.flag) {
  76. return 'rgba(5,204,161,0.15)'
  77. }
  78. },
  79. titleWidth(item) {
  80. let arr = []
  81. item.child.forEach(item => {
  82. if (item.flag) {
  83. arr.push(item)
  84. }
  85. })
  86. let percent = (arr.length / item.child.length * 100).toFixed(2)
  87. return percent + '%'
  88. },
  89. open(item) {
  90. item.open = !item.open
  91. this.$emit('update:list', this.list)
  92. },
  93. openPop(item) {
  94. this.msgType = 'info'
  95. this.item = item
  96. this.$refs.alertDialog.open()
  97. },
  98. dialogConfirm() {
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .plan-tea {
  105. display: flex;
  106. .children-item {
  107. width: 80%;
  108. height: 74rpx;
  109. border-radius: 5.33px;
  110. box-shadow: 0px 0px 8px 0px rgba(147, 147, 147, 0.20);
  111. margin-bottom: 24rpx;
  112. border-radius: 37rpx;
  113. padding: 0 32rpx;
  114. box-sizing: border-box;
  115. display: flex;
  116. align-items: center;
  117. }
  118. .plan-tea-right-item-top {
  119. width: 100%;
  120. height: 74rpx;
  121. border-radius: 5.33px;
  122. box-shadow: 0px 0px 8px 0px rgba(147, 147, 147, 0.20);
  123. margin-bottom: 24rpx;
  124. padding: 0 32rpx;
  125. box-sizing: border-box;
  126. display: flex;
  127. align-items: center;
  128. justify-content: space-between;
  129. position: relative;
  130. .plan-tea-right-item-top-color {
  131. left: 0;
  132. position: absolute;
  133. width: 100%;
  134. height: 100%;
  135. background-color: rgba(5, 204, 161, 0.15);
  136. border-radius: 5.33px;
  137. }
  138. }
  139. .plan-tea-left-item-title {
  140. text-align: right;
  141. font-size: 48rpx;
  142. margin-bottom: 24rpx;
  143. height: 74rpx;
  144. line-height: 74rpx;
  145. }
  146. .plan-tea-line {
  147. .plan-tea-line-item-color {
  148. width: 20.33px;
  149. height: 20.33px;
  150. background: #05cca1;
  151. border-radius: 50%;
  152. margin: 0 24rpx;
  153. }
  154. }
  155. .child-item {
  156. margin-bottom: 24rpx;
  157. text-align: right;
  158. height: 74rpx;
  159. line-height: 74rpx;
  160. }
  161. .plan-tea-right {
  162. flex: 1;
  163. margin-left: 32rpx;
  164. }
  165. }
  166. </style>