EndScoreManage.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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
  7. type="success"
  8. :loading="syncing"
  9. :disabled="importing"
  10. @click="toSync"
  11. >同步成绩</el-button
  12. >
  13. <el-button
  14. type="success"
  15. :loading="importing"
  16. :disabled="syncing"
  17. @click="toImportPaperStruct"
  18. >导入试卷结构</el-button
  19. >
  20. <el-button
  21. type="success"
  22. :loading="importing"
  23. :disabled="syncing"
  24. @click="toImportEndScore"
  25. >导入期末成绩</el-button
  26. >
  27. <el-button type="success" @click="toSetBlue">设置试卷蓝图</el-button>
  28. </div>
  29. </div>
  30. <div class="part-box part-box-pad">
  31. <el-table :data="dataList">
  32. <el-table-column type="index" label="序号" width="70"></el-table-column>
  33. <el-table-column prop="name" label="姓名" width="140"></el-table-column>
  34. <el-table-column
  35. prop="studentCode"
  36. label="学号"
  37. width="140"
  38. ></el-table-column>
  39. <el-table-column prop="score" label="成绩" width="80">
  40. </el-table-column>
  41. <el-table-column prop="scoreDetailContent" label="成绩明细">
  42. </el-table-column>
  43. <el-table-column class-name="action-column" label="操作" width="120px">
  44. <template slot-scope="scope">
  45. <el-button
  46. class="btn-primary"
  47. type="text"
  48. @click="toEdit(scope.row)"
  49. >编辑</el-button
  50. >
  51. <el-button
  52. :class="scope.row.enable ? 'btn-danger' : 'btn-primary'"
  53. type="text"
  54. @click="toEnable(scope.row)"
  55. >{{ scope.row.enable ? "禁用" : "启用" }}</el-button
  56. >
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. <div class="part-page">
  61. <el-pagination
  62. background
  63. layout="total, sizes, prev, pager, next, jumper"
  64. :pager-count="5"
  65. :current-page="current"
  66. :total="total"
  67. :page-size="size"
  68. @current-change="toPage"
  69. @size-change="pageSizeChange"
  70. >
  71. </el-pagination>
  72. </div>
  73. </div>
  74. <!-- ModifyEndScore -->
  75. <modify-end-score
  76. ref="ModifyEndScore"
  77. :instance="curRow"
  78. @modified="getList"
  79. ></modify-end-score>
  80. <!-- ImportEndScore -->
  81. <import-file
  82. ref="ImportEndScore"
  83. title="导入期末成绩"
  84. :upload-url="upload.score.uploadUrl"
  85. :upload-data="filter"
  86. :format="['xls', 'xlsx']"
  87. :download-handle="downloadHandle"
  88. :download-filename="upload.score.dfilename"
  89. :auto-upload="false"
  90. :uploading="uploading"
  91. @upload-success="uploadSuccess"
  92. @upload-error="uploadError"
  93. ></import-file>
  94. <!-- ImportPaperStruct -->
  95. <import-file
  96. ref="ImportPaperStruct"
  97. title="导入试卷结构"
  98. :upload-url="upload.paper.uploadUrl"
  99. :upload-data="filter"
  100. :format="['xls', 'xlsx']"
  101. :download-handle="() => downloadTemplate('paperStruct')"
  102. :download-filename="upload.paper.dfilename"
  103. :auto-upload="false"
  104. :uploading="uploading"
  105. @upload-success="uploadSuccess"
  106. @upload-error="uploadError"
  107. ></import-file>
  108. <!-- SetBlueDialog -->
  109. <set-blue-dialog ref="SetBlueDialog" :course="course"> </set-blue-dialog>
  110. <!-- select papers -->
  111. <sync-paper-dialog
  112. ref="SyncPaperDialog"
  113. :course="filter"
  114. @modified="getList"
  115. ></sync-paper-dialog>
  116. </div>
  117. </template>
  118. <script>
  119. import {
  120. endScoreListPage,
  121. endScoreEnable,
  122. endScoreTemplateDownload,
  123. } from "../../api";
  124. import ModifyEndScore from "./ModifyEndScore.vue";
  125. import SetBlueDialog from "./SetBlueDialog.vue";
  126. import ImportFile from "@/components/ImportFile.vue";
  127. import SyncPaperDialog from "./SyncPaperDialog.vue";
  128. import { downloadByApi } from "@/plugins/download";
  129. import templateDownload from "@/mixins/templateDownload";
  130. export default {
  131. name: "end-score-manage",
  132. components: { ModifyEndScore, SetBlueDialog, ImportFile, SyncPaperDialog },
  133. mixins: [templateDownload],
  134. props: {
  135. course: {
  136. type: Object,
  137. default() {
  138. return {};
  139. },
  140. },
  141. },
  142. data() {
  143. return {
  144. filter: {
  145. cultureProgramId: "",
  146. courseId: "",
  147. teachCourseId: "",
  148. },
  149. current: 1,
  150. size: this.GLOBAL.pageSize,
  151. total: 0,
  152. dataList: [],
  153. curRow: {},
  154. syncing: false,
  155. importing: false,
  156. // import
  157. upload: {
  158. score: {
  159. uploadUrl: "/api/admin/course/degree/final_score/import",
  160. dfilename: "期末成绩导入模板.xlsx",
  161. },
  162. paper: {
  163. uploadUrl: "/api/admin/course/degree/final_score/paper_struct/import",
  164. dfilename: "试卷结构导入模板.xlsx",
  165. },
  166. },
  167. downloading: false,
  168. };
  169. },
  170. mounted() {
  171. this.filter = this.$objAssign(this.filter, this.course);
  172. this.toPage(1);
  173. },
  174. methods: {
  175. async getList() {
  176. const datas = {
  177. ...this.filter,
  178. pageNumber: this.current,
  179. pageSize: this.size,
  180. };
  181. const data = await endScoreListPage(datas);
  182. this.dataList = data.records.map((item) => {
  183. const nitem = { ...item };
  184. if (item.scoreDetail) {
  185. nitem.scoreDetail = JSON.parse(item.scoreDetail);
  186. nitem.scoreDetailContent = nitem.scoreDetail
  187. .map((item) => item.score)
  188. .join();
  189. }
  190. return nitem;
  191. });
  192. this.total = data.total;
  193. },
  194. toPage(page) {
  195. this.current = page;
  196. this.getList();
  197. },
  198. toImportEndScore() {
  199. this.$refs.ImportEndScore.open();
  200. },
  201. toImportPaperStruct() {
  202. this.$refs.ImportPaperStruct.open();
  203. },
  204. toSync() {
  205. this.$refs.SyncPaperDialog.open();
  206. },
  207. toSetBlue() {
  208. this.$refs.SetBlueDialog.open();
  209. },
  210. toEdit(row) {
  211. this.curRow = { ...row, teachCourseId: this.course.teachCourseId };
  212. this.$refs.ModifyEndScore.open();
  213. },
  214. uploading() {
  215. this.importing = true;
  216. },
  217. uploadSuccess({ data }) {
  218. this.importing = false;
  219. const msg = `${data.success},错误:${data.error}`;
  220. this.$message.success(msg);
  221. this.getList();
  222. },
  223. uploadError() {
  224. this.importing = false;
  225. },
  226. async downloadHandle() {
  227. if (this.downloading) return;
  228. this.downloading = true;
  229. const res = await downloadByApi(() => {
  230. return endScoreTemplateDownload(this.filter);
  231. }).catch((e) => {
  232. this.$message.error(e || "下载失败,请重新尝试!");
  233. });
  234. this.downloading = false;
  235. if (!res) return;
  236. this.$message.success("下载成功!");
  237. },
  238. async toEnable(row) {
  239. const action = row.enable ? "禁用" : "启用";
  240. const confirm = await this.$confirm(
  241. `确定要${action}考生【${row.name}】的成绩吗?`,
  242. "提示",
  243. {
  244. type: "warning",
  245. }
  246. ).catch(() => {});
  247. if (confirm !== "confirm") return;
  248. const enable = !row.enable;
  249. await endScoreEnable({
  250. id: row.id,
  251. enable,
  252. teachCourseId: this.course.teachCourseId,
  253. });
  254. row.enable = enable;
  255. this.$message.success("操作成功!");
  256. },
  257. },
  258. };
  259. </script>