SyncManage.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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="checkPriv('condition', 'condition')">
  6. <secp-select
  7. v-model="filter"
  8. defaultSelectExam
  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. :disabled="typeDisabled"
  17. style="width: 300px"
  18. >
  19. <el-option
  20. v-for="(val, key) in STMMS_SYNC_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 v-model="filter.status" placeholder="同步状态" clearable>
  29. <el-option
  30. v-for="(val, key) in STMMS_SYNC_STATUS"
  31. :key="key"
  32. :value="key"
  33. :label="val"
  34. ></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="同步结果:">
  38. <el-select
  39. v-model="filter.result"
  40. placeholder="同步结果"
  41. clearable
  42. style="width: 120px"
  43. >
  44. <el-option
  45. v-for="(val, key) in DATA_TASK_RESULT"
  46. :key="key"
  47. :value="key"
  48. :label="val"
  49. ></el-option>
  50. </el-select>
  51. </el-form-item>
  52. </template>
  53. <el-form-item label-width="0px">
  54. <el-button
  55. v-if="checkPriv('button', 'select')"
  56. type="primary"
  57. @click="toPage(1)"
  58. >查询</el-button
  59. >
  60. </el-form-item>
  61. </el-form>
  62. </div>
  63. <div class="part-box part-box-pad">
  64. <el-table ref="TableList" :data="dataList">
  65. <el-table-column
  66. type="index"
  67. label="序号"
  68. width="70"
  69. :index="indexMethod"
  70. ></el-table-column>
  71. <el-table-column
  72. prop="semesterName"
  73. label="学期"
  74. min-width="160"
  75. ></el-table-column>
  76. <el-table-column
  77. prop="examName"
  78. label="考试"
  79. min-width="160"
  80. ></el-table-column>
  81. <el-table-column
  82. prop="paperNumber"
  83. label="试卷编号"
  84. min-width="100"
  85. ></el-table-column>
  86. <el-table-column prop="courseName" label="课程(代码)" min-width="200">
  87. <template slot-scope="scope">
  88. {{ scope.row.courseName }}({{ scope.row.courseCode }})
  89. </template>
  90. </el-table-column>
  91. <el-table-column prop="type" label="类别"></el-table-column>
  92. <el-table-column prop="status" label="状态" width="100">
  93. </el-table-column>
  94. <el-table-column prop="resultStr" label="结果" width="80">
  95. <template slot-scope="scope">
  96. <el-popover
  97. v-if="scope.row.result === 'ERROR'"
  98. placement="left-start"
  99. popper-class="answer-popover"
  100. width="400"
  101. trigger="hover"
  102. >
  103. <p class="text-prewrap" v-html="scope.row.errorMessage"></p>
  104. <span class="color-danger" slot="reference">{{
  105. scope.row.resultStr
  106. }}</span>
  107. </el-popover>
  108. <p v-else class="color-success">{{ scope.row.resultStr }}</p>
  109. </template>
  110. </el-table-column>
  111. <el-table-column prop="createTime" label="创建时间" width="170">
  112. <span slot-scope="scope">{{
  113. scope.row.createTime | timestampFilter
  114. }}</span>
  115. </el-table-column>
  116. <el-table-column
  117. prop="createName"
  118. label="创建人"
  119. width="140"
  120. ></el-table-column>
  121. <el-table-column
  122. class-name="action-column"
  123. label="操作"
  124. width="100"
  125. fixed="right"
  126. >
  127. <template slot-scope="scope">
  128. <el-button
  129. v-if="scope.row.hasReportFile && checkPriv('link', 'export')"
  130. type="text"
  131. class="btn-primary"
  132. :disabled="loading"
  133. @click="toDonwloadLog(scope.row)"
  134. >导出日志</el-button
  135. >
  136. <el-button
  137. v-if="scope.row.result === 'ERROR'"
  138. type="text"
  139. class="btn-primary"
  140. :disabled="loading"
  141. @click="toResync(scope.row)"
  142. >重新同步</el-button
  143. >
  144. </template>
  145. </el-table-column>
  146. </el-table>
  147. <div class="part-page">
  148. <el-pagination
  149. background
  150. layout="total, sizes, prev, pager, next, jumper"
  151. :pager-count="5"
  152. :current-page="current"
  153. :total="total"
  154. :page-size="size"
  155. @current-change="toPage"
  156. @size-change="pageSizeChange"
  157. >
  158. </el-pagination>
  159. </div>
  160. </div>
  161. </div>
  162. </template>
  163. <script>
  164. import { DATA_TASK_RESULT } from "@/constants/enumerate";
  165. import { syncResultListPage, syncResync } from "../api";
  166. import { attachmentDownload } from "../../login/api";
  167. import { getEnums } from "../../base/api";
  168. import { downloadByUrl } from "@/plugins/download";
  169. export default {
  170. name: "sync-manage",
  171. props: {
  172. syncType: {
  173. type: String,
  174. default: "",
  175. },
  176. nonePrivilege: {
  177. type: Boolean,
  178. default: false,
  179. },
  180. },
  181. data() {
  182. return {
  183. STMMS_SYNC_TYPE: {},
  184. STMMS_SYNC_STATUS: {},
  185. DATA_TASK_RESULT,
  186. filter: {
  187. semesterId: "",
  188. examId: "",
  189. courseCode: "",
  190. paperNumber: "",
  191. result: "",
  192. type: "",
  193. status: "",
  194. },
  195. typeDisabled: false,
  196. current: 1,
  197. size: this.GLOBAL.pageSize,
  198. total: 0,
  199. dataList: [],
  200. loading: false,
  201. };
  202. },
  203. created() {
  204. if (this.syncType) {
  205. this.filter.type = this.syncType;
  206. this.typeDisabled = true;
  207. }
  208. this.getSyncTypes();
  209. this.getSyncStatus();
  210. },
  211. methods: {
  212. checkPriv(type, field) {
  213. return this.nonePrivilege || this.checkPrivilege(type, field);
  214. },
  215. async getSyncTypes() {
  216. const res = await getEnums("PUSH_TYPE_ENUM");
  217. const data = res || [];
  218. this.STMMS_SYNC_TYPE = {};
  219. data.forEach((item) => {
  220. this.STMMS_SYNC_TYPE[item.code] = item.name;
  221. });
  222. },
  223. async getSyncStatus() {
  224. const res = await getEnums("TB_TASK_STATUS");
  225. const data = res || [];
  226. this.STMMS_SYNC_STATUS = {};
  227. data.forEach((item) => {
  228. this.STMMS_SYNC_STATUS[item.code] = item.name;
  229. });
  230. },
  231. async getList() {
  232. if (!this.checkPriv("list", "list")) return;
  233. const datas = {
  234. ...this.filter,
  235. pageNumber: this.current,
  236. pageSize: this.size,
  237. };
  238. const data = await syncResultListPage(datas);
  239. this.dataList = data.records;
  240. this.total = data.total;
  241. },
  242. toPage(page) {
  243. this.current = page;
  244. this.getList();
  245. },
  246. async toDonwloadLog(row) {
  247. if (this.loading) return;
  248. this.loading = true;
  249. const res = await attachmentDownload({
  250. id: row.id,
  251. type: "SYNC_REPORT",
  252. }).catch(() => {});
  253. this.loading = false;
  254. if (!res) {
  255. this.$message.error("文件下载失败,请重新尝试!");
  256. return;
  257. }
  258. const url = res.url;
  259. if (url.endsWith(".txt")) {
  260. this.loading = false;
  261. window.open(url);
  262. return;
  263. }
  264. downloadByUrl(url);
  265. this.$message.success("文件下载成功!");
  266. },
  267. async toResync(row) {
  268. if (this.loading) return;
  269. this.loading = true;
  270. const res = await syncResync(row.id).catch(() => false);
  271. this.loading = false;
  272. if (!res) return;
  273. this.$message.success("操作成功!");
  274. },
  275. },
  276. };
  277. </script>