uni-indexed-list-item.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view>
  3. <view v-if="loaded || list.itemIndex < 15" class="uni-indexed-list__title-wrapper">
  4. <text v-if="list.items && list.items.length > 0" class="uni-indexed-list__title">{{ list.key }}</text>
  5. </view>
  6. <view v-if="(loaded || list.itemIndex < 15) && list.items && list.items.length > 0" class="uni-indexed-list__list">
  7. <view v-for="(item, index) in list.items" :key="index" class="uni-indexed-list__item" hover-class="uni-indexed-list__item--hover">
  8. <view class="uni-indexed-list__item-container" @click="onClick(idx, index)">
  9. <view class="uni-indexed-list__item-border" :class="{'uni-indexed-list__item-border--last':index===list.items.length-1}">
  10. <view v-if="showSelect" style="margin-right: 20rpx;">
  11. <uni-icons :type="item.checked ? 'checkbox-filled' : 'circle'" :color="item.checked ? '#007aff' : '#aaa'" size="24" />
  12. </view>
  13. <text class="uni-indexed-list__item-content">{{ item.name }}</text>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import uniIcons from '../uni-icons/uni-icons.vue'
  22. export default {
  23. name: 'UniIndexedList',
  24. components: {
  25. uniIcons
  26. },
  27. props: {
  28. loaded: {
  29. type: Boolean,
  30. default: false
  31. },
  32. idx: {
  33. type: Number,
  34. default: 0
  35. },
  36. list: {
  37. type: Object,
  38. default () {
  39. return {}
  40. }
  41. },
  42. showSelect: {
  43. type: Boolean,
  44. default: false
  45. }
  46. },
  47. methods: {
  48. onClick(idx, index) {
  49. this.$emit("itemClick", {
  50. idx,
  51. index
  52. })
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. .uni-indexed-list__list {
  59. background-color: #ffffff;
  60. /* #ifndef APP-NVUE */
  61. display: flex;
  62. /* #endif */
  63. flex-direction: column;
  64. border-top-style: solid;
  65. border-top-width: 1px;
  66. border-top-color: #e5e5e5;
  67. }
  68. .uni-indexed-list__item {
  69. font-size: 16;
  70. /* #ifndef APP-NVUE */
  71. display: flex;
  72. /* #endif */
  73. flex: 1;
  74. flex-direction: row;
  75. justify-content: space-between;
  76. align-items: center;
  77. }
  78. .uni-indexed-list__item-container {
  79. padding-left: 15px;
  80. flex: 1;
  81. position: relative;
  82. /* #ifndef APP-NVUE */
  83. display: flex;
  84. box-sizing: border-box;
  85. /* #endif */
  86. flex-direction: row;
  87. justify-content: space-between;
  88. align-items: center;
  89. }
  90. .uni-indexed-list__item-border {
  91. flex: 1;
  92. position: relative;
  93. /* #ifndef APP-NVUE */
  94. display: flex;
  95. box-sizing: border-box;
  96. /* #endif */
  97. flex-direction: row;
  98. justify-content: space-between;
  99. align-items: center;
  100. height: 50px;
  101. padding: 15px;
  102. padding-left: 0;
  103. border-bottom-style: solid;
  104. border-bottom-width: 1px;
  105. border-bottom-color: #e5e5e5;
  106. }
  107. .uni-indexed-list__item-border--last {
  108. border-bottom-width: 0px;
  109. }
  110. .uni-indexed-list__item-content {
  111. flex: 1;
  112. font-size: 14px;
  113. }
  114. .uni-indexed-list {
  115. /* #ifndef APP-NVUE */
  116. display: flex;
  117. /* #endif */
  118. flex-direction: row;
  119. }
  120. .uni-indexed-list__title-wrapper {
  121. /* #ifndef APP-NVUE */
  122. display: flex;
  123. width: 100%;
  124. /* #endif */
  125. background-color: #f7f7f7;
  126. }
  127. .uni-indexed-list__title {
  128. padding: 6px 12px;
  129. line-height: 24px;
  130. font-size: 12px;
  131. }
  132. </style>