ImportExportTask.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div>
  3. <!-- 下载链接 -->
  4. <el-form ref="form" :model="form" :rules="rules" inline>
  5. <el-form-item label="任务名称" prop="type">
  6. <TaskSelect v-model="form.type" />
  7. </el-form-item>
  8. <el-button @click="searchForm">查询</el-button>
  9. </el-form>
  10. <el-table :data="tableData" stripe style="width: 100%;">
  11. <el-table-column type="selection" width="42" />
  12. <el-table-column width="100" label="ID">
  13. <span slot-scope="scope">{{ scope.row.id }}</span>
  14. </el-table-column>
  15. <el-table-column width="150" label="任务名称">
  16. <span slot-scope="scope">{{ scope.row.entityName }}</span>
  17. </el-table-column>
  18. <el-table-column width="150" label="上传文件名">
  19. <span slot-scope="scope">{{ scope.row.importFileName }}</span>
  20. </el-table-column>
  21. <el-table-column width="120" label="状态">
  22. <span slot-scope="scope">{{ scope.row.status }}</span>
  23. </el-table-column>
  24. <el-table-column label="异常">
  25. <span slot-scope="scope">{{ scope.row.summary }}</span>
  26. </el-table-column>
  27. <el-table-column width="100" label="上传时间">
  28. <span slot-scope="scope">{{
  29. scope.row.createTime | datetimeFilter
  30. }}</span>
  31. </el-table-column>
  32. <el-table-column :context="_self" label="操作" width="210">
  33. <div slot-scope="scope">
  34. <el-button
  35. size="mini"
  36. type="primary"
  37. plain
  38. v-if="scope.row.status === 'FINISH'"
  39. @click="
  40. download({
  41. id: scope.row.id,
  42. type: scope.row.hasResultFile === '1' ? 'RESULT' : 'IMPORTFILE',
  43. })
  44. "
  45. >
  46. 下载文件
  47. </el-button>
  48. <el-button
  49. size="mini"
  50. type="primary"
  51. plain
  52. v-if="scope.row.hasReportFile === '1'"
  53. @click="download({ id: scope.row.id, type: 'REPORT' })"
  54. >
  55. 导出报告
  56. </el-button>
  57. </div>
  58. </el-table-column>
  59. </el-table>
  60. <div class="page float-right">
  61. <el-pagination
  62. @current-change="handleCurrentChange"
  63. :current-page="currentPage"
  64. :page-size="pageSize"
  65. :page-sizes="[10, 20, 50, 100, 200, 300]"
  66. @size-change="handleSizeChange"
  67. layout="total, sizes, prev, pager, next, jumper"
  68. :total="total"
  69. />
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import { searchTasks } from "@/api/examwork-task";
  75. import { downloadFileURL } from "@/utils/utils";
  76. import { downloadFile } from "@/api/system-info";
  77. export default {
  78. name: "ImportExportTask",
  79. data() {
  80. return {
  81. form: {
  82. type: "",
  83. },
  84. rules: {},
  85. tableData: [],
  86. currentPage: 1,
  87. pageSize: 10,
  88. total: 10,
  89. };
  90. },
  91. methods: {
  92. async searchForm() {
  93. // try {
  94. // const valid = await this.$refs.form.validate();
  95. // if (!valid) return;
  96. // } catch (error) {
  97. // console.log(error);
  98. // return;
  99. // }
  100. const res = await searchTasks({
  101. type: this.form.type,
  102. pageNumber: this.currentPage,
  103. pageSize: this.pageSize,
  104. });
  105. this.tableData = res.data.data.records.records;
  106. this.total = res.data.data.records.total;
  107. },
  108. handleCurrentChange(val) {
  109. this.currentPage = val;
  110. this.searchForm();
  111. },
  112. handleSizeChange(val) {
  113. this.pageSize = val;
  114. this.currentPage = 1;
  115. this.searchForm();
  116. },
  117. async download({ id, type }) {
  118. const res = await downloadFile({ id, type });
  119. const url = res.data.data.url;
  120. downloadFileURL(url);
  121. },
  122. },
  123. };
  124. </script>
  125. <style></style>