From f6427b5dea54bbb8761fade351e9f86404b2fb61 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 30 三月 2026 10:22:59 +0800
Subject: [PATCH] fix: 规格型号搜索

---
 src/pages/consumablesLogistics/stockReport/index.vue |   58 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/src/pages/consumablesLogistics/stockReport/index.vue b/src/pages/consumablesLogistics/stockReport/index.vue
index 8dc324f..19b1b74 100644
--- a/src/pages/consumablesLogistics/stockReport/index.vue
+++ b/src/pages/consumablesLogistics/stockReport/index.vue
@@ -64,7 +64,7 @@
             <view class="row" v-if="searchForm.reportType === 'inout'"><text class="l">鍑哄簱鏁伴噺</text><text class="r">{{ item.totalStockOut }}</text></view>
             <view class="row"><text class="l">鐜板湪搴撳瓨</text><text class="r highlight">{{ item.currentStock }}</text></view>
             <view class="row" v-if="item.createBy"><text class="l">鍏ュ簱浜�</text><text class="r">{{ item.createBy }}</text></view>
-            <view class="row" v-if="item.currentWeight"><text class="l">鐜板噣閲�(鍚�)</text><text class="r">{{ item.currentWeight }}</text></view>
+            <!-- <view class="row" v-if="item.currentWeight"><text class="l">鐜板噣閲�(鍚�)</text><text class="r">{{ item.currentWeight }}</text></view> -->
             <view class="row" v-if="item.recordType"><text class="l">鏉ユ簮</text><text class="r">{{ getRecordType(item.recordType) }}</text></view>
           </view>
         </view>
@@ -74,15 +74,13 @@
       </view>
       <view v-else class="no-data">鏆傛棤鏁版嵁</view>
     </view>
-    <up-popup :show="showDatePicker" mode="bottom" @close="showDatePicker = false">
-      <up-datetime-picker
-        v-model="dateValue"
-        :mode="datePickerMode"
-        :show="showDatePicker"
-        @confirm="onDateConfirm"
-        @cancel="showDatePicker = false"
-      />
-    </up-popup>
+    <up-datetime-picker
+      v-model="dateValue"
+      :mode="datePickerMode"
+      :show="showDatePicker"
+      @confirm="onDateConfirm"
+      @cancel="showDatePicker = false"
+    />
   </view>
 </template>
 
@@ -90,7 +88,6 @@
 import { ref, reactive, toRefs, computed, watch } from "vue";
 import dayjs from "dayjs";
 import PageHeader from "@/components/PageHeader.vue";
-import { formatDateToYMD } from "@/utils/ruoyi";
 import { onShow, onReachBottom } from "@dcloudio/uni-app";
 import { getConsumablesInReportList, getConsumablesInInAndOutReportList } from "@/api/consumablesLogistics/consumablesIn.js";
 import {
@@ -207,6 +204,23 @@
   getList();
 };
 
+const toPickerTimestamp = (val, target) => {
+  if (!val) return Date.now();
+  let parsed;
+  if (target === "startMonth" || target === "endMonth") {
+    parsed = dayjs(`${val}-01`).valueOf();
+  } else {
+    parsed = dayjs(val).valueOf();
+  }
+  return Number.isNaN(parsed) ? Date.now() : parsed;
+};
+
+const formatPickerDate = (value, isMonth) => {
+  const parsed = dayjs(value);
+  if (!parsed.isValid()) return "";
+  return parsed.format(isMonth ? "YYYY-MM" : "YYYY-MM-DD");
+};
+
 const openDatePicker = (target) => {
   datePickerTarget.value = target;
   let val = "";
@@ -215,13 +229,18 @@
   else if (target === "endMonth") val = searchForm.value.endMonth;
   else if (target === "startDate") val = searchForm.value.startDate;
   else if (target === "endDate") val = searchForm.value.endDate;
-  dateValue.value = val ? new Date(val).getTime() : Date.now();
+  dateValue.value = toPickerTimestamp(val, target);
   showDatePicker.value = true;
 };
 
 const onDateConfirm = (e) => {
   const isMonth = datePickerTarget.value === "startMonth" || datePickerTarget.value === "endMonth";
-  const str = isMonth ? dayjs(e.value).format("YYYY-MM") : formatDateToYMD(e.value);
+  const str = formatPickerDate(e.value, isMonth);
+  if (!str) {
+    showDatePicker.value = false;
+    uni.showToast({ title: "鏃ユ湡鏍煎紡鏃犳晥", icon: "none" });
+    return;
+  }
   if (datePickerTarget.value === "single") {
     searchForm.value.singleDate = str;
     showDatePicker.value = false;
@@ -233,6 +252,10 @@
       openDatePicker("endMonth");
     }, 300);
   } else if (datePickerTarget.value === "endMonth") {
+    if (searchForm.value.startMonth && !dayjs(`${str}-01`).isAfter(dayjs(`${searchForm.value.startMonth}-01`))) {
+      uni.showToast({ title: "缁撴潫鏈堜唤蹇呴』澶т簬寮�濮嬫湀浠�", icon: "none" });
+      return;
+    }
     searchForm.value.endMonth = str;
     showDatePicker.value = false;
     handleQuery();
@@ -243,6 +266,10 @@
       openDatePicker("endDate");
     }, 300);
   } else if (datePickerTarget.value === "endDate") {
+    if (searchForm.value.startDate && !dayjs(str).isAfter(dayjs(searchForm.value.startDate))) {
+      uni.showToast({ title: "缁撴潫鏃ユ湡蹇呴』澶т簬寮�濮嬫棩鏈�", icon: "none" });
+      return;
+    }
     searchForm.value.endDate = str;
     showDatePicker.value = false;
     handleQuery();
@@ -262,6 +289,9 @@
     searchForm.value.endDate = today.format("YYYY-MM-DD");
     searchForm.value.startDate = today.subtract(6, "day").format("YYYY-MM-DD");
   }
+  if (!datePickerTarget.value) {
+    dateValue.value = toPickerTimestamp(searchForm.value.singleDate, "single");
+  }
 };
 
 watch(
@@ -277,6 +307,8 @@
   fetchStockRecordTypeOptions();
 });
 
+initDefaultDates();
+
 onReachBottom(() => loadMore());
 
 const goBack = () => uni.navigateBack();

--
Gitblit v1.9.3