List.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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.supplementWorkId)">{{item.type=='1'?'已外勤打卡':'已补卡'}}</button>
  13. <button type="button" class="mui-btn mui-btn-primary" v-if="item.result=='0' && item.status=='3'" @click="goToInfo(item.supplementWorkId)">已拒绝</button>
  14. <button type="button" class="mui-btn mui-btn-primary" v-if="item.result=='0' && item.status=='0'" @click="goToInfo(item.supplementWorkId)">审核中</button>
  15. <button type="button" class="mui-btn mui-btn-primary" v-if="item.result=='0' && item.status===null" @click="applybk(item.id,item.recordTime)">申请补卡</button>
  16. <button type="button" class="mui-btn mui-btn-primary" v-if="item.result=='0' && item.status==='6'" @click="applybk(item.id,item.recordTime)">申请补卡</button>
  17. <span :style="'color:'+statusColor[item.result]" v-text="status[item.result]">缺卡</span>
  18. </div>
  19. </li>
  20. </ul>
  21. </div>
  22. </div>
  23. <NullList :remark="'暂无考勤记录'" v-if="!recordList.length"></NullList>
  24. <!--弹窗-->
  25. <loading :visible="isLoading"></loading>
  26. </div>
  27. </template>
  28. <script>
  29. import * as API_Attendance from '@/apis/Master/attendance'
  30. import Common from '$project/components/Common.vue'
  31. import Loading from '$project/components/Loading.vue'
  32. import TopHeader from '$project/components/TopHeader.vue'
  33. import isReachBottom from '$project/utils/isReachBottom'
  34. import NullList from '$project/components/NullList.vue'
  35. import {
  36. mapGetters,
  37. mapMutations
  38. } from 'vuex'
  39. export default {
  40. name: 'MasterAttendanceList',
  41. components: {
  42. Common,
  43. Loading,
  44. TopHeader,
  45. NullList
  46. },
  47. data() {
  48. return {
  49. //pageTitle: '考勤记录',
  50. isLoading: false,
  51. listForm: {
  52. pageIndex: 1,
  53. pageSize: 20,
  54. totalPage: 1,
  55. result: 0,
  56. },
  57. recordList: [],
  58. status: ['缺卡', '正常', '迟到', '早退', '请假','出差'],
  59. statusColor: ['#fe616c', '#05c8af', '#f6f448', '#f6f448', '#f6f448', '#f6f448'],
  60. rightLink: {
  61. show: true,
  62. icon: 'icon-shijian',
  63. style: 'font-size:14px;color:#000;',
  64. title: '缺卡记录'
  65. },
  66. }
  67. },
  68. created() {
  69. this.listForm.openId = this.openId;
  70. this.listForm.result = this.$route.query.result != null ? this.$route.query.result : 0;
  71. },
  72. methods: {
  73. //申请补卡
  74. applybk(id,time) {
  75. this.$router.push({
  76. name: 'MasterAttendanceApply',
  77. query: {
  78. id: id,
  79. time:time
  80. }
  81. })
  82. },
  83. //跳转申请补卡详情
  84. goToInfo(id) {
  85. this.$router.push({
  86. name: 'XsyApprovalInfo',
  87. query: {
  88. id: id,
  89. formId:'applyWork'
  90. }
  91. })
  92. },
  93. //获取列表
  94. getList() {
  95. this.isLoading = true;
  96. API_Attendance.pageList(this.listForm).then(response => {
  97. if (response) {
  98. if (this.listForm.pageIndex == 1) {
  99. this.recordList = response.data;
  100. this.listForm.pageIndex = response.pageNumber;
  101. this.listForm.totalPage = response.totalPage;
  102. } else {
  103. this.recordList = [
  104. ...this.recordList,
  105. ...response.data
  106. ];
  107. }
  108. }
  109. this.listForm.pageIndex++;
  110. this.isLoading = false;
  111. }).catch(error => {
  112. this.isLoading = false;
  113. mui.toast(error);
  114. })
  115. },
  116. //下拉事件
  117. handleScrool() {
  118. if (isReachBottom()) {
  119. console.log('到达底部')
  120. if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
  121. this.getList();
  122. } else {
  123. return;
  124. }
  125. }
  126. },
  127. //右上角点击事件
  128. doRightLink() {
  129. this.listForm.pageIndex = 1;
  130. this.listForm.result = this.listForm.result == 1 ? 0 : 1;
  131. this.getList();
  132. },
  133. asynCallBack() {
  134. },
  135. },
  136. mounted() {
  137. this.getList();
  138. //监控下拉加载事件
  139. var _this = this;
  140. window.addEventListener('scroll', _this.handleScrool);
  141. },
  142. destroyed() {
  143. //销毁监听事件
  144. var _this = this;
  145. window.removeEventListener('scroll', _this.handleScrool);
  146. },
  147. computed: {
  148. pageTitle: {
  149. // getter
  150. get: function() {
  151. if (this.listForm.result) {
  152. return '缺卡记录';
  153. } else {
  154. return '考勤记录';
  155. }
  156. },
  157. // setter
  158. set: function(newValue) {
  159. console.log(newValue)
  160. }
  161. },
  162. ...mapGetters({
  163. openId: 'wx_openid',
  164. token: 'token',
  165. })
  166. },
  167. watch: {
  168. 'listForm.result': function(newVal, oldVal) {
  169. if (newVal == 0) {
  170. this.rightLink.title = '缺卡记录';
  171. } else {
  172. this.rightLink.title = '考勤记录';
  173. }
  174. }
  175. },
  176. //keepalive监控判断
  177. beforeRouteLeave(to, from, next) {
  178. console.log(to.name);
  179. if (['MasterAttendanceInfo', 'MasterAttendanceApply'].indexOf(to.name) > -1) {
  180. this.$store.commit('SET_KEEP_ALIVE_COMPONENTS', ['MasterAttendanceList'])
  181. } else {
  182. this.$store.commit('SET_KEEP_ALIVE_COMPONENTS', [])
  183. }
  184. next()
  185. },
  186. }
  187. </script>
  188. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  189. <style src="$project/assets/css/iconfont.css"></style>
  190. <style scoped>
  191. </style>