index-list.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="container">
  3. <scroll-view scroll-y="true" class="scroll-Y"
  4. >
  5. <view class="box" v-for="item in options">
  6. <view class="letter">{{item.letter}}</view>
  7. <view class="listWrap">
  8. <view class="list" v-for="val in item.data" @click="listClickHandle(val)">
  9. <view class="iconWrap">
  10. <image v-if="isSelectAll||checkedListIds.includes(val.id)" class="checkedIcon" src="../../static/check-checkbox.png" mode=""></image>
  11. </view>
  12. <text class="mainText">{{val.main}}</text>
  13. <text class="subText">{{val.sub}}</text>
  14. </view>
  15. </view>
  16. </view>
  17. </scroll-view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name:"index-list",
  23. props:{
  24. checkedResponsibleList:Array,
  25. options:Array,
  26. },
  27. data() {
  28. return {
  29. checkedList:[],
  30. checkedListIds:[],
  31. isSelectAll:false
  32. };
  33. },
  34. computed:{
  35. },
  36. watch:{
  37. checkedResponsibleList:function(newVal,oldVal){
  38. // console.log({newVal,oldVal});
  39. if(newVal.length != oldVal.length){
  40. this.checkedListIds = JSON.parse(JSON.stringify(newVal)).map(item=>item.id);
  41. this.checkedList = JSON.parse(JSON.stringify(newVal));
  42. this.$emit("listClick",this.checkedList);
  43. }
  44. }
  45. },
  46. mounted() {
  47. this.checkedListIds = JSON.parse(JSON.stringify(this.checkedResponsibleList)).map(item=>item.id);
  48. this.checkedList = JSON.parse(JSON.stringify(this.checkedResponsibleList));
  49. // console.log(this.checkedListIds);
  50. },
  51. methods:{
  52. listClickHandle(val){
  53. const tempIdsArr = JSON.parse(JSON.stringify(this.checkedListIds));
  54. const tempArr = JSON.parse(JSON.stringify(this.checkedList));
  55. const data = JSON.parse(JSON.stringify(val));
  56. // console.log({tempIdsArr,tempArr});
  57. // console.log(tempIdsArr.includes(data.id));
  58. if(tempIdsArr.includes(data.id)){
  59. this.isSelectAll = false;
  60. tempIdsArr.splice(tempIdsArr.indexOf(data.id),1);
  61. this.checkedList = tempArr.filter(item=>item.id != data.id);
  62. this.checkedListIds = tempIdsArr;
  63. }else {
  64. this.checkedList.push(data);
  65. this.checkedListIds.push(data.id);
  66. // console.log(this.checkedListIds);
  67. }
  68. this.$emit("listClick",this.checkedList);
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="less">
  74. .container {
  75. height: 100%;
  76. overflow: scroll;
  77. .scroll-Y {
  78. // height: 100%;
  79. .box {
  80. .letter {
  81. height: 62.5rpx;
  82. line-height: 62.5rpx;
  83. font-size: 22.5rpx;
  84. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  85. font-weight: 400;
  86. color: #666F80;
  87. padding: 0 25rpx;
  88. }
  89. .listWrap {
  90. background-color: #FFFFFF;
  91. .list {
  92. position: relative;
  93. display: flex;
  94. flex-direction: row;
  95. justify-content: flex-start;
  96. align-items: center;
  97. height:87.5rpx;
  98. padding: 0 25rpx;
  99. .iconWrap {
  100. width: 25rpx;
  101. height: 25rpx;
  102. margin-right: 25rpx;
  103. .checkedIcon {
  104. width: 25rpx;
  105. height: 25rpx;
  106. }
  107. }
  108. .mainText {
  109. display: inline-block;
  110. font-size: 22.5rpx;
  111. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  112. font-weight: 400;
  113. color: #292C33;
  114. margin-right: 50rpx;
  115. }
  116. .subText {
  117. font-size: 22.5rpx;
  118. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  119. font-weight: 400;
  120. color: #7A8499;
  121. }
  122. &::after {
  123. position: absolute;
  124. right: 0;
  125. bottom: 0;
  126. display: block;
  127. content: '';
  128. width: 90%;
  129. border-bottom: 1px solid #DADEE6;
  130. }
  131. &:last-child {
  132. &::after {
  133. display: none;
  134. }
  135. }
  136. }
  137. }
  138. }
  139. }
  140. }
  141. </style>