AnalysisBatchManage.vue 10 KB

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