DataTaskManage.vue 9.4 KB

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