瀏覽代碼

fix: import watch and fix types in WarehouseSection.vue

unknown 21 小時之前
父節點
當前提交
1d5e7bcbe3
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      src/components/admin/WarehouseSection.vue

+ 4 - 3
src/components/admin/WarehouseSection.vue

@@ -164,7 +164,7 @@
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, onMounted } from "vue";
+import { ref, reactive, onMounted, watch } from "vue";
 import { useI18n } from "vue-i18n";
 import { Package, Plus, PackageOpen, Check, Edit2, Trash2, Minus } from "lucide-vue-next";
 import { toast } from "vue-sonner";
@@ -197,8 +197,9 @@ const form = reactive({
   notes: ""
 });
 
-watch(() => [form.unit_mass, form.units_count], ([m, c]) => {
-  if (!editingId.value) {
+// Watch unit properties to calculate total quantity
+watch(() => [form.unit_mass, form.units_count], ([m, c]: any[]) => {
+  if (!editingId.value) { // Only auto-calc for new items to avoid overriding manual tweaks
      form.quantity = Number((m * c).toFixed(3));
   }
 });