EditComposition.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="edit-composition">
  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="topicNo" label="大题序号:">
  11. <el-input-number
  12. v-model="modalForm.topicNo"
  13. :min="1"
  14. :max="99"
  15. :step="1"
  16. step-strictly
  17. :controls="false"
  18. ></el-input-number>
  19. </el-form-item> -->
  20. <el-form-item prop="topicName" label="题目名称:">
  21. <card-name-edit v-model="modalForm"></card-name-edit>
  22. </el-form-item>
  23. </el-form>
  24. </div>
  25. </template>
  26. <script>
  27. import CardNameEdit from "../../components/common/CardNameEdit.vue";
  28. const initModalForm = {
  29. id: "",
  30. topicNo: null,
  31. topicName: "",
  32. nameFontSize: "14px",
  33. nameFontWeight: 400,
  34. };
  35. export default {
  36. name: "edit-composition",
  37. components: { CardNameEdit },
  38. props: {
  39. instance: {
  40. type: Object,
  41. default() {
  42. return {};
  43. },
  44. },
  45. },
  46. data() {
  47. return {
  48. modalForm: { ...initModalForm },
  49. rules: {
  50. topicNo: [
  51. {
  52. required: true,
  53. message: "请输入大题序号",
  54. trigger: "change",
  55. },
  56. ],
  57. topicName: [
  58. {
  59. required: true,
  60. message: "请输入题目名称",
  61. trigger: "change",
  62. },
  63. ],
  64. },
  65. };
  66. },
  67. mounted() {
  68. this.initData(this.instance);
  69. },
  70. methods: {
  71. initData(val) {
  72. const valInfo = val.parent || val;
  73. this.modalForm = { ...valInfo };
  74. },
  75. async submit() {
  76. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  77. if (!valid) return;
  78. this.modalForm.topicName = this.modalForm.topicName.trim();
  79. this.$emit("modified", this.modalForm);
  80. },
  81. },
  82. };
  83. </script>