<template> <el-dialog title="加入波次" :visible.sync="visible" :showaddwave="showaddwave" width="500px" append-to-body @close="$emit('update:showaddwave', false)" @open="diaOpen" > <el-form ref="waveForm" :model="waveForm" :rules="waverules" label-width="80px"> <el-form-item label="请选择:" prop="code"> <el-select v-model="waveForm.code" placeholder="请选择" :style="{width: '100%'}"> <el-option v-for="attr in waveOptions" :key="attr.code" :value="attr.name" :label="attr.name" /> </el-select> </el-form-item> </el-form> <div slot="footer" class="dialog-footer"> <el-button type="primary" @click="submitForm">确定</el-button> <el-button @click="cancel">取消</el-button> </div> </el-dialog> </template> <script> import { getWaveselect,addwavesure} from "@/api/shipment/shipmentHeader/header"; export default { props: { showaddwave: { type: Boolean, default: false }, id:{ type: String } }, data() { return { visible: this.showaddwave, waveOptions: [], waveForm: { code:'', id:'' }, waverules: { code:[{ required: true, message: '请选择', trigger: ['blur','change'] }], }, } }, watch: { showaddwave() { this.visible = this.showaddwave } }, created() { //波次select下拉接口获取 getWaveselect().then(response => { this.waveOptions = response.rows }); }, methods: { diaOpen() { this.resetForm('waveForm') }, submitForm() { let thisInfo=this; this.$refs["waveForm"].validate((valid) => { if (valid) { this.waveForm.id=thisInfo.$props.id addwavesure(this.waveForm).then(response=>{ if(response.code == 200) { this.msgSuccess(response.msg) this.visible = false this.$parent.getHeaderList() }else { this.msgError(response.msg) } }) } else { console.log('error submit!!'); return false; } }); }, cancel() { this.resetForm('waveForm') this.visible = false } } } </script> <style lang="scss" scoped> </style>