AnalysisBatchManage.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <div class="analysis-batch-manage">
  3. <div class="part-box part-box-filter part-box-flex">
  4. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  5. <template v-if="checkPrivilege('condition', 'condition')">
  6. <el-form-item label="分析批次:">
  7. <el-input
  8. style="width:100%;"
  9. v-model.trim="filter.gradeBatchName"
  10. placeholder="请输入批次名称"
  11. clearable
  12. ></el-input>
  13. </el-form-item>
  14. </template>
  15. <el-form-item>
  16. <el-button
  17. v-if="checkPrivilege('button', 'select')"
  18. type="primary"
  19. @click="toPage(1)"
  20. >查询</el-button
  21. >
  22. </el-form-item>
  23. </el-form>
  24. <div class="part-box-action">
  25. <el-button
  26. v-if="checkPrivilege('button', 'delete')"
  27. type="danger"
  28. :loading="loading"
  29. @click="toBatchDelete"
  30. >批量删除</el-button
  31. >
  32. <el-button
  33. v-if="checkPrivilege('button', 'add')"
  34. type="primary"
  35. @click="toAdd"
  36. >新建分析批次</el-button
  37. >
  38. </div>
  39. </div>
  40. <div class="part-box part-box-pad">
  41. <el-table
  42. ref="TableList"
  43. :data="dataList"
  44. @selection-change="handleSelectionChange"
  45. >
  46. <el-table-column
  47. type="selection"
  48. width="55"
  49. align="center"
  50. ></el-table-column>
  51. <el-table-column prop="batchName" label="分析批次"></el-table-column>
  52. <el-table-column prop="semesterName" label="学期"></el-table-column>
  53. <el-table-column prop="status" label="状态">
  54. <template slot-scope="scope">
  55. <span>
  56. {{ scope.row.status | analysisBatchStatusFilter }}
  57. </span>
  58. <span v-if="scope.row.status === 'CALCULATING'" class="ml-2">
  59. {{ scope.row.progress }}%</span
  60. >
  61. <span
  62. v-if="scope.row.status === 'FINISH_CALCULATE'"
  63. :class="[
  64. 'ml-2',
  65. scope.row.result === 'SUCCESS'
  66. ? 'color-success'
  67. : 'color-danger'
  68. ]"
  69. >
  70. {{ scope.row.result === "SUCCESS" ? "成功" : "失败" }}
  71. </span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column
  75. class-name="action-column"
  76. label="操作"
  77. width="300"
  78. align="center"
  79. >
  80. <template slot-scope="scope">
  81. <el-button
  82. v-if="checkPrivilege('link', 'window')"
  83. class="btn-primary"
  84. type="text"
  85. :disabled="loading"
  86. @click="toAddCourse(scope.row)"
  87. >添加分析试卷</el-button
  88. >
  89. <el-button
  90. v-if="
  91. checkPrivilege('link', 'StartCalc') &&
  92. scope.row.status === 'READY_TO_CALCULATE'
  93. "
  94. class="btn-primary"
  95. type="text"
  96. :disabled="loading"
  97. @click="toCalc(scope.row)"
  98. >开始计算</el-button
  99. >
  100. <el-button
  101. v-if="
  102. checkPrivilege('link', 'push') &&
  103. scope.row.status === 'PUSH_GRADE_BATCH'
  104. "
  105. class="btn-primary"
  106. type="text"
  107. :disabled="loading"
  108. @click="toImportAnalysisData(scope.row)"
  109. >提交分析数据</el-button
  110. >
  111. <el-button
  112. v-if="
  113. checkPrivilege('link', 'import') &&
  114. scope.row.status !== 'SETTING_GRADE_PAPER'
  115. "
  116. class="btn-primary"
  117. type="text"
  118. :disabled="loading"
  119. @click="toImport(scope.row)"
  120. >导入</el-button
  121. >
  122. <el-button
  123. v-if="checkPrivilege('link', 'delete')"
  124. class="btn-danger"
  125. type="text"
  126. :disabled="loading"
  127. @click="toDelete(scope.row)"
  128. >删除</el-button
  129. >
  130. <el-button
  131. v-if="
  132. scope.row.reportFilePath &&
  133. scope.row.status === 'FINISH_CALCULATE'
  134. "
  135. class="btn-primary"
  136. type="text"
  137. @click="toViewLog(row)"
  138. >下载日志</el-button
  139. >
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <div class="part-page">
  144. <el-pagination
  145. background
  146. layout="total,prev, pager, next"
  147. :current-page="current"
  148. :total="total"
  149. :page-size="size"
  150. @current-change="toPage"
  151. >
  152. </el-pagination>
  153. </div>
  154. </div>
  155. <!-- ModifyAnalysisBatch -->
  156. <modify-analysis-batch
  157. v-if="checkPrivilege('button', 'add')"
  158. ref="ModifyAnalysisBatch"
  159. :instance="curRow"
  160. @modified="getList"
  161. ></modify-analysis-batch>
  162. <!-- ModifyAnalysisBatchPaper -->
  163. <modify-analysis-batch-paper
  164. v-if="checkPrivilege('link', 'window')"
  165. ref="ModifyAnalysisBatchPaper"
  166. :instance="curRow"
  167. @closed="getList"
  168. ></modify-analysis-batch-paper>
  169. <!-- 数据导入 -->
  170. <import-file
  171. v-if="checkPrivilege('link', 'import')"
  172. ref="ImportFile"
  173. title="上传文件"
  174. :upload-url="uploadUrl"
  175. :upload-data="uploadData"
  176. :download-handle="downloadHandle"
  177. download-filename="考务数据模板"
  178. :format="['xls', 'xlsx']"
  179. @upload-success="fileUploaded"
  180. >
  181. </import-file>
  182. </div>
  183. </template>
  184. <script>
  185. import {
  186. analysisBatchList,
  187. deleteAnalysisBatch,
  188. analysisBatchTemplateExport,
  189. analysisDataImport,
  190. analysisBatchCalc
  191. } from "../api";
  192. import ModifyAnalysisBatch from "../components/ModifyAnalysisBatch.vue";
  193. import ModifyAnalysisBatchPaper from "../components/ModifyAnalysisBatchPaper.vue";
  194. import ImportFile from "@/components/ImportFile";
  195. import { downloadByApi } from "@/plugins/download";
  196. import timeMixins from "../../../mixins/timeMixin";
  197. export default {
  198. name: "analysis-batch-manage",
  199. components: { ModifyAnalysisBatch, ModifyAnalysisBatchPaper, ImportFile },
  200. mixins: [timeMixins],
  201. data() {
  202. return {
  203. filter: {
  204. gradeBatchName: ""
  205. },
  206. current: 1,
  207. size: this.GLOBAL.pageSize,
  208. total: 0,
  209. dataList: [],
  210. curRow: {},
  211. batchs: [],
  212. loading: false,
  213. multipleSelection: [],
  214. // upload
  215. uploadUrl: "/api/admin/grade/batch/upload",
  216. uploadData: {},
  217. downloading: false
  218. };
  219. },
  220. mounted() {
  221. this.toPage(1);
  222. },
  223. beforeDestroy() {
  224. this.clearSetTs();
  225. },
  226. methods: {
  227. async getList() {
  228. if (!this.checkPrivilege("list", "list")) return;
  229. this.clearSetTs();
  230. const datas = {
  231. ...this.filter,
  232. pageNumber: this.current,
  233. pageSize: this.size
  234. };
  235. const data = await analysisBatchList(datas);
  236. this.dataList = data.records.map(item => {
  237. item.loading = false;
  238. return item;
  239. });
  240. this.total = data.total;
  241. if (this.dataList.some(item => item.status === "CALCULATING")) {
  242. this.addSetTime(() => {
  243. this.getList();
  244. }, 10 * 1000);
  245. }
  246. },
  247. toPage(page) {
  248. this.multipleSelection = [];
  249. this.current = page;
  250. this.getList();
  251. },
  252. handleSelectionChange(val) {
  253. this.multipleSelection = val.map(item => item.id);
  254. },
  255. async toBatchDelete() {
  256. if (!this.multipleSelection.length) {
  257. this.$message.error("请选择要删除的批次!");
  258. return;
  259. }
  260. const confirm = await this.$confirm(`确定要删除选中的批次吗?`, "提示", {
  261. type: "warning"
  262. }).catch(() => {});
  263. if (confirm !== "confirm") return;
  264. await deleteAnalysisBatch(this.multipleSelection);
  265. this.$message.success("删除成功!");
  266. this.deletePageLastItem();
  267. },
  268. toAdd() {
  269. this.curRow = {};
  270. this.$refs.ModifyAnalysisBatch.open();
  271. },
  272. toAddCourse(row) {
  273. this.curRow = row;
  274. this.$refs.ModifyAnalysisBatchPaper.open();
  275. },
  276. async toCalc(row) {
  277. if (row.loading) return;
  278. row.loading = true;
  279. const res = await analysisBatchCalc({ batchId: row.id }).catch(() => {});
  280. row.loading = false;
  281. if (!res) return;
  282. this.$message.success("操作成功!");
  283. this.getList();
  284. },
  285. async toImportAnalysisData(row) {
  286. if (row.loading) return;
  287. row.loading = true;
  288. const res = await analysisDataImport({ batchId: row.id }).catch(() => {});
  289. row.loading = false;
  290. if (!res) return;
  291. this.$message.success("操作成功!");
  292. this.getList();
  293. },
  294. toImport(row) {
  295. this.curRow = row;
  296. this.uploadData = {
  297. batchId: row.id
  298. };
  299. this.$refs.ImportFile.open();
  300. },
  301. fileUploaded() {
  302. this.getList();
  303. },
  304. async downloadHandle() {
  305. if (this.downloading) return;
  306. this.downloading = true;
  307. const res = await downloadByApi(() => {
  308. return analysisBatchTemplateExport({
  309. batchId: this.curRow.id
  310. });
  311. }).catch(e => {
  312. this.$message.error(e || "下载失败,请重新尝试!");
  313. });
  314. this.downloading = false;
  315. if (!res) return;
  316. this.$message.success("下载成功!");
  317. },
  318. async toDelete(row) {
  319. const confirm = await this.$confirm(
  320. `确定要删除批次【${row.batchName}】吗?`,
  321. "提示",
  322. {
  323. type: "warning"
  324. }
  325. ).catch(() => {});
  326. if (confirm !== "confirm") return;
  327. await deleteAnalysisBatch([row.id]);
  328. this.$message.success("删除成功!");
  329. this.deletePageLastItem();
  330. },
  331. toViewLog(row) {
  332. window.open(row.reportFilePath);
  333. }
  334. }
  335. };
  336. </script>