Commit c4fd9448fe857ef682efdf0e5a844c1fd1592979

Authored by 曾国涛
2 parents 6ffe487f 450f13df

Merge remote-tracking branch 'origin/warning'

Showing 1 changed file with 11 additions and 2 deletions
src/pages/Order/Order/index.tsx
@@ -131,7 +131,7 @@ import './index.less'; @@ -131,7 +131,7 @@ import './index.less';
131 import { OrderListItemType, OrderType } from './type.d'; 131 import { OrderListItemType, OrderType } from './type.d';
132 // import { useNavigate } from 'react-router-dom'; 132 // import { useNavigate } from 'react-router-dom';
133 import { history } from '@umijs/max'; 133 import { history } from '@umijs/max';
134 -import { format } from 'fecha'; 134 +// import { format } from 'fecha';
135 135
136 const OrderPage = () => { 136 const OrderPage = () => {
137 const [orderDrawerVisible, setOrderDrawerVisible] = useState<boolean>(false); 137 const [orderDrawerVisible, setOrderDrawerVisible] = useState<boolean>(false);
@@ -4590,10 +4590,19 @@ const OrderPage = () =&gt; { @@ -4590,10 +4590,19 @@ const OrderPage = () =&gt; {
4590 } 4590 }
4591 function setOriginTime(value) { 4591 function setOriginTime(value) {
4592 const currentDate = new Date(); 4592 const currentDate = new Date();
  4593 +
4593 // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天 4594 // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天
4594 const newDate = new Date(currentDate); 4595 const newDate = new Date(currentDate);
4595 newDate.setDate(currentDate.getDate() - value); 4596 newDate.setDate(currentDate.getDate() - value);
4596 - const formattedDate = format(newDate, 'yyyy-MM-dd HH:mm:ss'); 4597 + // 检查日期是否有效,并格式化输出
  4598 + function formatDate(date) {
  4599 + const year = date.getFullYear();
  4600 + const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需加1
  4601 + const day = String(date.getDate()).padStart(2, '0'); // 确保是两位数
  4602 + return `${year}-${month}-${day} ${date.toTimeString().split(' ')[0]}`; // 获取时间部分
  4603 + }
  4604 + const formattedDate = formatDate(newDate);
  4605 + // const formattedDate = format(newDate, 'YYYY-MM-dd HH:mm:ss');
4597 return formattedDate; 4606 return formattedDate;
4598 } 4607 }
4599 const [invoiceWarningNum, setInvoiceWarningNum] = useState(0); 4608 const [invoiceWarningNum, setInvoiceWarningNum] = useState(0);