修复物料伙伴选项和空值处理
This commit is contained in:
parent
1474b4d066
commit
09bfd0e105
|
|
@ -62,8 +62,16 @@
|
||||||
{{ getUnitDisplay(row) }}
|
{{ getUnitDisplay(row) }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="supplier_name" label="供应商" min-width="140" />
|
<el-table-column label="供应商" min-width="140">
|
||||||
<el-table-column prop="manufacturer_name" label="制造商" min-width="140" />
|
<template #default="{ row }">
|
||||||
|
{{ row.supplier_name || '-' }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="制造商" min-width="140">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ row.manufacturer_name || '-' }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="操作"
|
label="操作"
|
||||||
width="240"
|
width="240"
|
||||||
|
|
@ -372,16 +380,32 @@ onMounted(async () => {
|
||||||
// 检索框却只给有效物料的话,作废的那些就搜不出来(而这一页正是恢复它们的入口)。
|
// 检索框却只给有效物料的话,作废的那些就搜不出来(而这一页正是恢复它们的入口)。
|
||||||
// 业务单据页(入库/出库/申请)仍用只有有效物料的 materialOptions。
|
// 业务单据页(入库/出库/申请)仍用只有有效物料的 materialOptions。
|
||||||
materialsStore.fetchHistoricalMaterialOptions()
|
materialsStore.fetchHistoricalMaterialOptions()
|
||||||
const [categoryResponse, unitResponse, supplierResponse, manufacturerResponse] = await Promise.all([
|
const [categoryResult, unitResult, supplierResult, manufacturerResult] = await Promise.allSettled([
|
||||||
materialCategoriesApi.list(),
|
materialCategoriesApi.list(),
|
||||||
unitsApi.list(),
|
unitsApi.list(),
|
||||||
loadPartners('supplier'),
|
loadPartners('supplier'),
|
||||||
loadPartners('manufacturer')
|
loadPartners('manufacturer')
|
||||||
])
|
])
|
||||||
categories.value = categoryResponse.data || []
|
if (categoryResult.status === 'fulfilled') {
|
||||||
units.value = (unitResponse.data || []).filter(item => item.status === 'active')
|
categories.value = categoryResult.value.data || []
|
||||||
suppliers.value = supplierResponse
|
} else {
|
||||||
manufacturers.value = manufacturerResponse
|
console.error('加载物料分类失败:', categoryResult.reason)
|
||||||
|
}
|
||||||
|
if (unitResult.status === 'fulfilled') {
|
||||||
|
units.value = (unitResult.value.data || []).filter(item => item.status === 'active')
|
||||||
|
} else {
|
||||||
|
console.error('加载计量单位失败:', unitResult.reason)
|
||||||
|
}
|
||||||
|
if (supplierResult.status === 'fulfilled') {
|
||||||
|
suppliers.value = supplierResult.value
|
||||||
|
} else {
|
||||||
|
console.error('加载供应商失败:', supplierResult.reason)
|
||||||
|
}
|
||||||
|
if (manufacturerResult.status === 'fulfilled') {
|
||||||
|
manufacturers.value = manufacturerResult.value
|
||||||
|
} else {
|
||||||
|
console.error('加载制造商失败:', manufacturerResult.reason)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
async function loadPartners(role) {
|
async function loadPartners(role) {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export function toMaterialPayload(source) {
|
||||||
const payload = {}
|
const payload = {}
|
||||||
for (const key of materialKeys) {
|
for (const key of materialKeys) {
|
||||||
payload[key] = key === 'supplier_id' || key === 'manufacturer_id'
|
payload[key] = key === 'supplier_id' || key === 'manufacturer_id'
|
||||||
? source[key] ?? 0
|
? (source[key] == null || source[key] === '' ? 0 : source[key])
|
||||||
: key.endsWith('_id') ? source[key] ?? null : source[key] || ''
|
: key.endsWith('_id') ? source[key] ?? null : source[key] || ''
|
||||||
}
|
}
|
||||||
if (!payload.unit) payload.unit = '个'
|
if (!payload.unit) payload.unit = '个'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user