list.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="list-page">
  3. <van-sticky>
  4. <van-tabs swipeable id="tabs" :active="status" title-active-color="#3385FF" color="#3385FF" @change="typeChange">
  5. <van-tab title="待审批" name="待审批"></van-tab>
  6. <van-tab title="已处理" name="已处理"></van-tab>
  7. </van-tabs>
  8. </van-sticky>
  9. <van-empty description="暂无数据" :image="require('@/static/empty.png')" v-if="finished&&list.length===0"/>
  10. <view class="list-wrap" v-else>
  11. <view class="item" v-for="item in list" :key="item.BusinessApplyId" @click="goDetail(item)">
  12. <view class="info-item" v-for="info in itemOpt" :key="info.key">
  13. <view class="label">{{info.lable}}:</view>
  14. <view class="content">
  15. <text v-if="info.key=='date'">{{item.ArriveDate|formatTime}}-{{item.ReturnDate|formatTime}}</text>
  16. <text v-else-if="info.key=='place'">{{item.Province}}{{item.City}}</text>
  17. <text v-else>{{item[info.key]}}</text>
  18. </view>
  19. </view>
  20. <view class="status approve-list-status-wait" v-if="item.Status==='待审批'">待审批</view>
  21. <view class="status approve-list-status-success" v-if="item.Status==='已审批'">已审批</view>
  22. <view class="status approve-list-status-fail" v-if="item.Status==='已驳回'">已驳回</view>
  23. <view class="status approve-list-status-cancel" v-if="item.Status==='已过期'">已过期</view>
  24. <view class="status approve-list-status-back" v-if="item.Status==='已撤回'">已撤回</view>
  25. </view>
  26. </view>
  27. <view class="fix-bottom-wrap">
  28. <view class="btn" @click="goAddApply">添加申请</view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import {apiApplyList} from '@/api/businessTrip/index'
  34. export default {
  35. data() {
  36. return {
  37. status: '待审批',
  38. list:[],
  39. page:1,
  40. finished:false,
  41. PageSize:20,
  42. itemOpt:[
  43. {lable:'出差日期',key:'date'},
  44. {lable:'目的地',key:'place'},
  45. {lable:'出差事由',key:'Reason'},
  46. {lable:'提交时间',key:'CreateTime'},
  47. ]
  48. }
  49. },
  50. onLoad(){
  51. this.getList()
  52. // 更新列表
  53. uni.$on('businessApproveListUpdate',(e)=>{
  54. console.log('更新列表');
  55. this.page=1
  56. this.finished=false
  57. this.list=[]
  58. this.getList()
  59. })
  60. },
  61. onShow() {
  62. this.selectComponent('#tabs').resize();// 解决初始渲染 vant tab 底部条
  63. },
  64. onUnload(){
  65. uni.$off('businessApproveListUpdate')
  66. },
  67. onPullDownRefresh() {
  68. this.page=1
  69. this.finished=false
  70. this.list=[]
  71. this.getList()
  72. setTimeout(()=>{
  73. uni.stopPullDownRefresh()
  74. },1500)
  75. },
  76. onReachBottom() {
  77. if(this.finished) return
  78. this.page++
  79. this.getList()
  80. },
  81. methods: {
  82. typeChange(e){
  83. this.status=e.detail.name
  84. this.page=1
  85. this.finished=false
  86. this.list=[]
  87. this.getList()
  88. },
  89. async getList(){
  90. const res=await apiApplyList({
  91. PageSize:this.PageSize,
  92. CurrentIndex:this.page,
  93. Status:this.status
  94. })
  95. if(res.code===200){
  96. const arr=res.data.List||[]
  97. this.list=[...this.list,...arr]
  98. this.finished=res.data.Paging.IsEnd
  99. }
  100. },
  101. goAddApply(){
  102. uni.navigateTo({
  103. url: '/pages-approve/businessTrip/add',
  104. success: (result) => {},
  105. fail: () => {},
  106. complete: () => {}
  107. });
  108. },
  109. goDetail(item){
  110. uni.navigateTo({
  111. url: '/pages-approve/businessTrip/detail?id='+item.BusinessApplyId,
  112. success: (result) => {},
  113. fail: () => {},
  114. complete: () => {}
  115. });
  116. }
  117. },
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .list-page{
  122. min-height: 100vh;
  123. padding-bottom: calc(150rpx + constant(safe-area-inset-bottom));
  124. padding-bottom: calc(150rpx + env(safe-area-inset-bottom));
  125. }
  126. .list-wrap{
  127. padding: 20rpx;
  128. .item{
  129. padding: 30rpx;
  130. background-color: #fff;
  131. margin-bottom: 20rpx;
  132. border-radius: 8rpx;
  133. .info-item{
  134. display: flex;
  135. font-size: 32rpx;
  136. margin-bottom: 30rpx;
  137. .label{
  138. width: 180rpx;
  139. flex-shrink: 0;
  140. text-align: right;
  141. }
  142. .content{
  143. flex: 1;
  144. }
  145. }
  146. .status{
  147. text-align: right;
  148. }
  149. }
  150. }
  151. .fix-bottom-wrap{
  152. .btn{
  153. width: 60%;
  154. text-align: center;
  155. line-height: 64rpx;
  156. height: 64rpx;
  157. color: #fff;
  158. background-color: #5890fb;
  159. border-radius: 50rpx;
  160. margin-left: auto;
  161. margin-right: auto;
  162. }
  163. }
  164. </style>