List.vue 3.7 KB

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