|
|
@@ -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) {
|