<template>
  <div class="formout">
    <el-form
      :inline="true"
      :model="formInline"
      label-width="0px"
      :rules="rules"
      ref="ruleForm"
      class="demo-form-inline"
    >
      <el-form-item>
        <p class="formname">申请部门：</p>
        <el-input
          disabled
          v-model="formInline.depart"
          placeholder="申请部门"
        ></el-input>
      </el-form-item>
      <el-form-item prop="preson">
        <p class="formname">部门联系人：</p>
        <el-input v-model="formInline.preson" placeholder="审批人"></el-input>
      </el-form-item>
      <el-form-item prop="phone">
        <p class="formname">联系电话：</p>
        <el-input v-model="formInline.phone" placeholder="联系电话"></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {},
  components: {},
  data() {
    var check_phone = (rule, value, callback) => {
      var phone_ruler=/^(?:(?:\+|00)86)?1[3-9]\d{9}$/
        setTimeout(() => {
          if (!phone_ruler.test(value)) {
            callback(new Error('请输入正确电话号码'));
          } else {
            callback();
          }
        });
      };
    
    return {
      formInline: {
        depart: "",
        preson: "",
        phone: "",
      },
      rules: {
        preson: [
          { required: true, message: "请输入部门联系人", trigger: "blur" },
        ],
        phone: [
          { required: true, message: "请输入联系电话", trigger: "blur" },
          { validator: check_phone,  trigger: "blur" },
        ],
      },
    };
  },
  watch: {},
  computed: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>

<style>
.formout .el-input__inner {
  width: 550px;
}
</style>
<style scoped>
.formout {
  width: 100%;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 1);
  box-shadow: 0px 3px 6px 0px rgba(195, 202, 248, 0.25);
  border-radius: 12px;
  padding: 30px;
}
.formout .formname {
  width: 520px;
  color: rgba(88, 97, 122, 1);
}
.formout .el-form-item {
  margin-right: 20px;
}
.formout .el-form-item:nth-of-type(2) {
  margin-right: 0px;
}
</style>
