List.vue 5.8 KB

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