|
|
|
@ -77,9 +77,17 @@ |
|
|
|
<el-col :span="6"> <el-form-item label="高度(mm)"> |
|
|
|
<el-input v-model="recvItem.height" /> |
|
|
|
</el-form-item></el-col> |
|
|
|
<el-col :span="18"><el-form-item label="送货单信息"> |
|
|
|
<el-col :span="8"><el-form-item label="送货单信息"> |
|
|
|
<el-input v-model="recvItem.deliveryNote" /> |
|
|
|
</el-form-item></el-col> |
|
|
|
<el-col :span="10"><el-form-item label="失效日期"> |
|
|
|
<el-date-picker v-model="recvItem.expiredDate" type="date" format="yyyy-MM-dd" |
|
|
|
value-format="yyyy-MM-dd" placeholder="请选择" style="width: 100%" |
|
|
|
inputmode="none" |
|
|
|
autocomplete="off" |
|
|
|
autocorrect="off" |
|
|
|
spellcheck="false" /> |
|
|
|
</el-form-item></el-col> |
|
|
|
<el-col :span="12"><el-form-item label="供应商生产日期"> |
|
|
|
<el-date-picker v-model="recvItem.supplierManufactureDate" type="date" format="yyyy-MM-dd" |
|
|
|
value-format="yyyy-MM-dd" placeholder="请选择" style="width: 100%" |
|
|
|
@ -193,7 +201,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { getPoList, receivePo, printLabel, getNextItemNo, validateLocationForReceiveCase,getPartAttributeInfo } from "@/api/po/po.js"; |
|
|
|
import { getPoList, receivePo, printLabel, getNextItemNo, validateLocationForReceiveCase, getPartAttributeInfo, getPartShelfLife } from "@/api/po/po.js"; |
|
|
|
import { filterRowsByAuthorizedSubSite, getAuthorizedSubSiteCodeList } from "@/utils/subSiteAuth.js"; |
|
|
|
|
|
|
|
export default { |
|
|
|
@ -211,7 +219,9 @@ export default { |
|
|
|
loadingText: '加载中...', // 动态loading文本 |
|
|
|
autoCalculate: true, // 自动计算包装数开关 |
|
|
|
locationHistoryList: [], |
|
|
|
locationHistoryLimit: 20 |
|
|
|
locationHistoryLimit: 20, |
|
|
|
// 上次参与计算的有效期和基准日。基准日没变时保留用户手改的失效日期。 |
|
|
|
expiryBaseKey: '' |
|
|
|
}; |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
@ -250,6 +260,13 @@ export default { |
|
|
|
} else { |
|
|
|
this.$message.success('已切换到手动输入模式'); |
|
|
|
} |
|
|
|
}, |
|
|
|
// 基准日的日期变化后重算。只改到达时间不会覆盖已经手改的失效日期。 |
|
|
|
'recvItem.supplierManufactureDate'() { |
|
|
|
this.refreshExpiredDate(); |
|
|
|
}, |
|
|
|
'recvItem.arrivalDate'() { |
|
|
|
this.refreshExpiredDate(); |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
@ -366,10 +383,64 @@ export default { |
|
|
|
deliveryNote: row.deliveryNote || '', |
|
|
|
wdr:"*", |
|
|
|
height: height, |
|
|
|
locationNo: locationNo |
|
|
|
locationNo: locationNo, |
|
|
|
durabilityDays: null, |
|
|
|
expiredDate: '' |
|
|
|
}; |
|
|
|
// 换行后按新的基准日重算,不沿用上一行的手改结果 |
|
|
|
this.expiryBaseKey = ''; |
|
|
|
await this.loadShelfLifeAndExpiredDate(row.site, row.partNo); |
|
|
|
this.processFlag = 2; |
|
|
|
}, |
|
|
|
async loadShelfLifeAndExpiredDate(site, partNo) { |
|
|
|
this.loadingText = '加载中...'; |
|
|
|
this.fullscreenLoading = true; |
|
|
|
try { |
|
|
|
const { data } = await getPartShelfLife({ site, partNo }); |
|
|
|
if (data.code === 0 && data.data) { |
|
|
|
this.recvItem.durabilityDays = data.data; |
|
|
|
this.refreshExpiredDate(); |
|
|
|
} else { |
|
|
|
this.$message.warning(data.msg || '请联系工程维护产品有效期!'); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('获取产品有效期失败:', error); |
|
|
|
this.$message.warning('获取产品有效期失败,请重试'); |
|
|
|
} finally { |
|
|
|
this.fullscreenLoading = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
// 和后端原口径一致:有供应商生产日期就用它,否则用到达日期,再加有效期天数。 |
|
|
|
// 只比较日期部分。到达时间变了但日期没变时,不覆盖用户手改的失效日期。 |
|
|
|
refreshExpiredDate() { |
|
|
|
const item = this.recvItem; |
|
|
|
const days = Number(item && item.durabilityDays); |
|
|
|
if (!days) return; |
|
|
|
const supplierDate = (item.supplierManufactureDate || '').toString().trim(); |
|
|
|
const arrivalDate = (item.arrivalDate || '').toString().trim(); |
|
|
|
const baseDate = supplierDate || arrivalDate; |
|
|
|
const baseDay = baseDate ? baseDate.substring(0, 10) : ''; |
|
|
|
const baseKey = `${days}|${baseDay}`; |
|
|
|
if (this.expiryBaseKey === baseKey) return; |
|
|
|
this.expiryBaseKey = baseKey; |
|
|
|
item.expiredDate = baseDate ? this.addDays(baseDate, days) : ''; |
|
|
|
}, |
|
|
|
addDays(dateText, days) { |
|
|
|
const matched = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(dateText).trim()); |
|
|
|
if (!matched) return ''; |
|
|
|
const date = new Date(Number(matched[1]), Number(matched[2]) - 1, Number(matched[3])); |
|
|
|
date.setDate(date.getDate() + Number(days)); |
|
|
|
const month = String(date.getMonth() + 1).padStart(2, '0'); |
|
|
|
const day = String(date.getDate()).padStart(2, '0'); |
|
|
|
return `${date.getFullYear()}-${month}-${day}`; |
|
|
|
}, |
|
|
|
isDateBeforeToday(dateText) { |
|
|
|
const day = (dateText || '').toString().trim().substring(0, 10); |
|
|
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(day)) return true; |
|
|
|
const now = new Date(); |
|
|
|
const today = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`; |
|
|
|
return day < today; |
|
|
|
}, |
|
|
|
// 获取当前日期 |
|
|
|
getCurrentDate() { |
|
|
|
const now = new Date(); |
|
|
|
@ -583,6 +654,14 @@ export default { |
|
|
|
this.fullscreenLoading = false; |
|
|
|
return this.$message.error("请填写完整信息"); |
|
|
|
} |
|
|
|
if (!item.expiredDate) { |
|
|
|
this.fullscreenLoading = false; |
|
|
|
return this.$message.error("失效日期不能为空"); |
|
|
|
} |
|
|
|
if (this.isDateBeforeToday(item.expiredDate)) { |
|
|
|
this.fullscreenLoading = false; |
|
|
|
return this.$message.error("失效日期早于当前日期,不能入库"); |
|
|
|
} |
|
|
|
if(item.qtyToReceive>item.qtyToReceive){ |
|
|
|
this.fullscreenLoading = false; |
|
|
|
return this.$message.error("接收数量不能大于待收数量"); |
|
|
|
@ -621,6 +700,7 @@ export default { |
|
|
|
wdr: item.wdr || '*', |
|
|
|
deliveryDate: item.deliveryDate, |
|
|
|
arrivalDate: item.arrivalDate, |
|
|
|
expiredDate: item.expiredDate, |
|
|
|
supplierBatchNo: item.supplierBatchNo, |
|
|
|
deliveryNote: item.deliveryNote, |
|
|
|
samplePercent: item.samplePercent || 0, |
|
|
|
@ -762,8 +842,13 @@ export default { |
|
|
|
color: #ccc !important; |
|
|
|
cursor: not-allowed !important; |
|
|
|
} |
|
|
|
.form-section >>> .el-col { |
|
|
|
margin-bottom: 2px; |
|
|
|
.form-section >>> .el-date-editor.el-input { |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
|
|
|
|
.form-section >>> .el-date-editor .el-input__inner { |
|
|
|
padding-left: 8px; |
|
|
|
padding-right: 26px; |
|
|
|
} |
|
|
|
.status-bar { |
|
|
|
display: flex; |
|
|
|
|