Explorar o código

feat: 添加订单管理页面默认日期范围功能

laiqi hai 2 meses
pai
achega
a4726f8efd

+ 1 - 0
apps/web-ele/src/api/request.ts

@@ -116,6 +116,7 @@ function createRequestClient(baseURL: string, options?: RequestClientOptions) {
 
 export const requestClient = createRequestClient(apiURL, {
   responseReturn: 'data',
+  timeout: 60_000,
 });
 
 export const baseRequestClient = new RequestClient({ baseURL: apiURL });

+ 23 - 0
apps/web-ele/src/views/order-manage/index.vue

@@ -26,6 +26,28 @@ import OrdersForm from './form.vue';
 const dealerOptions = ref<Array<{ label: string; value: string }>>([]);
 const userStore = useUserStore();
 
+// 获取当月第一天和最后一天作为默认日期范围
+const getDefaultDateRange = () => {
+  const now = new Date();
+  const year = now.getFullYear();
+  const month = now.getMonth();
+
+  // 当月第一天
+  const firstDay = new Date(year, month, 1);
+  // 当月最后一天
+  const lastDay = new Date(year, month + 1, 0);
+
+  // 格式化为 YYYY-MM-DD
+  const formatDate = (date: Date) => {
+    const y = date.getFullYear();
+    const m = String(date.getMonth() + 1).padStart(2, '0');
+    const d = String(date.getDate()).padStart(2, '0');
+    return `${y}-${m}-${d}`;
+  };
+
+  return [formatDate(firstDay), formatDate(lastDay)];
+};
+
 const fetchDealerOptions = async () => {
   try {
     const result = await getCustomerListApi({
@@ -123,6 +145,7 @@ const formOptions: VbenFormProps = {
       component: 'DatePicker',
       fieldName: 'ordersorderdate',
       label: '下单时间',
+      defaultValue: getDefaultDateRange(),
       componentProps: {
         type: 'daterange',
         startPlaceholder: '开始日期',