SetBlueDialog.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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 { mapState } from "vuex";
  80. import {
  81. endScorePaperPositiveDetail,
  82. endScorePaperPositiveSave,
  83. endScorePaperPositiveSync,
  84. courseOutlineTargetListPage,
  85. courseExamineWeightDetail,
  86. } from "../../api";
  87. import SelectBlueDimensionDialog from "./SelectBlueDimensionDialog.vue";
  88. export default {
  89. name: "SetBlueDialog",
  90. components: { SelectBlueDimensionDialog },
  91. data() {
  92. return {
  93. modalIsShow: false,
  94. isSubmit: false,
  95. dataList: [],
  96. curRow: {},
  97. selectedData: [],
  98. treeData: [],
  99. loading: false,
  100. totalInfo: "",
  101. unuseTargets: [],
  102. };
  103. },
  104. computed: {
  105. ...mapState("target", ["course"]),
  106. },
  107. watch: {
  108. "course.obeCourseOutlineId": {
  109. immediate: true,
  110. handler(val, oldVal) {
  111. if (!val) return;
  112. if (val !== oldVal) this.getTree();
  113. },
  114. },
  115. },
  116. methods: {
  117. async getTree() {
  118. await this.getUnuseTarget();
  119. const data = await courseOutlineTargetListPage({
  120. obeCourseOutlineId: this.course.obeCourseOutlineId,
  121. });
  122. this.treeData = (data || []).map((item) => {
  123. return {
  124. id: item.id,
  125. kid: item.id,
  126. name: item.targetName,
  127. totalWeight: item.totalWeight,
  128. disabled: false,
  129. children: item.dimensionList.map((elem) => {
  130. return {
  131. ...elem,
  132. kid: `${item.id}_${elem.id}`,
  133. disabled: false,
  134. };
  135. }),
  136. };
  137. });
  138. },
  139. async getUnuseTarget() {
  140. const res = await courseExamineWeightDetail({
  141. obeCourseOutlineId: this.course.obeCourseOutlineId,
  142. });
  143. const dataList = res.submitForm || [];
  144. this.unuseTargets = dataList
  145. .filter((item) => {
  146. return !item.evaluationList[0].weight;
  147. })
  148. .map((item) => item.courseTargetId);
  149. },
  150. async getBlueDetail() {
  151. const res = await endScorePaperPositiveDetail({
  152. cultureProgramId: this.course.cultureProgramId,
  153. courseId: this.course.courseId,
  154. examId: this.course.examId,
  155. paperNumber: this.course.paperNumber,
  156. });
  157. this.dataList = res || [];
  158. this.updateTotalInfo();
  159. },
  160. visibleChange() {
  161. this.getBlueDetail();
  162. },
  163. cancel() {
  164. this.modalIsShow = false;
  165. },
  166. open() {
  167. this.modalIsShow = true;
  168. },
  169. async toSync() {
  170. if (this.loading) return;
  171. this.loading = true;
  172. const res = await endScorePaperPositiveSync({
  173. cultureProgramId: this.course.cultureProgramId,
  174. courseId: this.course.courseId,
  175. paperNumber: this.dataList[0]?.paperNumber,
  176. examId: this.dataList[0]?.examId,
  177. }).catch(() => {});
  178. this.loading = false;
  179. if (!res) return;
  180. this.$message.success(`${res.success},错误:${res.error}`);
  181. this.getBlueDetail();
  182. },
  183. checkData() {
  184. const valid = !this.dataList.some(
  185. (item) => !item.targetList || !item.targetList.length
  186. );
  187. if (!valid) {
  188. this.$message.error("还有小题未设置知识点,请完成设置!");
  189. return;
  190. }
  191. return true;
  192. },
  193. toLink(row) {
  194. this.curRow = row;
  195. this.selectedData = [];
  196. row.targetList.forEach((target) => {
  197. target.dimensionList.forEach((dimension) => {
  198. this.selectedData.push(`${target.targetId}_${dimension.dimensionId}`);
  199. });
  200. });
  201. this.$refs.SelectBlueDimensionDialog.open();
  202. },
  203. dimensionSelected(targetList) {
  204. this.curRow.targetList = targetList;
  205. this.curRow.courseTargetName = targetList[0].targetName;
  206. this.updateTotalInfo();
  207. },
  208. updateTotalInfo() {
  209. const data = {};
  210. this.dataList.forEach((item) => {
  211. const target = item.targetList[0];
  212. if (!target) return;
  213. if (!data[target.targetName]) data[target.targetName] = 0;
  214. data[target.targetName] += item.score;
  215. });
  216. this.totalInfo = Object.keys(data)
  217. .map((key) => `${key}共${data[key]}分`)
  218. .join(",");
  219. },
  220. async submit() {
  221. if (!this.checkData()) {
  222. return;
  223. }
  224. if (this.isSubmit) return;
  225. this.isSubmit = true;
  226. const datas = {
  227. cultureProgramId: this.course.cultureProgramId,
  228. courseId: this.course.courseId,
  229. paperStruct: this.dataList,
  230. examId: this.course.examId,
  231. paperNumber: this.course.paperNumber,
  232. };
  233. const data = await endScorePaperPositiveSave(datas).catch(() => {});
  234. this.isSubmit = false;
  235. if (!data) return;
  236. this.$message.success("修改成功!");
  237. this.$emit("modified");
  238. this.cancel();
  239. },
  240. },
  241. };
  242. </script>