index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="intellReport" :class="!theme ? 'themeDark' : 'themeLight'">
  3. <el-row :gutter="50" justify="space-evenly" :style="pageHeight">
  4. <el-col :span="8" class="warn-table">
  5. <existing @getExistingData="getData" :height="tableHeight" />
  6. </el-col>
  7. <el-col :span="2" style="text-align: center;">
  8. <div :style="btnHeight">
  9. <el-button type="primary" @click="onAddItem1">
  10. <el-icon class="el-icon--right">
  11. <ArrowRight />
  12. </el-icon>
  13. </el-button>
  14. </div>
  15. <div :style="btnHeight">
  16. <el-button type="primary" @click="onAddItem2">
  17. <el-icon class="el-icon--right">
  18. <ArrowRight />
  19. </el-icon>
  20. </el-button>
  21. </div>
  22. </el-col>
  23. <el-col :span="12">
  24. <div class="listTop warn-table">
  25. <el-table :data="tableData" :height="listHeight">
  26. <el-table-column type="index" width="30" />
  27. <el-table-column label="脚本列表">
  28. <template #default="scope">
  29. <el-button v-if="scope.row.scriptName !==''" type="warning" round>
  30. {{ scope.row.scriptName}}
  31. </el-button>
  32. </template>
  33. </el-table-column>
  34. <el-table-column align="right">
  35. <template #default="scope">
  36. <el-button type="primary" :disabled="btnloading" @click="handleRun(scope.$index)">运行
  37. </el-button>
  38. <el-button type="danger" @click="handleDelete(scope.$index)">删除
  39. </el-button>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. <el-button class="run-all-script" type="primary" :disabled="btnloading" @click="runAllScript">运行所有脚本
  44. </el-button>
  45. </div>
  46. <div class="listBot warn-table">
  47. <p class="tableTit">每天运行一次</p>
  48. <el-table :data="tableData4" :height="listHeight">
  49. <el-table-column label="时间" width="300">
  50. <el-time-select v-model="timeValue" start="00:05" step="00:05" end="23:55"
  51. placeholder="选择时间" />
  52. </el-table-column>
  53. <el-table-column label="脚本名称">
  54. <template #default="scope">
  55. <el-button v-if="scope.row.scriptName !==''" type="warning" round>
  56. {{ scope.row.scriptName}}
  57. </el-button>
  58. </template>
  59. </el-table-column>
  60. <el-table-column align="right">
  61. <template #default="scope">
  62. <el-button type="primary" @click="handleDelete(scope.$index)">运行</el-button>
  63. <el-button type="danger" @click="handleDelete(scope.$index)">取消
  64. </el-button>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. </div>
  69. </el-col>
  70. </el-row>
  71. </div>
  72. </template>
  73. <script>
  74. import {
  75. run
  76. } from '@/api/report';
  77. import existing from "../existing.vue";
  78. export default {
  79. components: {
  80. existing
  81. },
  82. data() {
  83. return {
  84. childCurrentRow: [],
  85. tableData: [],
  86. tableData4: [],
  87. timeValue: '',
  88. theme: null,
  89. tableHeight: document.documentElement.clientHeight - 115,
  90. listHeight: (document.documentElement.clientHeight - 160) / 2,
  91. btnloading: false
  92. }
  93. },
  94. watch: {
  95. '$store.state.theme': {
  96. handler: function (newVal, oldVal) {
  97. this.theme = newVal
  98. },
  99. immediate: true
  100. }
  101. },
  102. computed: {
  103. pageHeight() {
  104. return {
  105. 'height': document.documentElement.clientHeight - 115 + 'px'
  106. }
  107. },
  108. btnHeight() {
  109. return {
  110. 'height': (document.documentElement.clientHeight - 160) / 4 + 'px',
  111. 'padding-top': (document.documentElement.clientHeight - 160) / 4 + 'px'
  112. }
  113. }
  114. },
  115. methods: {
  116. onAddItem1() {
  117. this.tableData.push(this.childCurrentRow)
  118. },
  119. onAddItem2() {
  120. this.tableData4.push(this.childCurrentRow)
  121. },
  122. runAllScript() {
  123. this.btnloading = true
  124. run(this.tableData).then(res => {
  125. console.log(res)
  126. this.btnloading = false
  127. });
  128. },
  129. handleRun(index) {
  130. this.btnloading = true
  131. run(new Array(this.tableData[index])).then(res => {
  132. console.log(res)
  133. this.btnloading = false
  134. })
  135. },
  136. handleDelete(index) {
  137. this.tableData.splice(index, 1)
  138. },
  139. getData(data) {
  140. console.log("data:", data)
  141. this.childCurrentRow = data
  142. }
  143. }
  144. }
  145. </script>
  146. <style scoped lang="less">
  147. .intellReport {
  148. .listTop {
  149. margin-bottom: 20px;
  150. }
  151. .run-all-script {
  152. position: absolute;
  153. right: 120px;
  154. }
  155. }
  156. .themeDark {
  157. padding: 20px 0;
  158. background: #161f1e;
  159. border-radius: 10px;
  160. .tableTit {
  161. color: #fff;
  162. }
  163. }
  164. .themeLight {
  165. padding: 20px 0;
  166. background: #edeffb;
  167. border-radius: 10px;
  168. .tableTit {
  169. color: #161f1e;
  170. }
  171. }
  172. </style>