ModifyPlanPaper.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <el-dialog
  3. class="modify-plan-paper"
  4. :visible.sync="modalIsShow"
  5. title="关联试卷"
  6. top="10px"
  7. width="900px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @open="visibleChange"
  12. >
  13. <div class="part-box part-box-pad part-box-border">
  14. <el-form
  15. class="form-info"
  16. ref="modalFormComp"
  17. label-width="130px"
  18. :rules="rules"
  19. :model="modalForm"
  20. >
  21. <el-row>
  22. <el-col :span="12">
  23. <el-form-item label="课程(代码):">
  24. <span
  25. >{{ instance.courseName }}({{ instance.courseCode }})</span
  26. >
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="12">
  30. <!-- <el-form-item label="适用专业(方向):">
  31. <span>{{ instance.specialty | defaultFieldFilter }}</span>
  32. </el-form-item> -->
  33. </el-col>
  34. </el-row>
  35. <el-row>
  36. <el-col :span="12">
  37. <el-form-item label="题卡规则:">
  38. <span>{{ instance.cardRuleName }}</span>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="12">
  42. <el-form-item label="命题老师:">
  43. <span>{{ instance.userName }}</span>
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. <el-row class="mb-2">
  48. <el-col :span="12">
  49. <el-form-item prop="paperNumber" label="试卷编号:">
  50. <el-select
  51. v-model="modalForm.paperNumber"
  52. placeholder="请选择"
  53. filterable
  54. @change="paperChange"
  55. >
  56. <el-option
  57. v-for="item in papers"
  58. :key="item.id"
  59. :value="item.paperNumber"
  60. :label="item.paperNumber"
  61. ></el-option>
  62. </el-select>
  63. <!-- <span>{{ instance.paperNumber }}</span> -->
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="12">
  67. <el-form-item prop="relatePaperType" label="关联类型:">
  68. <el-select
  69. v-model="modalForm.relatePaperType"
  70. placeholder="请选择"
  71. multiple
  72. :multiple-limit="drawCount"
  73. >
  74. <el-option
  75. v-for="item in paperTypes"
  76. :key="item"
  77. :value="item"
  78. :label="item"
  79. ></el-option>
  80. </el-select>
  81. </el-form-item>
  82. </el-col>
  83. </el-row>
  84. <el-row>
  85. <el-col :span="12">
  86. <el-form-item label="已曝光类型:">
  87. <span>{{ instance.exposedPaperType | defaultFieldFilter }}</span>
  88. </el-form-item>
  89. </el-col>
  90. <el-col :span="12">
  91. <el-form-item label="未曝光类型:">
  92. <span>{{
  93. instance.unexposedPaperType | defaultFieldFilter
  94. }}</span>
  95. </el-form-item>
  96. </el-col>
  97. </el-row>
  98. </el-form>
  99. </div>
  100. <h4 class="part-box-tips">试卷内容:</h4>
  101. <p class="tips-info tips-dark mb-2">
  102. 提示:多卷型试卷由于会绑定一个答题卡模板,因此试卷结构必须相同。多卷型试卷之间客观题要求试题内容相同,可允许大题内的小题题序不同。
  103. </p>
  104. <table class="table">
  105. <tr>
  106. <th>卷型</th>
  107. <th>试卷</th>
  108. <th>答题卡</th>
  109. </tr>
  110. <tr v-for="(attachment, index) in paperAttachments" :key="index">
  111. <td>{{ attachment.name }}卷</td>
  112. <td>
  113. <el-button
  114. type="text"
  115. class="btn-primary"
  116. @click="downloadPaper(attachment)"
  117. title="点击查看试卷"
  118. >
  119. <i
  120. class="icon icon-download mr-1"
  121. v-if="attachment.attachmentId"
  122. ></i
  123. >{{ attachment.filename }}
  124. </el-button>
  125. </td>
  126. <td>
  127. <el-button
  128. type="text"
  129. class="btn-primary"
  130. @click="toViewCard(attachment)"
  131. >查看答题卡</el-button
  132. >
  133. </td>
  134. </tr>
  135. </table>
  136. <div slot="footer">
  137. <el-button type="primary" :disabled="isSubmit" @click="submit"
  138. >确认</el-button
  139. >
  140. <el-button @click="cancel">取消</el-button>
  141. </div>
  142. </el-dialog>
  143. </template>
  144. <script>
  145. import { updatePlanLinkPaper, linkPaperNumberList } from "../api";
  146. import { taskApplyDetail } from "../../exam/api";
  147. import { attachmentPreview } from "../../login/api";
  148. const initModalForm = {
  149. id: null,
  150. examId: null,
  151. paperNumber: "",
  152. relatePaperType: [],
  153. };
  154. export default {
  155. name: "modify-plan-paper",
  156. props: {
  157. instance: {
  158. type: Object,
  159. default() {
  160. return {};
  161. },
  162. },
  163. },
  164. data() {
  165. return {
  166. modalIsShow: false,
  167. isSubmit: false,
  168. modalForm: { ...initModalForm },
  169. papers: [],
  170. paperTypes: [],
  171. paperAttachments: [],
  172. drawCount: 0,
  173. cardId: "",
  174. rules: {
  175. paperNumber: [
  176. {
  177. required: true,
  178. message: "请选择试卷编号",
  179. trigger: "change",
  180. },
  181. ],
  182. relatePaperType: [
  183. {
  184. required: true,
  185. validator: (rule, value, callback) => {
  186. if (
  187. value.length < this.drawCount ||
  188. value.length > this.drawCount
  189. ) {
  190. return callback(
  191. new Error(`需要选择${this.drawCount}套关联试卷`)
  192. );
  193. }
  194. callback();
  195. },
  196. trigger: "change",
  197. },
  198. ],
  199. },
  200. };
  201. },
  202. methods: {
  203. async getAttachments() {
  204. const data = await taskApplyDetail(this.instance.id);
  205. this.paperAttachments = data.paperAttachmentIds
  206. ? JSON.parse(data.paperAttachmentIds)
  207. : [];
  208. this.cardId = data.cardId;
  209. this.drawCount = data.drawCount;
  210. },
  211. // async getPaperTypes() {
  212. // const papers = await linkPaperNumberList({
  213. // examTaskId: this.instance.id,
  214. // printPlanId: this.instance.printPlanId
  215. // });
  216. // if (papers && papers[0]) this.paperTypes = papers[0].paperTypes;
  217. // },
  218. async getPapers() {
  219. this.papers = await linkPaperNumberList({
  220. examTaskId: this.instance.id,
  221. printPlanId: this.instance.printPlanId,
  222. courseCode: this.instance.courseCode,
  223. });
  224. const paper = this.papers.find(
  225. (item) => item.paperNumber === this.modalForm.paperNumber
  226. );
  227. if (paper) this.paperTypes = paper.paperTypes;
  228. },
  229. visibleChange() {
  230. this.modalForm = this.$objAssign(initModalForm, this.instance);
  231. this.modalForm.relatePaperType = this.instance.relatePaperType
  232. ? this.instance.relatePaperType.split(",")
  233. : [];
  234. this.getPapers();
  235. // this.getPaperTypes();
  236. this.getAttachments();
  237. this.$nextTick(() => {
  238. this.$refs.modalFormComp.clearValidate();
  239. });
  240. },
  241. cancel() {
  242. this.modalIsShow = false;
  243. },
  244. open() {
  245. this.modalIsShow = true;
  246. },
  247. paperChange() {
  248. this.modalForm.relatePaperType = [];
  249. this.paperTypes = [];
  250. const paper = this.papers.find(
  251. (item) => item.paperNumber === this.modalForm.paperNumber
  252. );
  253. if (paper) this.paperTypes = paper.paperTypes;
  254. },
  255. async downloadPaper(attachment) {
  256. const data = await attachmentPreview(attachment.attachmentId);
  257. window.open(data.url);
  258. },
  259. toViewCard(attachment) {
  260. window.open(
  261. this.getRouterPath({
  262. name: "CardPreview",
  263. params: {
  264. cardId: attachment.cardId,
  265. viewType: "view",
  266. },
  267. })
  268. );
  269. },
  270. async submit() {
  271. const valid = await this.$refs.modalFormComp.validate().catch(() => {});
  272. if (!valid) return;
  273. if (this.isSubmit) return;
  274. this.isSubmit = true;
  275. const datas = {
  276. examTaskId: this.modalForm.id,
  277. examId: this.modalForm.examId,
  278. relatePaperType: this.modalForm.relatePaperType.join(),
  279. paperNumber: this.modalForm.paperNumber,
  280. printPlanId: this.instance.printPlanId,
  281. examDetailCourseIds: this.instance.examDetailCourseIds,
  282. };
  283. const data = await updatePlanLinkPaper(datas).catch(() => {});
  284. this.isSubmit = false;
  285. if (!data) return;
  286. this.$message.success("保存成功!");
  287. this.$emit("modified");
  288. this.cancel();
  289. },
  290. },
  291. };
  292. </script>