BuildPaper.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <div class="build-paper">
  3. <div class="part-box">
  4. <div class="part-box-header">
  5. <div class="part-box-header-left">
  6. <h1 class="part-box-title">组卷</h1>
  7. <span>课程代码:{{ modalForm.courseCode }}</span>
  8. <span>课程名称:{{ modalForm.courseName }}</span>
  9. </div>
  10. <div>
  11. <el-button
  12. type="primary"
  13. size="small"
  14. icon="icon icon-save-white"
  15. @click="confirm"
  16. >确定</el-button
  17. >
  18. <el-button
  19. type="danger"
  20. size="small"
  21. plain
  22. icon="icon icon-back"
  23. @click="toback"
  24. >返回</el-button
  25. >
  26. </div>
  27. </div>
  28. <el-form
  29. ref="modalFormComp"
  30. class="part-filter-form"
  31. :model="modalForm"
  32. :rules="rules"
  33. inline
  34. >
  35. <el-form-item prop="paperName" label="试卷名称">
  36. <el-input
  37. v-model="modalForm.paperName"
  38. placeholder="试卷名称"
  39. ></el-input>
  40. </el-form-item>
  41. <el-form-item prop="genNumber" label="组卷套数">
  42. <el-input-number
  43. v-model="modalForm.genNumber"
  44. :min="1"
  45. :max="5"
  46. :step="1"
  47. step-strictly
  48. ></el-input-number>
  49. </el-form-item>
  50. <el-form-item style="border: none">
  51. <el-checkbox v-model="modalForm.topicRepeat"
  52. >多套试卷间试题不能重复</el-checkbox
  53. >
  54. </el-form-item>
  55. </el-form>
  56. <el-form>
  57. <el-form-item label="组卷模式" style="margin: 0">
  58. <el-radio-group
  59. v-model="modalForm.genModelType"
  60. style="padding-left: 15px"
  61. >
  62. <el-radio
  63. v-for="item in modelTypes"
  64. :key="item.code"
  65. :label="item.code"
  66. >{{ item.name }}</el-radio
  67. >
  68. </el-radio-group>
  69. </el-form-item>
  70. </el-form>
  71. </div>
  72. <div class="part-box">
  73. <component
  74. :is="buildCompName"
  75. ref="BuildPaperDetail"
  76. :course-id="modalForm.courseId"
  77. ></component>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import BuildPaperAuto from "../components/BuildPaperAuto.vue";
  83. import BuildPaperManual from "../components/BuildPaperManual.vue";
  84. import BuildPaperSimple from "../components/BuildPaperSimple.vue";
  85. import { buildPaperApi } from "../api";
  86. export default {
  87. name: "BuildPaper",
  88. components: { BuildPaperAuto, BuildPaperManual, BuildPaperSimple },
  89. data() {
  90. return {
  91. loading: false,
  92. modalForm: {
  93. courseId: "",
  94. courseCode: "",
  95. courseName: "",
  96. paperName: "",
  97. genNumber: 1,
  98. topicRepeat: false,
  99. genModelType: "auto",
  100. },
  101. rules: {
  102. paperName: [
  103. {
  104. required: true,
  105. message: "请输入试卷名称",
  106. trigger: "change",
  107. },
  108. {
  109. max: 100,
  110. message: "试卷名称不能超过100个字",
  111. trigger: "change",
  112. },
  113. ],
  114. genNumber: [
  115. {
  116. required: true,
  117. message: "请输入组卷套数",
  118. trigger: "change",
  119. },
  120. ],
  121. },
  122. modelTypes: [
  123. {
  124. code: "simple",
  125. name: "简易成卷",
  126. },
  127. {
  128. code: "auto",
  129. name: "自动成卷",
  130. },
  131. {
  132. code: "manual",
  133. name: "手动组卷",
  134. },
  135. ],
  136. };
  137. },
  138. computed: {
  139. buildCompName() {
  140. return `build-paper-${this.modalForm.genModelType}`;
  141. },
  142. },
  143. created() {
  144. this.modalForm.courseId = this.$route.params.courseId;
  145. },
  146. methods: {
  147. async confirm() {
  148. let valid = await this.$refs.modalFormComp.validate().catch(() => {});
  149. if (!valid) return;
  150. valid = await this.$refs.BuildPaperDetail.validate().catch(() => {});
  151. if (!valid) return;
  152. if (this.loading) return;
  153. this.loading = true;
  154. let paperSet = this.$refs.BuildPaperDetail.getData();
  155. const datas = {
  156. ...this.modalForm,
  157. paperSet,
  158. };
  159. const res = await buildPaperApi(datas).catch(() => {});
  160. this.loading = false;
  161. if (!res) return;
  162. this.$message.success("组卷成功!");
  163. },
  164. toback() {
  165. window.history.go(-1);
  166. },
  167. },
  168. };
  169. </script>