VerifyList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <div>
  3. <common @asynCallBack="asynCallBack"></common>
  4. <top-header :pageTitle="pageTitle"></top-header>
  5. <div class="mui-content vongi-wordcard-sp">
  6. <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
  7. <div class="mui-scroll">
  8. <a @click="reloadList('0')" :class="'mui-control-item '+(listForm.status=='0'?'mui-active':'')">
  9. <span class="fyy-badge">待处理<span class="mui-badge" v-if="firstRecordsTotal" v-text="firstRecordsTotal"></span></span>
  10. </a>
  11. <a @click="reloadList('1')" :class="'mui-control-item '+(listForm.status=='1'?'mui-active':'')">
  12. 已处理
  13. </a>
  14. </div>
  15. </div>
  16. <NullList :remark="'暂无申请记录'" v-if="!recordList.length"></NullList>
  17. <div id="slider" class="mui-slider mui-fullscreen vongi-over">
  18. <div class="mui-slider-group vongi-cchai">
  19. <div v-if="listForm.status=='0'" class="mui-slider-item mui-control-content mui-active">
  20. <div class="mui-scroll-wrapper vongi-over-hei">
  21. <div class="mui-scroll">
  22. <form class="mui-input-group fyy-checkbox">
  23. <div v-for="(item,index) in recordList" class="mui-input-row mui-checkbox mui-left">
  24. <router-link :to="{name:'MasterExtraWorkVerifyInfo',query:{id:item.id}}">
  25. <h4>{{item.personName}}的加班申请<span class="mui-h6 mui-pull-right" v-text="item.dateTime.substr(5)"></span></h4>
  26. <p class='mui-ellipsis'>加班时间:{{item.workOverTime}}</p>
  27. <p class='mui-ellipsis flew-items flew-sp'>
  28. 加班时长:{{item.hours}}小时
  29. <button type="button" class="mui-btn mui-btn-primary mui-btn-outlined" :style="getColor(item.status)"
  30. v-text="item.statusN"></button>
  31. </p>
  32. </router-link>
  33. <input name="checkbox" v-model="selectIdList" :value="item.id" type="checkbox">
  34. </div>
  35. </form>
  36. </div>
  37. </div>
  38. </div>
  39. <div v-if="listForm.status=='1'" class="mui-slider-item mui-control-content">
  40. <div class="mui-scroll-wrapper">
  41. <div class="mui-scroll">
  42. <ul class="mui-table-view mui-table-view-chevron">
  43. <li v-for="(item,index) in recordList" class="mui-table-view-cell mui-media">
  44. <router-link :to="{name:'MasterExtraWorkVerifyInfo',query:{id:item.id}}">
  45. <h4>{{item.personName}}的加班申请<span class="mui-h6 mui-pull-right" v-text="item.dateTime.substr(5)"></span></h4>
  46. <p class='mui-ellipsis'>加班时间:{{item.workOverTime}}</p>
  47. <p class='mui-ellipsis flew-items flew-sp'>
  48. 加班时长:{{item.hours}}小时
  49. <button type="button" class="mui-btn mui-btn-primary mui-btn-outlined" :style="getColor(item.status)"
  50. v-text="item.statusN"></button>
  51. </p>
  52. </router-link>
  53. </li>
  54. </ul>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div v-show="recordList.length>0 && listForm.status==0" class="vongi-ad-fix" style="z-index:99">
  61. <div class=" vongi-wordcard" v-if="approvalPersonList.length">
  62. <form class="mui-input-group">
  63. <div class="mui-input-row">
  64. <label class="color4fc5f7">下一步审批人</label>
  65. <div v-if="approvalPersonList.length!=1" class="mui-navigate-right" @click="selectPerson">
  66. <button id='showUserPicker' class="mui-btn mui-btn-block" type='button'><span v-text="approvalPersonName"></span></button>
  67. </div>
  68. <div v-if="approvalPersonList.length==1">
  69. <button class="mui-btn mui-btn-block" type='button'><span v-text="approvalPersonName"></span></button>
  70. </div>
  71. </div>
  72. </form>
  73. </div>
  74. <div class="fyy-bindfyy-btn">
  75. <form class="mui-input-group">
  76. <div class="mui-input-row mui-checkbox mui-left">
  77. <label>全选</label>
  78. <input v-model="allSelect" value="1" type="checkbox" @click="selectAll" :checked="recordList.length==selectIdList.length">
  79. </div>
  80. </form>
  81. <button type="button" class="mui-btn mui-btn-danger" @click="openFrom('2')">拒绝</button>
  82. <button type="button" class="mui-btn mui-btn-success" @click="openFrom('1')">同意</button>
  83. </div>
  84. </div>
  85. </div>
  86. <loading :visible="isLoading"></loading>
  87. </div>
  88. </template>
  89. <script>
  90. import * as API_BusinessTravel from '@/apis/Master/business_travel'
  91. import * as API_ExtraWork from '@/apis/Master/extra_work'
  92. import Common from '$project/components/Common.vue'
  93. import Loading from '$project/components/Loading.vue'
  94. import TopHeader from '$project/components/TopHeader.vue'
  95. import isReachBottom from '$project/utils/isReachBottom'
  96. import NullList from '$project/components/NullList.vue'
  97. import {
  98. mapGetters,
  99. mapMutations
  100. } from 'vuex'
  101. export default {
  102. name: 'MasterExtraWorkVerifyList',
  103. components: {
  104. Common,
  105. Loading,
  106. TopHeader,
  107. NullList
  108. },
  109. data() {
  110. return {
  111. pageTitle: '加班审批',
  112. isLoading: false,
  113. listForm: {
  114. type: '3',
  115. pageIndex: 1,
  116. pageSize: 20,
  117. totalPage: 1,
  118. status: '0'
  119. },
  120. recordList: [],
  121. approvalPersonList: [],
  122. approvalPerson: true,
  123. subForm: {
  124. ids: '',
  125. approvalContent: '',
  126. status: '',
  127. nextApprovalId: '',
  128. },
  129. //补卡1,外出2,出差3 ,请假/加班4
  130. personForm: {
  131. type: '4'
  132. },
  133. selectIdList: [],
  134. allSelect: [],
  135. firstRecordsTotal: 0,
  136. }
  137. },
  138. created() {},
  139. methods: {
  140. //获取审核人列表
  141. getBusinessOutApprovalPerson() {
  142. this.isLoading = true;
  143. API_BusinessTravel.getBusinessOutApprovalPerson(this.personForm).then(response => {
  144. this.isLoading = false;
  145. var list = response.data;
  146. var approvalPersonList = [];
  147. for (var i = 0; i < list.length; i++) {
  148. approvalPersonList.push({
  149. value: list[i]['id'],
  150. text: list[i]['personName']
  151. })
  152. }
  153. if (approvalPersonList.length) {
  154. this.subForm.nextApprovalId = approvalPersonList[0]['value'];
  155. this.approvalPersonName = approvalPersonList[0]['text'];
  156. }
  157. this.approvalPersonList = approvalPersonList;
  158. this.approvalPerson = true;
  159. }).catch(error => {
  160. this.isLoading = false;
  161. mui.toast(error);
  162. })
  163. },
  164. //选择审核人
  165. selectPerson() {
  166. var _this = this;
  167. var picker = new mui.PopPicker();
  168. picker.setData(_this.approvalPersonList);
  169. picker.pickers[0].setSelectedValue(this.subForm.nextApprovalId);
  170. picker.show(function(selectItems) {
  171. _this.subForm.nextApprovalId = selectItems[0].value;
  172. _this.approvalPersonName = selectItems[0].text;
  173. _this.$forceUpdate()
  174. picker.dispose();
  175. })
  176. },
  177. //获取列表
  178. getList() {
  179. this.isLoading = true;
  180. API_ExtraWork.verifyList(this.listForm).then(response => {
  181. if (response) {
  182. if (this.listForm.pageIndex == 1) {
  183. this.recordList = response.data;
  184. this.listForm.pageIndex = response.pageNumber;
  185. this.listForm.totalPage = response.totalPage;
  186. } else {
  187. this.recordList = [
  188. ...this.recordList,
  189. ...response.data
  190. ];
  191. }
  192. }
  193. if (this.listForm.status == 0) {
  194. this.firstRecordsTotal = response.recordsTotal;
  195. }
  196. this.listForm.pageIndex++;
  197. this.isLoading = false;
  198. }).catch(error => {
  199. this.isLoading = false;
  200. mui.toast(error);
  201. })
  202. },
  203. //下拉事件
  204. handleScrool() {
  205. if (isReachBottom()) {
  206. console.log('到达底部')
  207. if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
  208. this.getList();
  209. } else {
  210. return;
  211. }
  212. }
  213. },
  214. //切换
  215. reloadList(status) {
  216. this.listForm.status = status;
  217. this.listForm.pageIndex = 1;
  218. this.getList();
  219. },
  220. //选择所有
  221. selectAll() {
  222. if (this.allSelect.length) {
  223. this.selectIdList = [];
  224. } else {
  225. var selectIdList = [];
  226. this.recordList.forEach(function(item, index) {
  227. selectIdList.push(item.id);
  228. })
  229. this.selectIdList = selectIdList;
  230. }
  231. },
  232. //显示内容表单
  233. openFrom(status) {
  234. if (!this.selectIdList.length) {
  235. mui.toast('请选择要处理的信息');
  236. } else {
  237. this.subForm.status = status;
  238. this.subForm.approvalContent = status == 1 ? '同意' : '拒绝';
  239. //this.openFromVisible = true;
  240. //直接点击处理,不需要弹窗理由框
  241. this.doAction();
  242. }
  243. },
  244. //检测表单
  245. checkForm() {
  246. if (!this.approvalPerson) {
  247. mui.toast('加载下一级审批人失败,请刷新页面');
  248. return false;
  249. } else if (!this.subForm.ids) {
  250. mui.toast('请选择要处理的信息');
  251. return false;
  252. } else {
  253. return true;
  254. }
  255. },
  256. //同意拒绝
  257. doAction() {
  258. this.subForm.ids = this.selectIdList.join(',');
  259. if (this.checkForm()) {
  260. this.isLoading = true;
  261. API_ExtraWork.approvalWorkOver(this.subForm).then(response => {
  262. this.isLoading = false;
  263. this.openFromVisible = false;
  264. this.listForm.pageIndex = 1;
  265. this.getList();
  266. }).catch(error => {
  267. this.isLoading = false;
  268. mui.toast(error);
  269. })
  270. }
  271. },
  272. //获取状态颜色
  273. getColor(status) {
  274. var color = '';
  275. if (status == '0') {
  276. color = '#4fc5f7';
  277. } else if (status == '1') {
  278. color = '#55f868';
  279. } else if (status == '2') {
  280. color = '#fe616c';
  281. }
  282. return 'color:' + color + ';border-color:' + color + ';';
  283. },
  284. asynCallBack() {
  285. },
  286. },
  287. mounted() {
  288. this.getList();
  289. //this.getBusinessOutApprovalPerson()
  290. //监控下拉加载事件
  291. var _this = this;
  292. window.addEventListener('scroll', _this.handleScrool);
  293. },
  294. destroyed() {
  295. //销毁监听事件
  296. var _this = this;
  297. window.removeEventListener('scroll', _this.handleScrool);
  298. },
  299. computed: {
  300. ...mapGetters({
  301. openId: 'wx_openid',
  302. token: 'token',
  303. })
  304. },
  305. //keepalive监控判断
  306. beforeRouteLeave(to, from, next) {
  307. console.log(to.name);
  308. if (['MasterExtraWorkVerifyInfo'].indexOf(to.name) > -1) {
  309. this.$store.commit('SET_KEEP_ALIVE_COMPONENTS', ['MasterExtraWorkVerifyList'])
  310. } else {
  311. this.$store.commit('SET_KEEP_ALIVE_COMPONENTS', [])
  312. }
  313. next()
  314. },
  315. }
  316. </script>
  317. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  318. <style src="$project/assets/css/iconfont.css"></style>
  319. <style scoped>
  320. .mui-segmented-control {
  321. position: fixed;
  322. top: 44px;
  323. z-index: 99;
  324. background-color: #eee;
  325. }
  326. .mui-fullscreen {
  327. position: unset;
  328. margin-top: 45px;
  329. }
  330. </style>