SetBlueDialog.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div>
  3. <el-dialog
  4. :visible.sync="modalIsShow"
  5. title="设置试卷蓝图"
  6. top="10px"
  7. width="660px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @open="visibleChange"
  12. >
  13. <div class="mb-2 box-justify">
  14. <div class="box-grow mr-2"></div>
  15. <el-button type="primary" :loading="loading" @click="toSync"
  16. >同步</el-button
  17. >
  18. </div>
  19. <el-table :data="dataList" border height="400">
  20. <el-table-column
  21. prop="mainNumber"
  22. label="大题号"
  23. width="80px"
  24. ></el-table-column>
  25. <el-table-column
  26. prop="subNumber"
  27. label="小题号"
  28. width="80px"
  29. ></el-table-column>
  30. <el-table-column
  31. prop="score"
  32. label="小题满分"
  33. width="80px"
  34. ></el-table-column>
  35. <el-table-column prop="courseTargetName" label="所属课程目标">
  36. </el-table-column>
  37. <!-- <el-table-column prop="dimensionList" label="知识点">
  38. <template slot-scope="scope">
  39. <template v-for="target in scope.row.targetList">
  40. <p
  41. v-for="item in target.dimensionList"
  42. :key="`${target.targetId}_${item.dimensionId}`"
  43. >
  44. {{ item.dimensionName }}
  45. </p>
  46. </template>
  47. </template>
  48. </el-table-column> -->
  49. <el-table-column class-name="action-column" label="操作" width="110px">
  50. <template slot-scope="scope">
  51. <el-button
  52. class="btn-primary"
  53. type="text"
  54. @click="toLink(scope.row)"
  55. >关联知识点</el-button
  56. >
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. <div v-if="totalInfo" class="mt-2">{{ totalInfo }}</div>
  61. <div slot="footer">
  62. <el-button type="primary" :disabled="isSubmit" @click="submit"
  63. >确认</el-button
  64. >
  65. <el-button @click="cancel">取消</el-button>
  66. </div>
  67. </el-dialog>
  68. <!-- 设置知识点 -->
  69. <select-blue-dimension-dialog
  70. ref="SelectBlueDimensionDialog"
  71. :tree-data="treeData"
  72. :selected-data="selectedData"
  73. :unuse-targets="unuseTargets"
  74. @confirm="dimensionSelected"
  75. ></select-blue-dimension-dialog>
  76. </div>
  77. </template>
  78. <script>
  79. import {
  80. endScorePaperPositiveDetail,
  81. endScorePaperPositiveSave,
  82. endScorePaperPositiveSync,
  83. courseOutlineTargetListPage,
  84. courseExamineWeightDetail,
  85. } from "../../api";
  86. import SelectBlueDimensionDialog from "./SelectBlueDimensionDialog.vue";
  87. export default {
  88. name: "SetBlueDialog",
  89. components: { SelectBlueDimensionDialog },
  90. props: {
  91. course: {
  92. type: Object,
  93. default() {
  94. return {};
  95. },
  96. },
  97. },
  98. data() {
  99. return {
  100. modalIsShow: false,
  101. isSubmit: false,
  102. dataList: [],
  103. curRow: {},
  104. selectedData: [],
  105. treeData: [],
  106. loading: false,
  107. totalInfo: "",
  108. unuseTargets: [],
  109. };
  110. },
  111. watch: {
  112. "course.obeCourseOutlineId": {
  113. immediate: true,
  114. handler(val, oldVal) {
  115. if (!val) return;
  116. if (val !== oldVal) this.getTree();
  117. },
  118. },
  119. },
  120. methods: {
  121. async getTree() {
  122. await this.getUnuseTarget();
  123. const data = await courseOutlineTargetListPage({
  124. obeCourseOutlineId: this.course.obeCourseOutlineId,
  125. });
  126. this.treeData = (data || []).map((item) => {
  127. return {
  128. id: item.id,
  129. kid: item.id,
  130. name: item.targetName,
  131. totalWeight: item.totalWeight,
  132. disabled: false,
  133. children: item.dimensionList.map((elem) => {
  134. return {
  135. ...elem,
  136. kid: `${item.id}_${elem.id}`,
  137. disabled: false,
  138. };
  139. }),
  140. };
  141. });
  142. },
  143. async getUnuseTarget() {
  144. const res = await courseExamineWeightDetail({
  145. obeCourseOutlineId: this.course.obeCourseOutlineId,
  146. });
  147. const dataList = res.submitForm || [];
  148. this.unuseTargets = dataList
  149. .filter((item) => {
  150. return !item.evaluationList[0].weight;
  151. })
  152. .map((item) => item.courseTargetId);
  153. },
  154. async getBlueDetail() {
  155. const res = await endScorePaperPositiveDetail({
  156. cultureProgramId: this.course.cultureProgramId,
  157. courseId: this.course.courseId,
  158. examId: this.course.examId,
  159. paperNumber: this.course.paperNumber,
  160. });
  161. this.dataList = res || [];
  162. this.updateTotalInfo();
  163. },
  164. visibleChange() {
  165. this.getBlueDetail();
  166. },
  167. cancel() {
  168. this.modalIsShow = false;
  169. },
  170. open() {
  171. this.modalIsShow = true;
  172. },
  173. async toSync() {
  174. if (this.loading) return;
  175. this.loading = true;
  176. const res = await endScorePaperPositiveSync({
  177. cultureProgramId: this.course.cultureProgramId,
  178. courseId: this.course.courseId,
  179. paperNumber: this.dataList[0]?.paperNumber,
  180. examId: this.dataList[0]?.examId,
  181. }).catch(() => {});
  182. this.loading = false;
  183. if (!res) return;
  184. this.$message.success(`${res.success},错误:${res.error}`);
  185. this.getBlueDetail();
  186. },
  187. checkData() {
  188. const valid = !this.dataList.some(
  189. (item) => !item.targetList || !item.targetList.length
  190. );
  191. if (!valid) {
  192. this.$message.error("还有小题未设置知识点,请完成设置!");
  193. return;
  194. }
  195. return true;
  196. },
  197. toLink(row) {
  198. this.curRow = row;
  199. this.selectedData = [];
  200. row.targetList.forEach((target) => {
  201. target.dimensionList.forEach((dimension) => {
  202. this.selectedData.push(`${target.targetId}_${dimension.dimensionId}`);
  203. });
  204. });
  205. this.$refs.SelectBlueDimensionDialog.open();
  206. },
  207. dimensionSelected(targetList) {
  208. this.curRow.targetList = targetList;
  209. this.curRow.courseTargetName = targetList[0].targetName;
  210. this.updateTotalInfo();
  211. },
  212. updateTotalInfo() {
  213. const data = {};
  214. this.dataList.forEach((item) => {
  215. const target = item.targetList[0];
  216. if (!target) return;
  217. if (!data[target.targetName]) data[target.targetName] = 0;
  218. data[target.targetName] += item.score;
  219. });
  220. this.totalInfo = Object.keys(data)
  221. .map((key) => `${key}共${data[key]}分`)
  222. .join(",");
  223. },
  224. async submit() {
  225. if (!this.checkData()) {
  226. return;
  227. }
  228. if (this.isSubmit) return;
  229. this.isSubmit = true;
  230. const datas = {
  231. cultureProgramId: this.course.cultureProgramId,
  232. courseId: this.course.courseId,
  233. paperStruct: this.dataList,
  234. examId: this.course.examId,
  235. paperNumber: this.course.paperNumber,
  236. };
  237. const data = await endScorePaperPositiveSave(datas).catch(() => {});
  238. this.isSubmit = false;
  239. if (!data) return;
  240. this.$message.success("修改成功!");
  241. this.$emit("modified");
  242. this.cancel();
  243. },
  244. },
  245. };
  246. </script>