feat: 出库/借库记录记录并展示库位快照(DB加列+后端写入+记录页展示)
This commit is contained in:
@ -133,6 +133,9 @@ class TransOutbound(db.Model):
|
||||
outbound_time = db.Column(db.DateTime, default=beijing_time)
|
||||
operator_name = db.Column(db.String(100)) # 操作员
|
||||
|
||||
# [新增] 出库时的库位快照(从源库存记录带出,便于历史追溯)
|
||||
warehouse_location = db.Column(db.String(100))
|
||||
|
||||
remark = db.Column(db.Text)
|
||||
|
||||
def to_dict(self):
|
||||
@ -148,5 +151,6 @@ class TransOutbound(db.Model):
|
||||
'signature_path': self.signature_path,
|
||||
'outbound_time': self.outbound_time.strftime('%Y-%m-%d %H:%M:%S') if self.outbound_time else None,
|
||||
'operator_name': self.operator_name,
|
||||
'warehouse_location': self.warehouse_location or '',
|
||||
'remark': self.remark
|
||||
}
|
||||
@ -23,6 +23,8 @@ class TransBorrow(db.Model):
|
||||
return_operator = db.Column(db.String(100))
|
||||
return_signature = db.Column(db.Text)
|
||||
return_location = db.Column(db.String(100))
|
||||
# [新增] 借出时的库位快照(从源库存记录带出,便于历史追溯)
|
||||
location = db.Column(db.String(100))
|
||||
status = db.Column(db.String(20), default='borrowed')
|
||||
remark = db.Column(db.Text)
|
||||
|
||||
@ -49,6 +51,7 @@ class TransBorrow(db.Model):
|
||||
'return_operator': self.return_operator,
|
||||
'return_signature': self.return_signature,
|
||||
'return_location': self.return_location,
|
||||
'location': self.location or '',
|
||||
'status': self.status,
|
||||
'remark': self.remark,
|
||||
}
|
||||
|
||||
@ -278,6 +278,8 @@ class OutboundService:
|
||||
quantity=quantity,
|
||||
unit_price=unit_price,
|
||||
outbound_time=current_time,
|
||||
# [新增] 记录出库时的库位快照
|
||||
warehouse_location=getattr(stock_record, 'warehouse_location', None),
|
||||
**common_data
|
||||
)
|
||||
db.session.add(new_record)
|
||||
@ -647,7 +649,9 @@ class OutboundService:
|
||||
'quantity': qty,
|
||||
'unit_price': price,
|
||||
'subtotal': subtotal,
|
||||
'batch_sn': batch_sn
|
||||
'batch_sn': batch_sn,
|
||||
# [新增] 出库时的库位快照(展示用)
|
||||
'warehouse_location': getattr(d, 'warehouse_location', None) or ''
|
||||
})
|
||||
|
||||
# 4. 排序输出
|
||||
|
||||
@ -152,6 +152,8 @@ class TransService:
|
||||
borrow_signature=signature,
|
||||
remark=remark,
|
||||
expected_return_time=expected_return_time,
|
||||
# [新增] 记录借出时的库位快照
|
||||
location=getattr(stock, 'warehouse_location', None),
|
||||
status='borrowed',
|
||||
is_returned=False
|
||||
)
|
||||
|
||||
@ -56,6 +56,12 @@
|
||||
<el-table-column v-if="hasColumnPermission('category')" prop="category" label="类别" width="120" show-overflow-tooltip />
|
||||
<el-table-column v-if="hasColumnPermission('spec_model')" prop="spec_model" label="规格型号" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="batch_sn" label="批号/SN" min-width="120" />
|
||||
<el-table-column prop="warehouse_location" label="库位" min-width="120">
|
||||
<template #default="{row}">
|
||||
<span v-if="row.warehouse_location">{{ row.warehouse_location }}</span>
|
||||
<span v-else style="color:#ccc">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column v-if="hasColumnPermission('quantity')" prop="quantity" label="数量" width="100" />
|
||||
<el-table-column v-if="hasColumnPermission('unit_price')" prop="unit_price" label="单价" width="120">
|
||||
|
||||
@ -60,6 +60,12 @@
|
||||
<el-tag v-else type="success">0</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="location" label="借出库位" min-width="120">
|
||||
<template #default="{row}">
|
||||
<span v-if="row.location">{{ row.location }}</span>
|
||||
<span v-else style="color:#ccc">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="return_location" label="归还库位" min-width="120">
|
||||
<template #default="{row}">
|
||||
<span v-if="row.return_location">{{ row.return_location }}</span>
|
||||
|
||||
Reference in New Issue
Block a user