592 lines
18 KiB
Vue
592 lines
18 KiB
Vue
<template>
|
||
<view class="container" v-if="query">
|
||
<xinsoft-form-input :itemDefine='itemDefine1' :bindSource.sync="dataItem1" @toSearch='searchFacility(1)'></xinsoft-form-input>
|
||
<xinsoft-form-input :itemDefine='itemDefine2' :bindSource.sync="dataItem2" @toSearch='searchFacilityLocation(1)' @toScan='scanFacilityLocation(1)'></xinsoft-form-input>
|
||
|
||
<xinsoft-form-input :itemDefine='itemDefine3' :bindSource.sync="dataItem3" @toSearch='searchFacility(2)'></xinsoft-form-input>
|
||
<xinsoft-form-input :itemDefine='itemDefine4' :bindSource.sync="dataItem4" @toSearch='searchFacilityLocation(2)' @toScan='scanFacilityLocation(2)'></xinsoft-form-input>
|
||
<xinsoft-scan :qrCodeProps.sync='qrCodeProps' @submitData='submitData' ></xinsoft-scan>
|
||
<!-- //搜索仓库列表 -->
|
||
<chooseFacilitySingle :showsearch.sync="show_search_facility"
|
||
:itemInfo_.sync="search_value_facility"></chooseFacilitySingle>
|
||
<!-- //搜索仓位列表 -->
|
||
<chooseFacilityLocationSingle :showsearch.sync="show_search_location" :facilityId='facilityId_search'
|
||
:itemInfo_.sync="search_value_location"></chooseFacilityLocationSingle>
|
||
<view class="goHome" @click='goMain()'>
|
||
<img src="@/static/img/gohome.png">
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import jweixin from '@/jweixin-module/index.js';
|
||
import xinsoftFormInput from '@/components/xinsoft-form-input/xinsoft-form-input.vue'
|
||
//搜索仓库列表
|
||
import chooseFacilitySingle from '@/components/xinsoft-search-list/chooseFacilitySingle.vue'
|
||
//搜索仓位列表
|
||
import chooseFacilityLocationSingle from '@/components/xinsoft-search-list/chooseFacilityLocationSingle.vue'
|
||
//扫码组件
|
||
import xinsoftScan from '@/components/wms/xinsoft-scan.vue'
|
||
export default {
|
||
components: {
|
||
xinsoftFormInput,chooseFacilitySingle,chooseFacilityLocationSingle,xinsoftScan
|
||
},
|
||
data() {
|
||
return {
|
||
query:false,
|
||
qrCodeProps:{
|
||
title:'调拨物料明细',
|
||
countType:'调拨数量',
|
||
qrCodeDetailUrl:'/apis/scm/qrcode/outDetail',
|
||
countEdit:true,//入库/出库数量是否有disabled. true数量不可修改,false数量可修改
|
||
id:'',//源单id
|
||
facilityId:'',//仓库
|
||
facilityLocationId:'',
|
||
facilityIdRequired:true,//扫码之前是否要验证仓库必填
|
||
facilityLocationIdRequired:false,//扫码之前是否要验证仓位必填
|
||
clear:false,
|
||
allot:true
|
||
},
|
||
itemDefine1:{
|
||
title: "调出仓库",
|
||
fieldName: "valueName",
|
||
type: "kd-vlookup-edit",
|
||
required: true,
|
||
disabled: true,
|
||
placeholder: "",
|
||
canClear:false,//是否带清空按钮
|
||
},
|
||
dataItem1:{
|
||
valueName: "",
|
||
},
|
||
itemDefine2:{
|
||
title: "调出仓位",
|
||
fieldName: "valueName",
|
||
// type: "kd-vlookup-scan",
|
||
type: "kd-vlookup-scan-edit",
|
||
required: false,
|
||
disabled: true,
|
||
placeholder: "",
|
||
canClear:false
|
||
},
|
||
dataItem2:{
|
||
valueName: "",
|
||
},
|
||
itemDefine3:{
|
||
title: "调入仓库",
|
||
fieldName: "valueName",
|
||
type: "kd-vlookup-edit",
|
||
required: true,
|
||
disabled: true,
|
||
placeholder: "",
|
||
canClear:false,//是否带清空按钮
|
||
},
|
||
dataItem3:{
|
||
valueName: "",
|
||
},
|
||
itemDefine4:{
|
||
title: "调入仓位",
|
||
fieldName: "valueName",
|
||
// type: "kd-vlookup-scan",
|
||
type: "kd-vlookup-scan-edit",
|
||
required: false,
|
||
disabled: true,
|
||
placeholder: "",
|
||
canClear:false
|
||
},
|
||
dataItem4:{
|
||
valueName: "",
|
||
},
|
||
show_search_facility_index:'',//等于1,指调出仓库。等于2,指调入仓库
|
||
show_search_facility:false,//显示仓库搜索列表
|
||
search_value_facility:[],//选择的仓库信息
|
||
show_search_location:false,//显示仓位搜索列表
|
||
show_search_location_index:'',//等于1,指调出仓位。等于2,指调入仓位
|
||
search_value_location:[],//选择的仓位信息
|
||
facilityId:'',//调出仓库选的仓库id,
|
||
facilityLocationId:'',//调出仓位选的仓位id,
|
||
facilityId2:'',//调入仓库选的仓库id,
|
||
facilityLocationId2:'',//调入仓位选的仓位id,
|
||
facilityId_search:'',//用来搜索仓位的仓库id
|
||
}
|
||
},
|
||
mounted() {
|
||
let query=this.$route.query;
|
||
if(query.id){//获取列表页带过来的参数
|
||
this.qrCodeProps.id=decodeURIComponent(query.id)
|
||
this.qrCodeProps.contractNo=decodeURIComponent(query.contractNo)
|
||
|
||
}
|
||
this.query=true//必须要有这句
|
||
this.initiateWX();
|
||
},
|
||
|
||
methods:{
|
||
//获取微信相关
|
||
initiateWX() {
|
||
this.$http
|
||
.request({
|
||
url: '/apis/weChat/getSignature',
|
||
params: {
|
||
// url:"http://120.132.17.220:18093/gyhl-app/"
|
||
url: window.location.href.split('#')[0]
|
||
}
|
||
})
|
||
.then(res => {
|
||
if (res.data.code == 0) {
|
||
var s = res.data;
|
||
jweixin.config({
|
||
beta: true,
|
||
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||
appId: s.corpId, // 必填,公众号的唯一标识
|
||
timestamp: s.timestamp, // 必填,生成签名的时间戳
|
||
nonceStr: s.nonceStr, // 必填,生成签名的随机串
|
||
signature: s.signature.toLowerCase(), // 必填,签名,见附录1
|
||
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'scanQRCode']
|
||
});
|
||
} else {
|
||
uni.showToast({
|
||
title: res.msg ? res.msg : '获取微信配置失败',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
})
|
||
.catch(err => {
|
||
uni.showToast({
|
||
title: err,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
});
|
||
},
|
||
//点击显示仓库列表
|
||
searchFacility(index){
|
||
this.show_search_facility_index=index;
|
||
this.show_search_facility=true;
|
||
},
|
||
////点击显示仓位列表
|
||
searchFacilityLocation(index){
|
||
if(index==1){
|
||
if(this.facilityId==''){
|
||
uni.showToast({
|
||
title:'请先选择调出仓库',
|
||
icon:"none",
|
||
duration: 2000
|
||
});
|
||
return
|
||
}else{
|
||
this.facilityId_search=this.facilityId
|
||
this.show_search_location=true;
|
||
}
|
||
}else if(index==2){
|
||
if(this.facilityId2==''){
|
||
uni.showToast({
|
||
title:'请先选择调入仓库',
|
||
icon:"none",
|
||
duration: 2000
|
||
});
|
||
return
|
||
}else{
|
||
this.facilityId_search=this.facilityId2
|
||
this.show_search_location=true;
|
||
}
|
||
}
|
||
|
||
this.show_search_location_index=index;
|
||
},
|
||
|
||
//点击扫码仓位
|
||
scanFacilityLocation(index){
|
||
console.log("你点击了按钮")
|
||
if(index==1) {
|
||
if(this.facilityId==''){
|
||
uni.showToast({
|
||
title:'请先选择调出仓库',
|
||
icon:"none",
|
||
duration: 2000
|
||
});
|
||
return
|
||
}else{
|
||
this.facilityId_search=this.facilityId
|
||
this.show_search_location_index=index;
|
||
// 允许从相机和相册扫码
|
||
let _this = this;
|
||
jweixin.scanQRCode({
|
||
desc: 'scanQRCode desc',
|
||
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
|
||
scanType: ['qrCode'], // 可以指定扫二维码还是条形码(一维码),默认二者都有"qrCode", "barCode"
|
||
success: function(res) {
|
||
if (res.errMsg != 'scanQRCode:ok') {
|
||
uni.showToast({
|
||
title: '扫描结果:' + res.resultStr,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
} else {
|
||
//扫码正确
|
||
let resultStr = res.resultStr;
|
||
try {
|
||
resultStr = JSON.parse(resultStr);
|
||
if (resultStr.facilityLocationId) {
|
||
|
||
_this.getQrCodeInfo(resultStr.facilityLocationId);
|
||
} else {
|
||
uni.showToast({
|
||
title: '二维码错误,请扫描正确的二维码',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
} catch (e) {
|
||
uni.showToast({
|
||
title: '二维码错误,请扫描正确的二维码',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
}
|
||
// 回调
|
||
},
|
||
error: function(res) {
|
||
uni.showToast({
|
||
title: 'error:' + res,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
if (res.errMsg.indexOf('function_not_exist') > 0) {
|
||
alert('版本过低请升级');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
if(index==2){
|
||
if(this.facilityId2==''){
|
||
uni.showToast({
|
||
title:'请先选择调入仓库',
|
||
icon:"none",
|
||
duration: 2000
|
||
});
|
||
return
|
||
}else{
|
||
this.facilityId_search=this.facilityId2
|
||
this.show_search_location_index=index;
|
||
// 允许从相机和相册扫码
|
||
let _this = this;
|
||
jweixin.scanQRCode({
|
||
desc: 'scanQRCode desc',
|
||
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
|
||
scanType: ['qrCode'], // 可以指定扫二维码还是条形码(一维码),默认二者都有"qrCode", "barCode"
|
||
success: function(res) {
|
||
if (res.errMsg != 'scanQRCode:ok') {
|
||
uni.showToast({
|
||
title: '扫描结果:' + res.resultStr,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
} else {
|
||
//扫码正确
|
||
let resultStr = res.resultStr;
|
||
try {
|
||
resultStr = JSON.parse(resultStr);
|
||
if (resultStr.facilityLocationId) {
|
||
|
||
_this.getQrCodeInfo1(resultStr.facilityLocationId);
|
||
} else {
|
||
uni.showToast({
|
||
title: '二维码错误,请扫描正确的二维码',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
} catch (e) {
|
||
uni.showToast({
|
||
title: '二维码错误,请扫描正确的二维码',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
}
|
||
// 回调
|
||
},
|
||
error: function(res) {
|
||
uni.showToast({
|
||
title: 'error:' + res,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
if (res.errMsg.indexOf('function_not_exist') > 0) {
|
||
alert('版本过低请升级');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
},
|
||
//调用接口获取二维码信息
|
||
getQrCodeInfo(facilityLocationId) {
|
||
var _this = this
|
||
this.$http
|
||
.request({
|
||
url: '/apis/facilityLocation/detail',
|
||
params: {
|
||
id: facilityLocationId,
|
||
},
|
||
method: 'GET'
|
||
})
|
||
.then(res => {
|
||
if (res.data.code == 0) {
|
||
if(res.data.data.facilityId==_this.facilityId) {
|
||
_this.dataItem2.valueName=res.data.data.name
|
||
_this.facilityLocationId=res.data.data.id
|
||
_this.qrCodeProps.facilityLocationId=res.data.data.id
|
||
} else {
|
||
uni.showToast({
|
||
title: '对不起,当前扫描的仓位不属于所选仓库,请核对后重新操作。',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
_this.dataItem2.valueName=''
|
||
_this.facilityLocationId=''
|
||
_this.qrCodeProps.facilityLocationId=''
|
||
}
|
||
|
||
}else{
|
||
uni.showToast({
|
||
title: res.data.msg? res.data.msg:'扫码失败',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
});
|
||
},
|
||
//调用接口获取二维码信息
|
||
getQrCodeInfo1(facilityLocationId) {
|
||
var _this = this
|
||
this.$http
|
||
.request({
|
||
url: '/apis/facilityLocation/detail',
|
||
params: {
|
||
id: facilityLocationId,
|
||
},
|
||
method: 'GET'
|
||
})
|
||
.then(res => {
|
||
if (res.data.code == 0) {
|
||
if(res.data.data.facilityId==_this.facilityId2) {
|
||
_this.dataItem4.valueName=res.data.data.name
|
||
_this.facilityLocationId2=res.data.data.id
|
||
|
||
} else {
|
||
uni.showToast({
|
||
title: '对不起,当前扫描的仓位不属于所选仓库,请核对后重新操作。',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
_this.dataItem4.valueName=''
|
||
_this.facilityLocationId2=''
|
||
|
||
}
|
||
|
||
}else{
|
||
uni.showToast({
|
||
title: res.data.msg? res.data.msg:'扫码失败',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
});
|
||
},
|
||
submitData(data){
|
||
if(this.facilityId==''){
|
||
uni.showToast({
|
||
title: '请先选择调出仓库',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
return
|
||
}
|
||
if(this.facilityId2==''){
|
||
uni.showToast({
|
||
title: '请先选择调入仓库',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
return
|
||
}
|
||
if(data.length==0){
|
||
uni.showToast({
|
||
title: '请先扫码',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
return
|
||
}
|
||
let _this=this;
|
||
//验证扫码的仓库仓位都是一样的
|
||
let flag=true;
|
||
if(this.facilityId!=''){
|
||
data.forEach(p=>{
|
||
if(p.facilityId!=this.facilityId){
|
||
flag=false;
|
||
}
|
||
})
|
||
}
|
||
if(this.facilityLocationId!=''){
|
||
data.forEach(p=>{
|
||
if(p.facilityLocationId!=this.facilityLocationId){
|
||
flag=false;
|
||
}
|
||
})
|
||
}
|
||
if(!flag){
|
||
uni.showToast({
|
||
title:"调出仓库仓位不一样不可以提交",
|
||
icon:"none",
|
||
duration: 2000
|
||
});
|
||
return
|
||
}
|
||
let bodyDetail=[];
|
||
data.forEach(p=>{
|
||
let json_={
|
||
// materielId:p.materielId,
|
||
// batch:p.batch?p.batch:'',
|
||
count:p.count?p.count:0,
|
||
qrcodeId:p.qrcodeId,
|
||
stockId:p.stockId,
|
||
inFacility:_this.facilityId2,
|
||
inLocation:_this.facilityLocationId2
|
||
}
|
||
// if(this.qrCodeProps.contractNo){
|
||
// json_.sourceType=277//生产计划的源单类型
|
||
// json_.sourceId=this.qrCodeProps.id
|
||
// json_.sourceCode=this.qrCodeProps.contractNo
|
||
// }
|
||
bodyDetail.push(json_)
|
||
})
|
||
|
||
this.$http.request({
|
||
url: '/apis/allot/add',
|
||
params: {
|
||
allotTime:_this.getCurrentTime(),
|
||
qrSign:1,
|
||
body:encodeURIComponent(JSON.stringify(bodyDetail))
|
||
},
|
||
}).then(res => {
|
||
if(res.data.code==0){
|
||
uni.showToast({
|
||
title:"提交成功",
|
||
icon:"none",
|
||
duration: 2000
|
||
});
|
||
|
||
this.refresh()
|
||
}else{
|
||
uni.showToast({
|
||
title:res.data.msg?res.data.msg:"提交失败",
|
||
icon:"none",
|
||
duration: 2000
|
||
});
|
||
}
|
||
|
||
}).catch(err => {
|
||
uni.showToast({
|
||
title:err,
|
||
icon:"none",
|
||
duration: 2000
|
||
});
|
||
});
|
||
},
|
||
//获取当前时间
|
||
getCurrentTime(){
|
||
let date = new Date();
|
||
let y = date.getFullYear();
|
||
let MM = date.getMonth() + 1;
|
||
MM = MM < 10 ? ('0' + MM) : MM;
|
||
let d = date.getDate();
|
||
d = d < 10 ? ('0' + d) : d;
|
||
let h = date.getHours();
|
||
h = h < 10 ? ('0' + h) : h;
|
||
let m = date.getMinutes();
|
||
m = m < 10 ? ('0' + m) : m;
|
||
let s = date.getSeconds();
|
||
s = s < 10 ? ('0' + s) : s;
|
||
return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
|
||
},
|
||
//提交完清空数据
|
||
refresh(){
|
||
this.dataItem1.valueName=""
|
||
this.dataItem2.valueName=""
|
||
this.dataItem3.valueName=""
|
||
this.dataItem4.valueName=""
|
||
this.facilityId=""
|
||
this.facilityLocationId=""
|
||
this.facilityId2=""
|
||
this.facilityLocationId2=""
|
||
this.qrCodeProps.clear=true;
|
||
}
|
||
},
|
||
watch:{
|
||
search_value_facility(newv){
|
||
if(this.show_search_facility_index==1){
|
||
this.dataItem1.valueName=newv.name
|
||
this.facilityId=newv.id;
|
||
this.qrCodeProps.facilityId=newv.id;
|
||
}else if(this.show_search_facility_index==2){
|
||
this.dataItem3.valueName=newv.name
|
||
this.facilityId2=newv.id;
|
||
// this.qrCodeProps.facilityId=newv.id;
|
||
}
|
||
|
||
},
|
||
search_value_location(newv){
|
||
if(this.show_search_location_index==1){
|
||
this.dataItem2.valueName=newv.name
|
||
this.facilityLocationId=newv.id
|
||
this.qrCodeProps.facilityLocationId=newv.id;
|
||
}else if(this.show_search_location_index==2){
|
||
this.dataItem4.valueName=newv.name
|
||
this.facilityLocationId2=newv.id
|
||
// this.qrCodeProps.facilityLocationId=newv.id;
|
||
}
|
||
},
|
||
facilityId(newv,oldv){
|
||
if(newv!=oldv&&oldv!=''){
|
||
this.facilityLocationId='';
|
||
this.dataItem2.valueName=''
|
||
this.qrCodeProps.facilityLocationId=''
|
||
}
|
||
},
|
||
facilityId2(newv,oldv){
|
||
if(newv!=oldv&&oldv!=''){
|
||
this.facilityLocationId2='';
|
||
this.dataItem4.valueName=''
|
||
// this.qrCodeProps.facilityLocationId=''
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</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>
|