<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-select v-model="formData.storage_Id" placeholder="请选择仓库" class="input-300" @change="getPositionName()">
|
<el-option v-for="item in storageNames" :key="item.storage_Id" :label="item.storageName" :value="item.storage_Id"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item :label="formData.isOnShelve?'上架货位':'收货位'">
|
<el-input v-if="formData.isOnShelve" ref="positionName" v-model="formData.positionName" placeholder="请输入上架货位" class="input-300" @keyup.native.enter="positionNameKeyup">
|
</el-input>
|
<el-select v-else ref="positionName" v-model="formData.positionName" placeholder="请选择收货位" class="input-300">
|
<el-option v-for="(item, index) in positionList" :key="index" :label="item.positionName" :value="item.positionName" @click.native="positionNameClick(item)"></el-option>
|
</el-select>
|
<span class="sub-item">
|
<span class="sub-label">直接上架:</span>
|
<el-switch v-model="formData.isOnShelve" @change="onIsOnShelveChange"></el-switch>
|
</span>
|
</el-form-item>
|
<el-form-item label="收货拍号">
|
<el-input ref="plateCode" v-model="formData.plateCode" class="input-300" @keyup.native.enter.stop="getData"></el-input>
|
<!-- <span class="sub-item">
|
<span class="sub-label">扫描数量:</span>
|
<el-input-number v-model="formData.scanQty" :min="1" class="input-100" controls-position="right" @change="setScanQty"></el-input-number>
|
</span> -->
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="save">确认入库</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 class="padding-top-10">扫描结果</span>
|
<el-button type="text" class="floatRight" @click="setting.visible=true">字段设置</el-button>
|
</div>
|
<el-table ref="scan-table" :data="tableData" :row-class-name="rowClass" stripe style="width: 100%" class="scan-table" @row-dblclick="setCurrent">
|
<template v-for="(item, index) in setting.fields">
|
<template v-if="['unFinishedQuantity','finishedQuantity'].indexOf(item.prop)>=0">
|
<el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
|
<template slot-scope="scope">
|
<template v-if="!formData.isValidateProductCode">
|
<el-input-number v-model="scope.row[item.prop]" :min="0" :max="scope.row['quantity']" size="mini" class="w-100pc" controls-position="right" @change="rowChangeQty(item.prop, scope.row, 'quantity')"></el-input-number>
|
</template>
|
<template v-else>
|
{{ scope.row[item.prop] }}
|
</template>
|
</template>
|
</el-table-column>
|
</template>
|
<template v-else-if="'positionName,scanWeight'.indexOf(item.prop)>=0">
|
<el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
|
<template slot-scope="scope">
|
<template>
|
<el-input v-model="scope.row[item.prop]" size="mini" class="w-100pc"></el-input>
|
</template>
|
</template>
|
</el-table-column>
|
</template>
|
<template v-else-if="'produceDate,limitDate'.indexOf(item.prop)>=0">
|
<el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
|
<template slot-scope="scope">
|
<template>
|
<el-date-picker v-model="scope.row[item.prop]" size="mini" type="date" placeholder="选择日期" class="w-110" value-format="yyyy-MM-dd">
|
</el-date-picker>
|
</template>
|
</template>
|
</el-table-column>
|
</template>
|
<template v-else>
|
<el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
|
</el-table-column>
|
</template>
|
</template>
|
</el-table>
|
</el-card>
|
<scan-setting-dialog ref="setting-dialog" :visible.sync="setting.visible" :fields="setting.fields" :name="setting.name">
|
</scan-setting-dialog>
|
|
<!--声音文件-->
|
<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>
|
import YrtScanMixins from "@/components/common/yrtScanMixins.vue";
|
import ScanSettingDialog from "@/components/common/components/scanSettingDialog.vue";
|
|
export default {
|
name: "scan-purchase-order",
|
components: {
|
ScanSettingDialog
|
},
|
mixins: [YrtScanMixins],
|
data() {
|
return {
|
formData: {
|
orderCode: null,
|
// 是否校验物料
|
isValidateProductCode: true,
|
// 自动生成上架单
|
isOnShelve: false,
|
positionName: null,
|
plateCode: null,
|
scanQty: null
|
},
|
// 明细数据
|
tableData: [],
|
// 仓库列表
|
storageNames: null,
|
// 仓库ID
|
storage_Id: 0,
|
// 收货位候选项
|
positionList: [],
|
// 当前正在扫描的数据 {}
|
currentRow: null,
|
// 已经找到的数据
|
existRows: [],
|
// 装箱方式:0:常规扫描,1:一品一箱,2:多品一箱
|
caseMode: 0,
|
// 一次扫描的数量
|
scanCount: 1,
|
// 装箱新增行
|
caseNewRows: [],
|
// 配置参数
|
config: {
|
// 自动生成上架单
|
in_generateShelve: true,
|
// 是否启用装箱操作
|
in_caseNumber: false,
|
// 支持一品多码
|
sku_productToMultiBarcode: true
|
},
|
// 扫描列设置对话框参数
|
setting: {
|
visible: false,
|
name: "inbound-inPai-scan",
|
fields: [
|
{
|
prop: "productModel",
|
label: "条形码",
|
visible: true,
|
width: 130,
|
order: 1
|
},
|
{
|
prop: "finishedQuantity",
|
label: "扫描数量",
|
visible: true,
|
width: 100,
|
order: 2
|
},
|
{
|
prop: "unFinishedQuantity",
|
label: "未扫描数量",
|
visible: true,
|
width: 100,
|
order: 3
|
},
|
{
|
prop: "quantity",
|
label: "单据数量",
|
visible: true,
|
width: 90,
|
order: 4
|
},
|
{
|
prop: "plateCode",
|
label: "收货拍号",
|
visible: true,
|
width: 90,
|
order: 7
|
},
|
{
|
prop: "productCode",
|
label: "物料编号",
|
visible: false,
|
width: 130,
|
order: 6
|
},
|
|
{
|
prop: "positionName",
|
label: "收货位",
|
visible: true,
|
width: 120,
|
order: 8
|
},
|
{
|
prop: "produceDate",
|
label: "生产日期",
|
visible: true,
|
width: 130,
|
order: 9
|
},
|
{
|
prop: "limitDate",
|
label: "到期日期",
|
visible: false,
|
width: 130,
|
order: 10
|
},
|
{
|
prop: "purchasePrice",
|
label: "单价",
|
visible: false,
|
width: 80,
|
order: 11
|
},
|
{
|
prop: "productSpec",
|
label: "物料规格",
|
visible: true,
|
width: 80,
|
order: 12
|
},
|
{
|
prop: "weight",
|
label: "单位毛重",
|
visible: false,
|
width: 80,
|
order: 13
|
},
|
{
|
prop: "totalWeight",
|
label: "合计重量",
|
visible: false,
|
width: 80,
|
order: 14
|
},
|
{
|
prop: "scanWeight",
|
label: "已扫重量",
|
visible: false,
|
width: 80,
|
order: 15
|
},
|
{
|
prop: "productName",
|
label: "物料名称",
|
visible: true,
|
width: null,
|
order: 16
|
}
|
]
|
}
|
};
|
},
|
// 监听数据
|
watch: {
|
// 当前行扫描数据改变后,将扫描数量也改变
|
currentRow: {
|
handler: function(rowData) {
|
if (rowData) {
|
this.formData.scanQty = rowData.finishedQuantity;
|
}
|
},
|
deep: true
|
}
|
},
|
mounted() {
|
// 加载自定义数据
|
// 直接上架
|
const isOnShelve = localStorage["isOnShelve"];
|
if (isOnShelve) {
|
this.formData.isOnShelve = isOnShelve === "true";
|
}
|
|
// 校验物料
|
const isValidateProductCode = localStorage["isValidateProductCode"];
|
if (isValidateProductCode) {
|
this.formData.isValidateProductCode = isValidateProductCode === "true";
|
}
|
// 字段设置
|
const setting = localStorage[this.setting.name + "-setting"];
|
if (setting) {
|
this.setting.fields = JSON.parse(setting);
|
}
|
this.getStorageList();
|
},
|
methods: {
|
// 手动更新数量
|
setScanQty() {
|
// 判断是否有足够扫描数量
|
const totalQty = this.currentRow.unFinishedQuantity + this.currentRow.finishedQuantity;
|
const scanQty = this.formData.scanQty;
|
this.currentRow.finishedQuantity = scanQty;
|
this.currentRow.unFinishedQuantity = Math.Round(totalQty - scanQty, 4);
|
},
|
// 明细点击数据
|
setCurrent(row) {
|
this.tableData.filter(rowData => rowData.productModel === row.productModel).map(rowData => {
|
rowData.sortIndex = 1;
|
});
|
this.currentRow = this.tableData.filter(rowData => rowData.sortIndex === 1)[0];
|
this.currentRow.sortIndex = 1;
|
},
|
// 根据仓库获取货位
|
getPositionName() {
|
var url = "/api/inbound/inScan/getPosition";
|
// 仓库
|
for (var index3 in this.storageNames) {
|
if (this.storageNames[index3].storage_Id === this.formData.storage_Id) {
|
this.formData.storage_Id = this.storageNames[index3].storage_Id;
|
this.formData.storageName = this.storageNames[index3].storageName;
|
}
|
}
|
|
for (var index in this.consignorNames) {
|
if (this.consignorNames[index].consignor_Id === this.formData.consignor_Id) {
|
this.formData.consignorCode = this.consignorNames[index].consignorCode;
|
this.formData.consignorName = this.consignorNames[index].consignorName;
|
}
|
}
|
|
for (var index2 in this.providerShortNames) {
|
if (this.providerShortNames[index2].provider_Id === this.formData.provider_Id) {
|
this.formData.providerCode = this.providerShortNames[index2].providerCode;
|
this.formData.providerShortName = this.providerShortNames[index2].providerShortName;
|
}
|
}
|
var params = {
|
openNodeApi: true,
|
storage_Id: this.formData.storage_Id
|
};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
if (res.result) {
|
this.storageInfo = res.data;
|
this.positionList = res.dynamic;
|
if (this.positionList.length) {
|
this.formData.positionName = this.positionList[0].positionName;
|
}
|
} else {
|
this.storageInfo = {};
|
this.positionList = [];
|
}
|
// 条码框获得焦点
|
this.$refs.plateCode.focus();
|
this.$refs.plateCode.select();
|
},
|
true
|
);
|
},
|
// 获取仓库
|
getStorageList() {
|
const url = "/api/basicInfo/base/storage/getList";
|
const params = {};
|
var callback = res => {
|
if (res.result) {
|
this.storageNames = res.data;
|
}
|
};
|
this.common.ajax(url, params, callback, true);
|
},
|
// 直接上架设置
|
onIsValidateProductCodeChange() {
|
localStorage["isValidateProductCode"] = this.formData.isValidateProductCode;
|
},
|
// 直接上架设置
|
onIsOnShelveChange() {
|
localStorage["isOnShelve"] = this.formData.isOnShelve;
|
},
|
// 获得明细数据
|
getData() {
|
var plateCode = this.formData.plateCode;
|
var storage_Id = this.formData.storage_Id;
|
var userInfo = this.common.getUserInfo();
|
const url = "/api/inbound/inScan/getPlateCodeDate";
|
const params = {
|
user_Id: userInfo.user_Id,
|
storage_Id: storage_Id,
|
plateCode: plateCode
|
};
|
var callback = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
// 构建数据
|
this.currentRow = null;
|
// this.formData.positionName = null;
|
// this.formData.plateCode = null;
|
this.formData.scanQty = null;
|
this.tableData = res.data.map(row => {
|
row.unFinishedQuantity = 0;
|
row.finishedQuantity = row.quantity - (row.enterQuantity || 0);
|
row.positionName = this.formData.positionName;
|
row.sortIndex = 1;
|
return row;
|
});
|
// if (!this.formData.isValidateProductCode) {
|
// this.tableData.forEach(row => {
|
// row.finishedQuantity = row.unFinishedQuantity;
|
// row.unFinishedQuantity = 0;
|
// });
|
// }
|
// 直接上架选中时手工输入,未选中获取收货位
|
this.storage_Id = parseInt(res.statusCode);
|
if (!this.formData.isOnShelve) {
|
this.getPositionList();
|
} else {
|
this.focus("positionName");
|
}
|
} else {
|
this.focus("orderCode");
|
}
|
};
|
this.common.ajax(url, params, callback, this.$refs["form"]);
|
},
|
// 获得仓库和货位信息
|
getPositionList() {
|
var url = "/api/basicInfo/base/storage/getPositionList";
|
var params = {
|
storage_Id: this.storage_Id,
|
positionType: 4 // 4=收货位
|
};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
if (res.result) {
|
this.positionList = res.data;
|
if (this.positionList.length) {
|
this.formData.positionName = this.positionList[0].positionName;
|
// 明细设置默认货位
|
this.tableData.forEach(row => {
|
row.positionName = this.formData.positionName;
|
});
|
}
|
} else {
|
this.positionList = [];
|
}
|
// 条码框获得焦点
|
this.focus("plateCode");
|
},
|
false
|
);
|
},
|
// 判断扫描包装条码
|
checkPackingBarcode(evt) {
|
this.checkPackingProductModel(() => {
|
this.currentRow.positionName = this.formData.positionName;
|
});
|
},
|
// 扫描数量手工改变
|
changeScanQty() {
|
// 判断是否有足够扫描数量
|
const totalQty = this.currentRow.unFinishedQuantity + this.currentRow.finishedQuantity;
|
const scanQty = this.formData.scanQty;
|
this.currentRow.finishedQuantity = scanQty;
|
this.currentRow.unFinishedQuantity = Math.Round(totalQty - scanQty, 4);
|
},
|
// 重置onReset
|
onReset() {
|
this.formData = {
|
orderCode: null,
|
isValidateProductCode: true, // 是否校验物料
|
positionName: null,
|
plateCode: null,
|
scanQty: 0
|
};
|
this.tableData = [];
|
},
|
// 确认入库
|
save() {
|
var positionName = this.formData.positionName;
|
var plateCodeMain = this.formData.plateCode;
|
var userInfo = this.common.getUserInfo();
|
var orderCode = this.tableData[0].orderCode;
|
var emptypositionName = this.tableData
|
.filter(item => {
|
return !item.positionName && item.finishedQuantity > 0;
|
})
|
.map(item => {
|
return item.plateCode;
|
});
|
if (emptypositionName.length) {
|
this.$message.error("条形码[" + emptypositionName.join(",") + "]货位不能为空!");
|
this.$refs.sound_error.play(); // 播放声音
|
return;
|
}
|
|
var dataList = this.tableData.filter(rowData => rowData.finishedQuantity > 0).map(rowData => {
|
return {
|
orderList_Id: rowData.orderList_Id,
|
finishedQuantity: rowData.finishedQuantity,
|
positionName: rowData.positionName,
|
produceDate: rowData.produceDate,
|
limitDate: rowData.limitDate,
|
plateCode: rowData.plateCode,
|
weight: rowData.weight,
|
scanWeight: rowData.scanWeight
|
};
|
});
|
if (!dataList.length) {
|
this.$message.error("至少扫描一条!");
|
this.$refs.sound_error.play(); // 播放声音
|
return;
|
}
|
this.formData.positionName = dataList[0].positionName;
|
|
var url = "/api/inbound/inScan/enterPaiSave";
|
var params = {
|
user_Id: userInfo.user_Id,
|
orderCode: orderCode,
|
positionName: positionName,
|
plateCode: plateCodeMain,
|
list: dataList
|
};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.onReset();
|
this.$refs.sound_correct.play(); // 播放声音
|
} else {
|
this.$refs.sound_error.play(); // 播放声音
|
}
|
},
|
this.$refs.form
|
);
|
},
|
// 收货位
|
positionNameClick(item) {
|
const positionName = item.name;
|
this.tableData.forEach(rowData => {
|
rowData.positionName = positionName;
|
});
|
},
|
// 输入上架货位
|
positionNameKeyup(val) {
|
this.focus("plateCode");
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
@import "../../../styles/scan.scss";
|
</style>
|
<style lang="css">
|
.row-active {
|
background-color: skyblue !important;
|
}
|
</style>
|