<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 dropDownList_Storage" :key="item.storage_Id" :label="item.storageName" :value="item.storage_Id"></el-option>
|
</el-select>
|
</el-form-item> -->
|
<el-form-item label="到货二维码">
|
<el-input ref="QrCode" v-model="formData.QrCode" placeholder="扫描到货二维码" class="input-300" autofocus @keyup.native.enter.stop="getDataForQrCode"></el-input>
|
</el-form-item>
|
<el-form-item label="采购单号">
|
<el-input ref="poCode" v-model="formData.poCode" placeholder="扫描采购单号" class="input-300" autofocus @keyup.native.enter.stop="getData"></el-input>
|
<el-checkbox v-model="isChecked" @change="changeAutoPrint">自动打印</el-checkbox>
|
<el-checkbox v-model="isChecked_PrintForInStore" @change="changeAutoPrint_PrintForInStore">入库口打印机</el-checkbox>
|
<el-checkbox v-model="isChecked_PrintForOutStore" @change="changeAutoPrint_PrintForOutStore">出库口打印机</el-checkbox>
|
</el-form-item>
|
<el-form-item label="采购项号">
|
<el-input ref="itemNumber" v-model="formData.itemNumber" placeholder="请输入采购项号" class="input-300" autofocus @keyup.native.enter.stop="getData"></el-input>
|
<span class="sub-item">
|
<span class="sub-label">打印份数:</span>
|
<el-input-number v-model="printQty" :min="0" class="input-100" controls-position="right"></el-input-number>
|
</span>
|
</el-form-item>
|
<!-- <el-form-item label="跟踪号" //row.overcharges * row.bigQty + row.bigQty>
|
<el-input ref="trackingNumber" v-model="formData.trackingNumber" placeholder="选择采购单号后自动带出" class="input-300" autofocus></el-input>
|
</el-form-item> -->
|
<!-- <el-form-item label="销售单号">
|
<el-input ref="saleCode" v-model="formData.saleCode" placeholder="选择采购单号后自动带出" class="input-300" autofocus></el-input>
|
</el-form-item> -->
|
<el-form-item label="移动类型">
|
<el-select v-model="moveType" placeholder="请选择移动类型" class="input-300">
|
<el-option v-for="item in moveTypeData" :key="item.value" :label="item.label" :value="item.value">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item>
|
<el-button type="primary" @click="showInfoBeforeSave">确认</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" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="55" sortable>
|
</el-table-column>
|
<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="'scanWeight,receivedQuantity'.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="{row}">
|
<template>
|
<el-input-number v-model.number="row[item.prop]" precision="2"
|
:min="0" type="number" size="mini" class="w-100pc" @blur="qtyChange(row, item.prop, index)"/>
|
<!-- <div>{{((1+row.overcharges/100) * row.bigQty)-row.bigEnterQuantity }}</div> -->
|
<!-- :max="moveType=='101'?((1+row.overcharges/100) * row.bigQty)-row.bigEnterQuantity:row.bigEnterQuantity" -->
|
</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-if="'productBarCode,positionName'.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" placeholder="请输入内容"></el-input>
|
</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>
|
<el-dialog title="确认信息" :visible.sync="dialogTableVisible">
|
<el-table :data="gridData" max-height="500">
|
<el-table-column
|
type="index"
|
width="50">
|
</el-table-column>
|
<el-table-column property="poCode" label="采购单号" ></el-table-column>
|
<el-table-column property="itemNumber" label="采购项号" ></el-table-column>
|
<el-table-column property="extendField04" label="跟踪号"></el-table-column>
|
<el-table-column property="productCode" label="物料编号"></el-table-column>
|
<el-table-column property="productName" label="物料名称"></el-table-column>
|
<el-table-column property="quantity" label="本次操作量"></el-table-column>
|
<el-table-column property="productBarCode" label="存储位置"></el-table-column>
|
<el-table-column property="limitDate" label="限用日期"></el-table-column>
|
</el-table>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="cancelShowInfoBeforeSave">取 消</el-button>
|
<el-button type="primary" @click="save">确 定</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'
|
var moment = require('moment')
|
|
export default {
|
name: 'scan-purchase-order',
|
components: {
|
ScanSettingDialog
|
},
|
mixins: [YrtScanMixins],
|
data() {
|
return {
|
gridData: [],
|
dialogTableVisible: false,
|
moveTypeData: [
|
{
|
value: '101',
|
label: '收货101'
|
},
|
{
|
value: '102',
|
label: '退货102'
|
}
|
],
|
ismax: 0,
|
moveType: '101',
|
isUseQrCode:false,//是否使用到货二维码 【Editby shaocx,2023-11-5】
|
UseQrCodeData:{
|
qrCode_limitDate:'',//二维码的限用日期
|
qrCode_quantity:0,//二维码的收货数量
|
qrCode_guid:'',//二维码的GUID
|
},
|
isChecked: true,
|
isChecked_PrintForInStore:true,//是否选中 入库口打印机
|
isChecked_PrintForOutStore:false,// 是否选中 出库口打印机
|
printQty: 1,
|
formData: {
|
QrCode:'',//到货二维码
|
// 仓库ID
|
storage_Id: 87,
|
storageName: '立体库',
|
orderCode: null,
|
// 是否校验物料
|
isValidateProductCode: true,
|
// 自动生成上架单
|
isOnShelve: false,
|
positionName: '收货位',
|
productModel: null,
|
scanQty: null,
|
// 采购单号
|
poCode: null,
|
// 项目号
|
trackingNumber: null,
|
// 物料编号
|
productCode: null,
|
saleCode: null,
|
unitConvert: null,
|
itemNumber: null,
|
totalWeight: 0
|
},
|
dropDownList_Storage: [],
|
// 明细数据
|
tableData: [],
|
// 仓库ID
|
storage_Id: 87,
|
storageName: '立体库',
|
multipleSelection: [],
|
// 收货位候选项
|
positionList: [],
|
// 当前正在扫描的数据 {}
|
currentRow: null,
|
// 已经找到的数据
|
existRows: [],
|
// 装箱方式:0:常规扫描,1:一品一箱,2:多品一箱
|
caseMode: 0,
|
// 一次扫描的数量
|
scanCount: 1,
|
// 装箱新增行
|
caseNewRows: [],
|
// 配置参数
|
config: {
|
// 自动生成上架单
|
in_generateShelve: false,
|
// 是否启用装箱操作
|
in_caseNumber: false,
|
// 支持一品多码
|
sku_productToMultiBarcode: true
|
},
|
// 扫描列设置对话框参数
|
setting: {
|
visible: false,
|
name: 'inbound-order-scan',
|
fields: [
|
{
|
prop: 'poCode',
|
label: '采购单号',
|
visible: true,
|
width: 135,
|
order: 1
|
},
|
{
|
prop: 'itemNumber',
|
label: '采购项号',
|
visible: true,
|
width: 90,
|
order: 1
|
},
|
{
|
prop: 'extendField04',
|
label: '跟踪号',
|
visible: true,
|
width: 110,
|
order: 1
|
},
|
{
|
prop: 'productCode',
|
label: '物料编号',
|
visible: true,
|
width: 165,
|
order: 1
|
},
|
{
|
prop: 'productName',
|
label: '物料名称',
|
visible: true,
|
width: 155,
|
order: 2
|
},
|
{
|
prop: 'bigQty',
|
label: '采购数量',
|
visible: true,
|
width: 80,
|
order: 3
|
},
|
{
|
prop: 'bigUnit',
|
label: '采购单位',
|
visible: true,
|
width: 80,
|
order: 4
|
},
|
|
{
|
prop: 'bigEnterQuantity',
|
label: '已收货数量',
|
visible: true,
|
width: 110,
|
order: 5
|
},
|
{
|
prop: 'receivedQuantity',
|
label: '本次操作量',
|
visible: true,
|
width: 140,
|
order: 6
|
},
|
{
|
prop: 'productBarCode',
|
label: '存储位置',
|
visible: true,
|
width: 80,
|
order: 12
|
},
|
// {
|
// prop: "quantity",
|
// label: "库存单位收货数量",
|
// visible: true,
|
// width: 145,
|
// order: 10
|
// },
|
{
|
prop: 'smallUnit',
|
label: '库存单位',
|
visible: true,
|
width: 80,
|
order: 11
|
},
|
{
|
prop: 'unEnterQuantity',
|
label: '转换系数',
|
visible: true,
|
width: 100,
|
order: 12
|
},
|
{
|
prop: 'unitConvert',
|
label: '单位转换值',
|
visible: true,
|
width: 100,
|
order: 12
|
},
|
{
|
prop: 'overcharges',
|
label: '容差率(%)',
|
visible: true,
|
width: 90,
|
order: 12
|
},
|
|
{
|
prop: 'extendField07',
|
label: '销售单号',
|
visible: true,
|
width: 110,
|
order: 1
|
},
|
{
|
prop: 'specAlias',
|
label: '销售项号',
|
visible: true,
|
width: 90,
|
order: 1
|
},
|
{
|
prop: 'limitDate',
|
label: '限用日期',
|
visible: true,
|
width: 150,
|
order: 7
|
},
|
|
{
|
prop: 'extendField02',
|
label: '工厂',
|
visible: true,
|
width: 80,
|
order: 12
|
},
|
{
|
prop: 'productSpec',
|
label: '物料规格',
|
visible: false,
|
width: 80,
|
order: 12
|
},
|
{
|
prop: 'weight',
|
label: '重量',
|
visible: false,
|
width: 80,
|
order: 12
|
},
|
{
|
prop: 'qrCode_guid',
|
label: '收货二维码',
|
visible: false,
|
width: 80,
|
order: 13
|
}
|
]
|
}
|
}
|
},
|
// 监听数据
|
watch: {
|
// 当前行扫描数据改变后,将扫描数量也改变
|
currentRow: {
|
handler: function(rowData) {
|
if (rowData) {
|
this.formData.scanQty = rowData.finishedQuantity
|
}
|
},
|
deep: true
|
}
|
},
|
mounted() {
|
|
// 加载默认仓库的收货位
|
this.getPositionName()
|
|
// 加载自定义数据
|
// 直接上架
|
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)
|
}
|
},
|
created() {
|
this.getStorage()
|
},
|
methods: {
|
//自动打印checkbox选中事件
|
changeAutoPrint(){
|
if(this.isChecked){
|
this.isChecked_PrintForInStore=true
|
this.isChecked_PrintForOutStore=false
|
}else{
|
this.isChecked_PrintForInStore=false
|
this.isChecked_PrintForOutStore=false
|
}
|
},
|
changeAutoPrint_PrintForInStore(){
|
if(this.isChecked_PrintForInStore){
|
this.isChecked_PrintForOutStore=false
|
}else{
|
this.isChecked_PrintForOutStore=true
|
}
|
},
|
changeAutoPrint_PrintForOutStore(){
|
if(this.isChecked_PrintForOutStore){
|
this.isChecked_PrintForInStore=false
|
}else{
|
this.isChecked_PrintForInStore=true
|
}
|
},
|
// 根据仓库获取货位
|
getPositionName() {
|
var url = '/api/inbound/inScan/getPosition'
|
// 仓库
|
for (var index3 in this.dropDownList_Storage) {
|
if (this.dropDownList_Storage[index3].storage_Id === this.formData.storage_Id) {
|
this.formData.storage_Id = this.dropDownList_Storage[index3].storage_Id
|
this.formData.storageName = this.dropDownList_Storage[index3].storageName
|
}
|
}
|
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 = []
|
}
|
},
|
true
|
)
|
},
|
getStorage() {
|
var url = '/api/common/loadDropDown'
|
var params = {
|
openNodeApi: true,
|
where: '31',
|
data: JSON.stringify(this.formData)
|
}
|
var callBack = res => {
|
this.common.showMsg(res)
|
if (res.result) {
|
if (res.data && res.data['dropdown' + params.where] && res.data['dropdown' + params.where].length > 0) {
|
this.dropDownList_Storage = res.data['dropdown' + params.where]
|
}
|
}
|
}
|
this.common.ajax(url, params, callBack)
|
},
|
getAttrValue(targetStr) {
|
let endStr = '';
|
// let targetStr = str.replace(/\s/g,'')
|
//字符串拆分数组
|
const targetArr = targetStr.split(',')
|
return targetArr;
|
},
|
// 获得明细数据
|
getDataForQrCode() {
|
var _qrCode=this.formData.QrCode;
|
if(_qrCode.length<=12){
|
this.$message.error('二维码长度不够')
|
return
|
}
|
var aa=this.getAttrValue(_qrCode);
|
if(aa.length!=7){
|
this.$message.error('二维码格式不正确')
|
return
|
}
|
this.isUseQrCode=true;
|
//赋值
|
this.formData.poCode=aa[1].replace(/^["']|["']$/g, '');//PO号
|
this.formData.itemNumber=aa[2].replace(/^["']|["']$/g, '');//采购项号
|
this.UseQrCodeData.qrCode_quantity=aa[4].replace(/^["']|["']$/g, '');
|
this.UseQrCodeData.qrCode_limitDate= String(aa[5].replace(/^["']|["']$/g, ''));
|
this.UseQrCodeData.qrCode_guid=aa[6].replace(/^["']|["']$/g, '');
|
this._getData();
|
},
|
// 获得明细数据
|
getData() {
|
this.isUseQrCode=false;
|
this._getData();
|
},
|
// 获得明细数据
|
_getData() {
|
//debugger
|
var poCode = this.formData.poCode
|
var itemNumber = this.formData.itemNumber
|
if (!poCode) {
|
this.$message.error('PO单不能为空')
|
return
|
}
|
poCode = poCode.trim()
|
this.formData.poCode = poCode
|
const url = '/api/inbound/inScan/getData'
|
const params = {
|
poCode: poCode,
|
itemNumber: itemNumber,
|
isOnShelve: this.formData.isOnShelve
|
}
|
var callback = res => {
|
this.common.showMsg(res)
|
if (res.result) {
|
// 构建数据
|
this.currentRow = null
|
this.formData.positionName = null
|
this.formData.productModel = null
|
this.formData.scanQty = null
|
this.tableData = res.data.map(row => {
|
// row.unFinishedQuantity = Math.Round(row.quantity - (row.enterQuantity || 0), 4);
|
row.finishedQuantity = 0
|
row.sortIndex = 0
|
row.scanWeight = 0
|
this.formData.trackingNumber = row.trackingNumber
|
this.formData.saleCode = row.saleCode
|
|
|
//限用日期
|
if(this.isUseQrCode){
|
// row.limitDate =this.UseQrCodeData.qrCode_limitDate;
|
var str = this.UseQrCodeData.qrCode_limitDate;
|
row.limitDate = str.substr(0,4) + "-" + str.substr(4,2) + "-" + str.substr(6,2);
|
}else{
|
row.limitDate = moment(new Date())
|
.add(1, 'years')
|
.format('YYYY-MM-DD')
|
}
|
|
row.itemNumber = row.itemNumber
|
row.unitConvert = row.unitConvert
|
row.unEnterQuantity = row.unEnterQuantity
|
if (!row.overcharges) {
|
row.overcharges = null
|
}
|
row.itemNumber = parseInt(row.itemNumber)
|
// if (row.bigQty - row.bigEnterQuantity <= 0) {
|
// row.receivedQuantity = row.overcharges * row.bigQty + row.bigQty - row.bigEnterQuantity;
|
// } else {
|
// row.receivedQuantity = row.bigQty - row.bigEnterQuantity
|
//本次操作量
|
if(this.isUseQrCode){
|
row.receivedQuantity = this.UseQrCodeData.qrCode_quantity
|
}else{
|
row.receivedQuantity = row.bigQty - row.bigEnterQuantity
|
}
|
//}
|
//row.quantity = Math.Round((row.receivedQuantity || 0) * row.unitConvert)
|
row.extendField04 = row.extendField04
|
row.extendField07 = row.extendField07
|
row.weight = row.weight
|
row.bigUnit = row.bigUnit
|
|
this.formData.totalWeight = Math.Round((row.receivedQuantity || 0) * row.weight)
|
return row
|
})
|
if (!this.formData.isValidateProductCode) {
|
this.tableData.forEach(row => {
|
row.finishedQuantity = Math.Round(row.unFinishedQuantity, 4) //已收货数量
|
row.scanWeight = row.totalWeight
|
row.unFinishedQuantity = 0
|
row.bigUnit = row.bigUnit
|
row.bigQty = row.bigUnEnterQuantity
|
})
|
}
|
// 直接上架选中时手工输入,未选中获取收货位
|
this.storage_Id = parseInt(res.statusCode)
|
if (!this.formData.isOnShelve) {
|
this.getPositionList()
|
} else {
|
this.focus('positionName')
|
}
|
} else {
|
this.focus('poCode')
|
}
|
}
|
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("productModel");
|
},
|
false
|
)
|
},
|
// 判断扫描包装条码
|
checkPackingBarcode(evt) {
|
this.checkPackingProductModel(() => {
|
if (this.formData.positionName) {
|
this.currentRow.positionName = this.formData.positionName
|
}
|
})
|
},
|
// 扫描数量手工改变
|
changeScanQty() {
|
this.setScanQty()
|
},
|
handleSelectionChange(val) {
|
this.multipleSelection = val
|
},
|
// 重置onReset
|
onReset() {
|
this.tableData = []
|
//formData.itemNumber
|
this.formData = {
|
orderCode: null,
|
isValidateProductCode: true, // 是否校验物料
|
positionName: null,
|
productModel: null,
|
scanQty: 0,
|
storage_Id: 87,
|
storageName: '立体库'
|
}
|
// this.getData()
|
//this.getPositionName();
|
// this.$refs.orderCode.focus();
|
},
|
|
// 入库时保质期如果超过一定时长(可设定)需要预警提示是否入库
|
saveCheck() {
|
var dataList = this.tableData
|
.filter(item => {
|
return item.quantity > 0
|
})
|
.map(rowData => {
|
var orderList_Id = rowData.orderList_Id
|
// var bigUnit = rowData.bigUnit;
|
// var poCode = rowData.poCode;
|
return {
|
orderList_Id: orderList_Id
|
}
|
})
|
|
if (!dataList.length) {
|
this.$message.error('没有扫描可用的数据!')
|
return
|
}
|
|
if (!window.confirm('当前扫描要确认入库吗?')) return
|
var url = '/api/inbound/inScan/saveCheck'
|
var params = {
|
openNodeApi: true,
|
orderCode: this.formData.poCode,
|
positionName: this.formData.positionName,
|
dataList: dataList
|
}
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
if (res.result) {
|
this.save()
|
this.onReset()
|
}
|
},
|
this.$refs.form
|
)
|
},
|
showInfoBeforeSave(){
|
if (!this.formData.poCode) {
|
this.$message.error('请扫描采购单号!')
|
this.$refs.orderCode.focus()
|
this.$refs.sound_error.play() // 播放声音
|
return
|
}
|
var _tableData=this.tableData;
|
if (this.multipleSelection.length !== 0) {
|
_tableData = this.multipleSelection
|
}else{
|
this.$message.error('请至少选择一条收货明细!')
|
return
|
}
|
var dataList = this.getCheckList(_tableData);
|
debugger
|
//alert(dataList.length);
|
this.gridData=dataList;
|
this.dialogTableVisible=true
|
},
|
cancelShowInfoBeforeSave(){
|
this.dialogTableVisible=false
|
this.gridData=[]
|
},
|
getCheckList(_tableData){
|
var dataList = _tableData
|
.filter(
|
rowData =>
|
rowData.receivedQuantity > 0 &&
|
rowData.receivedQuantity <= rowData.overcharges * rowData.bigQty + rowData.bigQty - rowData.bigEnterQuantity
|
)
|
.map(rowData => {
|
return {
|
orderList_Id: rowData.orderList_Id,
|
positionName: rowData.positionName,
|
produceDate: rowData.produceDate,
|
limitDate: rowData.limitDate,
|
bigQty: rowData.quantity,
|
unitConvert: rowData.unitConvert,
|
quantity: rowData.receivedQuantity,
|
itemNumber: rowData.itemNumber,
|
receivedQuantity: rowData.receivedQuantity,
|
bigEnterQuantity: rowData.bigEnterQuantity,
|
productBarCode: rowData.productBarCode,
|
extendField02: rowData.extendField02,
|
poCode: rowData.poCode,
|
unEnterQuantity: rowData.unEnterQuantity == null ? 1 : rowData.unEnterQuantity,
|
productCode:rowData.productCode,
|
productName:rowData.productName,
|
extendField04:rowData.extendField04,
|
qrCode_guid:rowData.qrCode_guid //增加给后台传递的二维码GUID 【Editby shaocx,2023-11-5】
|
}
|
})
|
// 如果是退货的话
|
if (this.moveType === '102') {
|
// 本次操作数量小于等于已收数量,并且已收数量不能为0
|
dataList = _tableData
|
.filter(rowData => rowData.receivedQuantity <= rowData.bigEnterQuantity && rowData.bigEnterQuantity > 0)
|
.map(rowData => {
|
return {
|
orderList_Id: rowData.orderList_Id,
|
positionName: rowData.positionName,
|
produceDate: rowData.produceDate,
|
limitDate: rowData.limitDate,
|
bigQty: rowData.quantity,
|
quantity: rowData.receivedQuantity,
|
itemNumber: rowData.itemNumber,
|
receivedQuantity: rowData.receivedQuantity,
|
productBarCode: rowData.productBarCode,
|
extendField02: rowData.extendField02,
|
poCode: rowData.poCode,
|
productCode:rowData.productCode,
|
productName:rowData.productName,
|
extendField04:rowData.extendField04
|
}
|
})
|
|
//if (!dataList.length) {
|
// this.$message.error('退货数量不可超过已收数量!')
|
// this.$refs.sound_error.play() // 播放声音
|
//return
|
// }
|
|
}
|
return dataList;
|
},
|
// 确认入库
|
save() {
|
|
if (!this.formData.poCode) {
|
this.$message.error('请扫描采购单号!')
|
this.$refs.orderCode.focus()
|
this.$refs.sound_error.play() // 播放声音
|
return
|
}
|
|
if (this.multipleSelection.length !== 0) {
|
this.tableData = this.multipleSelection
|
}
|
// 采购单位大于0
|
// <!-- :max="moveType=='101'?((1+row.overcharges/100) * row.bigQty)-row.bigEnterQuantity:row.bigEnterQuantity" -->
|
// if (row.receivedQuantity > maxQuantity) {
|
// this.$message.error("采购项号" + row.itemNumber + "-操作数量超过上限");
|
|
let isBreak = 0
|
let msgg = ''
|
this.tableData.forEach(item => {
|
item.overcharges = item.overcharges == null ? 0 : item.overcharges
|
let maxValues = this.moveType == '101' ? (1 + item.overcharges / 100) * item.bigQty - item.bigEnterQuantity : item.bigEnterQuantity
|
if (item.receivedQuantity > maxValues) {
|
msgg = msgg + '-' + item.itemNumber
|
}
|
})
|
|
debugger
|
if (msgg !== '') {
|
this.$message.error('采购项号' + msgg + '-操作数量超过上限')
|
return
|
}
|
debugger
|
var dataList = this.getCheckList(this.tableData);
|
//alert(dataList.length);
|
|
// 如果是退货的话
|
if (this.moveType === '102') {
|
if (!dataList.length) {
|
this.$message.error('退货数量不可超过已收数量!')
|
this.$refs.sound_error.play() // 播放声音
|
return
|
}
|
}
|
const detailList = JSON.stringify(
|
dataList.map(m => {
|
return {
|
PoNumber: m.poCode, // 采购单号
|
PoItem: m.itemNumber, // 采购项号
|
MaterialCode: m.productCode,
|
Quantity: m.quantity, // 本次收货量
|
StorageLocation: m.productBarCode, // 存储位置
|
Plant: m.extendField02, // 工厂
|
MoveType: this.moveType
|
}
|
})
|
)
|
if (!dataList.length) {
|
this.$message.error('至少扫描一条!')
|
this.$refs.sound_error.play() // 播放声音
|
return
|
}
|
this.formData.positionName = dataList[0].positionName
|
|
var orderListDetail = this.tableData.map(rowData => {
|
return {
|
orderList_Id: rowData.orderList_Id
|
}
|
})
|
|
//判断取值isChecked [EditBy shaocx,2022-06-21]
|
let _printFlag=1 // 0不打印 1:入库口打印机 2:出库口打印机
|
if(this.isChecked){
|
_printFlag=1 //默认 入库口打印机
|
if(this.isChecked_PrintForOutStore){
|
_printFlag=2 //表示是 出库口打印机
|
}
|
}else{
|
_printFlag=0
|
}
|
//增加给后台传递的二维码GUID
|
var _qrCode_guid="";
|
if(this.isUseQrCode){
|
_qrCode_guid=this.UseQrCodeData.qrCode_guid;
|
}
|
|
var url = '/api/task/receiptConvert'
|
|
var creator = localStorage.getItem("creator") || ''; //创建人
|
debugger
|
var params = {
|
'creator':creator, //创建人
|
qrCode_guid:_qrCode_guid,
|
poCode: this.formData.poCode,
|
// trackingNumber: this.formData.trackingNumber,
|
// saleCode: this.formData.saleCode,
|
// positionName: this.formData.positionName,
|
// totalWeight: this.formData.totalWeight,
|
// LightSortInfo_Id: null,
|
dataList: dataList,
|
//detailList: detailList,
|
moveType: this.moveType,
|
isAutoPrint: this.isChecked, //传递参数是否自动打印 【Editby shaocx,2022-06-13】
|
printFlag:_printFlag
|
// printQty: this.printQty,
|
// orderListDetail: orderListDetail
|
}
|
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
/// this.common.showMsg(res);
|
this.cancelShowInfoBeforeSave();
|
if (res.result) {
|
this.onReset()
|
return this.$message.success(res.msg)
|
} else {
|
//return this.$message.error(res.);
|
|
return this.$message.error(res.msg)
|
}
|
},
|
true
|
)
|
},
|
// 明细数量改变
|
qtyChange(row, prop, index) {
|
console.log(row.receivedQuantity)
|
debugger
|
// if (prop === "receivedQuantity") {
|
let maxQuantity = this.moveType == '101' ? row.bigQty - row.bigEnterQuantity : row.bigEnterQuantity
|
|
maxQuantity = maxQuantity == null ? 0 : maxQuantity
|
if (this.moveType == '101') {
|
if (row.receivedQuantity > (1 + row.overcharges / 100) * maxQuantity) {
|
this.$message.error('采购项号' + row.itemNumber + '-操作数量超过上限')
|
return
|
}
|
} else {
|
if (row.receivedQuantity > maxQuantity) {
|
this.$message.error('采购项号' + row.itemNumber + '-操作数量超过上限')
|
return
|
}
|
}
|
|
row.quantity = Math.Round(row.receivedQuantity)
|
// row.quantity = Math.Round((row.receivedQuantity || 0) * row.unitConvert)
|
console.log(row.quantity)
|
this.formData.totalWeight = Math.Round((row.receivedQuantity || 0) * row.weight)
|
// }
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
@import '../../../styles/scan.scss';
|
</style>
|