更新前端上传错误部分
This commit is contained in:
70
ruoyi-ui/src/api/oa/oaHoliday.js
Normal file
70
ruoyi-ui/src/api/oa/oaHoliday.js
Normal file
@@ -0,0 +1,70 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询休假管理列表
|
||||
export function listOaHoliday(query) {
|
||||
return request({
|
||||
url: '/oa/oaHoliday/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询休假管理详细
|
||||
export function getOaHoliday(holidayId) {
|
||||
return request({
|
||||
url: '/oa/oaHoliday/' + holidayId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增休假管理
|
||||
export function addOaHoliday(data) {
|
||||
return request({
|
||||
url: '/oa/oaHoliday',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改休假管理
|
||||
export function updateOaHoliday(data) {
|
||||
return request({
|
||||
url: '/oa/oaHoliday',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除休假管理
|
||||
export function delOaHoliday(holidayId) {
|
||||
return request({
|
||||
url: '/oa/oaHoliday/' + holidayId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 根据日期查询具体的休假管理信息
|
||||
export function queryHolidayByDate(date) {
|
||||
return request({
|
||||
url: '/oa/oaHoliday/queryHolidayByDate',
|
||||
method: 'get',
|
||||
params: { date }
|
||||
})
|
||||
}
|
||||
|
||||
// 根据节假日类别查询
|
||||
export function queryHolidayByType(type) {
|
||||
return request({
|
||||
url: '/oa/oaHoliday/queryHolidayByType',
|
||||
method: 'get',
|
||||
params: { type }
|
||||
})
|
||||
}
|
||||
|
||||
// 查询当前月的所有休假
|
||||
export function queryHolidayByMonth() {
|
||||
return request({
|
||||
url: '/oa/oaHoliday/queryHolidayByMonth',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
143
ruoyi-ui/src/views/oa/holidaycal/index.vue
Normal file
143
ruoyi-ui/src/views/oa/holidaycal/index.vue
Normal file
@@ -0,0 +1,143 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-tabs v-model="activeName" style="margin-left: 10px;">
|
||||
<el-tab-pane label="休假日历" name="first">
|
||||
<el-calendar>
|
||||
<template #dateCell="{ date, data }">
|
||||
<div :class="{'is-selected': data.isSelected, 'blue-background': isHoliday(data.day)}" @click="handleCellClick(data)">
|
||||
<p>{{ data.day.split('-').slice(1).join('-') }} {{ data.isSelected ? '✔️' : '' }}</p>
|
||||
<p v-if="isHoliday(data.day)" class="holiday-name">{{ getHolidayName(data.day) }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</el-calendar>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="节假日列表" name="second">节假日列表</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<el-dialog :visible.sync="dialogVisible" title="编辑日期类型" width="30%">
|
||||
<el-form :model="currentHoliday" ref="form">
|
||||
<el-form-item label="选择类型">
|
||||
<el-select v-model="currentHoliday.type" placeholder="请选择">
|
||||
<el-option label="工作日" :value="0"></el-option>
|
||||
<el-option label="休息日" :value="1"></el-option>
|
||||
<el-option label="节假日" :value="2"></el-option>
|
||||
<el-option label="调休" :value="3"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="updateHoliday">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listOaHoliday, updateOaHoliday } from "@/api/oa/oaHoliday";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
activeName: 'first',
|
||||
holidays: [],
|
||||
dialogVisible: false,
|
||||
currentHoliday: {}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
fetchHolidayData() {
|
||||
listOaHoliday({}).then(response => {
|
||||
this.holidays = response.rows.map(item => ({
|
||||
date: item.holidayTime.split(" ")[0],
|
||||
type: item.type,
|
||||
name: item.name,
|
||||
fullData: item
|
||||
}));
|
||||
}).catch(error => {
|
||||
console.error("Error fetching holiday data:", error);
|
||||
});
|
||||
},
|
||||
isHoliday(date) {
|
||||
const holiday = this.holidays.find(holiday => holiday.date === date);
|
||||
return holiday && (holiday.type === 1 || holiday.type === 2);
|
||||
},
|
||||
getHolidayName(date) {
|
||||
const holiday = this.holidays.find(holiday => holiday.date === date);
|
||||
return holiday ? holiday.name : '';
|
||||
},
|
||||
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;
|
||||
break;
|
||||
case 1:
|
||||
this.currentHoliday.name = "休息日";
|
||||
break;
|
||||
case 2:
|
||||
this.currentHoliday.name = "节假日";
|
||||
break;
|
||||
case 3:
|
||||
this.currentHoliday.name = "调休";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
updateOaHoliday(this.currentHoliday).then(response => {
|
||||
this.dialogVisible = false;
|
||||
this.fetchHolidayData();
|
||||
this.$message.success("假期类型更新成功");
|
||||
}).catch(error => {
|
||||
console.error("Error updating holiday data:", error);
|
||||
this.$message.error("更新失败");
|
||||
});
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchHolidayData();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-calendar__cell {
|
||||
border: none !important;
|
||||
background-color: inherit;
|
||||
padding: 0;
|
||||
}
|
||||
.blue-background {
|
||||
background-color: #dcf2f2;
|
||||
color: inherit;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.el-calendar__cell p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.holiday-name {
|
||||
font-size: 16px;
|
||||
color: #141313;
|
||||
text-align: center;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.el-dialog {
|
||||
max-width: 100%;
|
||||
}
|
||||
</style>
|
||||
184
ruoyi-ui/src/views/oa/holidaylist/index.vue
Normal file
184
ruoyi-ui/src/views/oa/holidaylist/index.vue
Normal file
@@ -0,0 +1,184 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import { listOaHoliday, getOaHoliday, delOaHoliday, addOaHoliday, updateOaHoliday } from "@/api/oa/oaHoliday";
|
||||
|
||||
export default {
|
||||
name: "OaHoliday",
|
||||
data() {
|
||||
return {
|
||||
// 按钮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" }
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询休假管理列表 */
|
||||
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;
|
||||
});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('oa/oaHoliday/export', {
|
||||
...this.queryParams
|
||||
}, `oaHoliday_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user