<template>
|
<el-dialog
|
custom-class="sy-modal"
|
|
:title="title"
|
:close-on-click-modal="false"
|
width="600px"
|
:before-close="close"
|
>
|
<template #default>
|
<div class="sy-default-form-modal-content add-input-task-frame" v-loading="loading">
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="物料码" prop="cargoNo">
|
<el-input v-model.trim="form.cargoNo" placeholder="请录入..." @change="getGoodsInfo"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="序列号">
|
<el-input v-model="materialForm.SerialNumber" disabled></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="系列">
|
<el-input v-model="materialForm.SeriesName" disabled></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="品类">
|
<el-input v-model="materialForm.CargoTypeName" disabled></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</div>
|
</template>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="onClose">取 消</el-button>
|
<el-button type="primary" @click="onSubmit(false)" :disabled="!submitEnabled">提 交</el-button>
|
<el-button type="primary" @click="onSubmit(true)" :disabled="!submitEnabled">提交并继续新增</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</template>
|
|
<script>
|
import Pannel from '@/components/Pannel1.vue'
|
import { Search } from '@element-plus/icons'
|
const defaultForm = {
|
cargoNo:''
|
}
|
const materialDefaultForm = {
|
SerialNumber:'',
|
SeriesName:'',
|
CargoTypeName:''
|
}
|
export default {
|
name:'tasksOfVirtualInputAddModalCompontent',
|
components:{Pannel,'e-icon-search':Search},
|
emits:['submitCallback','update:visible'],
|
props:{
|
visible:{
|
type:Boolean,
|
default:false
|
}
|
},
|
data(){
|
return {
|
title:'新建入库任务',
|
loading:false,
|
form:{...defaultForm},
|
materialForm:{...materialDefaultForm},
|
rules:{
|
cargoNo:[
|
{ required: true, message: '请录入物料码!', trigger: 'blur' }
|
]
|
},
|
submitEnabled:false
|
}
|
},
|
watch:{
|
visible(newVal,oldVal){
|
if (newVal!==oldVal) {
|
if (newVal) {
|
this.initForm();
|
} else {
|
this.clearForm();
|
}
|
}
|
}
|
},
|
methods:{
|
initForm(){
|
this.restForm()
|
this.$nextTick(()=>{
|
this.$refs.form.clearValidate()
|
})
|
},
|
clearForm(){
|
this.form = {...defaultForm}
|
},
|
restForm(){
|
this.form = {...defaultForm}
|
this.submitEnabled = false
|
},
|
close(){
|
this.$emit('update:visible',false)
|
},
|
onClose(){
|
this.close();
|
},
|
onSubmit(isMore){
|
this.$refs.form.validate((valid) => {
|
if (valid) {
|
this.dealSubmit((f)=>{
|
if (f) {
|
if (isMore) {
|
this.restForm()
|
this.$nextTick(()=>{
|
this.$refs.form.clearValidate()
|
})
|
} else {
|
this.close();
|
}
|
this.$emit('submitCallback',!isMore)
|
}
|
})
|
}
|
})
|
},
|
dealSubmit(callback){
|
let params = {...this.form};
|
this.loading = true
|
this.$api.post('AddInVirtualStore',params,{block:'virtualTask'}).then((d)=>{
|
this.loading = false
|
callback && callback(true)
|
}).catch((err)=>{
|
this.loading = false
|
callback && callback(false)
|
})
|
},
|
getGoodsInfo(){
|
if (!this.form.cargoNo) {
|
return false;
|
}
|
let params = {cargoNo:this.form.cargoNo};
|
this.loading = true
|
this.$api.post('AnalyzeMaterial',params,{block:'taskMain'}).then((d)=>{
|
this.materialForm = {...d}
|
this.submitEnabled = true
|
this.loading = false
|
}).catch((err)=>{
|
this.materialForm = {...materialDefaultForm}
|
this.submitEnabled = false
|
this.loading = false
|
})
|
}
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
|
</style>
|