SetBlueDialog.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <div>
  3. <el-dialog
  4. :visible.sync="modalIsShow"
  5. title="设置试卷蓝图"
  6. top="10px"
  7. width="800px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @open="visibleChange"
  12. >
  13. <el-table :data="dataList">
  14. <el-table-column
  15. prop="mainNumber"
  16. label="大题号"
  17. width="80px"
  18. ></el-table-column>
  19. <el-table-column
  20. prop="subNumber"
  21. label="小题号"
  22. width="80px"
  23. ></el-table-column>
  24. <el-table-column prop="dimensionList" label="知识点">
  25. <template slot-scope="scope">
  26. <template v-for="target in scope.row.targetList">
  27. <p
  28. v-for="item in target.dimensionList"
  29. :key="`${target.targetId}_${item.dimensionId}`"
  30. >
  31. {{ item.dimensionName }}
  32. </p>
  33. </template>
  34. </template>
  35. </el-table-column>
  36. <el-table-column class-name="action-column" label="操作" width="110px">
  37. <template slot-scope="scope">
  38. <el-button
  39. class="btn-primary"
  40. type="text"
  41. @click="toLink(scope.row)"
  42. >关联知识点</el-button
  43. >
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. <div slot="footer">
  48. <el-button type="primary" :disabled="isSubmit" @click="submit"
  49. >确认</el-button
  50. >
  51. <el-button @click="cancel">取消</el-button>
  52. </div>
  53. </el-dialog>
  54. <!-- 设置知识点 -->
  55. <select-blue-dimension-dialog
  56. ref="SelectBlueDimensionDialog"
  57. :course="course"
  58. :selected-data="selectedData"
  59. @confirm="dimensionSelected"
  60. ></select-blue-dimension-dialog>
  61. </div>
  62. </template>
  63. <script>
  64. import { endScorePaperPositiveDetail, endScorePaperPositiveSave } from "../api";
  65. import SelectBlueDimensionDialog from "./SelectBlueDimensionDialog.vue";
  66. export default {
  67. name: "SetBlueDialog",
  68. components: { SelectBlueDimensionDialog },
  69. props: {
  70. course: {
  71. type: Object,
  72. default() {
  73. return {};
  74. },
  75. },
  76. },
  77. data() {
  78. return {
  79. modalIsShow: false,
  80. isSubmit: false,
  81. dataList: [],
  82. curRow: {},
  83. selectedData: [],
  84. };
  85. },
  86. methods: {
  87. async getBlueDetail() {
  88. const res = await endScorePaperPositiveDetail({
  89. examId: this.course.examId,
  90. courseCode: this.course.courseCode,
  91. paperNumber: this.course.paperNumber,
  92. });
  93. this.dataList = res || [];
  94. },
  95. visibleChange() {
  96. this.getBlueDetail();
  97. },
  98. cancel() {
  99. this.modalIsShow = false;
  100. },
  101. open() {
  102. this.modalIsShow = true;
  103. },
  104. checkData() {
  105. return !this.dataList.some(
  106. (item) => !item.targetList || !item.targetList.length
  107. );
  108. },
  109. toLink(row) {
  110. this.curRow = row;
  111. this.selectedData = [];
  112. row.targetList.forEach((target) => {
  113. target.dimensionList.forEach((dimension) => {
  114. this.selectedData.push(dimension.dimensionId);
  115. });
  116. });
  117. this.$refs.SelectBlueDimensionDialog.open();
  118. },
  119. dimensionSelected(targetList) {
  120. this.curRow.targetList = targetList;
  121. },
  122. async submit() {
  123. if (!this.checkData()) {
  124. this.$message.error("还有小题未设置知识点,请完成设置!");
  125. return;
  126. }
  127. if (this.isSubmit) return;
  128. this.isSubmit = true;
  129. const datas = {
  130. examId: this.course.examId,
  131. courseCode: this.course.courseCode,
  132. paperNumber: this.course.paperNumber,
  133. paperStruct: this.dataList,
  134. };
  135. const data = await endScorePaperPositiveSave(datas).catch(() => {});
  136. this.isSubmit = false;
  137. if (!data) return;
  138. this.$message.success("修改成功!");
  139. this.$emit("modified");
  140. this.cancel();
  141. },
  142. },
  143. };
  144. </script>