algoRun.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. this.info = response.data
  62. if(this.info.status==='2'){
  63. this.isOK=false
  64. }
  65. if((this.info.type==='6'||this.info.type==='5'||this.info.type==='3') && this.info.status==='2'){
  66. this.isDataHandle=true
  67. }
  68. this.loading = false
  69. })
  70. },
  71. /** 运行算法按钮操作 */
  72. handleRun(id) {
  73. this.message = ''
  74. this.show = true
  75. const taskId = `TASK-${id}`
  76. runAlgorithms(id).then(res => {
  77. this.timer = setInterval(this.getLogInfo, 3000, taskId)
  78. })
  79. },
  80. getLogInfo(taskId) {
  81. getLog(taskId).then(response => {
  82. let logData = response.data
  83. if (logData && logData.includes('任务执行完成')) {
  84. console.log("定时器销毁");
  85. clearInterval(this.timer)
  86. this.isOK=false
  87. }
  88. if (logData) {
  89. this.message = this.message + logData
  90. }
  91. })
  92. },
  93. // 跳转查看结果列表
  94. checkResult(id){
  95. this.$router.push({
  96. name: 'Result',
  97. params: {
  98. resultID: id,
  99. },
  100. })
  101. },
  102. // 查看数据对比结果
  103. checkContrast(id){
  104. this.$router.push({
  105. name: 'contrast',
  106. params: {
  107. nonIdealID: id,
  108. },
  109. })
  110. }
  111. },
  112. }
  113. </script>
  114. <style scoped lang="scss">
  115. .app-container {
  116. width: 100%;
  117. height: 100%;
  118. display: flex;
  119. flex-direction: column;
  120. align-items: center;
  121. }
  122. .info {
  123. width: 80%;
  124. position: relative;
  125. display: flex;
  126. justify-content: space-evenly;
  127. .btn {
  128. position: absolute;
  129. bottom: 0;
  130. right: 50px;
  131. }
  132. .detail {
  133. width: 70%;
  134. }
  135. }
  136. .log {
  137. width: 80%;
  138. height: 500px;
  139. border: 1px solid #d1d1d1;
  140. box-shadow: 10px 12px 10px #ebebeb;
  141. margin-top: 27px;
  142. .header {
  143. width: 80%;
  144. height: 27px;
  145. color: #888888;
  146. margin: 5px 0px 0px 15px;
  147. background-color: white;
  148. }
  149. .content {
  150. width: 100%;
  151. height: 475px;
  152. background-color: black;
  153. overflow-y: scroll;
  154. border-right: 10px solid white;
  155. padding: 15px;
  156. }
  157. }
  158. </style>