|
@@ -2840,6 +2840,18 @@
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ // 按周填报调用接口计算时间
|
|
|
+ async getWeekHoursByTimeRange(timeRange) {
|
|
|
+ const url = '/report/getHoursByTimeRange';
|
|
|
+ const data = { timeJsonStr: `${JSON.stringify(timeRange)}` };
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.http.post(url, data, function(res) {
|
|
|
+ res.code === 'ok' ? resolve(res.data) : reject(res.msg);
|
|
|
+ }, function(err) {
|
|
|
+ reject(err);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
removeTimeItem(item, index) {
|
|
|
item.worktimeList.splice(index, 1);
|
|
|
this.iptChangs()
|
|
@@ -5053,6 +5065,7 @@
|
|
|
var zhong = this.zhoData
|
|
|
zhong[this.zhoBaoIdx][this.zhoBaoName] = this.zhoBao
|
|
|
this.zhoData = zhong
|
|
|
+ console.log('该看看了', this.reportTimeType.type, 2)
|
|
|
if(this.reportTimeType.type == 1) this.zhoXuan(this.zhoBao, this.zhoBaoIdx)
|
|
|
if(this.reportTimeType.type == 2) this.zhoTimes(this.zhoBao, this.zhoBaoIdx)
|
|
|
if(this.reportTimeType.type == 3) this.addBli(this.zhoBao, this.zhoBaoIdx)
|
|
@@ -5350,35 +5363,32 @@
|
|
|
this.changdu = this.projectList.length + 1
|
|
|
},
|
|
|
// 自动选择时间点的事件
|
|
|
- zhoTimes(item, i, ims, event) {
|
|
|
- var iss = i
|
|
|
- if(item.time == null) {
|
|
|
- return
|
|
|
- } else {
|
|
|
- var zhi = this.zhoData[iss]
|
|
|
- var he = 0
|
|
|
- for(var i in zhi) {
|
|
|
- if(zhi[i].time && zhi[i].time.length > 0 && i != 'zhoDataTime' && i != 'he') {
|
|
|
- let selectionTime = this.getHour(zhi[i].time[0], zhi[i].time[1])
|
|
|
- let subtractedData = 0
|
|
|
- // he += +this.getHour(zhi[i].time[0], zhi[i].time[1])
|
|
|
- // 计算需要减去的时间
|
|
|
- let arr = JSON.parse(JSON.stringify(this.vacationTime))
|
|
|
- arr.unshift({s: zhi[i].time[0], e: zhi[i].time[1]})
|
|
|
- console.log(arr, '要看的数据')
|
|
|
-
|
|
|
- for(var j in arr) {
|
|
|
- subtractedData += +this.timeOverlap(j, arr)
|
|
|
- }
|
|
|
-
|
|
|
- he = +selectionTime - +subtractedData
|
|
|
- console.log(selectionTime ,subtractedData)
|
|
|
+ // async zhoTimes(item, i) {
|
|
|
+ // var iss = i
|
|
|
+ // if(item.time == null) {
|
|
|
+ // return
|
|
|
+ // } else {
|
|
|
+ // const zhi = this.zhoData[iss];
|
|
|
+ // let he = 0;
|
|
|
+ // const timeArr = Object.values(zhi)
|
|
|
+ // .filter(item => item.time && item.time.length > 0 && item !== zhi.zhoDataTime && item !== zhi.he)
|
|
|
+ // .map(item => ({ startTime: item.time[0], endTime: item.time[1] }));
|
|
|
+ // const data = await this.getWeekHoursByTimeRange(timeArr);
|
|
|
+ // console.log(data, 'data');
|
|
|
+ // zhi.he = `${he}h`;
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- zhi.he = he + 'h'
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ async zhoTimes(item, index) {
|
|
|
+ const zho = this.zhoData[index];
|
|
|
+ if (!item.time) {
|
|
|
+ return;
|
|
|
}
|
|
|
- console.log(zhi.he, '看看结果')
|
|
|
+ const timeArr = Object.values(zho)
|
|
|
+ .filter(({ time }) => time && time.length > 0 && time !== zho.zhoDataTime && time !== zho.he)
|
|
|
+ .map(({ time }) => ({ startTime: time[0], endTime: time[1] }));
|
|
|
+ const totalHours = await Promise.all([{}].map(() => this.getWeekHoursByTimeRange(timeArr)));
|
|
|
+ zho.he = `${totalHours[0]}h`;
|
|
|
},
|
|
|
// 判断两个时间段是否重叠
|
|
|
timeOverlap(idx, dateAr) {
|
|
@@ -5557,11 +5567,13 @@
|
|
|
this.dateAr = []
|
|
|
var alp = []
|
|
|
var zhis = zhi[i]
|
|
|
+ console.log(zhis)
|
|
|
for(var j in zhis) {
|
|
|
if(j != 'zhoDataTime' && j != 'he' && zhis[j].time != null && zhis[j].time != 'null' && zhis[j].time != '') {
|
|
|
let objs = {}
|
|
|
objs.s = zhis[j].time[0]
|
|
|
objs.e = zhis[j].time[1]
|
|
|
+ objs.p = j
|
|
|
alp.push(objs)
|
|
|
}
|
|
|
}
|
|
@@ -5573,14 +5585,21 @@
|
|
|
alp.push(objs)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ console.log(alp)
|
|
|
this.dateAr = alp
|
|
|
+ let str = this.$t('message.Filledtimeperiodsoverlap')
|
|
|
if(this.dateAr.length > 0) {
|
|
|
- let trus = this.fns()
|
|
|
+ const trus = this.fns();
|
|
|
+ const overlapDataTime = this.getOverlapData(alp);
|
|
|
+ if (overlapDataTime.length > 0) {
|
|
|
+ const arrList = overlapDataTime.map((item) => item.p);
|
|
|
+ str = `${this.zhoData[i].zhoDataTime} 【${arrList.join(',')}】项目 填写的时间段重叠`;
|
|
|
+ }
|
|
|
+
|
|
|
ll += 1
|
|
|
if(!trus) {
|
|
|
this.$message({
|
|
|
- message: this.$t('message.Filledtimeperiodsoverlap'),
|
|
|
+ message: str,
|
|
|
type: 'error'
|
|
|
})
|
|
|
return false
|
|
@@ -6074,11 +6093,12 @@
|
|
|
fns() {
|
|
|
for (let k in this.dateAr) {
|
|
|
if (!this.judege(k)) {
|
|
|
- return false
|
|
|
+ return false
|
|
|
}
|
|
|
}
|
|
|
return true
|
|
|
},
|
|
|
+
|
|
|
judege(idx){
|
|
|
for (let k in this.dateAr) {
|
|
|
if (idx !== k) {
|
|
@@ -6093,6 +6113,18 @@
|
|
|
return true
|
|
|
},
|
|
|
|
|
|
+ getOverlapData(data) {
|
|
|
+ let overlapData = [];
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ for (let j = i + 1; j < data.length; j++) {
|
|
|
+ if (data[i].s < data[j].e && data[j].s < data[i].e) {
|
|
|
+ overlapData.push(data[i], data[j]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return overlapData;
|
|
|
+ },
|
|
|
+
|
|
|
// 保存日报111111
|
|
|
submitReport(isDraft) {
|
|
|
this.isDraft = isDraft;
|