rotationBottom.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view
  3. class="rotation-wraper"
  4. :style="{
  5. height:
  6. tktype == 1
  7. ? `calc(100% - 256rpx - 168rpx)`
  8. : `calc(100% - 256rpx - 440rpx)`,
  9. }"
  10. >
  11. <view class="rotation-wraper-left">
  12. <view
  13. class="rotation-wraper-left__item"
  14. v-for="(item, index) in listData"
  15. :key="item.sfBid"
  16. @click="clickHandler(item, index)"
  17. :class="{ active: index === currentIndex }"
  18. >{{ item.sfDisplayname || item.sfName }}
  19. <image
  20. :src="borderBottomGray"
  21. class="border-bottom-gray"
  22. v-if="index === currentIndex"
  23. />
  24. </view>
  25. </view>
  26. <view class="rotation-wraper-right">
  27. <scroll-view
  28. scroll-y="true"
  29. enable-flex="true"
  30. scroll-with-animation
  31. class="server-page__list-scroll"
  32. :scroll-into-view="activeMenuId"
  33. >
  34. <rotationCard
  35. v-for="item in listData"
  36. :item="item"
  37. :tktype="tktype"
  38. :key="item.sfBid"
  39. @actionChecked="actionCheckedHandler"
  40. @changeTi="changeTiHandler"
  41. :id="'tab' + item.sfBid"
  42. />
  43. </scroll-view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import rotationCard from './rotationCard.vue';
  49. import borderBottomGray from '../assets/borderBottomGray.png';
  50. export default {
  51. name: 'rotationBottom',
  52. props: {
  53. alreadyList: {
  54. type: Array,
  55. default: () => [],
  56. },
  57. tktype: {
  58. type: Number,
  59. default: 1,
  60. },
  61. activeIndex: {
  62. type: Number,
  63. default: 0,
  64. },
  65. },
  66. data() {
  67. return {
  68. listData: [],
  69. borderBottomGray,
  70. currentIndex: 0,
  71. currentItem: {},
  72. activeMenuId: '',
  73. };
  74. },
  75. watch: {
  76. activeIndex() {
  77. this.currentIndex = 0;
  78. const firstItem = this.alreadyList[0];
  79. this.activeMenuId = `tab${firstItem?.sfBid}`;
  80. },
  81. alreadyList(value) {
  82. this.listData = value;
  83. },
  84. },
  85. components: {
  86. rotationCard,
  87. },
  88. methods: {
  89. changeTiHandler(item) {
  90. const index = this.getItemBySfBid(item.sfBid);
  91. this.$set(this.listData, index, {
  92. ...item,
  93. ti: item.ti,
  94. });
  95. this.$emit('updateList', this.listData);
  96. },
  97. // 通过sfBid查到某个item的index
  98. getItemBySfBid(sfBid) {
  99. return this.listData.findIndex((item) => item.sfBid === sfBid);
  100. },
  101. actionCheckedHandler(item) {
  102. const index = this.getItemBySfBid(item.sfBid);
  103. this.$set(this.listData, index, {
  104. ...item,
  105. isChecked: !item.isChecked,
  106. });
  107. this.$emit('updateList', this.listData);
  108. },
  109. clickHandler(item, index) {
  110. this.currentItem = item;
  111. this.currentIndex = index;
  112. this.activeMenuId = `tab${item.sfBid}`;
  113. },
  114. },
  115. };
  116. </script>
  117. <style scoped lang="scss">
  118. .server-page__list-scroll {
  119. height: 100%;
  120. overflow: hidden;
  121. }
  122. .rotation-wraper {
  123. display: flex;
  124. justify-content: space-between;
  125. position: relative;
  126. height: calc(100% - 256rpx - 168rpx);
  127. padding-bottom: 128rpx;
  128. overflow-y: hidden;
  129. .rotation-wraper-left {
  130. width: 240rpx;
  131. border-radius: 16rpx;
  132. background-color: #ffffff;
  133. height: 100%;
  134. background: #ffffff;
  135. overflow-y: auto;
  136. padding-top: 12rpx;
  137. &__item {
  138. height: 96rpx;
  139. line-height: 96rpx;
  140. padding: 0 32rpx;
  141. color: #364d46;
  142. font-family: 'Source Han Sans CN VF';
  143. font-size: 28rpx;
  144. font-weight: 400;
  145. position: relative;
  146. .border-bottom-gray {
  147. position: absolute;
  148. width: 40rpx;
  149. height: 40rpx;
  150. bottom: -30rpx;
  151. right: 0;
  152. }
  153. }
  154. }
  155. .active {
  156. background: #f5f6fa;
  157. color: #14a478;
  158. font-family: 'Source Han Sans CN VF';
  159. font-size: 28rpx;
  160. font-weight: 700;
  161. }
  162. .rotation-wraper-right {
  163. width: calc(100% - 240rpx - 64rpx);
  164. margin-right: 32rpx;
  165. overflow-y: scroll;
  166. }
  167. }
  168. </style>