This commit is contained in:
2026-06-23 09:38:31 +08:00
parent f6d8829071
commit 6b3188e693
11 changed files with 197 additions and 47 deletions
@@ -8,6 +8,7 @@ const { state, loadInventory, ensureStockBaseData } = useInventory()
const showModal = ref(false)
const editingItem = ref<any>(null)
const saving = ref(false)
const form = reactive({
product_id: null as number | null,
warehouse_id: null as number | null,
@@ -42,6 +43,24 @@ function openEdit(item: any) {
}
async function save() {
if (saving.value) return
if (!form.product_id) {
addNotification('请选择物料', 'warning')
return
}
if (!form.warehouse_id) {
addNotification('请选择仓库', 'warning')
return
}
if (form.quantity < 0) {
addNotification('数量不能为负数', 'warning')
return
}
if (form.locked_quantity > form.quantity) {
addNotification('锁定数量不能大于库存数量', 'warning')
return
}
saving.value = true
try {
const payload = {
product_id: form.product_id,
@@ -68,6 +87,8 @@ async function save() {
loadInventory()
} catch (e) {
handleApiError(e, '保存物料库存')
} finally {
saving.value = false
}
}
@@ -139,8 +160,8 @@ onMounted(() => { loadInventory() })
</t-form-item>
</t-form>
<template #footer>
<t-button @click="showModal = false">取消</t-button>
<t-button type="primary" @click="save">保存</t-button>
<t-button @click="showModal = false" :disabled="saving">取消</t-button>
<t-button type="primary" :loading="saving" :disabled="saving" @click="save">保存</t-button>
</template>
</t-dialog>
</div>