List.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div>
  3. <common @asynCallBack="asynCallBack"></common>
  4. <top-header :pageTitle="pageTitle"></top-header>
  5. <div class="mui-content vongi-hdsq">
  6. <div class="mui-slider-group">
  7. <ul class="mui-table-view">
  8. <li v-for="(item,index) in recordList" class="mui-table-view-cell">
  9. <router-link :to="{name:'XsyApprovalInfo',query:{id:item.id,formId:'travelWork'}}">
  10. <div class="mui-media-body flew-sp">
  11. 出差地点:{{item.destination}}
  12. <span class='mui-ellipsis mui-h6' v-text="item.startTime.substr(5)"></span>
  13. </div>
  14. <p class='mui-ellipsis'>出差事由:{{item.content}}</p>
  15. <p class='flew-sp flew-items'>
  16. 预估天数:{{item.estimatedTime}}天
  17. <button class="mui-btn mui-btn-outlined" :class="{'mui-btn-primary':item.status==0,
  18. 'mui-btn-danger':item.status==2||item.status==3,
  19. 'mui-btn-success':item.status==1||item.status==4}" >{{item.statusN}}</button>
  20. </p>
  21. </router-link>
  22. </li>
  23. </ul>
  24. </div>
  25. </div>
  26. <NullList :remark="'暂无申请记录'" v-if="!recordList.length"></NullList>
  27. <div class="fyy-footer">
  28. <div class="bindfyy-btn" @click="goToForm"><button type="submit" class="mui-btn mui-btn-primary ">填写出差申请单</button></div>
  29. </div>
  30. <loading :visible="isLoading"></loading>
  31. </div>
  32. </template>
  33. <script>
  34. import * as API_BusinessTravel from '@/apis/Master/business_travel'
  35. import Common from '$project/components/Common.vue'
  36. import Loading from '$project/components/Loading.vue'
  37. import TopHeader from '$project/components/TopHeader.vue'
  38. import isReachBottom from '$project/utils/isReachBottom'
  39. import NullList from '$project/components/NullList.vue'
  40. import {
  41. mapGetters,
  42. mapMutations
  43. } from 'vuex'
  44. export default {
  45. name: 'MasterBusinessTravelList',
  46. components: {
  47. Common,
  48. Loading,
  49. TopHeader,
  50. NullList
  51. },
  52. data() {
  53. return {
  54. pageTitle: '出差申请记录',
  55. isLoading: false,
  56. listForm: {
  57. type: '3',
  58. pageIndex: 1,
  59. pageSize: 20,
  60. totalPage: 1,
  61. },
  62. recordList: [],
  63. }
  64. },
  65. created() {},
  66. methods: {
  67. //获取列表
  68. getList() {
  69. this.isLoading = true;
  70. API_BusinessTravel.pageList(this.listForm).then(response => {
  71. if (response) {
  72. if (this.listForm.pageIndex == 1) {
  73. this.recordList = response.data;
  74. this.listForm.pageIndex = response.pageNumber;
  75. this.listForm.totalPage = response.totalPage;
  76. } else {
  77. this.recordList = [
  78. ...this.recordList,
  79. ...response.data
  80. ];
  81. }
  82. }
  83. this.listForm.pageIndex++;
  84. this.isLoading = false;
  85. }).catch(error => {
  86. this.isLoading = false;
  87. mui.toast(error);
  88. })
  89. },
  90. //下拉事件
  91. handleScrool() {
  92. if (isReachBottom()) {
  93. console.log('到达底部')
  94. if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
  95. this.getList();
  96. } else {
  97. return;
  98. }
  99. }
  100. },
  101. //填写表单
  102. goToForm() {
  103. this.$router.push({
  104. name: 'MasterBusinessTravelForm'
  105. })
  106. },
  107. //获取状态颜色
  108. getColor(status) {
  109. var color = '';
  110. if (status == '0') {
  111. color = '#4fc5f7';
  112. } else if (status == '1') {
  113. color = '#55f868';
  114. } else if (status == '2') {
  115. color = '#fe616c';
  116. }
  117. return 'color:' + color + ';border-color:' + color + ';';
  118. },
  119. asynCallBack() {
  120. },
  121. },
  122. mounted() {
  123. this.getList();
  124. //监控下拉加载事件
  125. var _this = this;
  126. window.addEventListener('scroll', _this.handleScrool);
  127. },
  128. destroyed() {
  129. //销毁监听事件
  130. var _this = this;
  131. window.removeEventListener('scroll', _this.handleScrool);
  132. },
  133. computed: {
  134. ...mapGetters({
  135. openId: 'wx_openid',
  136. token: 'token',
  137. })
  138. },
  139. }
  140. </script>
  141. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  142. <style src="$project/assets/css/iconfont.css"></style>
  143. <style>
  144. </style>