ModifyAutoBuildPaperStruct.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div>
  3. <el-dialog
  4. :visible.sync="modalIsShow"
  5. title="编辑试卷结构"
  6. :modal="true"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. fullscreen
  11. :show-close="false"
  12. >
  13. <div slot="title" class="box-justify">
  14. <div>
  15. <h2>编辑试卷结构</h2>
  16. <span>{{ instance.structName }}</span>
  17. </div>
  18. <div>
  19. <el-button
  20. size="small"
  21. type="primary"
  22. :loading="loading"
  23. @click="confirm"
  24. >确定</el-button
  25. >
  26. <el-button size="small" @click="cancel">取消</el-button>
  27. </div>
  28. </div>
  29. <div class="build-paper part-box">
  30. <BuildPaperAuto
  31. v-if="modalIsShow"
  32. ref="BuildPaperAuto"
  33. :course-id="instance.courseId"
  34. :detail-source="instance.structInfo"
  35. />
  36. </div>
  37. <div slot="footer"></div>
  38. </el-dialog>
  39. </div>
  40. </template>
  41. <script>
  42. import { autoBuildPaperStructSaveApi } from "../api";
  43. import BuildPaperAuto from "./BuildPaperAuto.vue";
  44. export default {
  45. name: "ModifyAutoBuildPaperStruct",
  46. components: { BuildPaperAuto },
  47. props: {
  48. instance: {
  49. type: Object,
  50. default() {
  51. return {};
  52. },
  53. },
  54. },
  55. data() {
  56. return {
  57. modalIsShow: false,
  58. loading: false,
  59. };
  60. },
  61. methods: {
  62. cancel() {
  63. this.modalIsShow = false;
  64. },
  65. open() {
  66. this.modalIsShow = true;
  67. },
  68. async confirm() {
  69. const valid = await this.$refs.BuildPaperAuto.validate().catch(() => {});
  70. if (!valid) return;
  71. if (this.loading) return;
  72. this.loading = true;
  73. let questionInfo = this.$refs.BuildPaperAuto.getData();
  74. let datas = { ...this.instance };
  75. datas.structInfo = JSON.stringify(questionInfo.detailInfo);
  76. const res = await autoBuildPaperStructSaveApi(datas).catch(() => {});
  77. this.loading = false;
  78. if (!res) return;
  79. this.$message.success("修改成功");
  80. this.cancel();
  81. this.$emit("modified");
  82. },
  83. },
  84. };
  85. </script>