leave.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. const app = getApp()
  2. const util = require("../../../utils/util");
  3. const mallapi = require('../../../api/mall.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. companyShortName: '',
  10. scrollTop: 200,
  11. inputShowed: false,
  12. //显示结果view的状态
  13. viewShowed: false,
  14. // 搜索框值
  15. inputVal: "",
  16. leaveList: [],
  17. pageNo: 1,
  18. pageSize: 30,
  19. total: 0,
  20. goLeaveState:true,
  21. },
  22. //取消请假
  23. cancelLeave: function (e) {
  24. console.log(e.currentTarget.dataset.id);
  25. let that=this;
  26. util.request(mallapi.CancelLeave, {
  27. id:e.currentTarget.dataset.id
  28. }, "GET").then(function (res) {
  29. if (res.errno === 0) {
  30. that.myshowtost('取消成功')
  31. that.getWorkerLeaveList();
  32. }else{
  33. that.myshowtost('取消失败')
  34. }
  35. });
  36. },
  37. goLeavepost: function () {
  38. wx.navigateTo({
  39. url: '/pages/servant/leavepost/leavepost'
  40. })
  41. },
  42. imgYu (event) {
  43. var src = event.currentTarget.dataset.src;//获取data-src
  44. var imgList = event.currentTarget.dataset.list;//获取data-list
  45. //图片预览
  46. wx.previewImage({
  47. current: src, // 当前显示图片的http链接
  48. urls: imgList // 需要预览的图片http链接列表
  49. })
  50. },
  51. /**
  52. * 生命周期函数--监听页面加载
  53. */
  54. onLoad: function (options) {
  55. },
  56. setGoLeave(){
  57. //北京不允许请假
  58. let userInfo = wx.getStorageSync('userInfo');
  59. if(userInfo.stationName&&userInfo.stationName!=''&&userInfo.stationName.indexOf('北京')!=-1){
  60. this.setData({
  61. goLeaveState:false
  62. })
  63. }
  64. },
  65. getWorkerLeaveList() {
  66. //最近30条请假够了
  67. let that=this;
  68. util.request(mallapi.GetLeavePageList, {
  69. pageNo: this.data.pageNo,
  70. pageSize: this.data.pageSize
  71. }, "GET").then(function (res) {
  72. if (res.errno === 0) {
  73. res.data.list.forEach(t=>{
  74. t.leaveStartTime=util.formatTime(new Date(t.leaveStartTime));
  75. t.leaveEndTime=util.formatTime(new Date(t.leaveEndTime));
  76. if(t.leaveImages!=null&&t.leaveImages!=''){
  77. t.imgarr=t.leaveImages.split(',');
  78. }else{
  79. t.imgarr=[];
  80. }
  81. })
  82. that.setData({
  83. leaveList:res.data.list,
  84. total:res.data.total,
  85. })
  86. }
  87. });
  88. },
  89. /**
  90. * 生命周期函数--监听页面初次渲染完成
  91. */
  92. onReady: function () {
  93. },
  94. /**
  95. * 生命周期函数--监听页面显示
  96. */
  97. onShow: function () {
  98. this.getWorkerLeaveList();
  99. this.setGoLeave();
  100. this.getWorkerLeaveList();
  101. },
  102. /**
  103. * 生命周期函数--监听页面隐藏
  104. */
  105. onHide: function () {
  106. },
  107. /**
  108. * 生命周期函数--监听页面卸载
  109. */
  110. onUnload: function () {
  111. },
  112. /**
  113. * 页面相关事件处理函数--监听用户下拉动作
  114. */
  115. onPullDownRefresh: function () {
  116. console.log('监听用户下拉动作')
  117. wx.showNavigationBarLoading()
  118. this.data.shareClueList = []
  119. this.data.pageNo = 1
  120. this.getSelectClueReceiveFranData()
  121. wx.stopPullDownRefresh(); //停止下拉刷新效果
  122. wx.hideNavigationBarLoading()
  123. },
  124. /**
  125. * 页面上拉触底事件的处理函数
  126. */
  127. onReachBottom: function () {
  128. },
  129. //退出
  130. ComLoginOutBtn: function () {
  131. wx.navigateBack({});
  132. },
  133. myshowtost: function (v) {
  134. wx.showToast({
  135. title: v,
  136. icon: 'none',
  137. duration: 2000
  138. })
  139. },
  140. })