<template>
|
<view class="page">
|
<view class="inventory-detail-bg"/>
|
<view class="inventory-detail-carmera">
|
<view class="inventory-detail-carmera-icon" @click="goScan">
|
</view>
|
<view class="inventory-detail-carmera-tip">
|
<text>扫一扫</text>
|
</view>
|
</view>
|
<u-navbar title="扫码盘点" :background="background" :border-bottom="false" :title-bold="true" title-color="#000" back-icon-color="#000"/>
|
<view class="inventory-detail-param">
|
<view class="inventory-detail-param-view">
|
<view class="inventory-detail-param-item param-extra">
|
<view class="inventory-detail-param-item-left">
|
<text class="item-one">盘点编号</text>
|
</view>
|
<view class="inventory-detail-param-item-right">
|
<text class="item-one">{{inyInfo.inyNo}}</text>
|
<u-icon name="arrow-right" color="#687792" size="28"></u-icon>
|
</view>
|
</view>
|
<view class="inventory-detail-param-item param-extra">
|
<view class="inventory-detail-param-item-left">
|
<text class="item-one">盘点库位</text>
|
</view>
|
<view class="inventory-detail-param-item-right" @click="goLoc()">
|
<text v-if="inyInfo.locNo" class="item-one">{{inyInfo.locNo}}</text>
|
<text v-if="!inyInfo.locNo" class="item-one item-two">请选择</text>
|
<u-icon name="arrow-right" color="#687792" size="28"></u-icon>
|
</view>
|
</view>
|
<view class="inventory-detail-param-item">
|
<view class="inventory-detail-param-item-left">
|
<text class="item-one">自动提交</text>
|
</view>
|
<view class="inventory-detail-param-item-right">
|
<!--<text class="item-one">{{isAuto?'是':'否'}}</text>-->
|
<picker class="item-one" style="width: 100%;" @change="autoNumBindChange($event,isAutoList)" :value="autoNumIndex" :range="isAutoList"
|
range-key="label">
|
<view>
|
<text>{{isAutoList[autoNumIndex].label}}</text>
|
</view>
|
</picker>
|
<u-icon name="arrow-right" color="#687792" size="28"></u-icon>
|
</view>
|
</view>
|
</view>
|
</view>
|
<view class="wrap">
|
<scroll-view class="inventory-detail-scroll-list" scroll-y="true">
|
<u-cell-group class="inventory-detail-scroll-list-group" :border="false">
|
<view class="tip" v-if="list.length==0">-请新增或扫码-</view>
|
<view class="content" v-for="(x, index) in list" :key="index" :index="index">
|
<u-form :model="x" ref="uForm" labelWidth="6em" >
|
<u-form-item label="零件号" prop="partNo" required>
|
<u-input v-model="x.partNo" disabled @click="x.isScan?null:goPart(index)"/>
|
<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
|
</u-form-item>
|
<u-form-item label="零件名称" prop="partName">
|
<u-input v-model="x.partName" disabled @click="x.isScan?null:goPart(index)"/>
|
<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
|
</u-form-item>
|
<u-form-item label="SN号" prop="sn" required>
|
<u-input v-model="x.sn" :disabled="x.isScan"/>
|
<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
|
</u-form-item>
|
<u-form-item label="IFS批次号" prop="ifsBatchNo" required>
|
<u-input v-model="x.ifsBatchNo" :disabled="x.isScan"/>
|
<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
|
</u-form-item>
|
<u-form-item label="盘点数量" prop="inyQty" required>
|
<u-input v-model="x.inyQty" type="number"/>
|
<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
|
</u-form-item>
|
<u-form-item label="单位" prop="unit">
|
<u-input v-model="x.unit" :disabled="x.isScan"/>
|
<u-icon slot="right" name="arrow-right" color="#687792" size="28"></u-icon>
|
</u-form-item>
|
</u-form>
|
<view class="content-btn">
|
<u-button size="mini" :custom-style="customStyle" @click="goMinus(index)">
|
<u-icon name="trash" color="#fff" size="28"></u-icon>
|
<text style="margin-left:4rpx;">删除</text>
|
</u-button>
|
</view>
|
</view>
|
</u-cell-group>
|
</scroll-view>
|
<view class="inventory-footer">
|
<u-button class="btn-left" size="medium" type="primary" @click="goAdd">新增</u-button>
|
<u-button class="btn-right" size="medium" type="primary" @click="goSubmit">提交</u-button>
|
</view>
|
<scan></scan>
|
<u-modal v-model="showConfirm" content="该零件批次已扫描过,是否继续扫描" @confirm="confirm" :show-cancel-button="true"/>
|
<u-modal v-model="showScanConfirm" content="该零件批次已扫描过,是否继续扫描" @confirm="confirmGoOn" :show-cancel-button="true"/>
|
</view>
|
</view>
|
</template>
|
<script>
|
import scan from "@/components/scan/scan.vue";
|
import content_bg from '@/static/custom/inventory/locNoBg.png'
|
export default {
|
components: { scan },
|
data() {
|
const rr=(type)=>{
|
return [
|
{
|
required: true,
|
message: `${type}为必填项`,
|
trigger: ['change'],
|
}
|
]
|
}
|
return {
|
background:{
|
backgroundImage: `url(${content_bg})`,
|
backgroundAttachment: 'fixed',
|
backgroundSize: '100% auto',
|
backgroundRepeat: 'no-repeat',
|
},
|
customStyle:{
|
color:'#fff',
|
background:'#ED837B'
|
},
|
labelStyle:{
|
fontSize:'32rpx',
|
whiteSpace:'nowrap'
|
},
|
bodyStyle:{
|
padding: '0 40rpx 10rpx'
|
},
|
inyInfo:{
|
inyid:'',
|
inyNo:'',
|
locNo:''
|
},
|
isAuto:false,
|
list:[
|
],
|
hasScanSnList:[],
|
currentIndex:-1,
|
rules:{
|
partNo:rr('零件号'),
|
sn:rr('SN号'),
|
ifsBatchNo:rr('IFS批次号'),
|
inyQty:rr('盘点数量')
|
},
|
showConfirm:false,
|
currResult:null,
|
currScanresult:null,
|
isBarcode:true,
|
showScanConfirm:false,
|
isAutoList:[
|
{value:false,label:'否'},
|
{value:true,label:'是'}
|
],
|
autoNumIndex:0
|
};
|
},
|
onLoad(option) {
|
this.inyInfo.inyid=option.id
|
this.inyInfo.inyNo=option.no
|
},
|
onShow() {
|
|
let that = this
|
|
uni.$off('scan') // 每次进来先 移除全局自定义事件监听器
|
uni.$on('scan', function(data) {
|
console.log('onscan');
|
//扫码成功后的回调,你可以写自己的逻辑代码在这里
|
console.log('扫码结果:', data.code);
|
that.scanHandle(data.code)
|
that.$forceUpdate();
|
|
})
|
},
|
onNavigationBarButtonTap(){
|
this.goScan()
|
},
|
methods: {
|
autoNumBindChange(e,storage){
|
if (storage.length <= 0) {
|
this.autoNumIndex = null
|
return
|
}
|
this.autoNumIndex = e.target.value
|
this.isAuto = storage[this.autoNumIndex].value
|
},
|
goScan(){
|
//let scanresult={"part_no":"88.118.1/A0044193","package_code":"TP092022101200001","unit_meas":"跦","wdr":"*","lot_batch_no":"*","qty_arrived":12}
|
//this.scanHandle(JSON.stringify(scanresult))
|
// return
|
if(!this.inyInfo.locNo){
|
this.$u.toast('请先选择盘点库位')
|
return
|
}
|
uni.scanCode({
|
scanType: ['qrCode'],
|
success: res => {
|
try {
|
console.log('扫码结果:', res);
|
this.scanHandle(res.result)
|
} catch (e) {}
|
}
|
});
|
},
|
confirmGoOn(){
|
if(this.isBarcode){
|
this.hasScanSnList.push(this.currScanresult)
|
//不自动,填写盘点数量
|
this.$u.api.inventory.getStockByLocNoAndSn({
|
locationNo:this.inyInfo.locNo,
|
sn:this.currScanresult
|
}).then(res=>{
|
let resultArr=[]
|
if(res.data.data!=null && res.data.data.length>0){
|
let resDataArr=res.data.data
|
resultArr =resDataArr.map(e=>{
|
return {
|
partNo: e.partNo,
|
partName: e.partName,
|
sn: this.currScanresult,
|
ifsBatchNo: e.ifsBatchNo,
|
inyQty: e.inyQty,
|
unit: e.unit,
|
isScan: true
|
}
|
})
|
}
|
if(resultArr.length==0){
|
this.$u.toast('无数据')
|
let hasScanSnIndex=this.hasScanSnList.indexOf(this.currScanresult)
|
this.hasScanSnList.splice(hasScanSnIndex,1)
|
}else{
|
this.$u.api.inventory.goCheck({
|
...resultArr[0],
|
inventoryMainId:this.inyInfo.inyid,
|
locNo:this.inyInfo.locNo
|
}).then(res2=>{
|
if (!res2.data.data.success) {
|
this.showConfirm=true
|
this.confirmData=resultArr
|
} else {
|
this.scanSave(resultArr)
|
}
|
let hasScanSnIndex=this.hasScanSnList.indexOf(this.currScanresult)
|
this.hasScanSnList.splice(hasScanSnIndex,1)
|
}).catch((e) => {
|
let hasScanSnIndex=this.hasScanSnList.indexOf(this.currScanresult)
|
this.hasScanSnList.splice(hasScanSnIndex,1)
|
console.log(e)
|
})
|
}
|
}).catch((e) => {
|
let hasScanSnIndex=this.hasScanSnList.indexOf(this.currScanresult)
|
this.hasScanSnList.splice(hasScanSnIndex,1)
|
console.log(e)
|
})
|
}else{
|
this.hasScanSnList.push(this.currResult.wdr+' '+this.currResult.lot_batch_no)
|
this.$u.api.inventory.getPartNo({
|
partNo:this.currResult.part_no,
|
}).then(res=>{
|
const obj=[{
|
partNo: this.currResult.part_no,
|
partName: res.data.partName,
|
sn: this.currResult.wdr,
|
ifsBatchNo: this.currResult.lot_batch_no,
|
inyQty: this.currResult.qty_arrived,
|
unit: this.currResult.unit_meas,
|
isScan: true
|
}]
|
this.$u.api.inventory.goCheck({
|
...obj[0],
|
inventoryMainId:this.inyInfo.inyid,
|
locNo:this.inyInfo.locNo
|
}).then(res2=>{
|
if (!res2.data.data.success) {
|
this.showConfirm=true
|
this.confirmData=obj
|
} else {
|
|
this.scanSave(obj)
|
}
|
let hasScanSnIndex=this.hasScanSnList.indexOf(this.currResult.wdr+' '+this.currResult.lot_batch_no)
|
this.hasScanSnList.splice(hasScanSnIndex,1)
|
}).catch((e) => {
|
let hasScanSnIndex=this.hasScanSnList.indexOf(this.currResult.wdr+' '+this.currResult.lot_batch_no)
|
this.hasScanSnList.splice(hasScanSnIndex,1)
|
console.log(e)
|
})
|
}).catch((e) => {
|
let hasScanSnIndex=this.hasScanSnList.indexOf(this.currResult.wdr+' '+this.currResult.lot_batch_no)
|
this.hasScanSnList.splice(hasScanSnIndex,1)
|
console.log(e)
|
})
|
}
|
},
|
scanHandle(scanresult){
|
if(!this.inyInfo.locNo){
|
this.$u.toast('请先选择盘点库位')
|
return
|
}
|
scanresult = scanresult.replace(/[\r\n]/g, "")
|
console.log(scanresult)
|
// const reg = /^{[\w\W]*}$/
|
// console.log(reg.test(scanresult))
|
if (scanresult.indexOf('{')>-1) {
|
//二维码
|
const result = JSON.parse(scanresult)
|
this.isBarcode=false
|
this.currResult=result
|
let flag=true
|
if(this.list.length>0){
|
let exist=this.list.find((item)=>{return (item.sn+' '+item.ifsBatchNo)==(result.wdr+' '+result.lot_batch_no)})
|
if(exist){
|
flag=false
|
}
|
}
|
//增加SN校验
|
let snFlag=true
|
console.log('this.hasScanSnList',this.hasScanSnList.length)
|
if(this.hasScanSnList.length>0){
|
let hasScanSnIndex=this.hasScanSnList.indexOf(result.wdr+' '+result.lot_batch_no)
|
if(hasScanSnIndex>-1){
|
snFlag=false
|
}
|
}
|
if(flag && snFlag){
|
this.confirmGoOn()
|
}else{
|
this.showScanConfirm=true
|
}
|
|
} else {
|
//条形码
|
if(this.isAuto){
|
//自动提交
|
this.$u.toast('条形码不支持自动提交')
|
// this.$u.api.inventory.getInventoryDetailByLocNoAndSn({
|
// id:this.inyInfo.inyid,
|
// locationNo:this.inyInfo.locNo,
|
// sn:scanresult
|
// }).then(res=>{
|
// this.$u.toast('提交成功')
|
// })
|
}else{
|
this.isBarcode=true
|
this.currScanresult=scanresult
|
let flag=true
|
if(this.list.length>0){
|
let exist=this.list.find((item)=>{return item.sn==scanresult})
|
if(exist){
|
flag=false
|
}
|
}
|
//增加SN校验
|
let snFlag=true
|
if(this.hasScanSnList.length>0){
|
let hasScanSnIndex=this.hasScanSnList.indexOf(scanresult)
|
if(hasScanSnIndex>-1){
|
snFlag=false
|
}
|
}
|
if(flag && snFlag){
|
this.confirmGoOn()
|
}else{
|
this.showScanConfirm=true
|
}
|
}
|
}
|
|
},
|
confirm(){
|
this.scanSave(this.confirmData)
|
},
|
scanSave(resultArr){
|
if(this.isAuto){
|
this.save(resultArr)
|
}else{
|
//往数组前排添加元素
|
resultArr.forEach((item)=>{
|
this.list.unshift(item)
|
})
|
//this.list=this.list.concat(resultArr)
|
}
|
},
|
goAdd() {
|
if(!this.inyInfo.locNo){
|
this.$u.toast('请先选择盘点库位')
|
return
|
}
|
this.list.unshift({
|
partNo: '',
|
partName: '',
|
sn: '',
|
ifsBatchNo: '',
|
inyQty: '',
|
unit: '',
|
isScan: false
|
})
|
this.$nextTick(()=>{
|
this.$refs.uForm[this.list.length-1].setRules(this.rules);
|
})
|
},
|
goMinus(i){
|
this.list.splice(i, 1)
|
},
|
goPart(index){
|
this.currentIndex=index;
|
uni.navigateTo({
|
url: `/pages/wareHouse/inventory/partchoose`
|
})
|
},
|
setPart(item){
|
this.list[this.currentIndex].partNo=item.partNo
|
this.list[this.currentIndex].partName=item.partName
|
},
|
goLoc(){
|
uni.navigateTo({
|
url: '/pages/wareHouse/inventory/locNoList'
|
})
|
},
|
setNo(no) {
|
this.inyInfo.locNo=no
|
},
|
goSubmit() {
|
if(this.list.length==0){
|
this.$u.toast('无待提交的盘点明细')
|
return
|
}
|
let pass=true
|
this.list.forEach((e,i)=>{
|
this.$refs.uForm[i].validate(valid => {
|
if(!valid){
|
pass=false
|
}
|
})
|
})
|
if(pass){
|
this.save(this.list,true)
|
}
|
},
|
save(list,clear){
|
uni.showLoading({
|
title: '正在提交...',
|
mask: true
|
});
|
let p=[]
|
list.forEach((e,i)=>{
|
const param={
|
...e,
|
inventoryMainId:this.inyInfo.inyid,
|
locNo:this.inyInfo.locNo
|
}
|
p.push(this.$u.api.inventory.addDetail(param))
|
})
|
Promise.all(p).then(()=>{
|
this.$u.toast('提交成功')
|
if(clear){
|
this.list=[]
|
this.hasScanSnList=[]
|
}
|
uni.hideLoading();
|
})
|
}
|
}
|
};
|
</script>
|
<style lang="scss" scoped>
|
.page{
|
position: relative;
|
}
|
.inventory-detail-bg{
|
background-color: #F6F9FF;
|
background-image: url('~@/static/custom/inventory/locNoBg.png');
|
// background: linear-gradient(180deg,rgba(206,227,254,1),rgba(206,227,254,1) 20%,rgba(206,227,254,0.5) 40%,rgba(206,227,254,0.25) 60%,rgba(206,227,254,0.08) 80%,rgba(206,227,254,0));
|
padding: 0 20rpx;
|
background-attachment: fixed;
|
background-size: 100% auto;
|
background-repeat: no-repeat;
|
position: fixed;
|
top: 0;
|
bottom: 0;
|
width: 100%;
|
z-index: -1;
|
}
|
|
.inventory-detail-carmera{
|
position: absolute;
|
top:10rpx;
|
right: 30rpx;
|
height: 82rpx;
|
width: 82rpx;
|
z-index: 1000;
|
.inventory-detail-carmera-icon{
|
background-image: url('~@/static/custom/inventory/carmera.png');
|
background-size: 100% auto;
|
background-repeat: no-repeat;
|
width: 82rpx;
|
height: 82rpx;
|
}
|
.inventory-detail-carmera-tip{
|
text{
|
font-size: 20rpx;
|
color:#3D8BFF;
|
}
|
}
|
}
|
|
.inventory-detail-param{
|
padding: 50rpx 30rpx 0rpx 30rpx;
|
.inventory-detail-param-view{
|
height: 300rpx;
|
background: rgba(255,255,255,0.61);
|
box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(110,120,135,0.09);
|
border-radius: 10rpx;
|
padding:0rpx 23rpx;
|
margin-bottom: 30rpx;
|
.inventory-detail-param-item{
|
height: 100rpx;
|
border: 1px solid #ADC8E4;
|
line-height: 100rpx;
|
display:flex;
|
justify-content: space-between;
|
border: none;
|
.inventory-detail-param-item-left{
|
.item-one{
|
font-size: 30rpx;
|
color: #4F4F4F;
|
}
|
}
|
.inventory-detail-param-item-right{
|
display: flex;
|
.item-one{
|
font-size: 30rpx;
|
color: #333333;
|
margin-right: 6rpx;
|
}
|
.item-two{
|
font-size: 30rpx;
|
color: #A6B4CC;
|
margin-right: 6rpx;
|
}
|
.item-three{
|
font-size: 30rpx;
|
color: #214DED;
|
margin-right: 6rpx;
|
}
|
}
|
}
|
.param-extra{
|
border-bottom: 1px solid #E8EBEE;
|
}
|
}
|
}
|
|
.wrap .inventory-detail-scroll-list{
|
height:calc(100vh - var(--window-top) - var(--window-bottom) - 596rpx);
|
width:100%;
|
}
|
.inventory-detail-scroll-list-group{
|
::v-deep .u-cell-item-box {
|
background-color:rgba(255,255,255,0) !important;
|
margin:0rpx 30rpx;
|
padding:0rpx 0rpx 0rpx 0rpx;
|
}
|
.tip{
|
text-align: center;
|
}
|
.content {
|
background-color: #fff;
|
border-radius: 10rpx;
|
margin-bottom: 20rpx;
|
box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(110,120,135,0.09);
|
::v-deep .u-form{
|
.u-form-item{
|
padding: 10rpx 22rpx 10rpx 10rpx !important;
|
.u-form-item--left__content{
|
justify-content: flex-end !important;
|
.u-form-item--left__content--required{
|
position:relative !important;
|
}
|
.u-form-item--left__content__label{
|
flex: none !important;
|
color: #666666;
|
}
|
}
|
.u-form-item--right__content{
|
.u-input{
|
text-align: right !important;
|
.u-input__input{
|
color: #B1B5BB !important;
|
}
|
}
|
}
|
}
|
}
|
.content-btn{
|
padding: 10rpx 0rpx;
|
text-align: right;
|
margin-right: 22rpx;
|
}
|
|
}
|
}
|
|
.inventory-footer{
|
padding: 0rpx 30rpx 0rpx 30rpx;
|
margin-bottom: 20rpx;
|
display: flex;
|
justify-content: space-between;
|
.btn-left{
|
width: 310rpx;
|
height: 90rpx;
|
background: #30AFFF;
|
border: 1px solid #BFCFE4 !important;
|
box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(110,120,135,0.3);
|
border-radius: 16rpx;
|
font-size: 40rpx;
|
font-weight: bold;
|
color: #FEFEFE;
|
}
|
.btn-left:after{
|
border:none !important;
|
}
|
.btn-right{
|
width: 310rpx;
|
height: 90rpx;
|
background: #214DED;
|
box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(4,49,212,0.3);
|
border-radius: 16rpx;
|
font-size: 40rpx;
|
font-weight: bold;
|
color: #FEFEFE;
|
}
|
}
|
</style>
|