List.vue 3.7 KB

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