新增节假日列表

This commit is contained in:
mkbk
2025-02-23 15:42:43 +08:00
parent e97e78a2aa
commit f54dc4aa3e

View File

@@ -10,8 +10,79 @@
</div>
</template>
</el-calendar>
<el-spin v-if="loading" size="large" class="loading-spinner" />
</el-tab-pane>
<el-tab-pane label="节假日列表" name="second">
<el-table v-loading="loading" :data="oaHolidayList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键id" align="center" prop="holidayId" v-if="true"/>
<el-table-column label="0正常1周日2节假日3调休" align="center" prop="type" />
<el-table-column label="假期日期" align="center" prop="holidayTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.holidayTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="假期名称" align="center" prop="name" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['oa:oaHoliday:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['oa:oaHoliday:remove']"
>删除</el-button>
<!-- 添加或修改休假管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="假期日期" prop="holidayTime">
<el-date-picker clearable
v-model="form.holidayTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择假期日期">
</el-date-picker>
</el-form-item>
<el-form-item label="假期名称" prop="name">
<el-input v-model="form.name" placeholder="请输入假期名称" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-tab-pane>
<el-tab-pane label="节假日列表" name="second">节假日列表</el-tab-pane>
</el-tabs>
<el-dialog :visible.sync="dialogVisible" title="编辑日期类型" width="30%">
@@ -42,11 +113,66 @@ export default {
activeName: 'first',
holidays: [],
dialogVisible: false,
currentHoliday: {}
currentHoliday: {},
loading: false, // New loading state
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 休假管理表格数据
oaHolidayList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
type: undefined,
holidayTime: undefined,
name: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
holidayId: [
{ required: true, message: "主键id不能为空", trigger: "blur" }
],
type: [
{ required: true, message: "0正常1周日2节假日3调休不能为空", trigger: "change" }
],
holidayTime: [
{ required: true, message: "假期日期不能为空", trigger: "blur" }
],
name: [
{ required: true, message: "假期名称不能为空", trigger: "blur" }
],
remark: [
{ required: true, message: "备注不能为空", trigger: "blur" }
],
delFlag: [
{ required: true, message: "删除标志不能为空", trigger: "blur" }
]
}
};
},
methods: {
fetchHolidayData() {
this.loading = true; // Set loading to true when fetching data
listOaHoliday({}).then(response => {
this.holidays = response.rows.map(item => ({
date: item.holidayTime.split(" ")[0],
@@ -54,8 +180,10 @@ export default {
name: item.name,
fullData: item
}));
this.loading = false; // Set loading to false once data is fetched
}).catch(error => {
console.error("Error fetching holiday data:", error);
this.loading = false; // Set loading to false even on error
});
},
isHoliday(date) {
@@ -69,15 +197,17 @@ export default {
handleCellClick(data) {
const holiday = this.holidays.find(holiday => holiday.date === data.day);
if (holiday) {
// 这里拷贝 fullData 保证不会直接修改列表中的数据
this.currentHoliday = { ...holiday.fullData, type: holiday.type };
this.dialogVisible = true;
}
},
updateHoliday() {
// 根据当前选择的类型更新 name 字段
// 举例:若 type 由 0 改为 2则 name 设为 "节假日"
// 若 type 由 1 改为 0则 name 设为 null
switch (this.currentHoliday.type) {
case 0:
this.currentHoliday.name = null;
@@ -103,10 +233,120 @@ export default {
console.error("Error updating holiday data:", error);
this.$message.error("更新失败");
});
}
},
/** 查询休假管理列表 */
getList() {
this.loading = true;
listOaHoliday(this.queryParams).then(response => {
this.oaHolidayList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
holidayId: undefined,
type: undefined,
holidayTime: undefined,
name: undefined,
createTime: undefined,
createBy: undefined,
updateTime: undefined,
updateBy: undefined,
remark: undefined,
delFlag: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.holidayId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加休假管理";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const holidayId = row.holidayId || this.ids
getOaHoliday(holidayId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改休假管理";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.holidayId != null) {
updateOaHoliday(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addOaHoliday(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const holidayIds = row.holidayId || this.ids;
this.$modal.confirm('是否确认删除休假管理编号为"' + holidayIds + '"的数据项?').then(() => {
this.loading = true;
return delOaHoliday(holidayIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
},
created() {
this.fetchHolidayData();
this.getList();
}
};
</script>
@@ -116,6 +356,7 @@ export default {
border: none !important;
background-color: inherit;
padding: 0;
transition: all 0.3s ease; /* Smooth transition for hover effect */
}
.blue-background {
background-color: #dcf2f2;
@@ -130,6 +371,7 @@ export default {
.el-calendar__cell p {
margin: 0;
padding: 0;
font-size: 14px; /* Improve text size for better readability */
}
.holiday-name {
font-size: 16px;
@@ -139,5 +381,15 @@ export default {
}
.el-dialog {
max-width: 100%;
padding: 20px;
}
.dialog-footer {
display: flex;
justify-content: space-between;
}
.loading-spinner {
display: block;
margin: 20px auto;
}
</style>