<template>
|
<a-modal
|
title="新增叫料"
|
width="90vw"
|
:visible="visible"
|
dialogClass="zero-modal"
|
@cancel="handleCancel">
|
<a-spin :spinning="confirmLoading">
|
<div class="ex-warehouse1-modal-content">
|
<div class="form-view">
|
<a-form :form="form">
|
<a-row>
|
<a-col :md="8" :sm="24">
|
<a-form-item label="单据号" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input disabled v-decorator="['OrderNo',{rules:[{required:true,message:'单据号不可为空!'}]}]" />
|
</a-form-item>
|
</a-col>
|
<!-- <a-col :md="8" :sm="24">
|
<a-form-item label="工程号" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input allowClear placeholder="请输入..." v-decorator="['engineeringNo',{rules:[{required:true,message:'请输入工程号!'}]}]" />
|
</a-form-item>
|
</a-col>
|
<a-col :md="8" :sm="24">
|
<a-form-item label="计划号" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input allowClear placeholder="请输入..." v-decorator="['planNo',{rules:[{required:true,message:'请输入计划号!'}]}]" />
|
</a-form-item>
|
</a-col> -->
|
<a-col :md="8" :sm="24">
|
<a-form-item label="叫料站点" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input v-show="false" v-decorator="['takeMaterialsSiteId',{rules:[{required:true,message:'请选择叫料站点!'}]}]" />
|
<station-select v-model="stationArr" :get-lines="getLines" :get-stations="getStations" @change="onChangeStation" />
|
</a-form-item>
|
</a-col>
|
<!-- <a-col :md="8" :sm="24">
|
<a-form-item label="班组" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-input allowClear placeholder="请输入..." v-decorator="['teamName',{rules:[{required:true,message:'请输入班组!'}]}]" />
|
</a-form-item>
|
</a-col> -->
|
</a-row>
|
</a-form>
|
</div>
|
<div class="action-view">
|
<a-button type="primary" icon="plus" @click="openChoose">
|
添加物料
|
</a-button>
|
</div>
|
<div class="list-view" ref="listWrapper">
|
<!-- 注意scroll.x的值 -->
|
<a-table v-if="th" :data-source="list" :columns="columns" rowKey="id" :pagination="false" :scroll="{x:1100,y:th}">
|
<template slot="index" slot-scope="text,record,index">{{index+1}}</template>
|
<template slot="action" slot-scope="text,record,index">
|
<a-button type="danger" size="small" @click.stop="cancelListItem(index)">删除</a-button>
|
</template>
|
</a-table>
|
</div>
|
</div>
|
</a-spin>
|
|
<choose-modal :visible.sync="chooseVisible" @callback="chooseBack" />
|
|
<template slot="footer">
|
<a-button key="back" @click="handleCancel">取消</a-button>
|
<a-button key="submit" type="primary" :loading="confirmLoading" @click="handleSubmit" :disabled="!list.length">确认</a-button>
|
</template>
|
</a-modal>
|
</template>
|
|
<script>
|
import ChooseModal from './chooseMaterials.vue'
|
import { CncTakeMaterialsAdd,GetBillNumber,GetLines,GetStations } from '@/api/modular/main/ExWarehouseManage1'
|
import StationSelect from '@/components/StationSelect.vue'
|
export default {
|
components:{ChooseModal,StationSelect},
|
data () {
|
return {
|
getLines:GetLines,
|
getStations:GetStations,
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 18 }
|
},
|
visible: false,
|
confirmLoading: false,
|
lines:[],
|
stations:[],
|
stationArr:[],
|
th:0,
|
list:[],
|
columns:[
|
{ title: '序号', key: 'index', width: 70, align:'center', fixed:"left", scopedSlots: { customRender: 'index' }},
|
{ title: '物料编码', dataIndex: 'materialNo', key: 'materialNo', width: 150 },
|
{ title: '图号', dataIndex: 'drawingNo', key: 'drawingNo' },
|
{ title: '尺寸', dataIndex: 'materialSpec', key: 'materialSpec', width: 150 },
|
{ title: '库区', dataIndex: 'areaName', key: 'areaName', width: 120 },
|
{ title: '库位', dataIndex: 'placeCode', key: 'placeCode', width: 150 },
|
{ title: '托盘号', dataIndex: 'containerCode', key: 'containerCode', width: 120 },
|
{ title: '数量', dataIndex: 'stockNumber', key: 'stockNumber', width: 100 },
|
{ title: '操作', key: 'action', width: 80, align:'center', fixed:"right", scopedSlots: { customRender: 'action' }}
|
],
|
chooseVisible:false
|
}
|
},
|
beforeCreate(){
|
this.form = this.$form.createForm(this)
|
},
|
methods: {
|
// 初始化方法
|
add (record) {
|
this.visible = true
|
this.$nextTick(() => {
|
this.th = this.$refs.listWrapper.clientHeight - 60
|
this.getInitData()
|
});
|
},
|
getInitData(){
|
this.confirmLoading = true;
|
GetBillNumber().then((d1)=>{
|
this.form.setFieldsValue({OrderNo:(d1.data.takeMaterialsNo || '')})
|
this.confirmLoading = false;
|
}).catch(()=>{
|
this.confirmLoading = false;
|
})
|
},
|
onChangeStation(arr){
|
this.form.setFieldsValue({takeMaterialsSiteId:arr[1]})
|
},
|
chooseBack(arr){
|
let newArr = [], reCount = 0;
|
arr.forEach((item)=>{
|
let f = false;
|
for (let i=0;i<this.list.length;i++) {
|
if (this.list[i].id === item.id) {
|
reCount++;
|
f = true
|
break;
|
}
|
}
|
if (!f) {
|
newArr.push(item)
|
}
|
})
|
this.list = [].concat(this.list,newArr)
|
if (reCount) {
|
this.$message.warning(`${reCount}笔数据已存在,未添加!`);
|
}
|
},
|
cancelListItem(index){
|
this.list.splice(index,1)
|
},
|
/**
|
* 提交表单
|
*/
|
handleSubmit () {
|
this.form.validateFields((errors, values) => {
|
if (!errors) {
|
this.confirmLoading = true
|
let params = {...values,...{WmsAssembleOrderDetails:this.list}}
|
CncTakeMaterialsAdd(params).then(()=>{
|
this.confirmLoading = false
|
this.handleCancel()
|
this.$emit('ok')
|
}).catch(()=>{
|
this.confirmLoading = false
|
})
|
}
|
})
|
},
|
handleCancel () {
|
this.form.resetFields()
|
this.visible = false
|
this.th = 0
|
this.list = []
|
this.chooseVisible = false
|
},
|
openChoose(){
|
this.chooseVisible = true
|
}
|
}
|
}
|
</script>
|
<style lang="less" scoped>
|
.ex-warehouse1-modal-content{
|
height: 70vh;
|
display: flex;
|
flex-direction: column;
|
.form-view,.action-view{
|
flex-shrink: 0;
|
}
|
.form-view{
|
background-color: #F3F7FA;
|
padding-top: 20px;
|
}
|
.action-view{
|
padding: 8px 16px;
|
}
|
.list-view{
|
flex-grow: 1;
|
padding: 0 16px;
|
overflow: auto;
|
}
|
}
|
</style>
|