// 表格数据转换函数 export function transformData(result) { const mapInfo = { '名称': 'name', '任务开始时间': 'taskStartDate', '任务结束时间': 'taskEndDate', '任务工时': 'taskHours', '所属员工': 'userId', '所属员工ID': 'userIds', '绩效工时': 'performanceHours', '任务状态': 'taskStatus', '任务状态ID': 'taskStatusID', '优先度': 'priority', '优先度ID': 'priorityID' } return result.map(item => { const zhKeys = Object.keys(item) const obj = {} zhKeys.forEach(zhKey => { const enKey = mapInfo[zhKey] if (enKey === 'taskStartDate' || enKey === 'taskEndDate') { // obj[enKey] = formatExcelDate(item[zhKey]) obj[enKey] = formatExcelDate(item[zhKey]) } else { obj[enKey] = item[zhKey] } }) return obj }) } // 转换表格时间为2021/1/2格式 // export function formatExcelDate(numb, format = '/') { // const time = new Date((numb - 25567) * 24 * 3600000 - 5 * 60 * 1000 - 43 * 1000 - 24 * 3600000 - 8 * 3600000) // time.setYear(time.getFullYear()) // const year = time.getFullYear() + '' // const month = time.getMonth() + 1 + '' // const date = time.getDate() + '' // if (format && format.length === 1) { // return year + format + month + format + date // } // return year + (month < 10 ? '0' + month : month) + (date < 10 ? '0' + date : date) // } // export function formatExcelDate(numb, format = '-') { // const time = new Date((numb - 25569) * 24 * 3600000); // let localTimeString = time.toISOString(); // // 格式化为"yyyy-mm-dd HH:MM:SS" // localTimeString = localTimeString.replace('T', ' ').split('.')[0].replace(/-/g, format); // return localTimeString; // } export function formatExcelDate(numb, format = '-') { const seconds = Math.round((numb - 25569) * 24 * 60 * 60); const time = new Date(seconds * 1000); let localTimeString = time.toISOString(); // 格式化为"yyyy-mm-dd HH:MM:SS" localTimeString = localTimeString.replace('T', ' ').split('.')[0].replace(/-/g, format); return localTimeString; }