更新班组

This commit is contained in:
2025-10-24 11:42:24 +08:00
parent 67b6b88863
commit 31bafae4aa
17 changed files with 1865 additions and 257 deletions

View File

@@ -2,101 +2,143 @@
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: zwq
* @LastEditTime: 2025-10-19 00:09:11
* @LastEditTime: 2025-10-23 13:29:58
* @Description:
-->
<template>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-position="top"
label-width="80px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="节假日名称" prop="name">
<el-input
v-model="dataForm.name"
clearable
:disabled="detail"
placeholder="请输入节假日名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="日历类型" prop="calendarType">
<el-select
v-model="dataForm.calendarType"
:disabled="detail"
style="width: 100%">
<el-option
v-for="item in options1"
:key="item.value"
:label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="日期类型" prop="dateType">
<el-select
style="width: 100%"
:disabled="detail"
v-model="dataForm.dateType">
<el-option
v-for="item in options2"
:key="item.value"
:label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="日期" prop="dateTime">
<el-date-picker
:disabled="detail"
style="width: 100%"
<div>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-position="top"
label-width="80px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="节假日名称" prop="name">
<el-input
v-model="dataForm.name"
clearable
:disabled="detail"
placeholder="请输入节假日名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="日历类型" prop="calendarType">
<el-select
v-model="dataForm.calendarType"
:disabled="detail"
style="width: 100%">
<el-option
v-for="item in options1"
:key="item.value"
:label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="日期类型" prop="dateType">
<el-select
style="width: 100%"
:disabled="detail"
v-model="dataForm.dateType">
<el-option
v-for="item in options2"
:key="item.value"
:label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
v-if="dataForm.dateType == 1"
key="date"
v-model="dataForm.dateDay"
type="date"
placeholder="选择日期"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"></el-date-picker>
<el-date-picker
:disabled="detail"
style="width: 100%"
v-else
key="daterange"
v-model="dataForm.dateDayArr"
type="daterange"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否每年重复" prop="repeat">
<el-select
v-model="dataForm.repeat"
:disabled="detail"
style="width: 100%">
<el-option
v-for="item in options3"
:key="item.value"
:label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
label="日期"
prop="dateDay">
<el-date-picker
:disabled="detail"
style="width: 100%"
key="date"
v-model="dataForm.dateDay"
type="date"
placeholder="选择日期"
format="yyyy-MM-dd"
value-format="--MM-dd"
:picker-options="pickerOptions"></el-date-picker>
</el-form-item>
<el-form-item v-else label="日期" prop="dateDayArr">
<el-date-picker
:disabled="detail"
style="width: 100%"
key="daterange"
v-model="dataForm.dateDayArr"
type="daterange"
format="yyyy-MM-dd"
value-format="--MM-dd"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
:picker-options="pickerOptions"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否每年重复" prop="repeat">
<el-select
v-model="dataForm.repeat"
:disabled="detail"
style="width: 100%">
<el-option
v-for="item in options3"
:key="item.value"
:label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" v-if="detail">
<el-form-item label="来源" prop="inherited">
<el-radio-group disabled v-model="dataForm.inherited">
<el-radio :label="true">继承</el-radio>
<el-radio :label="false">自定义</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-dialog
title="删除确认"
:visible.sync="dialogVisible"
width="30%"
append-to-body>
<span>
确认删除该节假日吗
<br />
该节假日已被排班计划使用建议确认是否同步更新排班计划
<br />
此操作不可恢复请确认是否继续
</span>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button @click="onlyDelete">仅删除</el-button>
<el-button type="primary" @click="deleteAndUpdate">
删除并更新
</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { createHoliday, updateHoliday,deleteHolidayn } from '@/api/group/holidaySetting';
import {
createHoliday,
updateHoliday,
checkDeleteHoliday,
deleteHoliday,
updateSchedule,
getHoliday,
} from '@/api/group/holidaySetting';
export default {
components: {},
@@ -110,6 +152,8 @@ export default {
dateDay: undefined,
dateDayArr: [],
repeat: true,
inherited: true, // 是否为继承
deptId: undefined,
},
detail: false,
options1: [
@@ -166,41 +210,170 @@ export default {
},
],
},
pickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now();
},
},
dialogVisible: false,
};
},
methods: {
init(id, detail) {
init(deptId, id, detail) {
this.dataForm.deptId = deptId || undefined;
this.dataForm.id = id || undefined;
this.detail = detail || false;
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
if (this.dataForm.id) {
getHoliday(this.dataForm.id).then((res) => {
this.dataForm = res.data;
if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 1
) {
this.dataForm.dateDay = this.dataForm.oneDay;
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1
) {
this.dataForm.dateDayArr = [
this.dataForm.startDay,
this.dataForm.endDay,
];
} else if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2
) {
this.dataForm.dateDay = this.dataForm.oneDayChinese;
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 2
) {
this.dataForm.dateDayArr = [
this.dataForm.startDayChinese,
this.dataForm.endDayChinese,
];
}
});
}
});
},
editHoliday() {
this.detail = false;
},
deleteHoliday() {
//删除节假日基础信息前校验是否影响排班
checkDeleteHoliday(this.dataForm.id).then((res) => {
if (res.data) {
this.dialogVisible = true;
} else {
this.$confirm(
'确认删除该节假日吗?<br/>此操作不可恢复,请确认是否继续',
'删除确认',
{
dangerouslyUseHTMLString: true,
confirmButtonText: '确认删除',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
deleteHoliday(this.dataForm.id).then((res) => {
console.log(res);
this.$modal.msgSuccess('删除成功');
this.$emit('refreshPage');
});
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消',
});
});
}
});
},
onlyDelete() {
deleteHoliday(this.dataForm.id).then((res) => {
this.dialogVisible = false;
this.$modal.msgSuccess('删除成功');
this.$emit('refreshPage');
});
},
deleteAndUpdate() {
deleteHoliday(this.dataForm.id).then((res) => {
this.dialogVisible = false;
this.$modal.msgSuccess('删除成功');
updateSchedule({ logId: res.data.logId }).then((res1) => {
this.$modal.msgSuccess('更新成功');
this.$emit('refreshPage');
});
});
},
editHoliday(){
this.detail = false
},
deleteHoliday(){
deleteHolidayn(this.dataForm.id).then(res=>{
console.log(res)
})
},
// 表单提交
dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => {
if (!valid) {
return false;
}
if (this.dataForm.dateType == 1 && this.dataForm.calendarType == 1) {
this.dataForm.oneDay = this.dataForm.dateDay;
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 1
) {
this.dataForm.startDay = this.dataForm.dateDayArr[0];
this.dataForm.endDay = this.dataForm.dateDayArr[1];
} else if (
this.dataForm.dateType == 1 &&
this.dataForm.calendarType == 2
) {
this.dataForm.oneDayChinese = this.dataForm.dateDay;
} else if (
this.dataForm.dateType == 2 &&
this.dataForm.calendarType == 2
) {
this.dataForm.startDayChinese = this.dataForm.dateDayArr[0];
this.dataForm.endDayChinese = this.dataForm.dateDayArr[1];
}
// 修改的提交
if (this.dataForm.id) {
updateHoliday(this.dataForm).then((response) => {
this.$modal.msgSuccess('修改成功');
this.visible = false;
this.$emit('refreshPage');
});
return;
}
// 添加的提交
createHoliday(this.dataForm).then((response) => {
this.$modal.msgSuccess('新增成功');
this.visible = false;
this.$emit('refreshPage');
createHoliday(this.dataForm).then((res) => {
updateSchedule;
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: '已取消',
});
});
}
});
});
},

View File

@@ -3,6 +3,7 @@
<search-bar
:formConfigs="formConfig"
ref="searchBarForm"
:isFold="true"
@headBtnClick="buttonClick" />
<base-table
:table-props="tableProps"

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2024-07-01 14:54:06
* @LastEditors: zwq
* @LastEditTime: 2025-10-19 00:35:24
* @LastEditTime: 2025-10-23 13:52:52
* @Description:
-->
<template>
@@ -73,12 +73,13 @@
<el-button
size="small"
type="primary"
@click="startDay = new Date()">
@click="startDay = new Date(),getHolidayPage()">
跳转到今天
</el-button>
</el-form-item>
</el-form>
<el-tag
v-if="topDeptId == deptId"
type="warning"
closable
style="margin-bottom: 10px; color: black">
@@ -92,15 +93,61 @@
<div class="calenderArea">
<el-calendar v-model="startDay">
<template slot="dateCell" slot-scope="{ data }">
<div v-if="data.type === 'current-month'" @click="showDetail">
<div v-if="data.type === 'current-month'">
<!-- 日期 -->
<div class="dateStyle">
<el-row :gutter="20">
<!-- 公历和农历 -->
<el-col :span="18">
{{ Number(data.day.split('-')[2]) }}
<div class="lunar-date">{{ getLunarDate(data.day) }}</div>
</el-col>
<el-col :span="6"><div class="work-tip"></div></el-col>
<!-- 显示假或班 -->
<el-col :span="6">
<div
class="work-tip"
:style="{
backgroundColor: HolidayList[
Number(data.day.split('-')[2]) - 1
]?.isHoliday
? '#67C23A'
: '#409EFF',
}">
{{
HolidayList[Number(data.day.split('-')[2]) - 1]
?.isHoliday
? '假'
: '班'
}}
</div>
</el-col>
<!-- 显示假期名和操作 -->
<el-col
:span="24"
v-if="
HolidayList[Number(data.day.split('-')[2]) - 1]
?.isHoliday
">
<div
class="holiday-div"
@click="
new Date(data.day).getTime() > Date.now() &&
showDetail(
HolidayList[Number(data.day.split('-')[2]) - 1]
.holidayId
)
">
{{
HolidayList[Number(data.day.split('-')[2]) - 1]
?.holidayName
}}
<span
class="holiday-div-btn"
v-if="new Date(data.day).getTime() > Date.now()">
<i class="el-icon-more" style="color: #fff"></i>
</span>
</div>
</el-col>
</el-row>
</div>
</div>
@@ -126,11 +173,12 @@
:dialogVisible="addOrUpdateVisible"
@cancel="cancel"
@confirm="handleConfirm"
:before-close="cancel"
:destroy-on-close="true"
width="40%">
<add-or-updata
ref="addOrUpdataRef"
@refreshPage="getHolidayPage"></add-or-updata>
@refreshPage="successSubmit"></add-or-updata>
<template #footer>
<slot name="footer">
<el-row slot="footer" type="flex" justify="end">
@@ -174,6 +222,7 @@
dialogTitle="节假日变更记录"
:dialogVisible="logVisible"
@cancel="cancelLog"
:before-close="cancelLog"
:destroy-on-close="true"
width="70%">
<holiday-log ref="holidayLogRef"></holiday-log>
@@ -196,9 +245,8 @@
import moment from 'moment';
import { solarToLunar } from 'chinese-lunar';
import { listSimpleDepts } from '@/api/system/dept';
import { getUserProfile } from '@/api/system/user';
import { deptHolidayList } from '@/api/group/holidaySetting';
import { deptHolidayList, getEnableData } from '@/api/group/holidaySetting';
import addOrUpdata from './add-or-updata.vue';
import holidayLog from './holidayLog';
@@ -212,12 +260,14 @@ export default {
data() {
return {
startDay: '', // 查询参数
HolidayList: [],
// 部门树选项
deptOptions: undefined,
// 查询的部门名称
deptName: undefined,
// 选择的部门名称
showDeptName: undefined,
topDeptId: undefined, // 保存当前用户的部门id为最高级部门id
deptId: undefined,
defaultProps: {
children: 'children',
@@ -240,6 +290,7 @@ export default {
// 查询用户个人信息
getUserProfile().then((response) => {
this.showDeptName = response.data.dept.name || '';
this.topDeptId = response.data.dept.id || ''; // 保存当前用户的部门id为最高级部门id
this.deptId = response.data.dept.id || '';
this.getHolidayPage();
});
@@ -247,16 +298,31 @@ export default {
},
methods: {
getHolidayPage() {
deptHolidayList({ deptId: this.deptId }).then((response) => {});
const now = new Date(this.startDay);
const year = now.getFullYear();
const month = now.getMonth();
const startTime = `${year}-${String(month + 1).padStart(2, '0')}-01`;
const lastDate = new Date(year, month + 1, 0).getDate();
const endTime = `${year}-${String(month + 1).padStart(2, '0')}-${String(
lastDate
).padStart(2, '0')}`;
this.HolidayList = [];
deptHolidayList({
deptId: this.deptId,
startTime: Date.parse(startTime),
endTime: Date.parse(endTime),
}).then((res) => {
this.HolidayList = res.data;
});
},
// 切换月份
selectMonth() {
console.log(this.startDay);
this.getHolidayPage();
},
/** 查询部门下拉树结构 */
getTreeselect() {
listSimpleDepts().then((response) => {
getEnableData().then((response) => {
// 处理 deptOptions 参数
this.deptOptions = [];
this.deptOptions.push(...this.handleTree(response.data, 'id'));
@@ -342,7 +408,7 @@ export default {
this.detail = false;
this.dialogTitle = '新增节假日';
this.$nextTick(() => {
this.$refs.addOrUpdataRef.init();
this.$refs.addOrUpdataRef.init(this.deptId);
});
},
holidayLog() {
@@ -352,8 +418,13 @@ export default {
});
},
cancel() {
this.getHolidayPage();
this.addOrUpdateVisible = false;
},
successSubmit() {
this.cancel();
this.getHolidayPage();
},
handleConfirm() {
this.$refs.addOrUpdataRef.dataFormSubmit();
},
@@ -362,7 +433,7 @@ export default {
this.detail = true;
this.dialogTitle = '节假日详情';
this.$nextTick(() => {
this.$refs.addOrUpdataRef.init(id, true);
this.$refs.addOrUpdataRef.init(this.deptId, id, true);
});
},
editHoliday() {
@@ -465,6 +536,20 @@ export default {
text-align: center;
float: right;
}
.holiday-div {
background-color: #67c23a;
border-radius: 3px;
height: 25px;
text-align: center;
line-height: 24px;
color: #fff;
.holiday-div-btn {
float: right;
transform: rotate(90deg);
font-size: 14px;
pointer-events: none;
}
}
}
}
}