<template>
|
<view class="page-containter page-containter-x">
|
<view class="page-header">
|
<page-header-x ctitle="手动入库" />
|
<user-row></user-row>
|
</view>
|
<view class="page-content">
|
<view class="add_site">
|
<u-form :model="addForm" ref="addRef" label-width="180">
|
|
<u-form-item label="入库类型:">
|
<u-input placeholder="请选择入库类型" v-model="addForm.inStockType" type="select" :border="true"
|
@click="StockType = true"></u-input>
|
<u-action-sheet :list="StockTypeList" v-model="StockType" @click="confirmInStock"></u-action-sheet>
|
</u-form-item>
|
|
<!-- 托盘号 -->
|
<u-form-item label="站点选择:">
|
<u-input placeholder="请选择站点" v-model="addForm.station" type="select" :border="true"
|
@click="siteFlag = true"></u-input>
|
<u-action-sheet :list="siteList" v-model="siteFlag" @click="confirm"></u-action-sheet>
|
</u-form-item>
|
<u-form-item label="空托盘类型:" v-if="Empty">
|
<u-input placeholder="请选择空托盘类型" v-model="addForm.emptyType" type="select" :border="true"
|
@click="emptyTypeFlag = true"></u-input>
|
<u-action-sheet :list="emptyTypeList" v-model="emptyTypeFlag" @click="confirmEmpty"></u-action-sheet>
|
</u-form-item>
|
<u-form-item label="托盘号:">
|
<u-input v-model="addForm.containerCode" :focus="true" placeholder="请扫描托盘条码" border></u-input>
|
</u-form-item>
|
|
<!-- 物料编码 -->
|
<u-form-item label="添加流水号" v-if="noEmpty">
|
<u-input v-model="productCode" :focus="true" @input="getCode" placeholder=" 请扫描条码" border></u-input>
|
</u-form-item>
|
<u-form-item label="物料编号:" v-if="noEmpty">
|
<!-- <u-input type="textarea" v-model=""></u-input> -->
|
<text>{{addForm.materialCode}}</text><!-- -->
|
</u-form-item>
|
<u-form-item label="数量:" v-if="noEmpty">
|
<text>{{addForm.quantity}}</text>
|
</u-form-item>
|
</u-form>
|
<view class="btns-row">
|
<view class="btn-block"><u-button type="error" @click="cancalAdd">取消</u-button></view>
|
<view class="divider-block"></view>
|
<view class="btn-block"><u-button type="primary" @click="confirmAdd">确定</u-button></view>
|
</view>
|
<view class="list-frame" v-if="noEmpty">
|
<view class="list-item">
|
<view class="list-no">序号</view>
|
<view class="list-value">流水号</view>
|
<view class="list-value">操作</view>
|
</view>
|
<view class="list-item" v-for="(item,index) in addForm.dataList" :key="'addsite-list-'+index">
|
<view class="list-no">{{item.id}}</view>
|
<view class="list-value">{{item.serialNumber}}</view>
|
<view class="btn-block"><u-button type="primary" @click="subList(index)">删除</u-button></view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
handInStock
|
} from '../../api/hand.js'
|
import PageHeaderX from '../../compontents/PageHeaderX.vue'
|
import UserRow from '../../compontents/UserRow.vue'
|
import $config from '../../util/config.js'
|
export default {
|
components: {
|
"page-header-x": PageHeaderX,
|
UserRow
|
},
|
data() {
|
return {
|
|
materialList: [], //物料列表数据
|
addForm: {
|
materialCode: '扫描后可自动获取',
|
station: '',
|
quantity: 0,
|
containerCode: '',
|
dataList: [],
|
inStockType:"",
|
emptyType:"",
|
userName:''
|
},
|
productCode: '',
|
result: {},
|
siteFlag: false,
|
StockType:false,
|
emptyTypeFlag:false,
|
siteList: [],
|
StockTypeList:[{text:"空托盘"},{text:"缸体"},{text:"缸盖"}],
|
emptyTypeList:[{text:"缸体空托盘"},{text:"缸盖空托盘"}],
|
Empty:true,
|
noEmpty:false
|
}
|
},
|
watch: {
|
addForm: {
|
handler(val) {
|
if (val.productCode == '') {
|
|
} else {
|
|
|
}
|
},
|
deep: true
|
}
|
},
|
/* 通常只用于获取传递参数 */
|
onLoad(options) {
|
console.log('load')
|
if (options.type === 'body') {
|
this.siteList = $config.sites.handInStock;
|
} else {
|
this.siteList = $config.sites.handInStock;
|
}
|
},
|
//页面加载事件
|
onReady() {
|
this.addForm.inStockType="空托盘"
|
// this.getMaterialList();
|
},
|
|
//下拉刷新
|
onPullDownRefresh() {
|
this.clearAddForm();
|
//重新获取物料列表
|
uni.stopPullDownRefresh();
|
},
|
methods: {
|
confirm(index) {
|
|
this.addForm.station = this.siteList[index].text;
|
},
|
confirmInStock(index){
|
this.$nextTick(function(){
|
this.addForm.station=''
|
})
|
this.$nextTick(function(){
|
this.addForm.materialCode=''
|
})
|
this.$nextTick(function(){
|
this.addForm.dataList= []
|
})
|
this.$nextTick(function(){
|
this.addForm.quantity=0
|
})
|
this.$nextTick(function(){
|
this.addForm.containerCode=''
|
})
|
this.$nextTick(function(){
|
this.addForm.emptyType=''
|
})
|
if(index==0)
|
{
|
this.Empty=true
|
this.noEmpty=false
|
}
|
else
|
{
|
this.Empty=false
|
this.noEmpty=true
|
}
|
this.addForm.inStockType = this.StockTypeList[index].text;
|
},
|
confirmEmpty(index){
|
this.addForm.emptyType = this.emptyTypeList[index].text;
|
},
|
change(e) {
|
console.log(e.detail);
|
},
|
edit(item) {
|
uni.showToast({
|
title: item.name,
|
icon: 'none'
|
});
|
},
|
subList(index)
|
{
|
this.addForm.dataList.splice(index,1);
|
},
|
//分割数据
|
getCode() {
|
|
if(this.productCode.trim().split('*').length==3)
|
{
|
uni.hideKeyboard();
|
var splits = this.productCode.trim().split('*');
|
if(this.addForm.materialCode!=='扫描后可自动获取' )
|
{
|
if(this.addForm.materialCode!== splits[0])
|
{
|
uni.showToast({
|
icon: 'error',
|
title: '不同物料不可组盘-'+splits[0]
|
});
|
return;
|
}
|
|
}
|
this.addForm.materialCode = splits[0];
|
let num = this.addForm.dataList.length;
|
var obj = {};
|
obj.id = num + 1;
|
var serials=splits[2].split(' ');
|
obj.serialNumber =serials.length>1?serials[0].trim():splits[2] ;
|
var ishave=0;
|
this.addForm.dataList.forEach(item=>{
|
if(item.serialNumber==obj.serialNumber)
|
{
|
|
uni.showToast({
|
icon: 'error',
|
title: '已存在-'+obj.serialNumber
|
});
|
ishave=1;
|
};
|
|
});
|
if(ishave==1)
|
{
|
this.$nextTick(function(){
|
this.productCode ='';
|
})
|
return;
|
}
|
this.addForm.dataList=this.addForm.dataList.reverse();
|
this.addForm.dataList.push(obj);
|
this.addForm.dataList=this.addForm.dataList.reverse();
|
this.addForm.quantity = this.addForm.dataList.length;
|
|
this.$nextTick(function(){
|
this.productCode ='';
|
})
|
}
|
else{
|
this.$nextTick(function(){
|
this.productCode ='';
|
})
|
uni.showToast({
|
icon: 'error',
|
title: '条码格式错误-'+this.productCode
|
})
|
|
}
|
|
},
|
|
//清空添加数据
|
clearAddForm() {
|
this.addForm.materialCode = '';
|
this.addForm.station = '';
|
this.addForm.quantity = 0;
|
this.addForm.containerCode = '';
|
this.addForm.dataList = [];
|
this.productCode = '扫码可自动获取';
|
this.Empty=true;
|
this.noEmpty=false;
|
|
},
|
//聚焦事件
|
focus() {
|
//阻止软件盘弹出
|
uni.hideKeyboard()
|
|
},
|
//取消添加
|
cancalAdd() {
|
uni.navigateBack({
|
delta: 1
|
})
|
},
|
//提交添加
|
confirmAdd() {
|
//验证 参数不为空
|
if(this.addForm.inStockType==="空托盘")
|
{
|
if(this.addForm.station==="")
|
{
|
uni.showToast({
|
title: '请选择站点号',
|
icon: 'error'
|
})
|
return
|
}
|
if(this.addForm.emptyType==="")
|
{
|
uni.showToast({
|
title: '请选择托盘类型',
|
icon: 'error'
|
})
|
return
|
}
|
if(this.addForm.containerCode==="")
|
{
|
uni.showToast({
|
title: '请扫描托盘号',
|
icon: 'error'
|
})
|
return
|
}
|
}
|
else
|
{
|
if(this.addForm.station==="")
|
{
|
uni.showToast({
|
title: '请选择站点号',
|
icon: 'error'
|
})
|
return
|
}
|
if(this.addForm.containerCode==="")
|
{
|
uni.showToast({
|
title: '请扫描托盘号',
|
icon: 'error'
|
})
|
return
|
}
|
if(this.addForm.dataList.length==0)
|
{
|
uni.showToast({
|
title: '请添加流水号',
|
icon: 'error'
|
})
|
return
|
}
|
}
|
|
this.addForm.userName= uni.getStorageSync('_username');
|
handInStock(this.addForm).then(res => {
|
uni.showToast({
|
title: '添加成功',
|
icon: 'success'
|
})
|
//关闭当前页面
|
setTimeout(() => {
|
//关闭当前页面
|
this.cancalAdd();
|
}, 2000)
|
}).catch(() => {
|
|
})
|
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.add_site {
|
width: 94%;
|
margin: 10rpx auto;
|
font-size: 30rpx;
|
text-align: left;
|
|
.btns-row{
|
display: flex;
|
padding: 12rpx 0;
|
.btn-block{
|
width: 10rpx;
|
flex: 1;
|
}
|
.divider-block{
|
width: 8px;
|
flex-shrink: 0;
|
}
|
}
|
|
.list-item{
|
display: flex;
|
padding-bottom: 16rpx;
|
border-bottom: 1px solid #dcdcdc;
|
.list-no{
|
width: 100rpx;
|
flex-shrink: 0;
|
display: flex;
|
align-items: center;
|
}
|
.list-value{
|
flex: 1;
|
word-break:break-all;
|
word-wrap:break-word;
|
}
|
}
|
}
|
</style>
|