List.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div>
  3. <common @asynCallBack="asynCallBack"></common>
  4. <top-header :pageTitle="pageTitle" :rightLink="rightLink" :doRightLink="doRightLink"></top-header>
  5. <div class="mui-content">
  6. <div class="mui-content-padded vongi-work">
  7. <!-- <h5>2020-09-28</h5> -->
  8. <ul class="mui-table-view">
  9. <li v-for="(item,index) in recordList" class="mui-table-view-cell">
  10. {{item.recordTime}}
  11. <div class="mui-media-body">
  12. <button type="button" class="mui-btn mui-btn-primary" v-if="item.result=='1' && item.status=='1'" @click="goToInfo(item.fillAttendanceId)">{{item.type=='1'?'已异地打卡':'已补卡'}}</button>
  13. <button type="button" class="mui-btn mui-btn-primary" v-if="item.result=='0' && item.status=='2'" @click="goToInfo(item.fillAttendanceId)">已拒绝</button>
  14. <button type="button" class="mui-btn mui-btn-primary" v-if="item.result=='0' && item.status=='0'" @click="goToInfo(item.fillAttendanceId)">审核中</button>
  15. <button type="button" class="mui-btn mui-btn-primary" v-if="item.result=='0' && item.status===null" @click="applybk(item.id)">申请补卡</button>
  16. <span :style="'color:'+statusColor[item.result]" v-text="status[item.result]">缺卡</span>
  17. </div>
  18. </li>
  19. </ul>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import * as API_Attendance from '@/apis/Master/attendance'
  26. import Common from '$project/components/Common.vue'
  27. import Loading from '$project/components/Loading.vue'
  28. import TopHeader from '$project/components/TopHeader.vue'
  29. import isReachBottom from '$project/utils/isReachBottom'
  30. import {
  31. mapGetters,
  32. mapMutations
  33. } from 'vuex'
  34. export default {
  35. name: 'MasterAttendanceList',
  36. components: {
  37. Common,
  38. Loading,
  39. TopHeader
  40. },
  41. data() {
  42. return {
  43. pageTitle: '考勤记录',
  44. isLoading: false,
  45. listForm: {
  46. pageIndex: 1,
  47. pageSize: 20,
  48. totalPage: 1,
  49. result: 0,
  50. },
  51. recordList: [],
  52. status: ['缺卡', '正常', '迟到', '早退'],
  53. statusColor: ['#fe616c', '#05c8af', '#f6f448', '#f6f448'],
  54. rightLink: {
  55. show: true,
  56. icon: 'icon-shijian',
  57. style: 'font-size:14px;color:#000;',
  58. title: '缺卡记录'
  59. },
  60. }
  61. },
  62. created() {
  63. this.listForm.openId = this.openId;
  64. this.listForm.result = this.$route.query.result != null ? this.$route.query.result : 0;
  65. },
  66. methods: {
  67. //申请补卡
  68. applybk(id) {
  69. this.$router.push({
  70. name: 'MasterAttendanceApply',
  71. query: {
  72. id: id
  73. }
  74. })
  75. },
  76. //跳转申请补卡详情
  77. goToInfo(id) {
  78. this.$router.push({
  79. name: 'MasterAttendanceInfo',
  80. query: {
  81. id: id
  82. }
  83. })
  84. },
  85. //获取列表
  86. getList() {
  87. this.isLoading = true;
  88. API_Attendance.pageList(this.listForm).then(response => {
  89. if (response) {
  90. if (this.listForm.pageIndex == 1) {
  91. this.recordList = response.data;
  92. this.listForm.pageIndex = response.pageNumber;
  93. this.listForm.totalPage = response.totalPage;
  94. } else {
  95. this.recordList = [
  96. ...this.recordList,
  97. ...response.data
  98. ];
  99. }
  100. }
  101. this.listForm.pageIndex++;
  102. this.isLoading = false;
  103. }).catch(error => {
  104. this.isLoading = false;
  105. mui.toast(error);
  106. })
  107. },
  108. //下拉事件
  109. handleScrool() {
  110. if (isReachBottom()) {
  111. console.log('到达底部')
  112. if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
  113. this.getList();
  114. } else {
  115. return;
  116. }
  117. }
  118. },
  119. //右上角点击事件
  120. doRightLink() {
  121. this.listForm.pageIndex = 1;
  122. this.listForm.result = this.listForm.result == 1 ? 0 : 1;
  123. this.getList();
  124. },
  125. asynCallBack() {
  126. },
  127. },
  128. mounted() {
  129. this.getList();
  130. //监控下拉加载事件
  131. var _this = this;
  132. window.addEventListener('scroll', _this.handleScrool);
  133. },
  134. destroyed() {
  135. //销毁监听事件
  136. var _this = this;
  137. window.removeEventListener('scroll', _this.handleScrool);
  138. },
  139. computed: {
  140. ...mapGetters({
  141. openId: 'wx_openid',
  142. token: 'token',
  143. })
  144. },
  145. watch: {
  146. 'listForm.result': function(newVal, oldVal) {
  147. if (newVal == 0) {
  148. this.rightLink.title = '缺卡记录';
  149. } else {
  150. this.rightLink.title = '考勤记录';
  151. }
  152. }
  153. }
  154. }
  155. </script>
  156. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  157. <style src="$project/assets/css/iconfont.css"></style>
  158. <style scoped>
  159. </style>