algoRun.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <div class="app-container">
  3. <div class="info">
  4. <el-descriptions title="算法运行信息" :column="2" class="detail">
  5. <el-descriptions-item label="编号">{{ info.id }}</el-descriptions-item>
  6. <el-descriptions-item label="算法类型">
  7. <dict-tag :options="dict.type.algorithm_type" :value="info.type" />
  8. </el-descriptions-item>
  9. <el-descriptions-item label="算法子类型">{{ info.algoSubName }}</el-descriptions-item>
  10. <el-descriptions-item label="名称">{{ info.name }}</el-descriptions-item>
  11. <el-descriptions-item label="备注">{{ info.remark }}</el-descriptions-item>
  12. </el-descriptions>
  13. <div>
  14. <el-button plain type="primary" class="btn" size="mini" @click="handleRun(info.id)">确认</el-button>
  15. </div>
  16. </div>
  17. <div class="log" v-if="show">
  18. <div class="header">算法运行日志</div>
  19. <div class="content" v-html="message"></div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { getAlgorithm, runAlgorithms, getLog } from '@/api/algoManager/algorithm'
  25. import { registerAction } from 'echarts/core'
  26. export default {
  27. name: 'AlgoRun',
  28. dicts: ['algorithm_type'],
  29. data() {
  30. return {
  31. // 遮罩层
  32. loading: true,
  33. // 算法运行信息
  34. info: [],
  35. // 显示log
  36. show: false,
  37. message: null,
  38. timer: null,
  39. }
  40. },
  41. created() {
  42. // this.getData()
  43. },
  44. activated() {
  45. this.getData()
  46. this.show = false
  47. },
  48. methods: {
  49. // 得到要执行的算法信息
  50. getData() {
  51. this.loading = true
  52. let id = this.$route.params.algoID
  53. getAlgorithm(id).then(response => {
  54. console.log('response', response)
  55. this.info = response.data
  56. this.loading = false
  57. })
  58. },
  59. /** 运行算法按钮操作 */
  60. handleRun(id) {
  61. this.message = ''
  62. this.show = true
  63. const taskId = `TASK-${id}`
  64. runAlgorithms(id).then(res => {
  65. this.timer = setInterval(this.getLogInfo, 3000, taskId)
  66. })
  67. },
  68. getLogInfo(taskId) {
  69. getLog(taskId).then(response => {
  70. let logData = response.data
  71. console.log('response.data', logData);
  72. if (logData && logData.includes('任务执行完成')) {
  73. console.log("定时器销毁");
  74. clearInterval(this.timer)
  75. }
  76. this.message = this.message + logData
  77. })
  78. },
  79. },
  80. }
  81. </script>
  82. <style scoped lang="scss">
  83. .app-container {
  84. width: 100%;
  85. height: 100%;
  86. display: flex;
  87. flex-direction: column;
  88. align-items: center;
  89. }
  90. .info {
  91. width: 80%;
  92. position: relative;
  93. display: flex;
  94. justify-content: space-evenly;
  95. .btn {
  96. position: absolute;
  97. bottom: 0;
  98. right: 50px;
  99. }
  100. .detail {
  101. width: 70%;
  102. }
  103. }
  104. .log {
  105. width: 80%;
  106. height: 500px;
  107. // background-color: black;
  108. border: 1px solid #d1d1d1;
  109. box-shadow: 10px 12px 10px #ebebeb;
  110. margin-top: 27px;
  111. .header {
  112. width: 80%;
  113. height: 27px;
  114. color: #888888;
  115. margin: 5px 0px 0px 15px;
  116. background-color: white;
  117. }
  118. .content {
  119. width: 100%;
  120. height: 475px;
  121. background-color: black;
  122. border-right: 10px solid white;
  123. padding: 15px;
  124. }
  125. }
  126. </style>