DataTaskManage.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <div class="data-task-manage">
  3. <div class="part-box part-box-filter part-box-flex">
  4. <el-form ref="FilterForm" label-position="left" label-width="55px" inline>
  5. <template v-if="checkPriv('condition', 'condition')">
  6. <secp-select
  7. v-model="filter"
  8. @semester-default="toPage(1)"
  9. ></secp-select>
  10. <el-form-item label="类别:">
  11. <el-select
  12. v-model="filter.type"
  13. placeholder="类别"
  14. clearable
  15. filterable
  16. :disabled="typeDisabled"
  17. style="width: 300px"
  18. >
  19. <el-option
  20. v-for="(val, key) in DATA_TASK_TYPE"
  21. :key="key"
  22. :value="key"
  23. :label="val"
  24. ></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="状态:">
  28. <el-select
  29. v-model="filter.status"
  30. placeholder="状态"
  31. clearable
  32. style="width: 120px"
  33. >
  34. <el-option
  35. v-for="(val, key) in DATA_TASK_STATUS"
  36. :key="key"
  37. :value="key"
  38. :label="val"
  39. ></el-option>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="数据结果:" label-width="85px">
  43. <el-select
  44. v-model="filter.result"
  45. placeholder="数据结果"
  46. clearable
  47. style="width: 120px"
  48. >
  49. <el-option
  50. v-for="(val, key) in DATA_TASK_RESULT"
  51. :key="key"
  52. :value="key"
  53. :label="val"
  54. ></el-option>
  55. </el-select>
  56. </el-form-item>
  57. </template>
  58. <el-form-item>
  59. <el-button
  60. v-if="checkPriv('button', 'select')"
  61. type="primary"
  62. @click="toPage(1)"
  63. >查询</el-button
  64. >
  65. </el-form-item>
  66. </el-form>
  67. <div class="part-box-action">
  68. <!-- <el-button
  69. type="danger"
  70. icon="el-icon-delete"
  71. @click="toRemove('DELETE')"
  72. >批量删除</el-button
  73. >
  74. <el-button
  75. type="danger"
  76. icon="el-icon-delete-solid"
  77. @click="toRemove('CLEAR')"
  78. >清空</el-button
  79. > -->
  80. </div>
  81. </div>
  82. <div class="part-box part-box-pad">
  83. <el-table
  84. ref="TableList"
  85. :data="tasks"
  86. @selection-change="handleSelectionChange"
  87. >
  88. <el-table-column
  89. type="index"
  90. label="序号"
  91. width="50"
  92. :index="indexMethod"
  93. ></el-table-column>
  94. <el-table-column
  95. prop="semesterName"
  96. label="学期"
  97. min-width="160"
  98. ></el-table-column>
  99. <el-table-column
  100. prop="examName"
  101. label="考试"
  102. min-width="160"
  103. ></el-table-column>
  104. <el-table-column
  105. prop="paperNumber"
  106. label="试卷编号"
  107. min-width="100"
  108. ></el-table-column>
  109. <el-table-column prop="courseName" label="课程(代码)" min-width="200">
  110. <template slot-scope="scope">
  111. {{ scope.row.courseName }}({{ scope.row.courseCode }})
  112. </template>
  113. </el-table-column>
  114. <el-table-column
  115. prop="printPlanName"
  116. label="项目"
  117. min-width="120"
  118. ></el-table-column>
  119. <el-table-column prop="type" label="类别" width="160">
  120. </el-table-column>
  121. <el-table-column prop="status" label="状态" width="100">
  122. </el-table-column>
  123. <el-table-column prop="result" label="结果" width="100">
  124. </el-table-column>
  125. <el-table-column prop="createTime" label="创建时间" width="170">
  126. <span slot-scope="scope">{{
  127. scope.row.createTime | timestampFilter
  128. }}</span>
  129. </el-table-column>
  130. <el-table-column
  131. prop="createName"
  132. label="创建人"
  133. min-width="80"
  134. ></el-table-column>
  135. <el-table-column
  136. class-name="action-column"
  137. label="操作"
  138. width="160px"
  139. fixed="right"
  140. >
  141. <template slot-scope="scope">
  142. <el-button
  143. v-if="scope.row.hasReportFile && checkPriv('link', 'export')"
  144. class="btn-primary"
  145. type="text"
  146. :disabled="loading"
  147. @click="toDonwloadFile(scope.row.id, 'TASK_REPORT')"
  148. >导出日志</el-button
  149. >
  150. <el-button
  151. v-if="scope.row.resetCreatePdf && checkPriv('link', 'createPdf')"
  152. class="btn-primary"
  153. type="text"
  154. :disabled="loading"
  155. @click="toResetCreatePdf(scope.row)"
  156. >重新生成PDF</el-button
  157. >
  158. <el-button
  159. v-if="scope.row.hasResultFile && checkPriv('link', 'download')"
  160. class="btn-primary"
  161. type="text"
  162. :disabled="loading"
  163. @click="toDonwloadFile(scope.row.id, scope.row.downloadType)"
  164. >下载文件</el-button
  165. >
  166. <el-button
  167. v-if="scope.row.hasErrorFile"
  168. class="btn-primary"
  169. type="text"
  170. :disabled="loading"
  171. @click="toDonwloadFile(scope.row.id, 'ERROR_FILE')"
  172. >下载错误文件</el-button
  173. >
  174. </template>
  175. </el-table-column>
  176. </el-table>
  177. <div class="part-page">
  178. <el-pagination
  179. background
  180. layout="total, sizes, prev, pager, next, jumper"
  181. :pager-count="5"
  182. :current-page="current"
  183. :total="total"
  184. :page-size="size"
  185. @current-change="toPage"
  186. @size-change="pageSizeChange"
  187. >
  188. </el-pagination>
  189. </div>
  190. </div>
  191. </div>
  192. </template>
  193. <script>
  194. import {
  195. DATA_TASK_STATUS,
  196. DATA_TASK_TYPE,
  197. DATA_TASK_RESULT,
  198. } from "@/constants/enumerate";
  199. import { dataTaskList, removeDataTask, taskResetPdf } from "../api";
  200. import { attachmentDownload } from "../../login/api";
  201. import { downloadByUrl } from "@/plugins/download";
  202. export default {
  203. name: "data-task-manage",
  204. props: {
  205. taskType: {
  206. type: String,
  207. default: "",
  208. },
  209. nonePrivilege: {
  210. type: Boolean,
  211. default: false,
  212. },
  213. },
  214. data() {
  215. return {
  216. filter: {
  217. semesterId: "",
  218. examId: "",
  219. courseCode: "",
  220. paperNumber: "",
  221. type: "",
  222. status: "",
  223. result: "",
  224. },
  225. typeDisabled: false,
  226. current: 1,
  227. size: this.GLOBAL.pageSize,
  228. total: 0,
  229. DATA_TASK_STATUS,
  230. DATA_TASK_TYPE,
  231. DATA_TASK_RESULT,
  232. tasks: [],
  233. curTask: {},
  234. multipleSelection: [],
  235. loading: false,
  236. };
  237. },
  238. mounted() {
  239. if (this.taskType) {
  240. this.filter.type = this.taskType;
  241. this.typeDisabled = true;
  242. }
  243. this.toPage(1);
  244. },
  245. methods: {
  246. checkPriv(type, field) {
  247. return this.nonePrivilege || this.checkPrivilege(type, field);
  248. },
  249. async getList() {
  250. if (!this.checkPriv("list", "list")) return;
  251. const datas = {
  252. ...this.filter,
  253. pageNumber: this.current,
  254. pageSize: this.size,
  255. };
  256. const data = await dataTaskList(datas);
  257. this.tasks = data.records;
  258. this.total = data.total;
  259. },
  260. toPage(page) {
  261. this.current = page;
  262. this.getList();
  263. this.multipleSelection = [];
  264. },
  265. handleSelectionChange(val) {
  266. this.multipleSelection = val.map((item) => item.id);
  267. console.log(this.multipleSelection);
  268. },
  269. toRemove(type) {
  270. let tips = "";
  271. if (type === "CLEAR") {
  272. tips = "确定要清空所有任务吗?";
  273. } else {
  274. tips = "确定要删除选中的任务吗?";
  275. if (!this.multipleSelection.length) {
  276. this.$message.error("请选择要删除的记录!");
  277. return;
  278. }
  279. }
  280. this.$confirm(tips, "提示", {
  281. type: "warning",
  282. })
  283. .then(async () => {
  284. const data = await removeDataTask({
  285. ids: type === "CLEAR" ? null : this.multipleSelection,
  286. type: type === "CLEAR" ? "ALL" : null,
  287. }).catch(() => {});
  288. if (!data) return;
  289. this.$message.success("操作成功!");
  290. this.deletePageLastItem();
  291. })
  292. .catch(() => {});
  293. },
  294. async toDonwloadFile(id, type) {
  295. if (this.loading) return;
  296. this.loading = true;
  297. const res = await attachmentDownload({
  298. id,
  299. type,
  300. }).catch(() => {});
  301. this.loading = false;
  302. if (!res) {
  303. this.$message.error("文件下载失败,请重新尝试!");
  304. return;
  305. }
  306. const url = res.url;
  307. if (url.endsWith(".txt")) {
  308. window.open(url);
  309. return;
  310. }
  311. downloadByUrl(res.url);
  312. this.$message.success("文件下载成功!");
  313. },
  314. async toResetCreatePdf(row) {
  315. if (this.loading) return;
  316. this.loading = true;
  317. const res = await taskResetPdf(row.id).catch(() => {});
  318. this.loading = false;
  319. if (!res) return;
  320. this.$message.success("操作成功!");
  321. this.getList();
  322. },
  323. },
  324. };
  325. </script>