Revert "fix: storId 选择追踪 — 用 onChange + selectedStorId ref + fallback"

This reverts commit 890edbc948.
This commit is contained in:
zhouz
2026-07-22 13:38:14 +08:00
parent 21204495a8
commit 865a128100

View File

@@ -61,9 +61,6 @@ const [Form, formApi] = useVbenForm({
options: storOptions,
placeholder: '请选择仓库',
fieldNames: { label: 'label', value: 'value' },
onChange: (val: string) => {
selectedStorId.value = val || '';
},
},
},
{
@@ -135,14 +132,14 @@ function updateSummary() {
});
}
// 当前选中的仓库 ID独立追踪避免 formApi.getValues() 拿到旧值)
const selectedStorId = ref('');
// 仓库切换 → 清空明细
watch(selectedStorId, () => {
watch(
() => formApi.getValues().storId,
() => {
detailList.value = [];
updateSummary();
});
},
);
function handleDeleteDetail(index: number) {
detailList.value.splice(index, 1);
@@ -153,10 +150,7 @@ function handleDeleteDetail(index: number) {
const inventorySelectRef = ref<any>();
function handleSelectFromInventory() {
let storId = selectedStorId.value;
if (!storId) {
storId = formApi.getValues().storId; // fallback
}
const storId = formApi.getValues().storId;
if (!storId) {
message.warning('请先选择仓库');
return;