DataTaskManage.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. <el-form-item label="状态:">
  6. <el-select v-model="filter.status" placeholder="请选择" clearable>
  7. <el-option
  8. v-for="(val, key) in DATA_TASK_STATUS"
  9. :key="key"
  10. :value="key"
  11. :label="val"
  12. ></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="类别:">
  16. <el-select v-model="filter.type" placeholder="请选择" clearable>
  17. <el-option
  18. v-for="(val, key) in DATA_TASK_TYPE"
  19. :key="key"
  20. :value="key"
  21. :label="val"
  22. ></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="数据结果:" label-width="85px">
  26. <el-select v-model="filter.result" placeholder="请选择" clearable>
  27. <el-option
  28. v-for="(val, key) in DATA_TASK_RESULT"
  29. :key="key"
  30. :value="key"
  31. :label="val"
  32. ></el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button type="primary" icon="icon icon-search" @click="toPage(1)"
  37. >查询</el-button
  38. >
  39. </el-form-item>
  40. </el-form>
  41. <div class="part-box-action">
  42. <!-- <el-button
  43. type="danger"
  44. icon="el-icon-delete"
  45. @click="toRemove('DELETE')"
  46. >批量删除</el-button
  47. >
  48. <el-button
  49. type="danger"
  50. icon="el-icon-delete-solid"
  51. @click="toRemove('CLEAR')"
  52. >清空</el-button
  53. > -->
  54. </div>
  55. </div>
  56. <div class="part-box">
  57. <el-table
  58. ref="TableList"
  59. :data="tasks"
  60. border
  61. stripe
  62. @selection-change="handleSelectionChange"
  63. >
  64. <el-table-column
  65. type="index"
  66. label="序号"
  67. width="50"
  68. align="center"
  69. :index="indexMethod"
  70. ></el-table-column>
  71. <el-table-column prop="printPlanName" label="项目"></el-table-column>
  72. <el-table-column prop="type" label="类别"> </el-table-column>
  73. <el-table-column prop="status" label="状态"> </el-table-column>
  74. <el-table-column prop="result" label="结果"> </el-table-column>
  75. <el-table-column prop="createTime" label="创建时间" width="180">
  76. <span slot-scope="scope">{{
  77. scope.row.createTime | timestampFilter
  78. }}</span>
  79. </el-table-column>
  80. <el-table-column prop="createName" label="创建人"></el-table-column>
  81. <el-table-column
  82. class-name="action-column"
  83. label="操作"
  84. align="center"
  85. width="120px"
  86. >
  87. <template slot-scope="scope">
  88. <el-button
  89. v-if="scope.row.hasReportFile"
  90. class="btn-table-icon"
  91. type="text"
  92. icon="el-icon-download"
  93. :disabled="loading"
  94. @click="toDonwloadLog(scope.row)"
  95. title="导出日志"
  96. ></el-button>
  97. <el-button
  98. class="btn-table-icon"
  99. type="text"
  100. icon="icon icon-download-act"
  101. :disabled="loading"
  102. @click="toDonwloadFile(scope.row)"
  103. title="下载文件"
  104. ></el-button>
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. <div class="part-page">
  109. <el-pagination
  110. background
  111. layout="total,prev, pager, next"
  112. :current-page="current"
  113. :total="total"
  114. :page-size="size"
  115. @current-change="toPage"
  116. >
  117. </el-pagination>
  118. </div>
  119. </div>
  120. </div>
  121. </template>
  122. <script>
  123. import {
  124. DATA_TASK_STATUS,
  125. DATA_TASK_TYPE,
  126. DATA_TASK_RESULT
  127. } from "@/constants/enumerate";
  128. import { dataTaskList, removeDataTask } from "../api";
  129. import { attachmentDownload } from "../../login/api";
  130. import { downloadFileURL } from "@/plugins/utils";
  131. export default {
  132. name: "data-task-manage",
  133. data() {
  134. return {
  135. filter: {
  136. type: "",
  137. status: "",
  138. result: ""
  139. },
  140. current: 1,
  141. size: this.GLOBAL.pageSize,
  142. total: 0,
  143. DATA_TASK_STATUS,
  144. DATA_TASK_TYPE,
  145. DATA_TASK_RESULT,
  146. tasks: [],
  147. curTask: {},
  148. multipleSelection: [],
  149. loading: false
  150. };
  151. },
  152. created() {
  153. this.toPage(1);
  154. },
  155. methods: {
  156. async getList() {
  157. const datas = {
  158. ...this.filter,
  159. pageNumber: this.current,
  160. pageSize: this.size
  161. };
  162. const data = await dataTaskList(datas);
  163. this.tasks = data.records;
  164. this.total = data.total;
  165. },
  166. toPage(page) {
  167. this.current = page;
  168. this.getList();
  169. this.multipleSelection = [];
  170. },
  171. handleSelectionChange(val) {
  172. this.multipleSelection = val.map(item => item.id);
  173. console.log(this.multipleSelection);
  174. },
  175. toRemove(type) {
  176. let tips = "";
  177. if (type === "CLEAR") {
  178. tips = "确定要清空所有任务吗?";
  179. } else {
  180. tips = "确定要删除选中的任务吗?";
  181. if (!this.multipleSelection.length) {
  182. this.$message.error("请选择要删除的记录!");
  183. return;
  184. }
  185. }
  186. this.$confirm(tips, "提示", {
  187. cancelButtonClass: "el-button--danger is-plain",
  188. confirmButtonClass: "el-button--primary",
  189. type: "warning"
  190. })
  191. .then(async () => {
  192. const data = await removeDataTask({
  193. ids: type === "CLEAR" ? null : this.multipleSelection,
  194. type: type === "CLEAR" ? "ALL" : null
  195. }).catch(() => {});
  196. if (!data) return;
  197. this.$message.success("操作成功!");
  198. this.deletePageLastItem();
  199. })
  200. .catch(() => {});
  201. },
  202. async toDonwloadLog(row) {
  203. if (this.loading) return;
  204. this.loading = true;
  205. const res = await attachmentDownload({
  206. id: row.id,
  207. type: "REPORT"
  208. }).catch(() => {});
  209. if (!res) {
  210. this.loading = false;
  211. this.$message.error("文件下载失败,请重新尝试!");
  212. return;
  213. }
  214. const url = res.url;
  215. let result = true;
  216. await downloadFileURL(url).catch(() => {
  217. result = false;
  218. });
  219. this.loading = false;
  220. if (result) {
  221. this.$message.success("文件下载成功!");
  222. } else {
  223. this.$message.error("文件下载失败,请重新尝试!");
  224. }
  225. },
  226. async toDonwloadFile(row) {
  227. if (this.loading) return;
  228. this.loading = true;
  229. const type = row.hasResultFile ? "RESULT" : "IMPORT_FILE";
  230. const res = await attachmentDownload({
  231. id: row.id,
  232. type
  233. }).catch(() => {});
  234. if (!res) {
  235. this.loading = false;
  236. this.$message.error("文件下载失败,请重新尝试!");
  237. return;
  238. }
  239. const url = res.url;
  240. let result = true;
  241. await downloadFileURL(url).catch(() => {
  242. result = false;
  243. });
  244. this.loading = false;
  245. if (result) {
  246. this.$message.success("文件下载成功!");
  247. } else {
  248. this.$message.error("文件下载失败,请重新尝试!");
  249. }
  250. }
  251. }
  252. };
  253. </script>