<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="getPositionList">
|
<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="收货位">
|
<el-select 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"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="上架货位">
|
<el-input ref="shelvePosition" v-model="formData.shelvePosition" class="input-300" autofocus @keyup.native.enter.stop="checkShelvePositionkeyup">
|
</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="setScanQty"></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 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="(row, column, event)=>{changeProduct(row)}">
|
<template v-for="(item, index) in setting.fields">
|
<template v-if="['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" size="mini" class="w-100pc" controls-position="right" @change="rowChangeQty(item.prop, scope.row)"></el-input-number>
|
</template>
|
<template v-else>
|
{{ scope.row[item.prop] }}
|
</template>
|
</template>
|
</el-table-column>
|
</template>
|
<template v-else-if="'shelvePosition,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>
|
|
<!--SKU列表-->
|
<el-dialog :visible.sync="dialogVisible" title="选择SKU" width="30%">
|
<template>
|
<el-table :data="findProductList" :row-class-name="rowClass" class="scan-table" style="width: 100%" @row-dblclick="setCurrent">
|
<el-table-column prop="productCode" label="物料编号" width="180">
|
</el-table-column>
|
<el-table-column prop="productModel" label="条码" width="180">
|
</el-table-column>
|
<el-table-column prop="productName" label="物料名称">
|
</el-table-column>
|
<el-table-column prop="productSpec" label="物料规格">
|
</el-table-column>
|
</el-table>
|
</template>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button type="primary" @click="changeProduct(saveProductInfo)">确 定</el-button>
|
</span>
|
</el-dialog>
|
<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-noBillscan',
|
components: {
|
ScanSettingDialog
|
},
|
mixins: [YrtScanMixins],
|
data() {
|
return {
|
formData: {
|
// 仓库ID
|
storage_Id: null,
|
positionName: null, // 货位id
|
shelvePosition: null, // 上架货位
|
productModel: null,
|
scanQty: null,
|
// 是否校验物料
|
isValidateProductCode: true
|
},
|
tableDataSKU: [{}],
|
// 供应商
|
// ProviderShortNames: null,
|
// 货主
|
// ConsignorNames: null,
|
// 仓库
|
storageNames: null,
|
// 是否弹出
|
isDisplay: false,
|
// 收货位候选项
|
positionList: [],
|
// 是否展示SKU
|
showProduct: false,
|
dialogVisible: false,
|
// SKU列表
|
findProductList: [],
|
// 明细数据
|
tableData: [],
|
|
// 仓库信息
|
storageInfo: {},
|
|
// 当前正在扫描的数据 {}
|
currentRow: null,
|
// 已经找到的数据
|
existRows: [],
|
// 装箱方式:0:常规扫描,1:一品一箱,2:多品一箱
|
caseMode: 0,
|
// 一次扫描的数量
|
scanCount: 1,
|
// 装箱新增行
|
caseNewRows: [],
|
// 配置参数
|
config: {
|
// 自动生成上架单
|
in_generateShelve: true,
|
// 是否启用装箱操作
|
in_caseNumber: false,
|
// 支持一品多码
|
sku_productToMultiBarcode: true,
|
caseMode: 0
|
},
|
saveProductInfo: {},
|
// 扫描列设置对话框参数
|
setting: {
|
visible: false,
|
name: 'scan-purchase-noBillscan',
|
fields: [
|
{
|
prop: 'productModel',
|
label: '条形码',
|
visible: true,
|
width: 130,
|
order: 1
|
},
|
{
|
prop: 'finishedQuantity',
|
label: '已扫描数量',
|
visible: true,
|
width: 90,
|
order: 4
|
},
|
{
|
prop: 'positionName',
|
label: '收货位',
|
visible: true,
|
width: 120,
|
order: 8
|
},
|
{
|
prop: 'shelvePosition',
|
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: 'batchNumber',
|
label: '批次号',
|
visible: false,
|
width: 100,
|
order: 6
|
},
|
{
|
prop: 'productCode',
|
label: '物料编号',
|
visible: false,
|
width: 130,
|
order: 6
|
},
|
{
|
prop: 'smallUnit',
|
label: '单位',
|
visible: true,
|
width: 50,
|
order: 7
|
},
|
{
|
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: 'sumTotalWeight',
|
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) {
|
this.formData.scanQty = rowData.finishedQuantity
|
},
|
deep: true
|
}
|
},
|
mounted() {
|
this.getStorageList()
|
// 字段设置
|
const setting = localStorage[this.setting.name + '-setting']
|
if (setting) {
|
this.setting.fields = JSON.parse(setting)
|
}
|
},
|
methods: {
|
checkShelvePositionkeyup() {
|
var shelvePosition = this.formData.shelvePosition
|
if (!shelvePosition) {
|
this.$message.error('上架货位不能为空!')
|
return
|
}
|
this.$refs.productModel.focus()
|
this.$refs.productModel.select()
|
},
|
// 获取仓库
|
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)
|
},
|
// 获得仓库和货位信息
|
getPositionList(storage_Id) {
|
this.formData.storageName = this.storageNames.find(item => item.storage_Id === storage_Id).storageName
|
var url = '/api/basicInfo/base/storage/getPositionList'
|
var params = {
|
storage_Id: 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('shelvePosition')
|
},
|
false
|
)
|
},
|
// 判断扫描包装条码
|
checkPackingBarcode(evt) {
|
this.checkPackingProductModel(this.tableData, null, this.getProductInfo)
|
},
|
// 获取物料信息
|
getProductInfo() {
|
var productModel = this.formData.productModel // masterData.productModel;
|
var storage_Id = this.formData.storage_Id
|
var positionName = this.formData.positionName
|
if (!productModel) {
|
this.$message({
|
message: '条码不能为空!',
|
type: 'warning'
|
})
|
return
|
}
|
if (!positionName) {
|
this.$message({
|
message: '收货位不能为空!',
|
type: 'warning'
|
})
|
return
|
}
|
var url = '/api/inbound/shelveScan/getShelveNoBillData'
|
var params = {
|
storage_Id: storage_Id,
|
positionName: positionName,
|
productModel: productModel
|
}
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res)
|
if (res.result) {
|
this.findProductList = []
|
for (var index in res.data) {
|
this.$set(this.findProductList, this.findProductList.length, res.data[index])
|
if (res.data.length === 1) {
|
this.changeProduct(res.data[0].product_Id, res.data[0].productName)
|
} else {
|
this.isDisplay = true
|
this.dialogVisible = true
|
}
|
}
|
} else {
|
this.$refs.sound_error.play() // 播放声音
|
}
|
},
|
true
|
)
|
},
|
//
|
// 选择物料
|
changeProduct(row, column, event) {
|
this.dialogVisible = false
|
var positionName = this.formData.positionName
|
var productModel = this.formData.productModel
|
var count = 1
|
var rows = null
|
if (this.isDisplay) {
|
for (var index in this.findProductList) {
|
if (this.findProductList[index].product_Id === row.product_Id) {
|
rows = this.findProductList[index]
|
}
|
}
|
} else {
|
for (var index1 in this.findProductList) {
|
if (this.findProductList[index1].product_Id === row) {
|
rows = this.findProductList[index1]
|
}
|
}
|
}
|
|
if (rows.middleBarcode === productModel) {
|
// 中包装条码
|
count = rows.middleUnitConvert
|
} else if (rows.BigBarcode === productModel) {
|
// 大包装条码
|
count = rows.unitConvert
|
}
|
rows.finishedQuantity = count
|
rows.positionName = positionName
|
rows.shelvePosition = this.formData.shelvePosition
|
this.$set(this.tableData, this.tableData.length, rows)
|
this.currentRow = rows
|
this.existRows.push(rows)
|
this.sortRow()
|
this.showProduct = false
|
},
|
|
// 排序高亮行靠前
|
sortRow() {
|
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
|
})
|
},
|
// 确认入库
|
saveCheck() {
|
var storage_Id = this.formData.storage_Id
|
var storageName = this.formData.storageName
|
|
var dataList = this.tableData.filter(item => item.finishedQuantity > 0).map(rowData => {
|
return {
|
storage_Id: storage_Id,
|
storageName: storageName,
|
product_Id: rowData.product_Id,
|
productCode: rowData.productCode,
|
productModel: rowData.productModel,
|
positionName: rowData.positionName,
|
shelvePosition: rowData.shelvePosition,
|
purchasePrice: rowData.purchasePrice,
|
batchNumber: rowData.batchNumber,
|
productSpec: rowData.productSpec,
|
produceDate: rowData.produceDate,
|
finishedQuantity: rowData.finishedQuantity,
|
consignor_Id: rowData.consignor_Id,
|
consignorName: rowData.consignorName,
|
consignorCode: rowData.consignorCode,
|
weight: rowData.weight,
|
totalWeight: rowData.totalWeight
|
}
|
})
|
var emptyPositionName = this.tableData.filter(item => !item.positionName).map(item => item.productModel)
|
if (!this.formData.shelvePosition) {
|
this.$message.error('上架货位不能为空!')
|
return
|
}
|
if (dataList.length === 0) {
|
this.$vux.toast.show({ text: '至少录入一条数据' })
|
return
|
}
|
|
if (emptyPositionName.length) {
|
this.$vux.toast.show({
|
text: '条形码[' + emptyPositionName.join(',') + ']货位不能为空!'
|
})
|
this.$refs.sound_error.play() // 播放声音
|
return
|
}
|
var url = '/api/inbound/shelveScan/shelveNoBillSave'
|
var params = {
|
dataList: 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() // 播放声音
|
}
|
},
|
true
|
)
|
},
|
onReset() {
|
this.formData.storage_Id = null
|
this.formData.positionName = null
|
this.formData.shelvePosition = null
|
this.formData.productModel = null
|
this.formData.scanQty = null
|
this.getStorageList()
|
this.tableData = []
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import '../../../styles/scan.scss';
|
</style>
|
<style lang="css">
|
.row-active {
|
background-color: skyblue !important;
|
}
|
</style>
|