kaoqin.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view >
  3. <view>
  4. <view style="display: flex;justify-content: center;margin: 30rpx;font-size:30rpx ;align-items: center;">
  5. <u-icon name="arrow-left-double" style="font-size: 40rpx;margin-right: 30rpx;" @click="previous"></u-icon>
  6. <div @click="show = true">
  7. {{"第"+weekNum+'周('+weeList[0]+"至"+weeList[weeList.length-1]+')' }}
  8. </div>
  9. <u-icon name="arrow-right-double" style="font-size: 40rpx;margin-left: 30rpx;" @click="next"></u-icon>
  10. </view>
  11. <u-cell-group>
  12. <u-cell icon="setting-fill" :title="v.fullName" size="large" @click="kaoqin(v)" v-for="v in list" :key="v.userId">
  13. <image slot="icon" src="/static/wjw-user.png" mode="widthFix" style="width: 60rpx;margin-right: 20rpx;"></image>
  14. <view slot="value" style="font-weight: 500;" :style="{color:v.isSave=='1'?'#19be6b':'#fa3534'}">
  15. {{v.isSave=='1'?'已打卡':'未打卡'}}
  16. </view>
  17. </u-cell>
  18. </u-cell-group>
  19. </view>
  20. <u-datetime-picker
  21. :show="show"
  22. v-model="today"
  23. mode="date"
  24. @confirm="confirm"
  25. @cancel="show=false"
  26. ></u-datetime-picker>
  27. </view>
  28. </template>
  29. <script>
  30. import {getWeekInYear,getNowWeekList} from "@/utils/wjw.js"
  31. export default {
  32. data() {
  33. return {
  34. list:[],//人员列表
  35. nowWeekNum:null,//当前周数
  36. //当前周数
  37. weekNum:null,
  38. weeList:[],//周日期列表
  39. nowWeeList:[],//当前周日期列表
  40. xiugaiDay:null,//可修改日期
  41. today:null,//当前日期
  42. show:false,//日历展示
  43. xgType:true,//是否能修改
  44. day:null,//当前日期
  45. mounth:null,//当前月
  46. year:null,//当前年
  47. }
  48. },
  49. onLoad(){
  50. this.today = new Date().getTime()
  51. this.nowWeekNum = getWeekInYear(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
  52. this.weekNum = getWeekInYear(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
  53. this.weeList = getNowWeekList(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
  54. this.nowWeeList = getNowWeekList(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
  55. this.getPeople()
  56. this.getModifyDay()
  57. },
  58. onShow(){
  59. uni.$once('query', (query) => {
  60. if(query.a === 1){
  61. this.getPeople()
  62. }
  63. });
  64. },
  65. onPullDownRefresh(){
  66. this.getPeople()
  67. },
  68. methods: {
  69. //跳转考勤详情页
  70. kaoqin(v){
  71. uni.navigateTo({
  72. url:`/pages/kqdetail/kqdetail?name=${v.fullName}&id=${v.userId}&weekNumber=${this.weekNum}&deptId=${v.deptId}&type=${this.xgType}`
  73. })
  74. },
  75. //查询考勤是否还能修改
  76. getModifyDay(){
  77. uni.$u.http.get('/system/config/configKey/attendanceEditDay').then(res=>{
  78. this.xiugaiDay = Number(res.msg)
  79. })
  80. },
  81. //点击上一周
  82. previous(){
  83. uni.showLoading({
  84. title:"加载中...",
  85. mask:true
  86. })
  87. this.today = this.today - 7*86400000
  88. this.weekNum = getWeekInYear(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  89. this.weeList = getNowWeekList(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  90. this.isXiugai(this.weekNum,this.weeList)
  91. this.getPeople()
  92. },
  93. //点击下一周
  94. next(){
  95. this.today = this.today + 7*86400000
  96. this.weekNum = getWeekInYear(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  97. this.weeList = getNowWeekList(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  98. this.isXiugai(this.weekNum,this.weeList)
  99. this.getPeople()
  100. },
  101. //日历确认
  102. confirm(e){
  103. this.today = e.value
  104. this.weekNum = getWeekInYear(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  105. this.weeList = getNowWeekList(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  106. this.show = false
  107. this.isXiugai(this.weekNum,this.weeList)
  108. this.getPeople()
  109. },
  110. //获取列表人员
  111. getPeople(){
  112. uni.$u.http.get(`/oa/attendance/dept/all/app/${this.weekNum}`).then(res=>{
  113. this.list = res.rows
  114. uni.hideLoading()
  115. setTimeout(()=>{
  116. uni.stopPullDownRefresh()
  117. },2000)
  118. })
  119. },
  120. //判断能否修改
  121. isXiugai(zs,list){
  122. if(zs == this.nowWeekNum){
  123. if(list[0] == this.nowWeeList[0]){
  124. this.xgType = true
  125. }else{
  126. this.xgType = false
  127. }
  128. }else{
  129. let day = uni.$u.timeFormat(new Date().toLocaleDateString(), 'd')
  130. if(this.xiugaiDay<day){
  131. let mounth = new Date(uni.$u.timeFormat(list[6],'yyyy-mm')).getTime()
  132. let dqmounth = new Date(uni.$u.timeFormat(this.nowWeeList[0],'yyyy-mm')).getTime()
  133. if(dqmounth == mounth){
  134. this.xgType = true
  135. }else{
  136. this.xgType = false
  137. }
  138. }else{
  139. if(list[0]>this.nowWeeList[6]){
  140. this.xgType = false
  141. }else{
  142. let mounth = new Date(uni.$u.timeFormat(list[6],'yyyy-mm')).getTime()
  143. let dqmounth = new Date(uni.$u.timeFormat(new Date(),'yyyy-mm')).getTime()
  144. if((dqmounth-mounth)/86400000 <= 31){
  145. this.xgType = true
  146. }else{
  147. this.xgType = false
  148. }
  149. }
  150. }
  151. }
  152. console.log(this.xgType)
  153. }
  154. }
  155. }
  156. </script>
  157. <style>
  158. </style>