履约验收

This commit is contained in:
吴红兵
2026-02-25 11:28:30 +08:00
parent 27b06b5034
commit c6ddf30116

View File

@@ -133,12 +133,18 @@ const syncFormFromModel = (val: Record<string, any> | undefined) => {
const loadContractOptions = async () => { const loadContractOptions = async () => {
if (contractLoaded.value || contractLoading.value) return if (contractLoaded.value || contractLoading.value) return
if (form.hasContract !== '1') return
contractLoading.value = true contractLoading.value = true
try { try {
const res = await getContracts(props.purchaseId ? { id: props.purchaseId } : {}) const res = await getContracts(props.purchaseId ? { id: props.purchaseId } : {})
const list = res?.data const list = res?.data
contractOptions.value = Array.isArray(list) ? list : [] contractOptions.value = Array.isArray(list) ? list : []
contractLoaded.value = true contractLoaded.value = true
// 回显时:列表中含当前合同,用其供应商名称填充(若尚未有值)
if (form.contractId) {
const c = contractOptions.value.find((it: any) => it.id === form.contractId)
if (c?.supplierName) form.supplierName = c.supplierName
}
} catch (_) { } catch (_) {
contractOptions.value = [] contractOptions.value = []
} finally { } finally {
@@ -152,7 +158,17 @@ const onContractSelectVisibleChange = (visible: boolean) => {
} }
} }
watch(() => props.modelValue, syncFormFromModel, { deep: true, immediate: true }) watch(
() => props.modelValue,
(val) => {
syncFormFromModel(val)
// 回显已有合同ID时主动加载合同列表以便下拉显示合同名称后端已排除“其他申请”的合同当前申请合同会在列表中
if (form.hasContract === '1' && form.contractId && props.purchaseId && !contractLoaded.value && !contractLoading.value) {
loadContractOptions()
}
},
{ deep: true, immediate: true }
)
// resetKey 变化时强制用 modelValue 覆盖内部 form并重置合同列表以便重新拉取 // resetKey 变化时强制用 modelValue 覆盖内部 form并重置合同列表以便重新拉取
watch(() => props.resetKey, () => { watch(() => props.resetKey, () => {
syncFormFromModel(props.modelValue) syncFormFromModel(props.modelValue)