123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <template>
- <view >
- <view>
- <view style="display: flex;justify-content: center;margin: 30rpx;font-size:30rpx ;align-items: center;">
- <u-icon name="arrow-left-double" style="font-size: 40rpx;margin-right: 30rpx;" @click="previous"></u-icon>
- <div @click="show = true">
- {{"第"+weekNum+'周('+weeList[0]+"至"+weeList[weeList.length-1]+')' }}
- </div>
- <u-icon name="arrow-right-double" style="font-size: 40rpx;margin-left: 30rpx;" @click="next"></u-icon>
- </view>
- <u-cell-group>
- <u-cell icon="setting-fill" :title="v.fullName" size="large" @click="kaoqin(v)" v-for="v in list" :key="v.userId">
- <image slot="icon" src="/static/wjw-user.png" mode="widthFix" style="width: 60rpx;margin-right: 20rpx;"></image>
- <view slot="value" style="font-weight: 500;" :style="{color:v.isSave=='1'?'#19be6b':'#fa3534'}">
- {{v.isSave=='1'?'已打卡':'未打卡'}}
- </view>
- </u-cell>
- </u-cell-group>
- </view>
- <u-datetime-picker
- :show="show"
- v-model="today"
- mode="date"
- @confirm="confirm"
- @cancel="show=false"
- ></u-datetime-picker>
- </view>
- </template>
- <script>
- import {getWeekInYear,getNowWeekList} from "@/utils/wjw.js"
- export default {
- data() {
- return {
- list:[],//人员列表
- nowWeekNum:null,//当前周数
- //当前周数
- weekNum:null,
- weeList:[],//周日期列表
- nowWeeList:[],//当前周日期列表
- xiugaiDay:null,//可修改日期
- today:null,//当前日期
- show:false,//日历展示
- xgType:true,//是否能修改
- day:null,//当前日期
- mounth:null,//当前月
- year:null,//当前年
- }
- },
- onLoad(){
- this.today = new Date().getTime()
- this.nowWeekNum = getWeekInYear(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
- this.weekNum = getWeekInYear(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
- this.weeList = getNowWeekList(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
- this.nowWeeList = getNowWeekList(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
- this.getPeople()
- this.getModifyDay()
- },
- onShow(){
- uni.$once('query', (query) => {
- if(query.a === 1){
- this.getPeople()
- }
- });
- },
- onPullDownRefresh(){
- this.getPeople()
- },
- methods: {
- //跳转考勤详情页
- kaoqin(v){
- uni.navigateTo({
- url:`/pages/kqdetail/kqdetail?name=${v.fullName}&id=${v.userId}&weekNumber=${this.weekNum}&deptId=${v.deptId}&type=${this.xgType}`
- })
- },
- //查询考勤是否还能修改
- getModifyDay(){
- uni.$u.http.get('/system/config/configKey/attendanceEditDay').then(res=>{
- this.xiugaiDay = Number(res.msg)
- })
- },
- //点击上一周
- previous(){
- uni.showLoading({
- title:"加载中...",
- mask:true
- })
- this.today = this.today - 7*86400000
- this.weekNum = getWeekInYear(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
- this.weeList = getNowWeekList(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
- this.isXiugai(this.weekNum,this.weeList)
- this.getPeople()
- },
- //点击下一周
- next(){
- this.today = this.today + 7*86400000
- this.weekNum = getWeekInYear(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
- this.weeList = getNowWeekList(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
- this.isXiugai(this.weekNum,this.weeList)
- this.getPeople()
- },
- //日历确认
- confirm(e){
- this.today = e.value
- this.weekNum = getWeekInYear(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
- this.weeList = getNowWeekList(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
- this.show = false
- this.isXiugai(this.weekNum,this.weeList)
- this.getPeople()
- },
- //获取列表人员
- getPeople(){
- uni.$u.http.get(`/oa/attendance/dept/all/app/${this.weekNum}`).then(res=>{
- this.list = res.rows
- uni.hideLoading()
- setTimeout(()=>{
- uni.stopPullDownRefresh()
- },2000)
- })
- },
- //判断能否修改
- isXiugai(zs,list){
- if(zs == this.nowWeekNum){
- if(list[0] == this.nowWeeList[0]){
- this.xgType = true
- }else{
- this.xgType = false
- }
- }else{
- let day = uni.$u.timeFormat(new Date().toLocaleDateString(), 'd')
- if(this.xiugaiDay<day){
- let mounth = new Date(uni.$u.timeFormat(list[6],'yyyy-mm')).getTime()
- let dqmounth = new Date(uni.$u.timeFormat(this.nowWeeList[0],'yyyy-mm')).getTime()
- if(dqmounth == mounth){
- this.xgType = true
- }else{
- this.xgType = false
- }
- }else{
- if(list[0]>this.nowWeeList[6]){
- this.xgType = false
- }else{
- let mounth = new Date(uni.$u.timeFormat(list[6],'yyyy-mm')).getTime()
- let dqmounth = new Date(uni.$u.timeFormat(new Date(),'yyyy-mm')).getTime()
- if((dqmounth-mounth)/86400000 <= 31){
- this.xgType = true
- }else{
- this.xgType = false
- }
- }
- }
- }
- console.log(this.xgType)
- }
- }
- }
- </script>
- <style>
- </style>
|