mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-07 01:46:43 +08:00
feat: 添加功能
日期框取消后,后续主动定位到相应的选项中
This commit is contained in:
@@ -775,7 +775,7 @@
|
||||
<!-- 不限制时间 -->
|
||||
<a-checkbox :checked="signDateTimeType === signTimeSection.NoLimit"
|
||||
@change="handleSelectSignDateTime(signTimeSection.NoLimit)">
|
||||
<span class="grey-color">不限制时间</span>
|
||||
<span class="grey-color">不限制</span>
|
||||
|
||||
<span v-if="signDateTimeType === signTimeSection.NoLimit" class="grey-color ml-10">
|
||||
{{ signDateTimeRange }}
|
||||
@@ -797,9 +797,9 @@
|
||||
<a-checkbox :checked="signDateTimeType === signTimeSection.Custom"
|
||||
@change="handleSelectSignDateTime(signTimeSection.Custom)">
|
||||
<div class="flex-center">
|
||||
<span class="grey-color">自定义时间</span>
|
||||
<span class="grey-color">自定义</span>
|
||||
<span v-if="signDateTimeType === signTimeSection.Custom" class="flex-center">
|
||||
<div class="flex-center">
|
||||
<div class="flex-center ml-10">
|
||||
<span style="color: #6d7584;margin-right:8px;">开始前</span>
|
||||
<a-input-number :min="0" :max="999999" :precision="0" style="
|
||||
width: 100px;
|
||||
@@ -3121,6 +3121,7 @@ export default defineComponent({
|
||||
state.assessmentName = ""; // 新增
|
||||
};
|
||||
const removePG = () => {
|
||||
resetSignDateTime()
|
||||
console.log("11111");
|
||||
state.changeName = false;
|
||||
state.assessmentId = null;
|
||||
@@ -3631,7 +3632,6 @@ export default defineComponent({
|
||||
removePG();
|
||||
};
|
||||
//保存开课
|
||||
|
||||
const handleSureStu = async () => {
|
||||
if (editBeginClass.value) {
|
||||
message.info("讲师费已进入审批阶段,无法编辑");
|
||||
@@ -3856,6 +3856,8 @@ export default defineComponent({
|
||||
state.offteachers = [...item.offteachers];
|
||||
state.cstm_hs = true;
|
||||
state.kk_eidt = true;
|
||||
|
||||
switchSignDateTimeType(item.beforeStart, item.afterStart)
|
||||
};
|
||||
const columnFun = (itm) => {
|
||||
console.log("itm", itm);
|
||||
@@ -5056,62 +5058,115 @@ export default defineComponent({
|
||||
*/
|
||||
const signDateTimeRange = ref("默认");
|
||||
|
||||
function resetSignDateTime() {
|
||||
signDateTimeType.value = 0;
|
||||
resetBeforeAndAfter()
|
||||
}
|
||||
function resetBeforeAndAfter() {
|
||||
state.beforeValue = null
|
||||
state.afterStartValue = null
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 签到时间类型
|
||||
*/
|
||||
const signDateTimeType = ref();
|
||||
|
||||
/**
|
||||
* 处理签到时间类型切换
|
||||
* @param type {typeof signTimeSection}
|
||||
*/
|
||||
function handleSelectSignDateTime(type) {
|
||||
resetBeforeAndAfter()
|
||||
// 重复点击取消按钮选中
|
||||
if (type === signDateTimeType.value) {
|
||||
signDateTimeType.value = 0;
|
||||
state.beforeValue = null
|
||||
state.afterStartValue = null
|
||||
resetSignDateTime()
|
||||
return
|
||||
}
|
||||
console.log("state.projectTime", state.xjkkinputV3)
|
||||
if (!state.xjkkinputV3[1] || !state.xjkkinputV3[0]) {
|
||||
message.error("请设置好面授时间")
|
||||
return
|
||||
}
|
||||
|
||||
// 面授开课时间
|
||||
const classStartTime = dayjs(state.xjkkinputV3[0])
|
||||
// 面授结束时间
|
||||
const classEndTime = dayjs(state.xjkkinputV3[1])
|
||||
console.log("classStartTime", classStartTime, "classEndTime", classEndTime)
|
||||
const { endSignTime, startSignTime } = getDayOfStartAndEnd()
|
||||
|
||||
signDateTimeType.value = type;
|
||||
if (type === signTimeSection.NoLimit) {
|
||||
// 如果不限制,那么就是从当前时间开始,到课程结束时间结束
|
||||
signDateTimeRange.value = `( 当前时间 至 ${endSignTime} )`;
|
||||
const classEndTime = state.xjkkinputV3[1]
|
||||
const diffEndTime = classEndTime.diff(dayjs(), "minute")
|
||||
state.beforeValue = diffEndTime
|
||||
|
||||
// console.log("before value", state.beforeValue)
|
||||
const diffStartTime = (dayjs(classStartTime).diff(dayjs(), "minute"))
|
||||
state.beforeValue = diffStartTime <= 0 ? 0 : diffStartTime
|
||||
state.afterValue = (dayjs(endSignTime).diff(classEndTime, "minute"))
|
||||
console.log("before value, after value", state.beforeValue, state.afterValue)
|
||||
} else if (type === signTimeSection.OpenDay) {
|
||||
// 如果限制在开课时间,选项签到规则是课程创建的“面授时间”的起始时间至开课当日23时59分。
|
||||
signDateTimeRange.value = `( ${startSignTime} 至 ${endSignTime} )`;
|
||||
const classEndTime = state.xjkkinputV3[1]
|
||||
const classStartTime = state.xjkkinputV3[0]
|
||||
|
||||
const diffEnd = dayjs(endSignTime).diff(classEndTime, "minute")
|
||||
const diffStart = dayjs(classStartTime).diff(startSignTime, "minute")
|
||||
state.afterStartValue = diffEnd
|
||||
state.beforeValue = diffStart
|
||||
// console.log("after value", state.afterStartValue, "before value", state.beforeValue)
|
||||
state.afterStartValue = (dayjs(endSignTime).diff(classEndTime, "minute"))
|
||||
state.beforeValue = (dayjs(classStartTime).diff(startSignTime, "minute"))
|
||||
console.log("before value, after value", state.beforeValue, state.afterStartValue)
|
||||
} else if (type === signTimeSection.Custom) {
|
||||
signDateTimeRange.value = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取开课和结束那天的终点时间
|
||||
*/
|
||||
function getDayOfStartAndEnd() {
|
||||
const endSignTime = dayjs(dayjs(classEndTime).add(1, "day").format("YYYY-MM-DD")).subtract(1, "second").format("YYYY-MM-DD HH:mm:ss")
|
||||
const startSignTime = dayjs(dayjs(classStartTime).format("YYYY-MM-DD")).format("YYYY-MM-DD HH:mm:ss")
|
||||
return { startSignTime, endSignTime }
|
||||
}
|
||||
}
|
||||
|
||||
function getDayOfStartAndEnd() {
|
||||
const endSignTime = dayjs(state.xjkkinputV3[1].add(1, "day").format("YYYY-MM-DD"))
|
||||
.subtract(1, "second")
|
||||
.format("YYYY-MM-DD HH:mm:ss")
|
||||
const startSignTime = dayjs(state.xjkkinputV3[0].format("YYYY-MM-DD")).format("YYYY-MM-DD HH:mm:ss")
|
||||
return { startSignTime, endSignTime }
|
||||
/**
|
||||
* 根据考勤开始前和考勤开始后的时间,切换签到时间类型
|
||||
* @param before
|
||||
* @param after
|
||||
*/
|
||||
function switchSignDateTimeType(before, after) {
|
||||
signDateTimeType.value = 0
|
||||
if (!before && !after) return;
|
||||
const start = state.xjkkinputV3[0]
|
||||
const end = state.xjkkinputV3[1]
|
||||
|
||||
//如果 end + after 的日期时间为 23:59:59,就排除自定义
|
||||
// 如果 start - before 的日期时间为 00:00:00,就为开课当日
|
||||
//反之则为不限制时间
|
||||
const isLastSecond = dayjs(end).add(after, "minute").format("HH:mm:ss") === "23:59:00"
|
||||
const isFirstSecond = dayjs(start).subtract(before, "minute").format("HH:mm:ss") === "00:00:00"
|
||||
console.log("isLastSecond", isLastSecond, "isFirstSecond", isFirstSecond);
|
||||
console.log(dayjs(end).add(after, "minute").format("HH:mm:ss"));
|
||||
console.log(dayjs(start).subtract(before, "minute").format("HH:mm:ss"));
|
||||
|
||||
// 面授开课时间
|
||||
const classStartTime = dayjs(state.xjkkinputV3[0])
|
||||
// 面授结束时间
|
||||
const classEndTime = dayjs(state.xjkkinputV3[1])
|
||||
const endSignTime = dayjs(dayjs(classEndTime).add(1, "day").format("YYYY-MM-DD")).subtract(1, "second").format("YYYY-MM-DD HH:mm:ss")
|
||||
const startSignTime = dayjs(dayjs(classStartTime).format("YYYY-MM-DD")).format("YYYY-MM-DD HH:mm:ss")
|
||||
|
||||
if (isLastSecond) {
|
||||
if (isFirstSecond) {
|
||||
signDateTimeType.value = signTimeSection.OpenDay
|
||||
signDateTimeRange.value = `( ${startSignTime} 至 ${endSignTime} )`;
|
||||
} else {
|
||||
signDateTimeType.value = signTimeSection.NoLimit
|
||||
signDateTimeRange.value = `( 当前时间 至 ${endSignTime} )`;
|
||||
}
|
||||
} else {
|
||||
signDateTimeType.value = signTimeSection.Custom
|
||||
// state.beforeValue = before
|
||||
// state.afterValue = after
|
||||
}
|
||||
}
|
||||
window.dayjs = dayjs;
|
||||
// window.dayjs = dayjs;
|
||||
return {
|
||||
signDateTimeRange,
|
||||
signTimeSection,
|
||||
|
||||
Reference in New Issue
Block a user