LeaveList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <div>
  3. <common @asynCallBack="asynCallBack"></common>
  4. <top-header :pageTitle="pageTitle" :routeName="'Master'"></top-header>
  5. <div class="mui-content">
  6. <div class="mui-content-padded vongi-work">
  7. <ul class="mui-table-view vongi-qingjia">
  8. <li class="mui-table-view-cell" v-for="mod in recordList" @click="detail(mod.id)">
  9. <h4>
  10. {{mod.title}}
  11. <span v-text="mod.createTime">12:00</span>
  12. </h4>
  13. <button type="button" class="mui-btn mui-btn-outlined" :class="statusColor[mod.status]" v-text="status[mod.status]">
  14. </button>
  15. </li>
  16. </ul>
  17. </div>
  18. <div class="fyy-footer">
  19. <div class="bindfyy-btn"><button type="submit" class="mui-btn mui-btn-primary " @click="save()">写请假条</button></div>
  20. </div>
  21. </div>
  22. <NullList :remark="'暂无请假记录'" v-if="!recordList.length"></NullList>
  23. <loading :visible="isLoading"></loading>
  24. </div>
  25. </template>
  26. <script>
  27. import * as API_Leave from '@/apis/Master/leave'
  28. import Common from '$project/components/Common.vue'
  29. import Loading from '$project/components/Loading.vue'
  30. import TopHeader from '$project/components/TopHeader.vue'
  31. import isReachBottom from '$project/utils/isReachBottom'
  32. import NullList from '$project/components/NullList.vue'
  33. import {
  34. mapGetters,
  35. mapMutations
  36. } from 'vuex'
  37. export default {
  38. name: 'MasterAttendanceLeaveList',
  39. components: {
  40. Common,
  41. Loading,
  42. TopHeader,NullList
  43. },
  44. data() {
  45. return {
  46. pageTitle: '请假记录',
  47. isLoading: false,
  48. listForm: {
  49. pageIndex: 1,
  50. pageSize: 20,
  51. // token: '',
  52. totalPage: 1,
  53. result: 0,
  54. },
  55. recordList: [],
  56. status: ['待审核', '已批准', '已拒绝'],
  57. statusColor: ['', 'mui-btn-success', 'mui-btn-danger'],
  58. }
  59. },
  60. created() {
  61. //this.listForm.openId = this.openId;
  62. //this.listForm.result = this.$route.query.result != null ? this.$route.query.result : 0;
  63. },
  64. methods: {
  65. //info
  66. detail(id) {
  67. this.$router.push({
  68. name: 'MasterAttendanceLeaveInfo',
  69. query: {
  70. id: id
  71. }
  72. })
  73. },
  74. save() {
  75. this.$router.push({
  76. name: 'MasterAttendanceLeaveForm',
  77. query: {
  78. }
  79. })
  80. },
  81. //获取列表
  82. getList() {
  83. this.isLoading = true;
  84. API_Leave.pageList(this.listForm).then(response => {
  85. if (response) {
  86. if (this.listForm.pageIndex == 1) {
  87. this.recordList = response.data;
  88. this.listForm.pageIndex = response.pageNumber;
  89. this.listForm.totalPage = response.totalPage;
  90. } else {
  91. this.recordList = [
  92. ...this.recordList,
  93. ...response.data
  94. ];
  95. }
  96. }
  97. this.listForm.pageIndex++;
  98. this.isLoading = false;
  99. }).catch(error => {
  100. this.isLoading = false;
  101. mui.toast(error);
  102. })
  103. },
  104. //下拉事件
  105. handleScrool() {
  106. if (isReachBottom()) {
  107. console.log('到达底部')
  108. if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
  109. this.getList();
  110. } else {
  111. return;
  112. }
  113. }
  114. },
  115. asynCallBack() {
  116. },
  117. },
  118. mounted() {
  119. this.getList();
  120. //监控下拉加载事件
  121. var _this = this;
  122. window.addEventListener('scroll', _this.handleScrool);
  123. },
  124. destroyed() {
  125. //销毁监听事件
  126. var _this = this;
  127. window.removeEventListener('scroll', _this.handleScrool);
  128. },
  129. computed: {
  130. ...mapGetters({
  131. openId: 'wx_openid',
  132. token: 'token',
  133. })
  134. },
  135. }
  136. </script>
  137. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  138. <style>
  139. </style>