headeraddDialog.vue 3 KB
<template>
  <el-dialog
    title="添加调整主单"
    :visible.sync="visible"
    :show="show"
    width="500px"
    append-to-body
    @open="openDia"
    @close="$emit('update:show', false)"
  >
    <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="120px"
    >
      <el-form-item label="调整类型" prop="problemType">
        <el-select
          v-model="ruleForm.problemType"
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option
            v-for="dict in adjustTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="盘点单编码" prop="cyclecountHeadCode">
        <el-input v-model="ruleForm.cyclecountHeadCode"></el-input>
      </el-form-item>
      <el-form-item label="质检单编码" prop="checkCode">
        <el-input v-model="ruleForm.checkCode"></el-input>
      </el-form-item>
      <el-form-item label="关联上游单编码" prop="referCode">
        <el-input v-model="ruleForm.referCode"></el-input>
      </el-form-item>
      <el-form-item label="关联上游说明" prop="referReason">
        <el-input v-model="ruleForm.referReason"></el-input>
      </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 { addAdjustHeader } from "@/api/cycle/adjustHeader/header";
export default {
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    options: {
      type: Array,
    },
  },
  data() {
    return {
      visible: this.show,
      adjustTypeOptions: this.options,
      ruleForm: {
        problemType: "",
        cyclecountHeadCode: "",
        checkCode: "",
        referCode: "",
        referReason: "",
      },
      rules: {
        problemType: [
          {
            required: true,
            message: "调整类型不能为空",
            trigger: ["blur", "change"],
          },
        ],
      },
    };
  },
  watch: {
    show() {
      this.visible = this.show;
    },
    options() {
      this.adjustTypeOptions = this.options;
    },
  },

  methods: {
    openDia() {
this.resetForm("ruleForm");
    },
   submitForm: function() {
      this.$refs["ruleForm"].validate(valid => {
        if (valid) {
         
            addAdjustHeader(this.ruleForm).then((response) => {
              if(response.code == 200) {
                   this.msgSuccess("新增成功");
                this.visible = false;
              this.$parent.getHeaderList();
            
              }
              else {
                this.msgError(response.msg)
              }
           
            });
          
        }
      });
    },
    cancel() {
      this.resetForm("ruleForm");
      this.visible = false;
    },
  },
};
</script>