Commit 9e7fdbd4 by 无尘

feat: 增加班次计算

parent 39d3f34f
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @Author: 无尘 * @Author: 无尘
* @Date: 2019-10-21 14:27:29 * @Date: 2019-10-21 14:27:29
* @LastEditors: 无尘 * @LastEditors: 无尘
* @LastEditTime: 2019-12-14 17:52:54 * @LastEditTime: 2019-12-15 17:41:14
--> -->
<!-- <!--
...@@ -29,7 +29,7 @@ import createWorkClass from '@/components/app/dailyAttendance/create-work-class. ...@@ -29,7 +29,7 @@ import createWorkClass from '@/components/app/dailyAttendance/create-work-class.
<el-radio-button label="1">1天1次上下班</el-radio-button> <el-radio-button label="1">1天1次上下班</el-radio-button>
<!-- <el-radio-button label="2">1天2次上下班</el-radio-button> <!-- <el-radio-button label="2">1天2次上下班</el-radio-button>
<el-radio-button label="3">1天3次上下班</el-radio-button> --> </el-radio-group <el-radio-button label="3">1天3次上下班</el-radio-button> --> </el-radio-group
><el-checkbox class="m-l-20" v-model="formData.clockType">打卡时段设置</el-checkbox> ><el-checkbox class="m-l-20" v-model="formData.clockType" @change="changeTimeRange">打卡时段设置</el-checkbox>
</div> </div>
<div class="times-set-content m-b-20"> <div class="times-set-content m-b-20">
<ul v-if="!formData.clockType"> <ul v-if="!formData.clockType">
...@@ -469,14 +469,19 @@ export default { ...@@ -469,14 +469,19 @@ export default {
console.log('下班时间-8 之后和上班时间比较:', await that.compareDate(item.startTime, rangeStart)); console.log('下班时间-8 之后和上班时间比较:', await that.compareDate(item.startTime, rangeStart));
const diff = parseInt(item.endTime.split(':')[0]) - 8; const diff = parseInt(item.endTime.split(':')[0]) - 8;
console.log('下班时间-8:', diff, rangeStart, await that.compareDate(item.startTime, rangeStart)); console.log('下班时间-8:', diff, rangeStart, await that.compareDate(item.startTime, rangeStart));
if (((await that.compareDate(item.startTime, item.endTime)) && diff < 0 && (await that.compareDate(item.startTime, rangeStart))) || (diff > 0 && !(await that.compareDate(item.startTime, rangeStart)))) { if (((await that.compareDate(item.startTime, item.endTime)) && diff < 0 && (await that.compareDate(item.startTime, rangeStart))) || ((await that.compareDate(item.startTime, item.endTime)) && diff > 0 && !(await that.compareDate(item.startTime, rangeStart)))) {
// 如 00:00-07:00 12:00-18:00 // 如 00:00-07:00 12:00-18:00
console.log(1);
rangeStart = await that.hmPlushm(item.startTime, '00:01'); // 下班时间 - 8 ,如果比上班时间还小,就把上班时间之前作为可打卡开始的最小时间 rangeStart = await that.hmPlushm(item.startTime, '00:01'); // 下班时间 - 8 ,如果比上班时间还小,就把上班时间之前作为可打卡开始的最小时间
} }
console.log(rangeStart);
// 跨天了(次日) // 跨天了(次日)
if (!(await that.compareDate(item.startTime, item.endTime)) && diff < 0 && !(await that.compareDate(item.startTime, rangeStart))) { if (!(await that.compareDate(item.startTime, item.endTime)) && diff < 0 && !(await that.compareDate(item.startTime, rangeStart))) {
//
console.log(2);
rangeStart = await that.hmPlushm(item.startTime, '00:01'); // 下班时间 - 8 ,如果比上班时间还小,就把上班时间之前作为可打卡开始的最小时间 rangeStart = await that.hmPlushm(item.startTime, '00:01'); // 下班时间 - 8 ,如果比上班时间还小,就把上班时间之前作为可打卡开始的最小时间
} }
console.log('是否跨天:', !(await that.compareDate(item.startTime, item.endTime)));
/* if (!(await that.compareDate(item.startTime, item.endTime)) && diff > 0 && !(await that.compareDate(item.startTime, rangeStart))) { /* if (!(await that.compareDate(item.startTime, item.endTime)) && diff > 0 && !(await that.compareDate(item.startTime, rangeStart))) {
// 09:07-09:05 // 09:07-09:05
rangeStart = await that.hmPlushm(item.startTime, '00:01'); // 下班时间 - 8 ,如果比上班时间还小,就把上班时间之前作为可打卡开始的最小时间 rangeStart = await that.hmPlushm(item.startTime, '00:01'); // 下班时间 - 8 ,如果比上班时间还小,就把上班时间之前作为可打卡开始的最小时间
...@@ -505,6 +510,11 @@ export default { ...@@ -505,6 +510,11 @@ export default {
if (diff > 24 && (await that.compareDate(item.startTime, rangeEnd))) { if (diff > 24 && (await that.compareDate(item.startTime, rangeEnd))) {
rangeEnd = await that.hmMinuxhm(item.startTime, '00:01'); // 上班时间 - 8 ,如果比下班时间还小,就把下班时间作为可打卡开始的最小时间 rangeEnd = await that.hmMinuxhm(item.startTime, '00:01'); // 上班时间 - 8 ,如果比下班时间还小,就把下班时间作为可打卡开始的最小时间
} }
// 跨天的(次日)
if (!(await that.compareDate(item.startTime, item.endTime)) && diff < 24 && (await that.compareDate(item.startTime, rangeEnd))) {
// 02:00-01:00 2 1+12 =13 <24,
rangeEnd = await that.hmMinuxhm(item.startTime, '00:01');
}
// 比较开始于结束,如果开始大于结束,分段计算 // 比较开始于结束,如果开始大于结束,分段计算
if (!(await that.compareDate(rangeStart, rangeEnd))) { if (!(await that.compareDate(rangeStart, rangeEnd))) {
arr.push([rangeStart + ':00', '23:59:00'].join('-')); arr.push([rangeStart + ':00', '23:59:00'].join('-'));
...@@ -518,26 +528,7 @@ export default { ...@@ -518,26 +528,7 @@ export default {
*/ */
async changeStart(e, item) { async changeStart(e, item) {
const that = this; const that = this;
let hours = 10.5; await that.setLateHours();
console.log(e);
const startTime = e;
const endTime = that.formData.classessTimesJson[0].endTime;
if (await that.compareDate(startTime, endTime)) {
hours = await that.timeDifference(startTime, endTime);
} else {
// 跨天了(次日)如 21:00-04:00
hours = Number(await that.timeDifference(startTime, '24:00')) + Number(await that.timeDifference('00:00', endTime));
}
// 计算时间间隔
that.maxLate = hours - 0.5; // 可设置的时间数必须小于最大的限制数 0.5
console.log(that.maxLate);
if (that.maxLate < 1.5) {
that.formData.lateRule = false; // 最大时间间隔小于 2小时,不能设置晚到规则
that.formData.lateRuleJson = [];
}
if (that.maxLate >= 10.5) {
that.maxLate = 10; // 最大只能填写是 10
}
// 计算当前禁用时间段 // 计算当前禁用时间段
item.forbidStartBeginTime = await that.forbidStartBeginTime(item); item.forbidStartBeginTime = await that.forbidStartBeginTime(item);
item.forbidStartEndTime = await that.forbidStartEndTime(item); item.forbidStartEndTime = await that.forbidStartEndTime(item);
...@@ -551,10 +542,22 @@ export default { ...@@ -551,10 +542,22 @@ export default {
*/ */
async changeEnd(e, item) { async changeEnd(e, item) {
const that = this; const that = this;
await that.setLateHours();
// 计算当前禁用时间段
item.forbidStartBeginTime = await that.forbidStartBeginTime(item);
item.forbidStartEndTime = await that.forbidStartEndTime(item);
item.forbidEndStartTime = await that.forbidEndStartTime(item);
item.forbidEndEndTime = await that.forbidEndEndTime(item);
that.$forceUpdate();
},
/**
* 计算设置晚到的时间
*/
async setLateHours() {
const that = this;
let hours = 10.5; let hours = 10.5;
console.log(e);
const startTime = that.formData.classessTimesJson[0].startTime; const startTime = that.formData.classessTimesJson[0].startTime;
const endTime = e; const endTime = that.formData.classessTimesJson[0].endTime;
if (await that.compareDate(startTime, endTime)) { if (await that.compareDate(startTime, endTime)) {
hours = await that.timeDifference(startTime, endTime); hours = await that.timeDifference(startTime, endTime);
} else { } else {
...@@ -571,11 +574,28 @@ export default { ...@@ -571,11 +574,28 @@ export default {
if (that.maxLate >= 10.5) { if (that.maxLate >= 10.5) {
that.maxLate = 10; that.maxLate = 10;
} }
},
/**
* 计算设置可选的时间段
*/
async setRangeData() {
const that = this;
// 计算当前禁用时间段 // 计算当前禁用时间段
let item = that.formData.classessTimesJson[0];
item.forbidStartBeginTime = await that.forbidStartBeginTime(item); item.forbidStartBeginTime = await that.forbidStartBeginTime(item);
item.forbidStartEndTime = await that.forbidStartEndTime(item); item.forbidStartEndTime = await that.forbidStartEndTime(item);
item.forbidEndStartTime = await that.forbidEndStartTime(item); item.forbidEndStartTime = await that.forbidEndStartTime(item);
item.forbidEndEndTime = await that.forbidEndEndTime(item); item.forbidEndEndTime = await that.forbidEndEndTime(item);
that.$forceUpdate();
},
/**
* 开启打卡时间段限制
*/
async changeTimeRange(e) {
const that = this;
if (e) {
await that.setRangeData();
}
}, },
/** /**
* 开启晚走规则 * 开启晚走规则
...@@ -743,6 +763,7 @@ export default { ...@@ -743,6 +763,7 @@ export default {
} else { } else {
showMsg.showmsg('新建成功', 'success'); showMsg.showmsg('新建成功', 'success');
} }
that.hideDialog();
return false; return false;
} }
errMsg.errorMsg(resData); errMsg.errorMsg(resData);
...@@ -754,11 +775,46 @@ export default { ...@@ -754,11 +775,46 @@ export default {
}); });
}); });
}, },
/**
* 隐藏弹出层
*/
hideDialog() { hideDialog() {
const that = this; const that = this;
that.customDialog = false; that.customDialog = false;
that.$emit('hideDetailDialog'); that.$emit('hideDetailDialog');
that.$nextTick(() => {
that.formData = {
classesId: '',
classesName: '', // 班次名称
times: '1', // 次数设置
classessTimesJson: [
{
startTime: '9:00',
endTime: '18:00',
allowStartBeginTime: '',
forbidStartBeginTime: [],
allowStartEndTime: '',
forbidStartEndTime: [],
allowEndStartTime: '',
forbidEndStartTime: [],
allowEndEndTime: '',
forbidEndEndTime: []
}
],
clockType: false, // 1/0 打开时间段设置
relaxFlag: false, // 休息时间
relaxStartDate: '12:00',
relaxEndDate: '13:00',
isAllowLate: false, // 允许迟到
isMoreLate: false, // 严重迟到
isMostLate: false, // 旷工迟到
allowLateDate: '30', // 允许迟到 分
moreLateDate: '35', // 严重迟到 分
mostLateDate: '60', // 旷工迟到 分
lateRule: false, // 晚走次日晚到
lateRuleJson: []
};
});
}, },
/** /**
* 获取列表数据 * 获取列表数据
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @Author: 无尘 * @Author: 无尘
* @Date: 2019-03-20 14:36:37 * @Date: 2019-03-20 14:36:37
* @LastEditors: 无尘 * @LastEditors: 无尘
* @LastEditTime: 2019-12-11 16:26:25 * @LastEditTime: 2019-12-15 16:31:44
--> -->
<!-- <!--
...@@ -208,7 +208,8 @@ export default { ...@@ -208,7 +208,8 @@ export default {
hideDetailDialog() { hideDetailDialog() {
const that = this; const that = this;
that.workClassShow = false; that.workClassShow = false;
that.classesId = ''; that.classesId = '';
console.log(that.workClassShow )
}, },
/** /**
* 删除 * 删除
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment