|
@@ -16,7 +16,7 @@
|
|
|
</template>
|
|
|
<span style="margin-left:20px">总填报时长:</span>
|
|
|
<span>{{totalReportHours}}h</span>
|
|
|
- </div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
<template #right-icon>
|
|
|
<van-button icon="replay" native-type="button" type="default" size="mini" style="height:0.6rem;padding:0 0.16667rem;" :loading="cardRefLoading" loading-size="0.26667rem" @click.stop.native="cardtimeRefresh(form.createDate)" v-if="user.timeType.syncCorpwxTime==1 && (form.createDate == today || !report.time || report.time.workHours <= 0) && (user.timeType.syncDingding == 1 || user.timeType.syncCorpwxTime == 1)"></van-button>
|
|
@@ -997,6 +997,7 @@ import timetoolVue from '../timetool/timetool.vue';
|
|
|
this.curWorktime.endTime = this.endTime;
|
|
|
this.showWorkEndTime = false;
|
|
|
}
|
|
|
+ this.setTotalReportHours()
|
|
|
},
|
|
|
|
|
|
confirmTime(item, field, index) {
|
|
@@ -1018,61 +1019,78 @@ import timetoolVue from '../timetool/timetool.vue';
|
|
|
let domains = this.form.domains
|
|
|
let hours = 0
|
|
|
let arrNum = [] // 用于时间段计算加班时间
|
|
|
+ let timeArr = []
|
|
|
for(let i in domains){
|
|
|
- // if(domains[i].projectId){
|
|
|
- // hours += parseFloat(domains[i].workingTime)
|
|
|
if(this.reportTimeType.multiWorktime == 1){
|
|
|
for(let m in domains[i].worktimeList){
|
|
|
if(domains[i].worktimeList[m].startTime && domains[i].worktimeList[m].endTime){
|
|
|
- hours += this.getHour(domains[i].worktimeList[m].startTime, domains[i].worktimeList[m].endTime)
|
|
|
+ // hours += this.getHour(domains[i].worktimeList[m].startTime, domains[i].worktimeList[m].endTime)
|
|
|
+ timeArr.push({startTime: domains[i].worktimeList[m].startTime, endTime:domains[i].worktimeList[m].endTime})
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
if(this.user.timeType.type == 2){
|
|
|
if(domains[i].startTime && domains[i].endTime){
|
|
|
- let selectionTime = this.getHour(domains[i].startTime, domains[i].endTime)
|
|
|
- let subtractedData = 0
|
|
|
- let arr = JSON.parse(JSON.stringify(this.vacationTime))
|
|
|
- arr.unshift({s: domains[i].startTime, e: domains[i].endTime})
|
|
|
- for(var j in arr) {
|
|
|
- subtractedData += +this.timeOverlap(j, arr)
|
|
|
- }
|
|
|
- console.log(selectionTime, subtractedData)
|
|
|
- hours += +selectionTime - +subtractedData
|
|
|
- console.log(hours)
|
|
|
- arrNum.push(+selectionTime - +subtractedData)
|
|
|
+ // let selectionTime = this.getHour(domains[i].startTime, domains[i].endTime)
|
|
|
+ // let subtractedData = 0
|
|
|
+ // let arr = JSON.parse(JSON.stringify(this.vacationTime))
|
|
|
+ // arr.unshift({s: domains[i].startTime, e: domains[i].endTime})
|
|
|
+ // for(var j in arr) {
|
|
|
+ // subtractedData += +this.timeOverlap(j, arr)
|
|
|
+ // }
|
|
|
+ // console.log(selectionTime, subtractedData)
|
|
|
+ // hours += +selectionTime - +subtractedData
|
|
|
+ // console.log(hours)
|
|
|
+ // arrNum.push(+selectionTime - +subtractedData)
|
|
|
+ timeArr.push({startTime: domains[i].startTime, endTime: domains[i].endTime})
|
|
|
}
|
|
|
} else {
|
|
|
hours += domains[i].workingTime ? parseFloat(domains[i].workingTime) : 0
|
|
|
}
|
|
|
}
|
|
|
- // }
|
|
|
}
|
|
|
- // return hours.toFixed(2)
|
|
|
- this.totalReportHours = hours.toFixed(2)
|
|
|
-
|
|
|
- if(this.user.timeType.type == 2 && this.reportTimeType.multiWorktime != 1) {
|
|
|
- let flg = false
|
|
|
- let zuiNum = 0
|
|
|
- for(let j in arrNum) {
|
|
|
- zuiNum += arrNum[j]
|
|
|
- console.log(zuiNum, arrNum[j], flg)
|
|
|
- if(flg) {
|
|
|
- this.$set(this.form.domains[j],'isOvertime', true)
|
|
|
- this.$set(this.form.domains[j],'overtimeHours', arrNum[j])
|
|
|
- }
|
|
|
- if(zuiNum > this.user.timeType.allday && !flg) {
|
|
|
- flg = true
|
|
|
- this.$set(this.form.domains[j],'isOvertime', true)
|
|
|
- this.$set(this.form.domains[j],'overtimeHours', zuiNum - this.user.timeType.allday)
|
|
|
- }
|
|
|
|
|
|
- if(zuiNum < this.user.timeType.allday && !flg) {
|
|
|
- this.$set(this.form.domains[j],'isOvertime', false)
|
|
|
- this.$set(this.form.domains[j],'overtimeHours', '')
|
|
|
- }
|
|
|
- }
|
|
|
+ // this.totalReportHours = hours.toFixed(2)
|
|
|
+ console.log('timeArr', timeArr)
|
|
|
+ if(this.reportTimeType.multiWorktime == 1 || this.user.timeType.type == 2){
|
|
|
+ this.getTimeHours(timeArr)
|
|
|
+ } else {
|
|
|
+ this.totalReportHours = hours.toFixed(2)
|
|
|
}
|
|
|
+
|
|
|
+ // if(this.user.timeType.type == 2 && this.reportTimeType.multiWorktime != 1) {
|
|
|
+ // let flg = false
|
|
|
+ // let zuiNum = 0
|
|
|
+ // for(let j in arrNum) {
|
|
|
+ // zuiNum += arrNum[j]
|
|
|
+ // console.log(zuiNum, arrNum[j], flg)
|
|
|
+ // if(flg) {
|
|
|
+ // this.$set(this.form.domains[j],'isOvertime', true)
|
|
|
+ // this.$set(this.form.domains[j],'overtimeHours', arrNum[j])
|
|
|
+ // }
|
|
|
+ // if(zuiNum > this.user.timeType.allday && !flg) {
|
|
|
+ // flg = true
|
|
|
+ // this.$set(this.form.domains[j],'isOvertime', true)
|
|
|
+ // this.$set(this.form.domains[j],'overtimeHours', zuiNum - this.user.timeType.allday)
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if(zuiNum < this.user.timeType.allday && !flg) {
|
|
|
+ // this.$set(this.form.domains[j],'isOvertime', false)
|
|
|
+ // this.$set(this.form.domains[j],'overtimeHours', '')
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ getTimeHours(arr) {
|
|
|
+ this.$axios.post("/report/getHoursByTimeRange", {timeJsonStr: JSON.stringify(arr)})
|
|
|
+ .then(res => {
|
|
|
+ if(res.code == "ok") {
|
|
|
+ this.totalReportHours = res.data
|
|
|
+ } else {
|
|
|
+ this.$toast.clear();
|
|
|
+ this.$toast.fail('获取失败');
|
|
|
+ }
|
|
|
+ }).catch(err=> {this.$toast.clear();});
|
|
|
},
|
|
|
|
|
|
filter(type, options) {
|
|
@@ -1688,6 +1706,8 @@ import timetoolVue from '../timetool/timetool.vue';
|
|
|
}
|
|
|
|
|
|
this.form.domains.push(item)
|
|
|
+ //重新计算总时长
|
|
|
+ this.setTotalReportHours();
|
|
|
this.canEdit = true
|
|
|
this.$forceUpdate()
|
|
|
},
|
|
@@ -1699,6 +1719,8 @@ import timetoolVue from '../timetool/timetool.vue';
|
|
|
message: '是否移除当前项目'
|
|
|
}).then(() => {
|
|
|
this.form.domains.splice(i,1);
|
|
|
+ //重新计算总时长
|
|
|
+ this.setTotalReportHours();
|
|
|
}).catch(() => {
|
|
|
});
|
|
|
},
|