ScoreArchive.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <div class="score-archive">
  3. <div class="part-box part-box-filter part-box-flex">
  4. <el-form ref="FilterForm" label-position="left" inline>
  5. <template v-if="checkPrivilege('condition', 'condition')">
  6. <el-form-item label="考试时间:">
  7. <semester-select
  8. v-model="filter.semesterId"
  9. placeholder="考试时间"
  10. ></semester-select>
  11. </el-form-item>
  12. <el-form-item label="学院:">
  13. <college-select
  14. v-model="filter.orgId"
  15. :semester-id="filter.semesterId"
  16. cascader
  17. placeholder="学院"
  18. ></college-select>
  19. </el-form-item>
  20. <el-form-item label="专业:">
  21. <major-select
  22. v-model="filter.majorId"
  23. :college-id="filter.orgId"
  24. cascader
  25. placeholder="专业"
  26. ></major-select>
  27. </el-form-item>
  28. <el-form-item label="班级:">
  29. <class-select
  30. v-model="filter.clazzId"
  31. :major-id="filter.majorId"
  32. cascader
  33. placeholder="班级"
  34. ></class-select>
  35. </el-form-item>
  36. <el-form-item label="课程:">
  37. <course-select
  38. v-model="filter.courseCode"
  39. placeholder="课程"
  40. filterable
  41. clearable
  42. ></course-select>
  43. </el-form-item>
  44. </template>
  45. <el-form-item label-width="0px">
  46. <el-button
  47. v-if="checkPrivilege('button', 'select')"
  48. type="primary"
  49. :disabled="!filter.semesterId || !filter.orgId"
  50. @click="toPage(1)"
  51. >查询</el-button
  52. >
  53. </el-form-item>
  54. </el-form>
  55. <div class="part-box-action">
  56. <el-button
  57. type="success"
  58. icon="el-icon-refresh"
  59. :loading="loading"
  60. @click="toSync"
  61. >同步</el-button
  62. >
  63. <el-button
  64. v-if="checkPrivilege('button', 'BatchDownload')"
  65. type="primary"
  66. icon="el-icon-download"
  67. :loading="loading"
  68. @click="toDownloadAll"
  69. >一键下载</el-button
  70. >
  71. <el-button
  72. v-if="checkPrivilege('button', 'export')"
  73. type="primary"
  74. icon="el-icon-download"
  75. :loading="loading"
  76. @click="toExport"
  77. >成绩导出</el-button
  78. >
  79. </div>
  80. </div>
  81. <div class="part-box part-box-pad">
  82. <el-table ref="TableList" :data="dataList">
  83. <el-table-column
  84. type="index"
  85. label="序号"
  86. width="70"
  87. :index="indexMethod"
  88. ></el-table-column>
  89. <el-table-column prop="semesterName" label="考试时间"></el-table-column>
  90. <el-table-column prop="name" label="姓名" width="120"></el-table-column>
  91. <el-table-column prop="studentCode" label="学号"></el-table-column>
  92. <el-table-column prop="orgName" label="院系"></el-table-column>
  93. <el-table-column prop="majorName" label="专业"></el-table-column>
  94. <el-table-column prop="clazzName" label="班级"></el-table-column>
  95. <el-table-column prop="courseName" label="课程名"></el-table-column>
  96. <el-table-column
  97. prop="totalScore"
  98. label="成绩"
  99. width="80"
  100. ></el-table-column>
  101. <el-table-column class-name="action-column" label="操作" width="160px">
  102. <template slot-scope="scope">
  103. <el-button
  104. v-if="checkPrivilege('link', 'Preview')"
  105. class="btn-primary"
  106. type="text"
  107. @click="toViewPaper(scope.row)"
  108. >查看原卷</el-button
  109. >
  110. <el-button
  111. v-if="checkPrivilege('link', 'download')"
  112. class="btn-primary"
  113. type="text"
  114. :loading="downloading"
  115. @click="toDownload(scope.row)"
  116. >下载</el-button
  117. >
  118. </template>
  119. </el-table-column>
  120. </el-table>
  121. <div class="part-page">
  122. <el-pagination
  123. background
  124. layout="total,prev, pager, next"
  125. :current-page="current"
  126. :total="total"
  127. :page-size="size"
  128. @current-change="toPage"
  129. >
  130. </el-pagination>
  131. </div>
  132. </div>
  133. <!-- image-preview -->
  134. <simple-image-preview
  135. :cur-image="curImage"
  136. simple
  137. ref="SimpleImagePreview"
  138. ></simple-image-preview>
  139. </div>
  140. </template>
  141. <script>
  142. import {
  143. scoreListPage,
  144. scoreExport,
  145. scoreBatchDownload,
  146. scoreDownload,
  147. scoreSync
  148. } from "../api";
  149. // import { downloadPaper } from "../components/downloadPaper";
  150. import { downloadByApi } from "@/plugins/download";
  151. import SimpleImagePreview from "@/components/SimpleImagePreview";
  152. export default {
  153. name: "score-archive",
  154. components: { SimpleImagePreview },
  155. data() {
  156. return {
  157. filter: {
  158. semesterId: "",
  159. orgId: "",
  160. majorId: "",
  161. clazzId: "",
  162. courseCode: ""
  163. },
  164. current: 1,
  165. size: this.GLOBAL.pageSize,
  166. total: 0,
  167. dataList: [],
  168. curImage: {},
  169. curRow: {},
  170. curPapers: [],
  171. downloading: false,
  172. loading: false
  173. };
  174. },
  175. mounted() {
  176. // this.getList();
  177. },
  178. methods: {
  179. async getList() {
  180. if (!this.checkPrivilege("list", "list")) return;
  181. const datas = {
  182. ...this.filter,
  183. pageNumber: this.current,
  184. pageSize: this.size
  185. };
  186. const data = await scoreListPage(datas);
  187. this.dataList = data.records;
  188. this.total = data.total;
  189. },
  190. toPage(page) {
  191. this.current = page;
  192. this.getList();
  193. },
  194. async toSync() {
  195. if (this.loading) return;
  196. this.loading = true;
  197. const res = await scoreSync({ examId: "" }).catch(() => {});
  198. this.loading = false;
  199. if (!res) return;
  200. this.$message.success("同步任务已经提交");
  201. },
  202. async toDownloadAll() {
  203. if (this.loading) return;
  204. this.loading = true;
  205. const res = await scoreBatchDownload(this.filter).catch(() => {});
  206. this.loading = false;
  207. if (!res) return;
  208. this.$message.success("下载任务已经提交");
  209. },
  210. async toExport() {
  211. if (this.loading) return;
  212. this.loading = true;
  213. const res = await scoreExport(this.filter).catch(() => {});
  214. this.loading = false;
  215. if (!res) return;
  216. this.$message.success("导出任务已经提交");
  217. },
  218. toViewPaper(row) {
  219. if (!row.sheetUrls) {
  220. this.$message.error("原卷缺失!");
  221. return;
  222. }
  223. this.curImage = { url: row.sheetUrls };
  224. this.$refs.SimpleImagePreview.open();
  225. },
  226. async toDownload(row) {
  227. if (this.downloading) return;
  228. this.downloading = true;
  229. const res = await downloadByApi(() => {
  230. return scoreDownload(row.studentCode);
  231. }, `${row.name}-原卷.jpg`).catch(e => {
  232. console.log(e);
  233. });
  234. this.downloading = false;
  235. if (!res) {
  236. this.$message.error("下载失败,请重新尝试!");
  237. return;
  238. }
  239. this.$message.success("下载成功!");
  240. }
  241. }
  242. };
  243. </script>