<template>
|
<a-spin :spinning="loading">
|
<div class="wms-in-bound-page">
|
<div class="in-bound-page-block block-one">
|
<search-box
|
label="托盘号"
|
v-model="prevFrom.containter"
|
:msg-type="msgType.containter"
|
:msg="msg.containter"
|
:label-width="labelWidth"
|
placeholder="请输入..."
|
@search="onContainterSearch"
|
@reset="onContainterReset"
|
/>
|
</div>
|
<div class="in-bound-page-block block-two">
|
<div class="radios-box">
|
<div class="label" :style="{width:labelWidth}">工段:</div>
|
<div class="content">
|
<div class="radio-group">
|
<a-radio-group v-model="prevFrom.workType">
|
<a-radio v-for="(item,index) in selectList.workTypes" :value="item.code" :key="'work-type-radio-'+index">{{item.name}}</a-radio>
|
</a-radio-group>
|
</div>
|
<div v-if="msg.workType" class="msg-row">
|
<a-alert :message="msg.workType" type="error" show-icon />
|
</div>
|
</div>
|
</div>
|
<search-box
|
label="物料码"
|
v-model="prevFrom.material"
|
:msg-type="msgType.material"
|
:msg="msg.material"
|
:label-width="labelWidth"
|
placeholder="请输入..."
|
:btn-disabled="materialDisabled"
|
@search="onMaterialSearch"
|
@reset="onMaterialReset"
|
/>
|
<div class="table-box">
|
<a-table :columns="columns" :data-source="list" :row-key="tableKey" :pagination="false">
|
<template slot="index" slot-scope="text, record, index">{{index+1}}</template>
|
<template slot="input" slot-scope="text, record">
|
<a-input-number v-model="record.bindquantity" :min="0" />
|
</template>
|
<template slot="action" slot-scope="text, record, index">
|
<a-button type="danger" @click.stop="onDel(record,index)" :disabled="materialDisabled">删 除</a-button>
|
</template>
|
</a-table>
|
</div>
|
</div>
|
<div class="in-bound-page-block block-three">
|
<a-row :gutter="16">
|
<a-col :md="8" :sm="24">
|
<input-layout label="起始位置" :label-width="labelWidth">
|
<a-input placeholder="请输入..." v-model.trim="sufFrom.entrance" allowClear />
|
</input-layout>
|
</a-col>
|
<a-col :md="8" :sm="24">
|
<input-layout label="目标仓库" :label-width="labelWidth">
|
<a-select v-model="sufFrom.areaId" placeholder="请选择..." style="width:100%;" allowClear>
|
<a-select-option v-for="(item,index) in selectList.areas" :value="item.areaId" :key="'area-sel-'+index">{{item.areaName}}</a-select-option>
|
</a-select>
|
</input-layout>
|
</a-col>
|
<a-col :md="8" :sm="24">
|
<input-layout label="目标库位号/工位" :label-width="labelWidth2">
|
<a-input placeholder="请输入..." v-model.trim="sufFrom.placecode" allowClear />
|
</input-layout>
|
</a-col>
|
</a-row>
|
</div>
|
<div class="bottom-btns-view">
|
<a-button type="primary" :disabled="bindBtnDisabled" @click="onBind">组盘</a-button>
|
<a-button type="danger" :disabled="manualIntranceBtnDisabled" @click="onManualIntrance">人工入库</a-button>
|
<a-button type="primary" :disabled="autoIntranceBtnDisabled" @click="onAutoIntrance">自动入库</a-button>
|
<a-button type="danger" :disabled="moveBtnDisabled" @click="onTransfer">移库</a-button>
|
<a-button @click="onReset">重 置</a-button>
|
</div>
|
</div>
|
</a-spin>
|
</template>
|
<script>
|
import SearchBox from './searchBox.vue'
|
import InputLayout from './inputLayout.vue'
|
import {
|
BindEntranceGetContainer,
|
BindEntranceGetMaterial,
|
BindAction,
|
BindEntranceGetSelects,
|
BindEntranceManualWare,
|
BindEntranceAutoWare,
|
BindEntranceTransfer
|
} from '@/api/modular/main/BindEntranceManage'
|
export default {
|
name:'wmsBindEntrancePage',
|
components:{SearchBox,InputLayout},
|
data(){
|
return {
|
loading:false,
|
labelWidth:'75px',
|
labelWidth2:'120px',
|
containter:null,
|
materialDisabled:false,
|
msg:{
|
containter:'',
|
material:'',
|
workType:''
|
},
|
msgType:{
|
containter:'info',
|
material:'error'
|
},
|
prevFrom:{
|
containter:'',
|
material:'',
|
workType:''
|
},
|
sufFrom:{
|
entrance:'',
|
areaId:undefined,
|
placecode:''
|
},
|
selectList:{
|
workTypes:[],
|
areas:[]
|
},
|
tableKey:'tableKey',
|
list:[],
|
columns:[
|
{
|
dataIndex:'index',
|
title:'序号',
|
fixed:'left',
|
width:'60',
|
scopedSlots: { customRender: 'index' }
|
},
|
{
|
dataIndex:'materialno',
|
title:'物料编号'
|
},
|
{
|
dataIndex:'materialname',
|
title:'物料名称'
|
},
|
{
|
dataIndex:'materialspec',
|
title:'尺寸'
|
},
|
{
|
dataIndex:'materialDensity',
|
title:'密度'
|
},
|
{
|
dataIndex:'materialbatch',
|
title:'批次'
|
},
|
{
|
dataIndex:'bindquantity',
|
title:'数量',
|
scopedSlots: { customRender: 'input' }
|
},
|
{
|
dataIndex:'action',
|
title:'操作',
|
fixed:'right',
|
width:'70',
|
scopedSlots: { customRender: 'action' }
|
}
|
]
|
}
|
},
|
computed:{
|
bindBtnDisabled(){
|
let res = true;
|
if (this.containter && this.containter.containerstatus!==3 && this.list.length>0) {
|
res = false;
|
}
|
return res;
|
},
|
manualIntranceBtnDisabled(){
|
let res = true;
|
//只有托盘表示空托入库 ; 只有物料表示无托物料入库
|
if ((this.containter || this.list.length>0) && (this.sufFrom.placecode || this.sufFrom.areaId)) {
|
res = false;
|
}
|
return res;
|
},
|
autoIntranceBtnDisabled(){
|
let res = true;
|
//只有托盘表示空托入库 ; 只有物料表示无托物料入库
|
if ((this.containter || this.list.length>0) && this.sufFrom.entrance && (this.sufFrom.placecode || this.sufFrom.areaId)) {
|
res = false;
|
}
|
return res;
|
},
|
moveBtnDisabled(){
|
let res = true;
|
if (this.sufFrom.placecode && this.materialDisabled) {
|
res = false;
|
}
|
return res;
|
}
|
},
|
methods:{
|
getSelectList(){
|
this.loading = true;
|
BindEntranceGetSelects().then((d)=>{
|
this.selectList.areas = d.data
|
this.loading = false;
|
}).catch(()=>{
|
this.loading = false;
|
})
|
},
|
onContainterReset(){
|
this.resetContainter()
|
},
|
onContainterSearch(){
|
if (!this.prevFrom.containter) {
|
this.msgType.containter = 'error'
|
this.msg.containter = '请输入托盘号!';
|
return false;
|
}
|
|
this.msg.containter = ''
|
this.loading = true;
|
this.getContainterInfo((f)=>{
|
this.loading = false;
|
})
|
},
|
onMaterialReset(){
|
this.resetMaterial()
|
},
|
resetContainter(){
|
this.msg.containter = '';
|
this.prevFrom.containter = ''
|
this.containter = null;
|
this.materialDisabled = false;
|
},
|
resetMaterial(){
|
this.msg.material = '';
|
this.prevFrom.material = ''
|
},
|
resetSufFrom(){
|
this.sufFrom.entrance = ''
|
this.sufFrom.placecode = ''
|
},
|
onMaterialSearch(){
|
if (!this.prevFrom.workType) {
|
this.msg.workType = '请选择工段!';
|
return false;
|
}
|
this.msg.workType = ''
|
if (!this.prevFrom.material) {
|
this.msg.material = '请输入物料编号!';
|
return false;
|
}
|
this.msg.material = ''
|
this.loading = true;
|
this.getMaterialInfo((f)=>{
|
this.loading = false;
|
})
|
},
|
getContainterInfo(callback){
|
let params = {Containercode:this.prevFrom.containter}
|
BindEntranceGetContainer(params).then((d)=>{
|
if (d.data) {
|
let _temp1 = this.$options.filters['dictType']('container_type',d.data.wmsContainer.containertype)
|
let _temp2 = this.$options.filters['dictType']('container_status',d.data.wmsContainer.containerstatus)
|
this.msgType.containter = 'info'
|
this.msg.containter = `材质:${_temp1},状态:${_temp2}`;
|
this.containter = d.data.wmsContainer
|
this.list = (d.data.wmsMaterials || []).map((mapItem)=>{
|
return this.createTableKey(mapItem)
|
})
|
if (d.data.wmsContainer.containerstatus===3) {
|
this.materialDisabled = true;
|
}
|
callback && callback(true)
|
} else {
|
this.msgType.containter = 'error'
|
this.msg.containter = d.message || '查无信息!';
|
this.containter = null;
|
this.list = []
|
callback && callback(false)
|
}
|
}).catch((err)=>{
|
this.containter = null;
|
this.list = []
|
callback && callback(false)
|
})
|
},
|
getMaterialInfo(callback){
|
let params = {Materialno:this.prevFrom.material,LesWorkshopSection:this.prevFrom.workType}
|
BindEntranceGetMaterial(params).then((d)=>{
|
if (d.data) {
|
let arr = (d.data || []).map((mapItem)=>{
|
return this.createTableKey(mapItem)
|
})
|
this.checkInList(arr)
|
callback && callback(true)
|
} else {
|
this.msg.material = d.message || '查无信息!';
|
callback && callback(false)
|
}
|
}).catch((err)=>{
|
callback && callback(false)
|
})
|
},
|
/* 创建唯一键,根据业务逻辑(判断同种物料的规则)改动 */
|
createTableKey(obj){
|
obj[this.tableKey] = obj.materialno
|
return obj
|
},
|
checkInList(arr){
|
let newArr = [], reCount = 0;
|
arr.forEach((item)=>{
|
let f = false;
|
for (let i=0;i<this.list.length;i++) {
|
if (this.list[i][this.tableKey] === item[this.tableKey]) {
|
reCount++;
|
f = true
|
break;
|
}
|
}
|
if (!f) {
|
newArr.push(item)
|
}
|
})
|
this.list = [].concat(this.list,newArr)
|
if (reCount) {
|
this.$message.warning(`${reCount}笔数据已存在,未添加!`);
|
}
|
},
|
getContainterMaterials(callback){
|
let params = {ContainerName:this.prevFrom.containter}
|
WmsGetContainterList(params).then(d=>{
|
this.list = d.data || []
|
callback && callback(true)
|
}).catch(err=>{
|
this.list = []
|
callback && callback(false)
|
})
|
},
|
onDel(obj,index){
|
this.list.splice(index,1)
|
},
|
onManualIntrance(){
|
let cf = this.checkBeforeSubmit();
|
if (!cf) return false;
|
this.loading = true;
|
this.dealManualIntrance((f)=>{
|
this.loading = false;
|
if (f) {
|
this.$message.success('入库成功!');
|
this.resetContainter()
|
this.resetMaterial()
|
this.resetSufFrom()
|
this.list = [];
|
}
|
})
|
},
|
onAutoIntrance(){
|
let cf = this.checkBeforeSubmit();
|
if (!cf) return false;
|
this.loading = true;
|
this.dealAutoIntrance((f)=>{
|
this.loading = false;
|
if (f) {
|
this.$message.success('入库成功!');
|
this.resetContainter()
|
this.resetMaterial()
|
this.resetSufFrom()
|
this.list = [];
|
}
|
})
|
},
|
onBind(){
|
let cf = this.checkBeforeSubmit('bind');
|
if (!cf) return false;
|
this.loading = true;
|
this.dealBind((f)=>{
|
if (f) {
|
this.getContainterInfo((f1)=>{
|
this.loading = false;
|
this.$message.success('组盘成功!');
|
})
|
} else {
|
this.loading = false;
|
}
|
})
|
},
|
onTransfer(){
|
this.loading = true;
|
this.dealTransfer((f)=>{
|
this.loading = false;
|
if (f) {
|
this.$message.success('移库成功!');
|
this.resetContainter()
|
this.resetMaterial()
|
this.resetSufFrom()
|
this.list = [];
|
}
|
})
|
},
|
onReset(){
|
this.resetContainter()
|
this.resetMaterial()
|
this.list = [];
|
},
|
checkBeforeSubmit(type){
|
let flag=true, msg="";
|
|
if (this.list.length>0) {
|
for (let i=0;i<this.list.length;i++) {
|
if (!this.list[i].bindquantity) {
|
msg = `请确认第${i+1}笔物料的数量!`
|
flag = false;
|
}
|
if (flag && this.list[i].bindquantity!==parseInt(this.list[i].bindquantity)) {
|
msg = `第${i+1}笔物料,数量只能是正整数!`
|
flag = false;
|
}
|
}
|
} else {
|
if (type==='bind') {
|
msg = '没有物料信息!'
|
flag = false;
|
}
|
}
|
|
if (!flag && msg) {
|
this.$error({
|
title: '系统提示',
|
content: msg,
|
});
|
}
|
|
return flag;
|
},
|
dealBind(callback){
|
let params = {
|
containercode:this.containter.containercode,
|
wmsMaterials:this.list
|
}
|
BindAction(params).then(()=>{
|
callback && callback(true)
|
}).catch(()=>{
|
callback && callback(false)
|
})
|
},
|
dealManualIntrance(callback){
|
let params = {
|
containercode:this.containter?this.containter.containercode:null,
|
wmsMaterials:this.list,
|
placecode:this.sufFrom.placecode,
|
areaId:this.sufFrom.areaId
|
}
|
BindEntranceManualWare(params).then(()=>{
|
callback && callback(true)
|
}).catch(()=>{
|
callback && callback(false)
|
})
|
},
|
dealAutoIntrance(callback){
|
let params = {
|
containercode:this.containter?this.containter.containercode:null,
|
wmsMaterials:this.list,
|
placecode:this.sufFrom.placecode,
|
areaId:this.sufFrom.areaId,
|
entrance:this.sufFrom.entrance
|
}
|
BindEntranceAutoWare(params).then(()=>{
|
callback && callback(true)
|
}).catch(()=>{
|
callback && callback(false)
|
})
|
},
|
dealTransfer(callback){
|
let params = {
|
containercode:this.containter.containercode,
|
placecode:this.sufFrom.placecode
|
}
|
BindEntranceTransfer(params).then(()=>{
|
callback && callback(true)
|
}).catch(()=>{
|
callback && callback(false)
|
})
|
}
|
},
|
created(){
|
this.selectList.workTypes = this.$options.filters['dictData']('lesworkshop_section')
|
},
|
mounted(){
|
this.getSelectList()
|
}
|
}
|
</script>
|
<style lang="less" scoped>
|
.wms-in-bound-page{
|
border-radius: 6px 6px 0 0;
|
background-color: #fff;
|
}
|
.in-bound-page-block{
|
border-bottom:2px solid #dcdcdc;
|
overflow: auto;
|
padding-top: 16px;
|
padding-bottom: 16px;
|
&.block-two{
|
padding-top:12px;
|
.table-box{
|
padding-top:20px;
|
min-height: 241px;
|
}
|
}
|
&.block-three{
|
overflow: hidden;
|
padding-left:8px;
|
padding-right:8px;
|
}
|
}
|
.bottom-btns-view{
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
flex-wrap: wrap;
|
padding:16px 8px;
|
.ant-btn + .ant-btn {
|
margin-left:20px;
|
}
|
}
|
.radios-box{
|
width:600px;
|
display:flex;
|
margin:0 auto;
|
padding-bottom: 12px;
|
&>.label{
|
flex-shrink: 0;
|
text-align: right;
|
}
|
&>.content{
|
flex-grow:1;
|
.msg-row{
|
padding-top:4px;
|
}
|
}
|
}
|
</style>
|