BuildPaper.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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 v-if="!IS_MANUAL_MODE" prop="paperCount" label="组卷套数">
  42. <el-input-number
  43. v-model="modalForm.paperCount"
  44. :min="1"
  45. :max="5"
  46. :step="1"
  47. step-strictly
  48. ></el-input-number>
  49. </el-form-item>
  50. <el-form-item v-if="!IS_MANUAL_MODE" style="border: none">
  51. <el-checkbox v-model="modalForm.checkRepeat"
  52. >校验试卷重复率</el-checkbox
  53. >
  54. </el-form-item>
  55. <el-form-item v-else></el-form-item>
  56. </el-form>
  57. <el-form>
  58. <template v-if="modalForm.checkRepeat && !IS_MANUAL_MODE">
  59. <el-form-item
  60. label="校验重复率的试卷范围:"
  61. label-width="180px"
  62. style="margin-bottom: 10px"
  63. >
  64. <el-radio-group v-model="modalForm.storage" size="small">
  65. <el-radio-button :label="false">卷库列表试卷</el-radio-button>
  66. <el-radio-button :label="true">试卷仓库试卷</el-radio-button>
  67. </el-radio-group>
  68. </el-form-item>
  69. <el-form-item
  70. label="试卷间重复率不高于:"
  71. label-width="180px"
  72. style="margin-bottom: 10px"
  73. >
  74. <el-input-number
  75. v-model="modalForm.maxLimit"
  76. style="width: 125px"
  77. :min="0"
  78. :max="100"
  79. :step="1"
  80. step-strictly
  81. :controls="false"
  82. ></el-input-number>
  83. %
  84. <el-checkbox v-model="modalForm.topicOnly"
  85. >本次组的试卷间不允许重复</el-checkbox
  86. >
  87. <p class="tips-info">注:试卷间的重复率会小于等于设定值</p>
  88. </el-form-item>
  89. <el-form-item
  90. label="试卷重复率校验时间周期:"
  91. label-width="180px"
  92. style="margin-bottom: 10px"
  93. >
  94. <el-input-number
  95. v-model="modalForm.timeLimit"
  96. style="width: 125px"
  97. :min="1"
  98. :max="100"
  99. :step="1"
  100. step-strictly
  101. :controls="false"
  102. ></el-input-number>
  103. 个月
  104. <p class="tips-info">注:月份按照自然月计数,当前月份记为第1个月</p>
  105. </el-form-item>
  106. </template>
  107. <el-form-item label="组卷模式" style="margin: 0">
  108. <el-radio-group v-model="genModelType" style="padding-left: 15px">
  109. <el-radio
  110. v-for="item in modelTypes"
  111. :key="item.code"
  112. :label="item.code"
  113. >{{ item.name }}</el-radio
  114. >
  115. </el-radio-group>
  116. </el-form-item>
  117. </el-form>
  118. </div>
  119. <div class="part-box">
  120. <component
  121. :is="buildCompName"
  122. ref="BuildPaperDetail"
  123. :course-id="modalForm.courseId"
  124. ></component>
  125. </div>
  126. </div>
  127. </template>
  128. <script>
  129. import BuildPaperAuto from "../components/BuildPaperAuto.vue";
  130. import BuildPaperManual from "../components/BuildPaperManual.vue";
  131. import BuildPaperSimple from "../components/BuildPaperSimple.vue";
  132. import { buildPaperApi } from "../api";
  133. const initModalForm = {
  134. courseId: "",
  135. courseCode: "",
  136. courseName: "",
  137. paperName: "",
  138. paperCount: 1,
  139. checkRepeat: false,
  140. storage: false,
  141. maxLimit: 0,
  142. topicOnly: false,
  143. timeLimit: 1,
  144. };
  145. export default {
  146. name: "BuildPaper",
  147. components: { BuildPaperAuto, BuildPaperManual, BuildPaperSimple },
  148. data() {
  149. return {
  150. loading: false,
  151. modalForm: {
  152. ...initModalForm,
  153. },
  154. rules: {
  155. paperName: [
  156. {
  157. required: true,
  158. message: "请输入试卷名称",
  159. trigger: "change",
  160. },
  161. {
  162. max: 100,
  163. message: "试卷名称不能超过100个字",
  164. trigger: "change",
  165. },
  166. ],
  167. paperCount: [
  168. {
  169. required: true,
  170. message: "请输入组卷套数",
  171. trigger: "change",
  172. },
  173. ],
  174. },
  175. genModelType: "auto",
  176. modelTypes: [
  177. {
  178. code: "simple",
  179. name: "简易成卷",
  180. },
  181. {
  182. code: "auto",
  183. name: "自动成卷",
  184. },
  185. {
  186. code: "manual",
  187. name: "手动组卷",
  188. },
  189. ],
  190. };
  191. },
  192. computed: {
  193. buildCompName() {
  194. return `build-paper-${this.genModelType}`;
  195. },
  196. IS_MANUAL_MODE() {
  197. return this.genModelType === "manual";
  198. },
  199. },
  200. created() {
  201. let genPaperInfo = sessionStorage.getItem("gen_paper");
  202. genPaperInfo = genPaperInfo ? JSON.parse(genPaperInfo) : {};
  203. this.modalForm.courseCode = genPaperInfo.courseCode;
  204. this.modalForm.courseName = genPaperInfo.courseName;
  205. this.modalForm.courseId = genPaperInfo.courseId;
  206. },
  207. methods: {
  208. async confirm() {
  209. let valid = await this.$refs.modalFormComp.validate().catch(() => {});
  210. if (!valid) return;
  211. valid = await this.$refs.BuildPaperDetail.validate().catch(() => {});
  212. if (!valid) return;
  213. if (this.loading) return;
  214. this.loading = true;
  215. let questionInfo = this.$refs.BuildPaperDetail.getData();
  216. const datas = {
  217. ...this.modalForm,
  218. ...questionInfo,
  219. };
  220. const res = await buildPaperApi(datas, this.genModelType).catch(() => {});
  221. this.loading = false;
  222. if (!res) return;
  223. this.$message.success("组卷成功!");
  224. },
  225. toback() {
  226. window.history.go(-1);
  227. },
  228. },
  229. };
  230. </script>