list.vue 5.1 KB

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