algoRun.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 class="btn">
  14. <el-button plain type="primary" size="mini" @click="handleRun(info.id)">确认</el-button>
  15. <el-button plain :disabled="isOK" type="primary" size="mini" @click="checkResult(info.id)">查看结果</el-button>
  16. <el-button plain v-show="isDataHandle" type="primary" size="mini" @click="checkContrast(info.id)">查看数据对比</el-button>
  17. </div>
  18. </div>
  19. <div class="log" v-if="show">
  20. <div class="header">算法运行日志</div>
  21. <div class="content" v-html="message" v-bind:style="{height: dynamicHeight}"></div>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import { getAlgorithm, runAlgorithms, getLog,setLog } from '@/api/algoManager/algorithm'
  27. import { registerAction } from 'echarts/core'
  28. export default {
  29. name: 'AlgoRun',
  30. dicts: ['algorithm_type'],
  31. data() {
  32. return {
  33. // 遮罩层
  34. loading: true,
  35. // 算法运行信息
  36. info: [],
  37. // 显示log
  38. show: false,
  39. message: null,
  40. timer: null,
  41. dynamicHeight: '500px',
  42. // 当算法运行成功时按钮可点击查看结果
  43. isOK:true,
  44. // 当运行的算法是数据处理时,显示“查看数据对比”按钮
  45. isDataHandle:false
  46. }
  47. },
  48. created() {
  49. // this.getData()
  50. },
  51. activated() {
  52. this.getData()
  53. this.show = false
  54. },
  55. methods: {
  56. // 得到要执行的算法信息
  57. getData() {
  58. this.loading = true
  59. let id = this.$route.params.algoID
  60. getAlgorithm(id).then(response => {
  61. console.log('response', response)
  62. this.info = response.data
  63. if(this.info.status==='2'){
  64. this.isOK=false
  65. }
  66. if((this.info.type==='6'||this.info.type==='5'||this.info.type==='3') && this.info.status==='2'){
  67. this.isDataHandle=true
  68. }
  69. this.loading = false
  70. })
  71. },
  72. /** 运行算法按钮操作 */
  73. handleRun(id) {
  74. this.message = ''
  75. this.show = true
  76. const taskId = `TASK-${id}`
  77. runAlgorithms(id).then(res => {
  78. this.timer = setInterval(this.getLogInfo, 3000, taskId)
  79. })
  80. },
  81. getLogInfo(taskId) {
  82. getLog(taskId).then(response => {
  83. let logData = response.data
  84. console.log('response.data', logData);
  85. if (logData && logData.includes('任务执行完成')) {
  86. console.log("定时器销毁");
  87. clearInterval(this.timer)
  88. this.isOK=false
  89. }
  90. if (logData) {
  91. this.message = this.message + logData
  92. }
  93. })
  94. },
  95. // 跳转查看结果列表
  96. checkResult(id){
  97. this.$router.push({
  98. name: 'Result',
  99. params: {
  100. resultID: id,
  101. },
  102. })
  103. },
  104. // 查看数据对比结果
  105. checkContrast(id){
  106. this.$router.push({
  107. name: 'Contrast',
  108. params: {
  109. nonIdealID: id,
  110. },
  111. })
  112. }
  113. },
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. .app-container {
  118. width: 100%;
  119. height: 100%;
  120. display: flex;
  121. flex-direction: column;
  122. align-items: center;
  123. }
  124. .info {
  125. width: 80%;
  126. position: relative;
  127. display: flex;
  128. justify-content: space-evenly;
  129. .btn {
  130. position: absolute;
  131. bottom: 0;
  132. right: 50px;
  133. }
  134. .detail {
  135. width: 70%;
  136. }
  137. }
  138. .log {
  139. width: 80%;
  140. height: 500px;
  141. border: 1px solid #d1d1d1;
  142. box-shadow: 10px 12px 10px #ebebeb;
  143. margin-top: 27px;
  144. .header {
  145. width: 80%;
  146. height: 27px;
  147. color: #888888;
  148. margin: 5px 0px 0px 15px;
  149. background-color: white;
  150. }
  151. .content {
  152. width: 100%;
  153. height: 475px;
  154. background-color: black;
  155. overflow-y: scroll;
  156. border-right: 10px solid white;
  157. padding: 15px;
  158. }
  159. }
  160. </style>