extraLessonsStudentList.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view class="content">
  3. <view class="filter-box">
  4. <u-search placeholder="请输入关键字" v-model="filterText" @search="setFilterText" @custom="setFilterText"></u-search>
  5. </view>
  6. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  7. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  8. @refresherrestore="onRestore">
  9. <u-checkbox-group :active-color="mainColor" shape="circle" size="56" icon-size="36">
  10. <u-card :head-border-bottom="false" :foot-border-top="false" padding="0px" margin="0" borderRadius="0" v-for="(item, index) in tableList"
  11. :key="index" class="card-box" @click="changeStatus(item)">
  12. <view class="card-content" slot="body">
  13. <view class="card-info-img">
  14. <u-avatar :src="site.url" size="100"></u-avatar>
  15. </view>
  16. <view class="card-info-text">{{item.name}}</view>
  17. <u-checkbox v-model="item.checked" @click.native.stop=""></u-checkbox>
  18. </view>
  19. </u-card>
  20. </u-checkbox-group>
  21. <u-divider v-if="isOver" bg-color="transparent">没有更多了</u-divider>
  22. </scroll-view>
  23. <view class="handle-fix-box">
  24. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="selectStudent()">确定</u-button>
  25. </view>
  26. <u-top-tips ref="uTips"></u-top-tips>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. mapGetters
  32. } from 'vuex'
  33. const NET = require('@/utils/request')
  34. const API = require('@/config/api')
  35. export default {
  36. computed: {
  37. ...mapGetters([
  38. 'mainColor',
  39. 'customStyle',
  40. ])
  41. },
  42. data() {
  43. return {
  44. filterText: '',
  45. triggered: false,
  46. isOver: false,
  47. pageIndex: 1,
  48. tableList: [],
  49. }
  50. },
  51. onLoad() {
  52. this.getTableList()
  53. },
  54. onReady() {},
  55. methods: {
  56. // 设置过滤字段
  57. setFilterText(value) {
  58. this.onRefresh()
  59. },
  60. // 下拉刷新
  61. onRefresh() {
  62. this.triggered = true
  63. this.isOver = false
  64. this.pageIndex = 1
  65. this.tableList = []
  66. this.getTableList()
  67. },
  68. // 重置下拉刷新状态
  69. onRestore() {
  70. this.triggered = 'restore'
  71. this.triggered = false
  72. },
  73. // 懒加载
  74. handleLoadMore() {
  75. if (!this.isOver) {
  76. this.pageIndex++
  77. this.getTableList()
  78. }
  79. },
  80. // 获取列表数据
  81. getTableList() {
  82. NET.request(API.getExtraLessonsStudentList, {
  83. name: this.filterText,
  84. page: this.pageIndex,
  85. size: 10,
  86. }, 'POST').then(res => {
  87. this.triggered = false
  88. res.data.row.forEach(site => site.checked = false)
  89. this.tableList = this.tableList.concat(res.data.row)
  90. this.isOver = res.data.row.length != 10
  91. }).catch(error => {
  92. this.triggered = false
  93. this.$refs.uTips.show({
  94. title: error.message,
  95. type: 'warning',
  96. })
  97. })
  98. },
  99. // 变更状态
  100. changeStatus(item) {
  101. item.checked = !item.checked
  102. },
  103. // 选择学员
  104. selectStudent() {
  105. uni.setStorage({
  106. key: 'extraLessonsUserList',
  107. data: this.tableList.filter(site => site.checked)
  108. })
  109. uni.navigateBack()
  110. }
  111. },
  112. }
  113. </script>
  114. <style>
  115. page {
  116. width: 100%;
  117. height: 100%;
  118. background-color: #f7f7f7;
  119. }
  120. </style>
  121. <style lang="scss" scoped>
  122. @import "@/static/css/themes.scss";
  123. .content {
  124. width: 100%;
  125. float: left;
  126. .filter-box {
  127. height: 48px;
  128. padding: 10px 15px;
  129. background-color: #FFFFFF;
  130. }
  131. .scroll-box {
  132. width: 100%;
  133. height: calc(100vh - 108px);
  134. .card-box {
  135. border-bottom: 1px solid #cccccc;
  136. .card-content {
  137. padding: 5px 15px;
  138. display: flex;
  139. align-items: center;
  140. .card-info-img {
  141. width: 50px;
  142. height: 50px;
  143. margin-right: 5px;
  144. display: flex;
  145. align-items: center;
  146. justify-content: center;
  147. }
  148. .card-info-text {
  149. line-height: 20px;
  150. font-size: 14px;
  151. flex: 1;
  152. }
  153. }
  154. }
  155. }
  156. }
  157. </style>