waveDialog.vue 2.67 KB
<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="100px">
      <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.code"
            :label="attr.name"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="波次名称:" prop="name">
        <el-input v-model="waveForm.name" placeholder="请输入波次名称" />
      </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:'',
          ids:''
        },
        waverules: {
          code:[{ required: true, message: '请选择波次主表', trigger: ['blur','change'] }],
          name:[{ 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.ids=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 {
            return false;
          }
        });
      },
      cancel() {
        this.resetForm('waveForm')
        this.visible = false
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>