Commit 400adca2 authored by ‘老张’'s avatar ‘老张’

员工年假和填报工时优化

parent 8d8af891
import request from '@/utils/request'
// 查询员工年假列表
export function listAnnualleave(query) {
// 查询员工余额列表
export function listBalance(query) {
return request({
url: '/system/annualleave/list',
url: '/system/balance/list',
method: 'get',
params: query
})
}
// 查询员工年假详细
export function getAnnualleave(id) {
// 查询员工余额详细
export function getBalance(id) {
return request({
url: '/system/annualleave/' + id,
url: '/system/balance/' + id,
method: 'get'
})
}
// 新增员工年假
export function addAnnualleave(data) {
// 新增员工余额
export function addBalance(data) {
return request({
url: '/system/annualleave',
url: '/system/balance',
method: 'post',
data: data
})
}
// 修改员工年假
export function updateAnnualleave(data) {
// 修改员工余额
export function updateBalance(data) {
return request({
url: '/system/annualleave',
url: '/system/balance',
method: 'put',
data: data
})
}
// 删除员工年假
export function delAnnualleave(id) {
// 删除员工余额
export function delBalance(id) {
return request({
url: '/system/annualleave/' + id,
url: '/system/balance/' + id,
method: 'delete'
})
}
......@@ -284,30 +284,46 @@ const submitProject = async () => {
/** 查询工时记录列表 */
function getList(employId) {
loading.value = true;
getPersonalTimesheet(employId).then(response => {
console.log(response)
if (Array.isArray(response)) { // 检查是否为数组
personalTimesheetList.value = response.map(project => ({
...project,
addWorkList: project.addWorkList.map(day => ({
...day,
hours: Number(day.hours) || 0,
})),
totalHours: project.totalHours || 0,
approvalState: parseInt(project.approvalState),
departmentLeaderName: project.departmentLeaderName || '',
}));
loading.value = true;
// 从本地存储获取缓存数据
const cachedData = localStorage.getItem(`timesheet_${employId}`);
if (cachedData) {
personalTimesheetList.value = JSON.parse(cachedData);
}
getPersonalTimesheet(employId).then(response => {
console.log(response);
if (Array.isArray(response)) {
const newData = response.map(project => ({
...project,
addWorkList: project.addWorkList.map(day => ({
...day,
hours: Number(day.hours) || 0,
})),
totalHours: project.totalHours || 0,
approvalState: parseInt(project.approvalState),
departmentLeaderName: project.departmentLeaderName || '',
}));
// 对比数据是否相同
const isSame = JSON.stringify(newData) === cachedData;
if (!isSame) {
personalTimesheetList.value = newData;
// 将新数据存入本地存储
localStorage.setItem(`timesheet_${employId}`, JSON.stringify(newData));
}
} else {
console.error("Invalid response format:", response);
console.error("Invalid response format:", response);
}
loading.value = false;
})
.catch(error => {
// console.error("API error:", error);
})
.catch(error => {
console.error("API error:", error);
loading.value = false;
});
});
}
const A =(data)=>{
getPersonalTimesheet(data).then(response => {
if (response.code === 200) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment