EditForbidArea.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div class="edit-text">
  3. <el-form
  4. ref="modalFormComp"
  5. :model="modalForm"
  6. :rules="rules"
  7. :key="modalForm.id"
  8. label-width="100px"
  9. >
  10. <el-form-item prop="content" label="内容:">
  11. <el-input placeholder="请输入内容" v-model="modalForm.content">
  12. </el-input>
  13. </el-form-item>
  14. </el-form>
  15. </div>
  16. </template>
  17. <script>
  18. const initModalForm = {
  19. id: "",
  20. content: "",
  21. };
  22. export default {
  23. name: "edit-forbid-area",
  24. props: {
  25. instance: {
  26. type: Object,
  27. default() {
  28. return {};
  29. },
  30. },
  31. },
  32. data() {
  33. return {
  34. modalForm: { ...initModalForm },
  35. isBold: false,
  36. rules: {
  37. content: [
  38. {
  39. required: true,
  40. message: "请输入文本内容",
  41. trigger: "change",
  42. },
  43. ],
  44. },
  45. };
  46. },
  47. mounted() {
  48. this.initData(this.instance);
  49. },
  50. methods: {
  51. initData(val) {
  52. this.modalForm = { ...val };
  53. },
  54. async submit() {
  55. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  56. if (!valid) return;
  57. this.$emit("modified", this.modalForm);
  58. },
  59. },
  60. };
  61. </script>