yxk_h5_master/pages/wms/stock/inventory/add.vue

174 lines
4.3 KiB
Vue

<template>
<view class="container" v-if="query">
<xinsoft-form-input :itemDefine='itemDefine1' :bindSource.sync="dataItem1" @toSearch='searchFacility'></xinsoft-form-input>
<xinsoft-form-input :itemDefine='itemDefine2' :bindSource.sync="dataItem2" @toSearch='searchFacilityLocation'></xinsoft-form-input>
<view class="supplier" v-if="qrCodeProps.supplierId">供应商:{{qrCodeProps.supplierName}}</view>
<xinsoft-scan :qrCodeProps.sync='qrCodeProps' @submitData='submitData' ></xinsoft-scan>
<view class="goHome" @click='goMain()'>
<img src="@/static/img/gohome.png">
</view>
</view>
</template>
<script>
import xinsoftFormInput from '@/components/xinsoft-form-input/xinsoft-form-input.vue'
//扫码组件
import xinsoftScan from '@/components/wms/xinsoft-scan.vue'
export default {
components: {
xinsoftFormInput,xinsoftScan
},
data() {
return {
query:false,
qrCodeProps:{
title:'盘点明细',
countType:'数量',
qrCodeDetailUrl:'/apis/scm/qrcode/outDetail',
countEdit:true,//入库/出库数量是否有disabled. true数量不可修改,false数量可修改
inventory:true
},
itemDefine1:{
title: "盘点编号",
fieldName: "valueName",
type: "text",
required: false,
disabled: false,
placeholder: "",
canClear:false,//是否带清空按钮
},
dataItem1:{
valueName: "",
},
itemDefine2:{
title: "仓库",
fieldName: "valueName",
type: "text",
required: false,
disabled: false,
placeholder: "",
canClear:false
},
dataItem2:{
valueName: "",
},
inventoryInfo:{
code:"",
id:'',
warehouse:'',
warehouseName:'',
}
}
},
mounted() {
let query=this.$route.query;
if(query.id){//获取列表页带过来的参数
this.inventoryInfo={
code:decodeURIComponent(query.code),
id:decodeURIComponent(query.id),
warehouse:decodeURIComponent(query.warehouse),
warehouseName:decodeURIComponent(query.warehouseName),
}
this.dataItem1.valueName=decodeURIComponent(query.code)
this.dataItem2.valueName=decodeURIComponent(query.warehouseName)
this.qrCodeProps.inventoryId=decodeURIComponent(query.id)
}
this.query=true//必须要有这句
},
methods:{
submitData(data){
// if(this.facilityId==''){
// uni.showToast({
// title: '请先选择仓库',
// icon: 'none',
// duration: 2000
// });
// return
// }
if(data.length==0){
uni.showToast({
title: '请先扫码',
icon: 'none',
duration: 2000
});
return
}
let _this=this;
let bodyDetail=[];
data.forEach(p=>{
let json_={
materielId:p.materielId,
batch:p.batch?p.batch:'无',
checkCount:p.count?p.count:0,
warehouse:p.facilityId,
warehLocation:p.facilityLocationId,
qrId:p.qrcodeId
}
bodyDetail.push(json_)
})
this.$http.request({
url: '/apis/scm/inventoryPlan/phoneCheckResuls',
params: {
planId:this.inventoryInfo.id,
checkBodyDO:encodeURIComponent(JSON.stringify(bodyDetail))
},
}).then(res => {
if(res.data.code==0){
uni.showToast({
title:"提交成功",
icon:"none",
duration: 2000
});
setTimeout(function(){
uni.redirectTo({
url: 'index'
});
},1000)
}else{
uni.showToast({
title:res.data.msg?res.data.msg:"提交失败",
icon:"none",
duration: 2000
});
}
}).catch(err => {
uni.showToast({
title:err,
icon:"none",
duration: 2000
});
});
}
},
watch:{
}
}
</script>
<style scoped>
.container{
position: relative;
min-height: 100%;
background-color: #fff;
}
.supplier{
height: 40px;
line-height: 40px;
border-bottom: 1px solid #e6e6e6;
box-sizing: border-box;
font-size: 15px;
padding: 0 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>