作者 xudada

C6航班日期少一天BUG修复

@@ -3028,21 +3028,24 @@ Handling Information @@ -3028,21 +3028,24 @@ Handling Information
3028 Object.assign(this.$data, this.$options.data()); 3028 Object.assign(this.$data, this.$options.data());
3029 }, 3029 },
3030 NumberToDate(cellValue){ 3030 NumberToDate(cellValue){
3031 - // 将 Excel 的序列号转换为 JavaScript 的 Date 对象  
3032 - // 注意:Excel 的日期序列号是从 1900 年 1 月 1 日开始计算的(不考虑1904日期系统)  
3033 - let dateObj = new Date((cellValue - 1) * 24 * 3600 * 1000 + new Date(1900, 0, 1).getTime()); 3031 + // 计算从1900年1月1日到目标日期的总毫秒数
  3032 + let totalMilliseconds = (cellValue - 1) * 24 * 3600 * 1000;
3034 3033
3035 - // 考虑 Excel 中的一个已知错误,即它认为1900年是闰年,所以需要减去一天 3034 + // 创建一个基于1900年1月1日的UTC时间对象
  3035 + let dateObj = new Date(Date.UTC(1900, 0, 1) + totalMilliseconds);
  3036 +
  3037 + // 修正 Excel 中的一个已知错误,即它认为1900年是闰年
3036 if (cellValue > 60) { 3038 if (cellValue > 60) {
3037 dateObj = new Date(dateObj.getTime() - 24 * 3600 * 1000); 3039 dateObj = new Date(dateObj.getTime() - 24 * 3600 * 1000);
3038 } 3040 }
3039 3041
3040 - // 将 Date 对象格式化为你想要的日期字符串 3042 + // 格式化为中文日期字符串
3041 let formattedDate = dateObj.toLocaleDateString('zh-CN', { 3043 let formattedDate = dateObj.toLocaleDateString('zh-CN', {
3042 year: 'numeric', 3044 year: 'numeric',
3043 month: '2-digit', 3045 month: '2-digit',
3044 day: '2-digit' 3046 day: '2-digit'
3045 }); 3047 });
  3048 +
3046 return formattedDate; 3049 return formattedDate;
3047 }, 3050 },
3048 handleChange(file, fileList) { 3051 handleChange(file, fileList) {
@@ -3146,6 +3149,7 @@ Handling Information @@ -3146,6 +3149,7 @@ Handling Information
3146 3149
3147 this.form.isu.isu_day_mounth_year=this.formattedDate(); 3150 this.form.isu.isu_day_mounth_year=this.formattedDate();
3148 }else{ 3151 }else{
  3152 + console.log(M18)
3149 const tempDate=this.NumberToDate(M18); 3153 const tempDate=this.NumberToDate(M18);
3150 const outFlightDate=tempDate.split('/')[2]; 3154 const outFlightDate=tempDate.split('/')[2];
3151 const SSRInfo = A20.replace(/[^a-zA-Z0-9\s]/g, ''); 3155 const SSRInfo = A20.replace(/[^a-zA-Z0-9\s]/g, '');