EndScoreManage.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <div class="end-score-manage">
  3. <div class="part-box part-box-pad box-justify">
  4. <p></p>
  5. <div>
  6. <el-button type="success" @click="toImport">导入期末成绩</el-button>
  7. <el-button type="success" @click="toSetBlue">设置试卷蓝图</el-button>
  8. </div>
  9. </div>
  10. <div class="part-box part-box-pad">
  11. <el-table :data="dataList">
  12. <el-table-column type="index" label="序号" width="70"></el-table-column>
  13. <el-table-column prop="name" label="姓名"></el-table-column>
  14. <el-table-column prop="studentCode" label="学号"></el-table-column>
  15. <el-table-column prop="score" label="成绩" width="80">
  16. </el-table-column>
  17. <el-table-column prop="scoreDetailContent" label="成绩明细">
  18. </el-table-column>
  19. <el-table-column class-name="action-column" label="操作" width="120px">
  20. <template slot-scope="scope">
  21. <el-button
  22. class="btn-primary"
  23. type="text"
  24. @click="toEdit(scope.row)"
  25. >编辑</el-button
  26. >
  27. <el-button
  28. :class="scope.row.enable ? 'btn-danger' : 'btn-primary'"
  29. type="text"
  30. @click="toEnable(scope.row)"
  31. >{{ scope.row.enable ? "禁用" : "启用" }}</el-button
  32. >
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. </div>
  37. <!-- ModifyEndScore -->
  38. <modify-end-score
  39. ref="ModifyEndScore"
  40. :instance="curRow"
  41. @modified="getList"
  42. ></modify-end-score>
  43. <!-- ImportFile -->
  44. <import-file
  45. ref="ImportFile"
  46. title="导入期末成绩"
  47. :upload-url="uploadUrl"
  48. :upload-data="filter"
  49. :format="['xls', 'xlsx']"
  50. :download-handle="downloadHandle"
  51. :download-filename="dfilename"
  52. :auto-upload="false"
  53. @upload-success="uploadSuccess"
  54. ></import-file>
  55. <!-- SetBlueDialog -->
  56. <set-blue-dialog ref="SetBlueDialog" :course="course"> </set-blue-dialog>
  57. </div>
  58. </template>
  59. <script>
  60. import {
  61. endScoreListPage,
  62. endScoreEnable,
  63. endScoreTemplateDownload,
  64. } from "../api";
  65. import ModifyEndScore from "./ModifyEndScore.vue";
  66. import SetBlueDialog from "./SetBlueDialog.vue";
  67. import ImportFile from "@/components/ImportFile.vue";
  68. import { downloadByApi } from "@/plugins/download";
  69. export default {
  70. name: "end-score-manage",
  71. components: { ModifyEndScore, SetBlueDialog, ImportFile },
  72. props: {
  73. course: {
  74. type: Object,
  75. default() {
  76. return {};
  77. },
  78. },
  79. },
  80. data() {
  81. return {
  82. filter: {
  83. examId: "",
  84. courseCode: "",
  85. paperNumber: "",
  86. },
  87. current: 1,
  88. size: this.GLOBAL.pageSize,
  89. total: 0,
  90. dataList: [],
  91. curRow: {},
  92. // import
  93. uploadUrl: "/api/admin/course/degree/final_score/import",
  94. dfilename: "期末成绩导入模板.xlsx",
  95. downloading: false,
  96. };
  97. },
  98. mounted() {
  99. this.filter = this.$objAssign(this.filter, this.course);
  100. this.toPage(1);
  101. },
  102. methods: {
  103. async getList() {
  104. const datas = {
  105. ...this.filter,
  106. pageNumber: this.current,
  107. pageSize: this.size,
  108. };
  109. const data = await endScoreListPage(datas);
  110. this.dataList = data.records.map((item) => {
  111. const nitem = { ...item };
  112. if (item.scoreDetail) {
  113. nitem.scoreDetail = JSON.parse(item.scoreDetail);
  114. nitem.scoreDetailContent = nitem.scoreDetail
  115. .map((item) => item.score)
  116. .join();
  117. }
  118. return nitem;
  119. });
  120. this.total = data.total;
  121. },
  122. toPage(page) {
  123. this.current = page;
  124. this.getList();
  125. },
  126. toImport() {
  127. this.$refs.ImportFile.open();
  128. },
  129. toSetBlue() {
  130. this.$refs.SetBlueDialog.open();
  131. },
  132. toEdit(row) {
  133. this.curRow = { ...row };
  134. this.$refs.ModifyEndScore.open();
  135. },
  136. uploadSuccess({ data }) {
  137. let msg = `${data.success}`;
  138. if (data.error) {
  139. msg = +`,${data.error}`;
  140. }
  141. this.$message.success(msg);
  142. this.getList();
  143. },
  144. async downloadHandle() {
  145. if (this.downloading) return;
  146. this.downloading = true;
  147. const res = await downloadByApi(() => {
  148. const datas = {
  149. examId: this.course.examId,
  150. courseCode: this.course.courseCode,
  151. paperNumber: this.course.paperNumber,
  152. };
  153. return endScoreTemplateDownload(datas);
  154. }).catch((e) => {
  155. this.$message.error(e || "下载失败,请重新尝试!");
  156. });
  157. this.downloading = false;
  158. if (!res) return;
  159. this.$message.success("下载成功!");
  160. },
  161. async toEnable(row) {
  162. const action = row.enable ? "禁用" : "启用";
  163. const confirm = await this.$confirm(
  164. `确定要${action}考生【${row.name}】的成绩吗?`,
  165. "提示",
  166. {
  167. type: "warning",
  168. }
  169. ).catch(() => {});
  170. if (confirm !== "confirm") return;
  171. const enable = !row.enable;
  172. await endScoreEnable({
  173. id: row.id,
  174. enable,
  175. });
  176. row.enable = enable;
  177. this.$message.success("操作成功!");
  178. },
  179. },
  180. };
  181. </script>