ソースを参照

fix: 补货建议数量输入后焦点移出被重置的问题

- suggestions 从 ref<any[]> 改为 reactive<any[]>,确保深层对象属性修改可靠响应
- 数组赋值改为 length=0 + push(...) 保持 reactive 引用不变

Co-Authored-By: Claude <noreply@anthropic.com>
skyline 1 日 前
コミット
b2667830a8

+ 7 - 6
haha-admin-web/src/views/replenishment-order/components/CreateDialog.vue

@@ -26,8 +26,8 @@ const filteredDeviceList = computed(() => {
   return deviceList.value.filter((d: any) => lowStockDeviceIds.value.has(d.deviceId));
 });
 
-// 补货建议结果(按设备分组)
-const suggestions = ref<any[]>([]);
+// 补货建议结果(按设备分组)。用 reactive 替代 ref,确保数组内嵌套对象的深层属性修改可靠响应
+const suggestions = reactive<any[]>([]);
 
 // 公共字段
 const commonForm = reactive({
@@ -44,7 +44,7 @@ async function open() {
 
 function resetState() {
   selectedDevices.value = [];
-  suggestions.value = [];
+  suggestions.length = 0;
   suggestionsLoading.value = false;
   showLowStockOnly.value = false;
   commonForm.supplierName = "";
@@ -77,7 +77,7 @@ function handleSelectionChange(selection: any[]) {
 }
 
 function resetToSelect() {
-  suggestions.value = [];
+  suggestions.length = 0;
   selectedDevices.value = [];
 }
 
@@ -94,7 +94,8 @@ async function fetchSuggestions() {
     if (list.length === 0) {
       message("所选设备当前均无需补货", { type: "info" });
     }
-    suggestions.value = list;
+    suggestions.length = 0;
+    suggestions.push(...list);
   } catch (e) {
     console.error("获取补货建议失败:", e);
     message("获取补货建议失败", { type: "error" });
@@ -104,7 +105,7 @@ async function fetchSuggestions() {
 }
 
 async function handleSubmit() {
-  const validSuggestions = suggestions.value.filter(
+  const validSuggestions = suggestions.filter(
     s => s.items.some((i: any) => i.suggestedQuantity > 0)
   );
   if (validSuggestions.length === 0) {