feat: BOM 子件展示自制件 BOM 版本号——子件列表与出库/借库 BOM 清单打印均显示
This commit is contained in:
@ -320,13 +320,28 @@ class BomService:
|
|||||||
parent_material = MaterialBase.query.get(parent_id)
|
parent_material = MaterialBase.query.get(parent_id)
|
||||||
|
|
||||||
children = []
|
children = []
|
||||||
|
|
||||||
|
# ★ 子件若本身是"自制件"(也是某 BOM 的父件),带出它的 BOM 编号与最新版本号(仅展示识别用)
|
||||||
|
child_self_bom = {}
|
||||||
|
self_ids = [bom.child_id for bom, _, _ in rows if bom.child_id]
|
||||||
|
if self_ids:
|
||||||
|
_self_q = (db.session.query(BomTable.parent_id, BomTable.bom_no, BomTable.version)
|
||||||
|
.filter(BomTable.parent_id.in_(self_ids))
|
||||||
|
.order_by(BomTable.parent_id, BomTable.id.desc()).all())
|
||||||
|
for _pid, _no, _ver in _self_q:
|
||||||
|
if _pid not in child_self_bom:
|
||||||
|
child_self_bom[_pid] = {'bom_no': _no, 'version': _ver}
|
||||||
|
|
||||||
for bom, child_name, child_spec in rows:
|
for bom, child_name, child_spec in rows:
|
||||||
|
_ref = child_self_bom.get(bom.child_id) or {}
|
||||||
children.append({
|
children.append({
|
||||||
'child_id': bom.child_id,
|
'child_id': bom.child_id,
|
||||||
'child_name': child_name or '[已删除物料]',
|
'child_name': child_name or '[已删除物料]',
|
||||||
'child_spec': child_spec or '',
|
'child_spec': child_spec or '',
|
||||||
'dosage': float(bom.dosage) if bom.dosage else 0.0,
|
'dosage': float(bom.dosage) if bom.dosage else 0.0,
|
||||||
'remark': bom.remark or ''
|
'remark': bom.remark or '',
|
||||||
|
'child_bom_no': _ref.get('bom_no', ''),
|
||||||
|
'child_bom_version': _ref.get('version', '')
|
||||||
})
|
})
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
|
|||||||
@ -196,6 +196,10 @@
|
|||||||
style="font-size: 16px; padding: 4px;"
|
style="font-size: 16px; padding: 4px;"
|
||||||
/>
|
/>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
<!-- ★ 自制件子件:显示其对应 BOM 版本(仅识别用) -->
|
||||||
|
<el-tag v-if="row.child_bom_version" size="small" type="warning" style="margin-left: 4px;">
|
||||||
|
自制{{ row.child_bom_version }}
|
||||||
|
</el-tag>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -290,6 +294,7 @@ interface ChildRow {
|
|||||||
material_spec: string
|
material_spec: string
|
||||||
dosage: number
|
dosage: number
|
||||||
remark: string
|
remark: string
|
||||||
|
child_bom_version?: string // 自制件子件对应的 BOM 版本(仅展示识别)
|
||||||
}
|
}
|
||||||
|
|
||||||
const originalDraftHash = ref('')
|
const originalDraftHash = ref('')
|
||||||
@ -649,7 +654,8 @@ const executeSaveDraftRequest = async (targetBomNo: string) => {
|
|||||||
.map(child => ({
|
.map(child => ({
|
||||||
child_id: child.child_id,
|
child_id: child.child_id,
|
||||||
dosage: child.dosage,
|
dosage: child.dosage,
|
||||||
remark: child.remark || ''
|
remark: child.remark || '',
|
||||||
|
child_bom_version: child.child_bom_version || ''
|
||||||
}))
|
}))
|
||||||
|
|
||||||
saving.value = true
|
saving.value = true
|
||||||
@ -683,7 +689,8 @@ const restoreDraftToForm = (draftData: any) => {
|
|||||||
material_name: child.child_name || '',
|
material_name: child.child_name || '',
|
||||||
material_spec: child.child_spec || '',
|
material_spec: child.child_spec || '',
|
||||||
dosage: child.dosage,
|
dosage: child.dosage,
|
||||||
remark: child.remark || ''
|
remark: child.remark || '',
|
||||||
|
child_bom_version: child.child_bom_version || ''
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if (draftData.parent_id) {
|
if (draftData.parent_id) {
|
||||||
@ -800,7 +807,8 @@ const handleSaveAs = async (row: any) => {
|
|||||||
material_name: child.child_name || '未知物料',
|
material_name: child.child_name || '未知物料',
|
||||||
material_spec: child.child_spec || '',
|
material_spec: child.child_spec || '',
|
||||||
dosage: child.dosage,
|
dosage: child.dosage,
|
||||||
remark: child.remark || ''
|
remark: child.remark || '',
|
||||||
|
child_bom_version: child.child_bom_version || ''
|
||||||
}))
|
}))
|
||||||
if (raw.parent_id) {
|
if (raw.parent_id) {
|
||||||
form.parent_id = raw.parent_id
|
form.parent_id = raw.parent_id
|
||||||
@ -836,7 +844,8 @@ const loadDetail = async (bomNo: string, version: string) => {
|
|||||||
material_name: child.child_name || '未知物料',
|
material_name: child.child_name || '未知物料',
|
||||||
material_spec: child.child_spec || '',
|
material_spec: child.child_spec || '',
|
||||||
dosage: child.dosage,
|
dosage: child.dosage,
|
||||||
remark: child.remark || ''
|
remark: child.remark || '',
|
||||||
|
child_bom_version: child.child_bom_version || ''
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if (data.parent_id) {
|
if (data.parent_id) {
|
||||||
|
|||||||
@ -274,7 +274,7 @@
|
|||||||
<tr v-for="(row, idx) in bomDetailList" :key="idx">
|
<tr v-for="(row, idx) in bomDetailList" :key="idx">
|
||||||
<td>{{ idx + 1 }}</td>
|
<td>{{ idx + 1 }}</td>
|
||||||
<td>{{ row.name }}</td>
|
<td>{{ row.name }}</td>
|
||||||
<td>{{ row.sku }}</td>
|
<td>{{ row.sku }}<span v-if="row.child_bom_version" style="color:#666; font-size:11px;">(自制 {{ row.child_bom_version }})</span></td>
|
||||||
<td>{{ row.need }}</td>
|
<td>{{ row.need }}</td>
|
||||||
<td>{{ row.available }}</td>
|
<td>{{ row.available }}</td>
|
||||||
<td>{{ row.shortage > 0 ? row.shortage : '-' }}</td>
|
<td>{{ row.shortage > 0 ? row.shortage : '-' }}</td>
|
||||||
@ -304,7 +304,7 @@
|
|||||||
<tr v-for="(row, idx) in bomDetailList.filter(i => i.shortage > 0)" :key="idx">
|
<tr v-for="(row, idx) in bomDetailList.filter(i => i.shortage > 0)" :key="idx">
|
||||||
<td>{{ idx + 1 }}</td>
|
<td>{{ idx + 1 }}</td>
|
||||||
<td>{{ row.name }}</td>
|
<td>{{ row.name }}</td>
|
||||||
<td>{{ row.sku }}</td>
|
<td>{{ row.sku }}<span v-if="row.child_bom_version" style="color:#666; font-size:11px;">(自制 {{ row.child_bom_version }})</span></td>
|
||||||
<td>{{ row.shortage }}</td>
|
<td>{{ row.shortage }}</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -610,7 +610,8 @@ const bomDetailList = computed(() => {
|
|||||||
sku: bomItem.child_sku || bomItem.sku || '-',
|
sku: bomItem.child_sku || bomItem.sku || '-',
|
||||||
need: totalNeed,
|
need: totalNeed,
|
||||||
available: stock,
|
available: stock,
|
||||||
shortage
|
shortage,
|
||||||
|
child_bom_version: bomItem.child_bom_version || ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
|
|||||||
@ -280,7 +280,7 @@
|
|||||||
<tr v-for="(row, idx) in bomDetailList" :key="idx">
|
<tr v-for="(row, idx) in bomDetailList" :key="idx">
|
||||||
<td>{{ idx + 1 }}</td>
|
<td>{{ idx + 1 }}</td>
|
||||||
<td>{{ row.name }}</td>
|
<td>{{ row.name }}</td>
|
||||||
<td>{{ row.sku }}</td>
|
<td>{{ row.sku }}<span v-if="row.child_bom_version" style="color:#666; font-size:11px;">(自制 {{ row.child_bom_version }})</span></td>
|
||||||
<td>{{ row.need }}</td>
|
<td>{{ row.need }}</td>
|
||||||
<td>{{ row.available }}</td>
|
<td>{{ row.available }}</td>
|
||||||
<td>{{ row.shortage > 0 ? row.shortage : '-' }}</td>
|
<td>{{ row.shortage > 0 ? row.shortage : '-' }}</td>
|
||||||
@ -310,7 +310,7 @@
|
|||||||
<tr v-for="(row, idx) in bomDetailList.filter(i => i.shortage > 0)" :key="idx">
|
<tr v-for="(row, idx) in bomDetailList.filter(i => i.shortage > 0)" :key="idx">
|
||||||
<td>{{ idx + 1 }}</td>
|
<td>{{ idx + 1 }}</td>
|
||||||
<td>{{ row.name }}</td>
|
<td>{{ row.name }}</td>
|
||||||
<td>{{ row.sku }}</td>
|
<td>{{ row.sku }}<span v-if="row.child_bom_version" style="color:#666; font-size:11px;">(自制 {{ row.child_bom_version }})</span></td>
|
||||||
<td>{{ row.shortage }}</td>
|
<td>{{ row.shortage }}</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -632,7 +632,8 @@ const bomDetailList = computed(() => {
|
|||||||
sku: bomItem.child_spec || bomItem.spec_model || '-',
|
sku: bomItem.child_spec || bomItem.spec_model || '-',
|
||||||
need: totalNeed,
|
need: totalNeed,
|
||||||
available: stock,
|
available: stock,
|
||||||
shortage
|
shortage,
|
||||||
|
child_bom_version: bomItem.child_bom_version || ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user