waveDialog.vue 2.03 KB
<template>
  <el-dialog
    title="加入波次"
    :visible.sync="visible"
    :showaddwave="showaddwave"
    width="500px"
    append-to-body
    @close="$emit('update:showaddwave', false)"
  >
    <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('waveForm')">确定</el-button>
      <el-button @click="resetForm('waveForm')">取消</el-button>
    </div>
  </el-dialog>

</template>

<script>

  import { getWave} from "@/api/shipment/shipmentHeader/header";
  export default {
    props: {
      showaddwave: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        visible: this.showaddwave,
        waveOptions: [],
        waveForm: {
          code:'',
        },
        waverules: {
          code:[{ required: true, message: '请选择', trigger: ['blur','change'] }],
        }
      }
    },
    watch: {
      showaddwave() {
        this.visible = this.showaddwave
      }
    },

    created() {
      //货主select下拉接口获取
      getWave().then(response => {
        console.log(response)
        this.waveOptions = response
      });
    },

    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
            this.visible = false
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
        this.visible = false
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>