<template>
  <div class="edit-text">
    <el-form
      ref="modalFormComp"
      :model="modalForm"
      :rules="rules"
      :key="modalForm.id"
      label-width="100px"
    >
      <el-form-item prop="content" label="内容：">
        <el-input placeholder="请输入内容" v-model="modalForm.content">
        </el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
const initModalForm = {
  id: "",
  content: "",
};

export default {
  name: "edit-forbid-area",
  props: {
    instance: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      modalForm: { ...initModalForm },
      isBold: false,
      rules: {
        content: [
          {
            required: true,
            message: "请输入文本内容",
            trigger: "change",
          },
        ],
      },
    };
  },
  mounted() {
    this.initData(this.instance);
  },
  methods: {
    initData(val) {
      this.modalForm = { ...val };
    },
    async submit() {
      const valid = await this.$refs.modalFormComp.validate().catch(() => {});
      if (!valid) return;
      this.$emit("modified", this.modalForm);
    },
  },
};
</script>
