|
@@ -164,7 +164,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { ref, reactive, onMounted } from "vue";
|
|
|
|
|
|
|
+import { ref, reactive, onMounted, watch } from "vue";
|
|
|
import { useI18n } from "vue-i18n";
|
|
import { useI18n } from "vue-i18n";
|
|
|
import { Package, Plus, PackageOpen, Check, Edit2, Trash2, Minus } from "lucide-vue-next";
|
|
import { Package, Plus, PackageOpen, Check, Edit2, Trash2, Minus } from "lucide-vue-next";
|
|
|
import { toast } from "vue-sonner";
|
|
import { toast } from "vue-sonner";
|
|
@@ -197,8 +197,9 @@ const form = reactive({
|
|
|
notes: ""
|
|
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));
|
|
form.quantity = Number((m * c).toFixed(3));
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|