clxxAddDialog.vue 2.48 KB
<!--
 * @Description:
 * @Autor: renchao
 * @LastEditTime: 2023-07-18 08:55:31
-->
<template>
  <dialogBox title="新建材料信息" width="20%" isMain v-model="myValue" @closeDialog="closeDialog" @submitForm="handleSubmit"
    :isFullscreen="false">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="材料类型" prop="cllx">
            <el-select v-model="ruleForm.cllx" class="width100" placeholder="请选择">
              <el-option v-for="item in dictData['A40']" :key="item.dcode" :label="item.dname" :value="item.dcode">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="材料名称" prop="clmc">
            <el-input v-model="ruleForm.clmc"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </dialogBox>
</template>

<script>
  import { mapGetters } from "vuex";
  export default {
    props: {
      value: { type: Boolean, default: false },
    },
    data () {
      return {
        myValue: this.value,
        ruleForm: {
          cllx: "",
          clmc: "",
        },
        rules: {
          cllx: [
            { required: true, message: '请选择材料类型', trigger: 'change' }
          ],
          clmc: [
            { required: true, message: '请输入材料名称', trigger: 'blur' }
          ]
        }
      }
    },
    computed: {
      ...mapGetters(["dictData"]),
    },
    watch: {
      value (val) {
        this.myValue = val;
      },
    },
    methods: {
      /**
       * @description: closeDialog
       * @author: renchao
       */
      closeDialog () {
        this.$emit("input", false);
        this.ruleForm = {
          cllx: "",
          clmc: "",
        }
      },
      /**
       * @description: handleSubmit
       * @author: renchao
       */
      handleSubmit () {
        this.$refs['ruleForm'].validate((valid) => {
          if (valid) {
            this.$parent.addSave(this.ruleForm);
            this.ruleForm = {
              cllx: "",
              clmc: "",
            }
            this.$emit("input", false);
          } else {
            return false;
          }
        })
      }
    }
  };
</script>
<style scoped lang="scss">
  .submit-button {
    text-align: center;
    height: 52px;
    padding-top: 10px;
    background-color: #fff;
  }
</style>