Browse Source

供应商生产日期和供应商批次号

master
han\hanst 3 weeks ago
parent
commit
d0bc70b8db
  1. 114
      src/views/modules/production-inbound/inboundRegister.vue

114
src/views/modules/production-inbound/inboundRegister.vue

@ -99,6 +99,27 @@
style="width: 100%"
/>
</el-form-item></el-col>
<el-col :span="12"><el-form-item label="供应商批次号">
<el-input
v-model.trim="inboundItem.supplierBatchNo"
placeholder="请扫描标签二维码(自动回车)或输入供应商批次号"
@keyup.enter.native="querySupplierInfoByLabel"
/>
</el-form-item></el-col>
<el-col :span="12"><el-form-item label="供应商生产日期">
<el-date-picker
v-model="inboundItem.supplierManufactureDate"
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" style="margin-top: 2px">
<el-form-item>
@ -191,6 +212,7 @@
<script>
import { getShopOrderFromIfs, getNextSequenceNo, submitShopOrderInbound, validateMaterialIssued, printLabelCommon } from "@/api/production/production-inbound.js";
import { getHandlingUnitDetail } from "@/api/handlingunit/handlingunit.js";
export default {
data() {
@ -382,7 +404,9 @@ export default {
ifsAutoReport: true, // Auto Report of Operation
ifsSimplifiedMaterial: true, // Simplified Material Check
height: this.parseHeightFromPartNo(row.partNo), //
ifsExpiryDate: '' // IFS
ifsExpiryDate: '', // IFS
supplierManufactureDate: '',
supplierBatchNo: ''
};
this.processFlag = 2;
} catch (error) {
@ -392,6 +416,92 @@ export default {
this.fullscreenLoading = false;
}
},
// (unit_id)
async querySupplierInfoByLabel() {
const unitId = this.extractUnitIdFromScanCode(this.inboundItem.supplierBatchNo);
if (!unitId) {
this.$message.warning('请先扫描标签二维码');
return;
}
const previousLoadingText = this.loadingText;
this.loadingText = '查询标签中...';
this.fullscreenLoading = true;
try {
const { data } = await getHandlingUnitDetail({
site: this.site,
unitId: unitId
});
if (!data || data.code !== 0) {
this.$message.warning((data && data.msg) || '标签查询失败');
return;
}
const labelInfo = data && data.data;
if (!labelInfo) {
this.$message.warning(`未查询到标签:${unitId}`);
return;
}
//
this.inboundItem.supplierManufactureDate = this.normalizeDateToYmd(labelInfo.supplierManufactureDate);
this.inboundItem.supplierBatchNo = labelInfo.supplierBatchNo || '';
if (!this.inboundItem.supplierManufactureDate && !this.inboundItem.supplierBatchNo) {
this.$message.warning('标签中未维护供应商生产日期/供应商批次号');
return;
}
//this.$message.success('');
} catch (error) {
console.error('查询标签失败:', error);
this.$message.error('查询标签失败,请重试');
} finally {
this.loadingText = previousLoadingText;
this.fullscreenLoading = false;
}
},
// PDAunit_idunit_idURL
extractUnitIdFromScanCode(scanValue) {
if (!scanValue) return '';
const rawText = String(scanValue).trim();
if (!rawText) return '';
const queryMatch = rawText.match(/(?:^|[?&])unit[_-]?id=([^&]+)/i);
if (queryMatch && queryMatch[1]) {
try {
return decodeURIComponent(queryMatch[1]).trim();
} catch (error) {
return queryMatch[1].trim();
}
}
const keyValueMatch = rawText.match(/unit[_-]?id[:=]\s*([^\s,;]+)/i);
if (keyValueMatch && keyValueMatch[1]) {
return keyValueMatch[1].trim();
}
return rawText;
},
// yyyy-MM-dd便
normalizeDateToYmd(dateValue) {
if (!dateValue) return '';
if (typeof dateValue === 'string') {
const text = dateValue.trim();
if (!text) return '';
const datePart = text.slice(0, 10);
if (/^\d{4}-\d{2}-\d{2}$/.test(datePart)) {
return datePart;
}
}
const dateObj = new Date(dateValue);
if (Number.isNaN(dateObj.getTime())) return '';
const year = dateObj.getFullYear();
const month = String(dateObj.getMonth() + 1).padStart(2, '0');
const day = String(dateObj.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
},
//
checkQuantity() {
const transQty = parseFloat(this.inboundItem.transQty) || 0;
@ -563,6 +673,8 @@ export default {
qtyComplete: item.qtyComplete,
height: item.height || null, // (mm)
ifsExpiryDate: item.ifsExpiryDate || null, //
supplierManufactureDate: item.supplierManufactureDate || null, //
supplierBatchNo: item.supplierBatchNo || null, //
// IFS
ifsAutoReport: item.ifsAutoReport ? 'Yes' : 'No',
ifsSimplifiedMaterial: item.ifsSimplifiedMaterial ? 'Yes' : 'No',

Loading…
Cancel
Save