rotationBottom.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. export default {
  50. name: 'rotationBottom',
  51. props: {
  52. alreadyList: {
  53. type: Array,
  54. default: () => [],
  55. },
  56. tktype: {
  57. type: Number,
  58. default: 1,
  59. },
  60. activeIndex: {
  61. type: Number,
  62. default: 0,
  63. },
  64. },
  65. data() {
  66. return {
  67. listData: [],
  68. borderBottomGray:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/deviceIcons/shuifei/borderBottomGray.png',
  69. currentIndex: 0,
  70. currentItem: {},
  71. activeMenuId: '',
  72. };
  73. },
  74. watch: {
  75. activeIndex() {
  76. this.currentIndex = 0;
  77. const firstItem = this.alreadyList[0];
  78. this.activeMenuId = `tab${firstItem?.sfBid}`;
  79. },
  80. alreadyList(value) {
  81. this.listData = value;
  82. },
  83. },
  84. components: {
  85. rotationCard,
  86. },
  87. methods: {
  88. changeTiHandler(item) {
  89. const index = this.getItemBySfBid(item.sfBid);
  90. this.$set(this.listData, index, {
  91. ...item,
  92. ti: item.ti,
  93. });
  94. this.$emit('updateList', this.listData);
  95. },
  96. // 通过sfBid查到某个item的index
  97. getItemBySfBid(sfBid) {
  98. return this.listData.findIndex((item) => item.sfBid === sfBid);
  99. },
  100. actionCheckedHandler(item) {
  101. const index = this.getItemBySfBid(item.sfBid);
  102. this.$set(this.listData, index, {
  103. ...item,
  104. isChecked: !item.isChecked,
  105. });
  106. this.$emit('updateList', this.listData);
  107. },
  108. clickHandler(item, index) {
  109. this.currentItem = item;
  110. this.currentIndex = index;
  111. this.activeMenuId = `tab${item.sfBid}`;
  112. },
  113. },
  114. };
  115. </script>
  116. <style scoped lang="scss">
  117. .server-page__list-scroll {
  118. height: 100%;
  119. overflow: hidden;
  120. }
  121. .rotation-wraper {
  122. display: flex;
  123. justify-content: space-between;
  124. position: relative;
  125. height: calc(100% - 256rpx - 168rpx);
  126. padding-bottom: 128rpx;
  127. overflow-y: hidden;
  128. .rotation-wraper-left {
  129. width: 240rpx;
  130. border-radius: 16rpx;
  131. background-color: #ffffff;
  132. height: 100%;
  133. background: #ffffff;
  134. overflow-y: auto;
  135. padding-top: 12rpx;
  136. &__item {
  137. height: 96rpx;
  138. line-height: 96rpx;
  139. padding: 0 32rpx;
  140. color: #364d46;
  141. font-family: 'Source Han Sans CN VF';
  142. font-size: 28rpx;
  143. font-weight: 400;
  144. position: relative;
  145. .border-bottom-gray {
  146. position: absolute;
  147. width: 40rpx;
  148. height: 40rpx;
  149. bottom: -30rpx;
  150. right: 0;
  151. }
  152. }
  153. }
  154. .active {
  155. background: #f5f6fa;
  156. color: #14a478;
  157. font-family: 'Source Han Sans CN VF';
  158. font-size: 28rpx;
  159. font-weight: 700;
  160. }
  161. .rotation-wraper-right {
  162. width: calc(100% - 240rpx - 64rpx);
  163. margin-right: 32rpx;
  164. overflow-y: scroll;
  165. }
  166. }
  167. </style>