<template>
|
<div class="scan-container">
|
<el-card class="scan-card">
|
<div slot="header" class="clearfix">
|
<span>补货扫描</span>
|
</div>
|
<el-form ref="form" :model="formData" label-width="120px" class="scan-form">
|
<el-form-item label="补货单号">
|
<el-input ref="replenishmentCode" v-model="formData.replenishmentCode" class="input-300" autofocus @keyup.native.enter.stop="getData"></el-input>
|
<span class="sub-item">
|
<span class="sub-label">扫描物料</span>
|
<el-switch v-model="formData.isValidateProductCode" @change="onIsValidateProductCodeChange"></el-switch>
|
</span>
|
</el-form-item>
|
<el-form-item label="目标货位">
|
<el-input ref="targetPositionName" v-model="formData.targetPositionName" :disabled="!formData.isValidateProductCode" class="input-300" @keyup.native.enter.stop="positionNameClick"></el-input>
|
</el-form-item>
|
<el-form-item label="物料条码">
|
<el-input ref="productModel" v-model="formData.productModel" :disabled="!formData.isValidateProductCode" class="input-300" @keyup.native.enter.stop="checkPackingBarcode"></el-input>
|
<span class="sub-item">
|
<span class="sub-label">扫描数量:</span>
|
<!-- :min="1" -->
|
<el-input-number v-model="formData.scanQty" :disabled="!formData.isValidateProductCode" class="input-100" controls-position="right" @change="changeScanQty"></el-input-number>
|
</span>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="saveCheck">确认出库</el-button>
|
<el-button @click="onReset">重置</el-button>
|
</el-form-item>
|
</el-form>
|
</el-card>
|
<el-card class="scan-card body-no-padding">
|
<div slot="header" class="clearfix">
|
<span>扫描结果</span>
|
</div>
|
<el-table ref="scan-table" :data="tableData" :row-class-name="rowClass" stripe style="width: 100%" class="scan-table" @row-click="setCurrent">
|
<el-table-column prop="productModel" label="条形码" width="130">
|
</el-table-column>
|
<el-table-column prop="batchNumber" label="批次号" width="80">
|
</el-table-column>
|
<el-table-column prop="plateCode" label="拍号" width="100">
|
</el-table-column>
|
<el-table-column prop="produceDate" label="生产时间" width="120">
|
<template slot-scope="scope">
|
<template>
|
<el-date-picker v-model="scope.row.produceDate" :disabled="true" size="mini" type="date" placeholder="选择日期" class="w-100">
|
</el-date-picker>
|
</template>
|
</template>
|
</el-table-column>
|
<el-table-column prop="storageName" label="仓库" width="100">
|
</el-table-column>
|
<el-table-column prop="originalPositionName" label="原货位" width="100">
|
</el-table-column>
|
<el-table-column prop="targetPositionName" label="目标货位" width="100">
|
</el-table-column>
|
<el-table-column prop="finishedQuantity" label="已扫描数量" width="100">
|
<template slot-scope="scope">
|
<template v-if="!formData.isValidateProductCode">
|
<el-input-number v-model.number="scope.row.placeholderStorage" :disabled="false" size="mini" class="w-90" controls-position="right"></el-input-number>
|
</template>
|
<template v-else>
|
{{ scope.row.finishedQuantity }}
|
</template>
|
</template>
|
</el-table-column>
|
<el-table-column prop="unFinishedQuantity" label="未扫描数量" width="100">
|
<template slot-scope="scope">
|
<template v-if="!formData.isValidateProductCode">
|
0
|
<!-- <el-input-number v-model="scope.row.unFinishedQuantity" :disabled="true" size="mini" class="w-90" controls-position="right"></el-input-number> -->
|
</template>
|
<template v-else>
|
{{ scope.row.unFinishedQuantity }}
|
</template>
|
</template>
|
</el-table-column>
|
<el-table-column prop="productCode" label="物料编号" width="130">
|
</el-table-column>
|
<el-table-column prop="productSpec" label="物料规格" width="100">
|
</el-table-column>
|
<el-table-column prop="manufacturer" label="生产厂家" width="120">
|
</el-table-column>
|
<el-table-column prop="productName" label="物料名称" width="120">
|
</el-table-column>
|
</el-table>
|
</el-card>
|
|
<!--声音文件-->
|
<audio ref="sound_error" controls="controls" style="display:none;">
|
<source src="@/assets/sounds/error2.mp3" type="audio/mpeg" />
|
</audio>
|
<audio ref="sound_correct" controls="controls" style="display:none;">
|
<source src="@/assets/sounds/feixin.mp3" type="audio/mpeg" />
|
</audio>
|
<audio controls="controls" style="display:none;">
|
<source ref="sound_scan" src="@/assets/sounds/saomiao.wav" type="audio/mpeg" />
|
</audio>
|
|
</div>
|
</template>
|
|
<script>
|
export default {
|
name: "scan-purchase-order",
|
data() {
|
return {
|
formData: {
|
orderCode: null,
|
// 是否校验物料
|
isValidateProductCode: true,
|
// 自动生成上架单
|
isOnShelve: false,
|
positionName: null,
|
productModel: null,
|
scanQty: null
|
},
|
// 明细数据
|
tableData: [],
|
// 仓库ID
|
storage_Id: 0,
|
// 仓库信息
|
storageInfo: {},
|
// 收货位候选项
|
positionList: [],
|
// 当前正在扫描的数据 {}
|
currentRow: null,
|
// 已经找到的数据
|
existRows: [],
|
// 装箱方式:0:常规扫描,1:一品一箱,2:多品一箱
|
caseMode: 0,
|
// 一次扫描的数量
|
scanCount: 1,
|
// 装箱新增行
|
caseNewRows: [],
|
// 配置参数
|
config: {
|
// 自动生成上架单
|
in_generateShelve: true,
|
// 是否启用装箱操作
|
in_caseNumber: false,
|
// 支持一品多码
|
sku_productToMultiBarcode: true
|
}
|
};
|
},
|
// 监听数据
|
watch: {
|
// 当前行扫描数据改变后,将扫描数量也改变
|
currentRow: {
|
handler: function(rowData) {
|
this.formData.scanQty = rowData.finishedQuantity;
|
},
|
deep: true
|
}
|
},
|
activated() {
|
const isOnShelve = localStorage["isOnShelve"];
|
if (isOnShelve) {
|
this.formData.isOnShelve = isOnShelve === "true";
|
}
|
const isValidateProductCode = localStorage["isValidateProductCode"];
|
if (isOnShelve) {
|
this.formData.isValidateProductCode = isValidateProductCode === "true";
|
}
|
},
|
methods: {
|
// 直接上架设置
|
onIsValidateProductCodeChange() {
|
localStorage["isValidateProductCode"] = this.formData.isValidateProductCode;
|
},
|
positionNameClick() {
|
this.$refs.productModel.focus();
|
this.$refs.productModel.select();
|
},
|
// 获得明细数据
|
getData() {
|
var replenishmentCode = this.formData.replenishmentCode;
|
if (!replenishmentCode) {
|
this.$message.error("补货单号不能为空");
|
return;
|
}
|
const url = "/api/storage/replenishment/replenishmentGetData";
|
const params = {
|
replenishmentCode: replenishmentCode
|
};
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
// 构建数据
|
// this.currentRow = {};
|
this.tableData = res.data.map(row => {
|
row.unFinishedQuantity = Math.Round(row.placeholderStorage - 0, 4);
|
row.finishedQuantity = 0;
|
row.sortIndex = 0;
|
row.originalPositionName = row.positionName;
|
return row;
|
});
|
}
|
};
|
this.common.ajax(url, params, callback, this.$refs["form"]);
|
},
|
// 判断扫描包装条码
|
checkPackingBarcode(evt) {
|
evt.target.select();
|
var code = this.formData.productModel;
|
code = code.trim();
|
if (!code) return;
|
this.existRows = [];
|
var targetPositionName = "";
|
if (this.formData.targetPositionName) {
|
targetPositionName = this.formData.targetPositionName.trim();
|
}
|
|
var isItemFinished = false;
|
var isExistsProduct = false; // 物料是否在明细存在
|
for (var index in this.tableData) {
|
var rowData = this.tableData[index];
|
if (rowData.productModel === code) {
|
isExistsProduct = true;
|
var finishedQuantity = parseInt(rowData.finishedQuantity);
|
var unFinishedQuantity = parseInt(rowData.unFinishedQuantity);
|
if (unFinishedQuantity > 0) {
|
this.currentRow = rowData;
|
this.existRows.push(rowData);
|
rowData.finishedQuantity = finishedQuantity + 1;
|
rowData.unFinishedQuantity = unFinishedQuantity - 1;
|
this.$refs.sound_error.play(); // 播放声音
|
if (targetPositionName) {
|
rowData.targetPositionName = targetPositionName;
|
}
|
} else {
|
// 查找明细中是否还有该 条码 的物料
|
var isHaveAnother = false;
|
for (var index2 in this.tableData) {
|
var rowData2 = this.tableData[index2];
|
if (rowData2.productModel === code && parseInt(rowData2.unFinishedQuantity) > 0) {
|
isHaveAnother = true;
|
var _finishedQuantity = parseInt(rowData2.finishedQuantity);
|
var _unFinishedQuantity = parseInt(rowData2.unFinishedQuantity);
|
this.currentRow = rowData2;
|
this.existRows.push(rowData2);
|
rowData2.finishedQuantity = _finishedQuantity + 1;
|
rowData2.unFinishedQuantity = _unFinishedQuantity - 1;
|
this.$refs.sound_error.play(); // 播放声音
|
if (targetPositionName) {
|
rowData2.targetPositionName = targetPositionName;
|
}
|
break;
|
}
|
}
|
if (!isHaveAnother) {
|
isItemFinished = true;
|
}
|
}
|
// 不管这个物料编号有几个item,满足第一个物料编号后就跳出,不能扫描一个条码,对每一个明细扫描数量都加1
|
break;
|
}
|
}
|
if (!isExistsProduct) {
|
this.$message.error("物料条码【" + code + "】在该订单不存在!");
|
this.$refs.sound_error.play(); // 播放声音
|
return;
|
}
|
if (isItemFinished) {
|
this.$message.error("物料【" + code + "】已经扫描完成,不需要再扫描!");
|
this.$refs.sound_error.play(); // 播放声音
|
return;
|
}
|
},
|
// 扫描数量手工改变
|
changeScanQty() {
|
var code = this.formData.productModel;
|
if (this.currentRow) {
|
if (this.formData.scanQty <= 0) {
|
this.$message.error("数量不正确");
|
this.$refs.sound_error.play(); // 播放声音
|
return false;
|
}
|
if (this.formData.scanQty > this.currentRow.placeholderStorage) {
|
this.$message.error("物料 【" + code + "】的未扫描数量小于您的输入的数量。");
|
this.$refs.sound_error.play(); // 播放声音
|
return false;
|
}
|
this.currentRow.finishedQuantity = this.formData.scanQty;
|
this.currentRow.unFinishedQuantity = this.currentRow.placeholderStorage - this.formData.scanQty;
|
}
|
},
|
// 行样式
|
rowClass({ row, rowIndex }) {
|
if (this.existRows.find(f => f === row)) {
|
return "row-active";
|
}
|
},
|
// 重置onReset
|
onReset() {
|
this.formData = {
|
replenishmentCode: null,
|
isValidateProductCode: true, // 是否校验物料
|
targetPositionName: null,
|
productModel: null,
|
scanQty: 0
|
};
|
this.tableData = [];
|
this.$refs.replenishmentCode.focus();
|
},
|
// 确认出库
|
saveCheck() {
|
var replenishmentCode = this.formData.replenishmentCode;
|
var IsLess = 0;
|
var IsnoEnd = 0;
|
var productModelList = [];
|
this.tableData.forEach(rowData => {
|
if (!this.formData.isValidateProductCode) {
|
rowData.finishedQuantity = parseInt(rowData.placeholderStorage);
|
rowData.unFinishedQuantity = 0;
|
}
|
if (rowData.finishedQuantity <= 0) return;
|
if (rowData.unFinishedQuantity !== 0) {
|
IsnoEnd = 1;
|
return;
|
}
|
IsLess = 1;
|
productModelList.push({
|
product_Id: parseInt(rowData.product_Id),
|
finishedQuantity: parseInt(rowData.finishedQuantity),
|
originalPositionName: rowData.originalPositionName,
|
targetPositionName: rowData.targetPositionName,
|
batchNumber: rowData.batchNumber,
|
produceDate: rowData.produceDate,
|
plateCode: rowData.plateCode,
|
consignor_Id: rowData.consignor_Id
|
});
|
});
|
var zeroList = [];
|
zeroList = productModelList.filter(r => r.finishedQuantity === 0);
|
if (zeroList.length > 0) {
|
this.$message.error("已扫描数量不能全部为零!");
|
return;
|
}
|
if (IsLess === 0) {
|
this.$message.error("已扫描数量不能全部为零!");
|
return;
|
}
|
if (IsnoEnd === 1) {
|
this.$message.error("不允许部分扫描!");
|
return;
|
}
|
|
var url = "/api/storage/replenishment/replenishmentSave";
|
var params = {
|
productModelList: productModelList,
|
replenishmentCode: replenishmentCode
|
};
|
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.onReset();
|
this.$refs.sound_correct.play(); // 播放声音
|
} else {
|
this.$refs.sound_error.play(); // 播放声音
|
}
|
};
|
this.common.ajax(url, params, callback);
|
},
|
|
// 双击事件
|
setCurrent(row, event, column) {
|
if (row.productModel === this.formData.productModel) {
|
this.currentRow = row;
|
this.existRows = [];
|
this.tableData.forEach(element => {
|
element.sortIndex = 0;
|
});
|
this.currentRow.sortIndex = 1;
|
this.tableData = this.tableData.sort(function(a, b) {
|
return b.sortIndex - a.sortIndex;
|
});
|
this.tableData.forEach(element => {
|
element.sortIndex = 0;
|
});
|
this.existRows.push(row);
|
}
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
@import "../../../styles/scan.scss";
|
</style>
|