This commit is contained in:
2025-12-11 12:51:41 +08:00
parent 0e343279ac
commit 4383067eb1
4 changed files with 515 additions and 443 deletions

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: zwq
* @LastEditTime: 2025-11-27 14:06:11
* @LastEditTime: 2025-12-11 10:47:50
* @Description:
-->
<template>
@@ -66,7 +66,7 @@
type="date"
placeholder="选择日期"
format="yyyy-MM-dd"
value-format="--MM-dd"
value-format="yyyy-MM-dd"
@blur="$forceUpdate()"
:picker-options="pickerOptions"></el-date-picker>
</el-form-item>
@@ -81,7 +81,7 @@
v-model="dataForm.dateDayArr"
type="daterange"
format="yyyy-MM-dd"
value-format="--MM-dd"
value-format="yyyy-MM-dd"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
@@ -341,45 +341,70 @@ export default {
this.$refs['dataForm'].resetFields();
if (this.dataForm.id) {
getHoliday(this.dataForm.id).then((res) => {
//设置年份,不重复的直接用返回的年份,重复的直接用当年年份
let year = new Date().getFullYear();
if (res.data.calendarType == 1 && !res.data.repeat) {
year = res.data.noRepeatYear;
} else if (res.data.calendarType == 2 && !res.data.repeat) {
year = res.data.noRepeatYearChinese;
}
this.dataForm = res.data;
if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 1
) {
this.dataForm.dateDay = this.dataForm.oneDay;
this.dataForm.dateDay =
year + '-' + this.dataForm.oneDay.slice(-5);
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1
) {
let num = this.compareMonthDay(
this.dataForm.startDay.slice(-5),
this.dataForm.endDay.slice(-5)
);
this.dataForm.dateDayArr = [
this.dataForm.startDay,
this.dataForm.endDay,
year + '-' + this.dataForm.startDay.slice(-5),
(num > 0 ? year : year + 1) +
'-' +
this.dataForm.endDay.slice(-5),
];
} else if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2
) {
this.dataForm.dateDayChinese =
'L' +
new Date().getFullYear() +
this.dataForm.oneDayChinese.slice(-6);
'L' + year + this.dataForm.oneDayChinese.slice(-6);
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 2
) {
let num = this.compareMonthDay(
this.dataForm.startDayChinese.slice(-6),
this.dataForm.endDayChinese.slice(-6)
);
this.dataForm.dateDayArrChinese = [
'L' + year + this.dataForm.startDayChinese.slice(-6),
'L' +
new Date().getFullYear() +
this.dataForm.startDayChinese.slice(-6),
'L' +
new Date().getFullYear() +
this.dataForm.endDayChinese.slice(-6),
(num > 0 ? year : year + 1) +
+this.dataForm.endDayChinese.slice(-6),
];
}
});
}
});
},
//用于比较日期大小判断年份是否要加1
compareMonthDay(dateStr1, dateStr2) {
const [month1, day1] = dateStr1.split('-').map(Number);
const [month2, day2] = dateStr2.split('-').map(Number);
if (month1 !== month2) {
return month2 - month1;
}
return day2 - day1;
},
editHoliday() {
this.detail = false;
},
@@ -442,13 +467,16 @@ export default {
return false;
}
if (this.dataForm.dateType == 1 && this.dataForm.calendarType == 1) {
this.dataForm.oneDay = this.dataForm.dateDay;
const [year, month, day] = this.dataForm.dateDay.split('-');
this.dataForm.oneDay = `--${month}-${day}`;
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1
) {
this.dataForm.startDay = this.dataForm.dateDayArr[0];
this.dataForm.endDay = this.dataForm.dateDayArr[1];
const [year, month, day] = this.dataForm.dateDayArr[0].split('-');
this.dataForm.startDay = `--${month}-${day}`;
const [year1, month1, day1] = this.dataForm.dateDayArr[1].split('-');
this.dataForm.endDay = `--${month1}-${day1}`;
} else if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2
@@ -464,10 +492,35 @@ export default {
this.dataForm.endDayChinese =
'--' + this.dataForm.dateDayArrChinese[1].slice(-5);
}
if (this.dataForm.calendarType == 1 && !this.dataForm.repeat) {
this.dataForm.noRepeatYear = new Date().getFullYear();
} else if (this.dataForm.calendarType == 2 && !this.dataForm.repeat) {
this.dataForm.noRepeatYearChinese = new Date().getFullYear();
//是否每年重复,不重复的话需要传 年份
if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 1 &&
!this.dataForm.repeat
) {
const [year, month, day] = this.dataForm.dateDay.split('-');
this.dataForm.noRepeatYear = year;
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1 &&
!this.dataForm.repeat
) {
const [year, month, day] = this.dataForm.dateDayArr[0].split('-');
this.dataForm.noRepeatYear = year;
} else if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2 &&
!this.dataForm.repeat
) {
this.dataForm.noRepeatYearChinese =
this.dataForm.dateDayChinese.slice(1, 5);
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 2 &&
!this.dataForm.repeat
) {
this.dataForm.noRepeatYearChinese =
this.dataForm.dateDayArrChinese[0].slice(1, 5);
}
// 修改的提交
if (this.dataForm.id) {
@@ -475,8 +528,45 @@ export default {
this.dataForm.inherited = false;
}
updateHoliday(this.dataForm).then((res) => {
if (res.code === 0 || res.code === 200) {
if (!res.data.updateFlag) {
this.$modal.msgSuccess('修改成功');
this.$emit('refreshPage');
} else {
this.$confirm(
'新增节假日影响已有排班计划,是否立即更新?',
'更新排班',
{
confirmButtonText: '立即更新',
cancelButtonText: '暂不更新',
type: 'warning',
}
)
.then(() => {
updateSchedule({ logId: res.data.logId }).then((res1) => {
this.$modal.msgSuccess('更新成功');
});
this.$emit('refreshPage');
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消',
});
this.$emit('refreshPage');
});
}
} else {
this.$modal.msg(res.msg);
}
});
return;
}
// 添加的提交
createHoliday(this.dataForm).then((res) => {
if (res.code === 0 || res.code === 200) {
if (!res.data.updateFlag) {
this.$modal.msgSuccess('修改成功');
this.$modal.msgSuccess('新增成功');
this.$emit('refreshPage');
} else {
this.$confirm(
@@ -502,37 +592,8 @@ export default {
this.$emit('refreshPage');
});
}
});
return;
}
// 添加的提交
createHoliday(this.dataForm).then((res) => {
if (!res.data.updateFlag) {
this.$modal.msgSuccess('新增成功');
this.$emit('refreshPage');
} else {
this.$confirm(
'新增节假日影响已有排班计划,是否立即更新?',
'更新排班',
{
confirmButtonText: '立即更新',
cancelButtonText: '暂不更新',
type: 'warning',
}
)
.then(() => {
updateSchedule({ logId: res.data.logId }).then((res1) => {
this.$modal.msgSuccess('更新成功');
});
this.$emit('refreshPage');
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消',
});
this.$emit('refreshPage');
});
this.$modal.msg(res.msg);
}
});
});

View File

@@ -210,7 +210,7 @@
</template>
<script>
import moment from 'moment';
import JDatePickerScript from './jDatePicker.js'
import JDatePickerScript from './JDatePicker.js'
export default {
props: {