list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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=='place'">{{item.Province}}{{item.City}}</text>
  16. <text v-else>{{item[info.key]}}</text>
  17. </view>
  18. </view>
  19. <view class="status approve-list-status-wait" v-if="item.Status==='待审批'">待审批</view>
  20. <view class="status approve-list-status-success" v-if="item.Status==='已通过'">已通过</view>
  21. <view class="status approve-list-status-fail" 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>
  28. </template>
  29. <script>
  30. import {apiApproveList} from '@/api/businessTrip/index'
  31. export default {
  32. data() {
  33. return {
  34. status: '待审批',
  35. list:[],
  36. page:1,
  37. finished:false,
  38. PageSize:20,
  39. itemOpt:[
  40. {lable:'申请人',key:'ApplyRealName'},
  41. {lable:'目的地',key:'place'},
  42. {lable:'出差事由',key:'Reason'},
  43. {lable:'提交时间',key:'CreateTime'},
  44. ]
  45. }
  46. },
  47. onLoad(){
  48. this.getList()
  49. // 更新列表
  50. uni.$on('businessApproveListUpdate',(e)=>{
  51. console.log('更新列表');
  52. this.page=1
  53. this.finished=false
  54. this.list=[]
  55. this.getList()
  56. })
  57. },
  58. onShow() {
  59. this.selectComponent('#tabs').resize();// 解决初始渲染 vant tab 底部条
  60. },
  61. onUnload(){
  62. uni.$off('businessApproveListUpdate')
  63. },
  64. onPullDownRefresh() {
  65. this.page=1
  66. this.finished=false
  67. this.list=[]
  68. this.getList()
  69. setTimeout(()=>{
  70. uni.stopPullDownRefresh()
  71. },1500)
  72. },
  73. onReachBottom() {
  74. if(this.finished) return
  75. this.page++
  76. this.getList()
  77. },
  78. methods: {
  79. typeChange(e){
  80. this.status=e.detail.name
  81. this.page=1
  82. this.finished=false
  83. this.list=[]
  84. this.getList()
  85. },
  86. async getList(){
  87. const res=await apiApproveList({
  88. PageSize:this.PageSize,
  89. CurrentIndex:this.page,
  90. Status:this.status
  91. })
  92. if(res.code===200){
  93. const arr=res.data.List||[]
  94. this.list=[...this.list,...arr]
  95. this.finished=res.data.Paging.IsEnd
  96. }
  97. },
  98. goDetail(item){
  99. uni.navigateTo({
  100. url: '/pages-approve/businessTrip/detail?id='+item.BusinessApplyId,
  101. success: (result) => {},
  102. fail: () => {},
  103. complete: () => {}
  104. });
  105. }
  106. },
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .list-page{
  111. min-height: 100vh;
  112. }
  113. .list-wrap{
  114. padding: 20rpx;
  115. .item{
  116. padding: 30rpx;
  117. background-color: #fff;
  118. margin-bottom: 20rpx;
  119. border-radius: 8rpx;
  120. .info-item{
  121. display: flex;
  122. font-size: 32rpx;
  123. margin-bottom: 30rpx;
  124. .label{
  125. width: 180rpx;
  126. flex-shrink: 0;
  127. text-align: right;
  128. }
  129. .content{
  130. flex: 1;
  131. }
  132. }
  133. .status{
  134. text-align: right;
  135. }
  136. }
  137. }
  138. </style>