index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <view class="content">
  3. <u-tabs-swiper ref="uTabs" :active-color="mainColor" :list="tabList" :current="current" @change="tabsChange"
  4. :is-scroll="false"></u-tabs-swiper>
  5. <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" class="swiper-box">
  6. <swiper-item class="swiper-item" v-for="(item, index1) in tabList" :key="index1">
  7. <scroll-view scroll-y class="scroll-box" @scrolltolower="handleLoadMore" :refresher-enabled="true"
  8. :refresher-triggered="triggered" :refresher-threshold="100" refresher-background="white" @refresherrefresh="onRefresh"
  9. @refresherrestore="onRestore">
  10. <view class="filter-box" v-if="current == 3">
  11. <u-search placeholder="请输入关键字" v-model="filterText" @search="setFilterText" @custom="setFilterText"></u-search>
  12. </view>
  13. <u-card :head-border-bottom="false" :foot-border-top="false" padding="0px" margin="10px" borderRadius="40" v-for="(site, index2) in item.tableList"
  14. :key="index2" class="class-card">
  15. <view class="class-content" slot="head" style="padding-top: 10px; display: flex; justify-content: space-between;">
  16. <view class="student-name">{{site.studentName}}</view>
  17. <view class="class-date">{{site.time}}</view>
  18. </view>
  19. <view class="class-content" slot="body">
  20. <view class="class-info-text">{{site.content}}</view>
  21. <!-- type 0病假 4事假-->
  22. <view v-if="current == 1 && site.type == 4 && !site.get" style="display: flex;justify-content: flex-end;">
  23. <u-button type="warning" :custom-style="{background: mainColor}" size="mini" shape="circle" :ripple="true" @click="handleAgreeClick(site)" >同意</u-button>
  24. </view>
  25. </view>
  26. </u-card>
  27. <u-divider v-if="item.isOver" bg-color="transparent">没有更多了</u-divider>
  28. </scroll-view>
  29. </swiper-item>
  30. </swiper>
  31. <u-top-tips ref="uTips"></u-top-tips>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. mapGetters
  37. } from 'vuex'
  38. const NET = require('@/utils/request')
  39. const API = require('@/config/api')
  40. export default {
  41. computed: {
  42. ...mapGetters([
  43. 'mainColor',
  44. 'handleCustomStyle',
  45. 'handleDefaultCustomStyle',
  46. ])
  47. },
  48. data() {
  49. return {
  50. triggered: false,
  51. tabList: [{
  52. name: '全部',
  53. isOver: false,
  54. pageIndex: 1,
  55. tableList: [],
  56. }, {
  57. name: '请假',
  58. isOver: false,
  59. pageIndex: 1,
  60. tableList: [],
  61. }, {
  62. name: '续费',
  63. isOver: false,
  64. pageIndex: 1,
  65. tableList: [],
  66. }, {
  67. name: '签到',
  68. isOver: false,
  69. pageIndex: 1,
  70. tableList: [],
  71. }],
  72. current: 0,
  73. swiperCurrent: 0,
  74. filterText: ''
  75. }
  76. },
  77. onLoad() {
  78. this.getTableList(0)
  79. this.getTableList(1)
  80. this.getTableList(2)
  81. this.getTableList(3)
  82. },
  83. methods: {
  84. // tab页面切换
  85. tabsChange(index) {
  86. this.swiperCurrent = index;
  87. },
  88. // swiper-item左右移动,通知tabs的滑块跟随移动
  89. transition(e) {
  90. let dx = e.detail.dx;
  91. this.$refs.uTabs.setDx(dx);
  92. },
  93. // swiper滑动结束,分别设置tabs和swiper的状态
  94. animationfinish(e) {
  95. let current = e.detail.current;
  96. this.$refs.uTabs.setFinishCurrent(current);
  97. this.swiperCurrent = current;
  98. this.current = current;
  99. },
  100. // 同意
  101. handleAgreeClick(site) {
  102. const that = this
  103. NET.request(API.leaveLessonsOk, {msgId: site.id}, 'POST').then(res =>{
  104. if(res.status == 10000) {
  105. site.get=true
  106. //this.tabList[this.current].tableList = []
  107. //that.getTableList(1)
  108. }
  109. })
  110. },
  111. // 过滤搜索
  112. setFilterText() {
  113. this.tabList[this.current].isOver = false
  114. this.tabList[this.current].pageIndex = 1
  115. this.tabList[this.current].tableList = []
  116. this.getTableList(this.current, 'refresh', this.filterText)
  117. },
  118. // 下拉刷新
  119. onRefresh() {
  120. if (!this.triggered) {
  121. this.triggered = true
  122. this.tabList[this.current].isOver = false
  123. this.tabList[this.current].pageIndex = 1
  124. this.tabList[this.current].tableList = []
  125. this.getTableList(this.current, 'refresh')
  126. }
  127. },
  128. // 重置下拉刷新状态
  129. onRestore() {
  130. this.triggered = 'restore'
  131. this.triggered = false
  132. },
  133. // 懒加载
  134. handleLoadMore() {
  135. if (!this.tabList[this.current].isOver) {
  136. this.tabList[this.current].pageIndex++
  137. this.getTableList(this.current)
  138. }
  139. },
  140. // 获取列表数据
  141. getTableList(index, refresh,name = '') {
  142. NET.request(API.getMessageList, {
  143. type: index,
  144. page: this.tabList[index].pageIndex,
  145. size: 10,
  146. name: name
  147. }, 'POST').then(res => {
  148. this.triggered = false
  149. this.tabList[index].tableList = this.tabList[index].tableList.concat(res.data.row)
  150. this.tabList[index].isOver = res.data.row.length != 10
  151. }).catch(error => {
  152. this.triggered = false
  153. this.$refs.uTips.show({
  154. title: error.message,
  155. type: 'warning',
  156. })
  157. })
  158. }
  159. },
  160. }
  161. </script>
  162. <style>
  163. page {
  164. width: 100%;
  165. height: 100%;
  166. background-color: #f7f7f7;
  167. }
  168. </style>
  169. <style lang="scss" scoped>
  170. @import "@/static/css/themes.scss";
  171. .content {
  172. width: 100%;
  173. float: left;
  174. .swiper-box {
  175. height: calc(100vh - 34px);
  176. .filter-box {
  177. height: 48px;
  178. padding: 10px 15px;
  179. background-color: #FFFFFF;
  180. border-top: 2px solid #f7f7f7;
  181. }
  182. .swiper-item {
  183. height: calc(100vh - 34px);
  184. .scroll-box {
  185. width: 100%;
  186. height: calc(100vh - 34px);
  187. .class-card {
  188. .class-content {
  189. padding: 5px 15px;
  190. }
  191. .student-name {
  192. height: 20px;
  193. display: inline-block;
  194. font-weight: bold;
  195. font-size: 14px;
  196. line-height: 20px;
  197. }
  198. .class-date {
  199. height: 20px;
  200. display: inline-block;
  201. font-size: 14px;
  202. line-height: 20px;
  203. color: #999999;
  204. }
  205. .class-info-text {
  206. margin-bottom: 5px;
  207. font-size: 14px;
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. </style>