SyncManage.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <div class="sync-manage">
  3. <div class="part-box part-box-filter part-box-flex">
  4. <el-form ref="FilterForm" label-position="left" inline>
  5. <template v-if="checkPrivilege('condition', 'condition')">
  6. <el-form-item label="同步类型:">
  7. <el-select v-model="filter.type" placeholder="同步类型" clearable>
  8. <el-option
  9. v-for="(val, key) in STMMS_SYNC_TYPE"
  10. :key="key"
  11. :value="key"
  12. :label="val"
  13. ></el-option>
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item label="同步结果:">
  17. <el-select
  18. v-model="filter.result"
  19. placeholder="同步结果"
  20. clearable
  21. style="width: 120px;"
  22. >
  23. <el-option
  24. v-for="(val, key) in DATA_TASK_RESULT"
  25. :key="key"
  26. :value="key"
  27. :label="val"
  28. ></el-option>
  29. </el-select>
  30. </el-form-item>
  31. </template>
  32. <el-form-item label-width="0px">
  33. <el-button
  34. v-if="checkPrivilege('button', 'select')"
  35. type="primary"
  36. @click="toPage(1)"
  37. >查询</el-button
  38. >
  39. </el-form-item>
  40. </el-form>
  41. </div>
  42. <div class="part-box part-box-pad">
  43. <el-table ref="TableList" :data="dataList">
  44. <el-table-column
  45. type="index"
  46. label="序号"
  47. width="70"
  48. :index="indexMethod"
  49. ></el-table-column>
  50. <el-table-column prop="type" label="类别"></el-table-column>
  51. <el-table-column prop="status" label="状态"> </el-table-column>
  52. <el-table-column prop="result" label="结果" width="100">
  53. </el-table-column>
  54. <el-table-column prop="createTime" label="创建时间" width="180">
  55. <span slot-scope="scope">{{
  56. scope.row.createTime | timestampFilter
  57. }}</span>
  58. </el-table-column>
  59. <el-table-column prop="createName" label="创建人"></el-table-column>
  60. <el-table-column class-name="action-column" label="操作" width="100">
  61. <template slot-scope="scope">
  62. <el-button
  63. v-if="scope.row.hasReportFile && checkPrivilege('link', 'export')"
  64. type="text"
  65. class="btn-primary"
  66. :disabled="loading"
  67. @click="toDonwloadLog(scope.row)"
  68. >导出日志</el-button
  69. >
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. <div class="part-page">
  74. <el-pagination
  75. background
  76. layout="total,prev, pager, next"
  77. :current-page="current"
  78. :total="total"
  79. :page-size="size"
  80. @current-change="toPage"
  81. >
  82. </el-pagination>
  83. </div>
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. import { STMMS_SYNC_TYPE, DATA_TASK_RESULT } from "@/constants/enumerate";
  89. import { syncResultListPage } from "../api";
  90. import { attachmentDownload } from "../../login/api";
  91. import { downloadByUrl } from "@/plugins/download";
  92. export default {
  93. name: "sync-manage",
  94. data() {
  95. return {
  96. STMMS_SYNC_TYPE,
  97. DATA_TASK_RESULT,
  98. filter: {
  99. result: "",
  100. type: ""
  101. },
  102. current: 1,
  103. size: this.GLOBAL.pageSize,
  104. total: 0,
  105. dataList: [],
  106. loading: false
  107. };
  108. },
  109. created() {
  110. this.getList();
  111. },
  112. methods: {
  113. async getList() {
  114. if (!this.checkPrivilege("list", "list")) return;
  115. const datas = {
  116. ...this.filter,
  117. pageNumber: this.current,
  118. pageSize: this.size
  119. };
  120. const data = await syncResultListPage(datas);
  121. this.dataList = data.records;
  122. this.total = data.total;
  123. },
  124. toPage(page) {
  125. this.current = page;
  126. this.getList();
  127. },
  128. async toDonwloadLog(row) {
  129. if (this.loading) return;
  130. this.loading = true;
  131. const res = await attachmentDownload({
  132. id: row.id,
  133. type: "SYNC_REPORT"
  134. }).catch(() => {});
  135. this.loading = false;
  136. if (!res) {
  137. this.$message.error("文件下载失败,请重新尝试!");
  138. return;
  139. }
  140. const url = res.url;
  141. if (url.endsWith(".txt")) {
  142. this.loading = false;
  143. window.open(url);
  144. return;
  145. }
  146. downloadByUrl(url);
  147. this.$message.success("文件下载成功!");
  148. }
  149. }
  150. };
  151. </script>