<template>
|
<view class="page-containter page-containter-x">
|
<view class="page-header">
|
<page-header-x :ctitle="page_ctitle" />
|
<user-row></user-row>
|
</view>
|
<view class="page-content">
|
<view class="add_site">
|
<view class="list-frame">
|
<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>
|
<u-form :model="addForm" ref="addRef" label-width="180">
|
<u-form-item label="数量:">
|
<text>{{addForm.quantity}}</text>
|
</u-form-item>
|
<!-- 物料编码 -->
|
<u-form-item label="">
|
<u-input v-model="productCode" :focus="focus_productCode" @input="getCode" placeholder=" 请扫描条码" border></u-input>
|
</u-form-item>
|
<u-form-item label="">
|
<u-input v-model="productCode2" placeholder=" 请输入条码" border></u-input>
|
<u-button type="primary" @click="getCode2">确定输入</u-button>
|
</u-form-item>
|
<u-form-item label="物料编号:">
|
<!-- <u-input type="textarea" v-model=""></u-input> -->
|
<text>{{addForm.productCode}}</text><!-- -->
|
</u-form-item>
|
<!-- 供应商 -->
|
<u-form-item label="供应商:">
|
<!-- <u-input type="textarea" v-model=""></u-input> -->
|
<text>{{addForm.supplier}}</text><!-- -->
|
</u-form-item>
|
|
<!-- 物料名称 -->
|
<u-form-item label="物料名称:">
|
<!-- <u-input type="textarea" v-model=""></u-input> -->
|
<text>{{materialName}}</text>
|
</u-form-item>
|
<!-- 托盘号 -->
|
<u-form-item label="托盘号:">
|
<u-input v-model="addForm.containerCode" placeholder="请扫描托盘条码" border></u-input>
|
</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="目标点选择(可选,如果选择,表示物料不入立库,直达上线点):">
|
<u-input placeholder="请选择目标点" v-model="addForm.toStieCode" type="select" :border="true"
|
@click="to_siteFlag = true"></u-input>
|
<u-action-sheet :list="to_siteList" v-model="to_siteFlag" @click="confirm_toPlace"></u-action-sheet>
|
</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>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
getMaterial,
|
addSite,
|
getInCode,
|
validateSingalSerialNumber
|
} from '../../api/addSite/addSite.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 {
|
addEditFlag:'add',//新增或编辑标记 【EditBy shaocx,2022-03-31】
|
focus_productCode:true,
|
page_ctitle:'新建组盘',
|
materialList: [], //物料列表数据
|
addForm: {
|
orderCodeId:0,//组盘表单的ID,编辑用【EditBy shaocx,2022-03-31】
|
type:'', //类型:body header
|
productCode: '扫描后可自动获取',
|
station: '',
|
supplier:'扫描后可自动获取',//供应商
|
quantity: 0,
|
containerCode: '',//托盘号
|
dataList: []
|
},
|
productCode: '',
|
productCode2:'',
|
materialName: '扫描后可自动获取', //物料名称
|
result: {},
|
siteFlag: false,
|
to_siteFlag: false,
|
siteList: [],
|
to_siteList: [],
|
}
|
},
|
watch: {
|
addForm: {
|
handler(val) {
|
if (val.productCode == '') {
|
this.materialName = '扫描后可自动获取';
|
} else {
|
|
this.materialList.forEach(item => {
|
if (item.productCode == this.addForm.productCode) {
|
this.materialName = item.materialName;
|
}
|
})
|
}
|
},
|
deep: true
|
}
|
},
|
/* 通常只用于获取传递参数 */
|
onLoad(options) {
|
console.log('load')
|
this.addEditFlag=options.addEditFlag;//新增或编辑标记 【EditBy shaocx,2022-03-31】
|
if(this.addEditFlag=='edit'){
|
//debugger
|
this.addForm.orderCodeId=options.orderCodeId;
|
}
|
this.addForm.type=options.type;//记住type值 【EditBy shaocx,2022-03-16】
|
if (options.type === 'body') {
|
this.siteList = $config.sites.offlineBody;
|
this.to_siteList=$config.sites.onLineBody;
|
this.page_ctitle='组盘(缸体)';
|
} else {
|
this.siteList = $config.sites.offlineHeader;
|
this.to_siteList=$config.sites.onLineHeader;
|
this.page_ctitle='组盘(缸盖)';
|
}
|
},
|
//页面加载事件
|
onReady() {
|
|
this.getMaterialList();
|
if(this.addForm.orderCodeId!=0){
|
this.getInCode();
|
}
|
},
|
|
//下拉刷新
|
onPullDownRefresh() {
|
this.clearAddForm();
|
//重新获取物料列表
|
uni.stopPullDownRefresh();
|
},
|
methods: {
|
confirm(index) {
|
this.addForm.station = this.siteList[index].text;
|
},
|
confirm_toPlace(index) {
|
this.addForm.toStieCode = this.to_siteList[index].text;
|
},
|
change(e) {
|
console.log(e.detail);
|
},
|
edit(item) {
|
uni.showToast({
|
title: item.name,
|
icon: 'none'
|
});
|
},
|
subList(index)
|
{
|
//debugger;
|
this.addForm.dataList.splice(index,1);
|
this.addForm.quantity = this.addForm.dataList.length;
|
},
|
getCode2(){
|
this.productCode=this.productCode2;
|
this.getCode();
|
},
|
//分割数据
|
getCode() {
|
|
if(this.productCode.trim().split('*').length==3)
|
{
|
uni.hideKeyboard();
|
var splits = this.productCode.trim().split('*');
|
if(this.addForm.productCode!=='扫描后可自动获取' )
|
{
|
if(this.addForm.productCode!== splits[0])
|
{
|
uni.showToast({
|
icon: 'none',
|
title: '不同物料不可组盘-'+splits[0]
|
});
|
this.getFocus();
|
return;
|
}
|
}
|
if(this.addForm.supplier!=='扫描后可自动获取' )
|
{
|
if(this.addForm.supplier!== splits[1])
|
{
|
uni.showToast({
|
icon: 'none',
|
title: '不同供应商不可组盘-'+splits[1]
|
});
|
this.getFocus();
|
return;
|
}
|
|
}
|
this.addForm.supplier = splits[1];
|
this.addForm.productCode = 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: 'none',
|
title: '已存在流水号'+obj.serialNumber
|
});
|
ishave=1;
|
};
|
|
});
|
if(ishave==1)
|
{
|
this.$nextTick(function(){
|
this.productCode ='';
|
})
|
this.getFocus();
|
return;
|
}
|
|
//增加验证流水号校验【Editby shaocx,2022-03-31】
|
validateSingalSerialNumber(this.addForm.orderCodeId,obj.serialNumber,this.addForm.productCode).then(res => {
|
//debugger
|
//this.addForm = res.data;
|
|
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;
|
let matObj = this.materialList.find(item => item.materialCode == this.result);
|
if (matObj != undefined) {
|
this.materialName = matObj.materialName;
|
}
|
this.$nextTick(function(){
|
this.productCode ='';
|
})
|
this.getFocus();
|
|
}).catch(() => {
|
|
})
|
|
|
}
|
else{
|
this.$nextTick(function(){
|
this.productCode ='';
|
})
|
this.getFocus();
|
uni.showToast({
|
icon: 'none',
|
title: '条码格式错误-'+this.productCode
|
})
|
|
}
|
|
},
|
getFocus(){
|
this.focus_productCode=false;
|
this.$nextTick(function(){
|
this.focus_productCode=true;
|
})
|
},
|
//获取物料列表
|
getMaterialList() {
|
getMaterial().then(res => {
|
//debugger
|
this.materialList = res.data;
|
}).catch(() => {
|
|
})
|
},
|
//获取组盘数据
|
getInCode() {
|
getInCode(this.addForm.orderCodeId).then(res => {
|
//debugger
|
this.addForm = res.data;
|
}).catch(() => {
|
|
})
|
},
|
//清空添加数据
|
clearAddForm() {
|
this.addForm.productCode = '';
|
this.addForm.station = '';
|
this.addForm.toStieCode = '';
|
this.addForm.quantity = 0;
|
this.addForm.containerCode = '';
|
this.addForm.dataList = [];
|
this.productCode = '扫码可自动获取';
|
this.materialName = '扫码可自动获取';
|
|
},
|
//聚焦事件
|
focus() {
|
//阻止软件盘弹出
|
uni.hideKeyboard()
|
|
|
},
|
//取消添加
|
cancalAdd() {
|
uni.navigateBack({
|
delta: 1
|
})
|
},
|
//提交添加
|
confirmAdd() {
|
|
//debugger
|
//this.addForm.quantity -= 0;
|
if (this.addForm.productCode && this.addForm.station&&this.addForm.containerCode) {
|
addSite(this.addForm).then(res => {
|
uni.showToast({
|
title: '添加成功',
|
icon: 'success'
|
})
|
//关闭当前页面
|
setTimeout(() => {
|
//关闭当前页面
|
//this.cancalAdd();
|
//跳转到前一页
|
var url='';
|
//debugger
|
if(this.addForm.type ==='body'){
|
url='cylinder/cylinder';
|
}else{
|
url='cylinderHead/cylinderHead';
|
}
|
uni.navigateTo({
|
url:`../`+url
|
})
|
}, 2000)
|
}).catch(() => {
|
|
})
|
} else {
|
uni.showToast({
|
title: '参数不规范'
|
})
|
}
|
}
|
}
|
}
|
</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>
|