index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <div class="pa-3 white">
  3. <m-filter :option="filter" @search="handleSearch" />
  4. <m-table
  5. class="mt-3"
  6. :loading="loading"
  7. :headers="headers"
  8. :items="items"
  9. :total="total"
  10. :page-info="pageInfo"
  11. item-key="task_id"
  12. @add="handleAdd"
  13. @delete="handleDelete"
  14. @pageHandleChange="pageHandleChange"
  15. @sort="handleSort"
  16. >
  17. <template #status="{item}">
  18. <v-chip :color="item.status === 'failed' ? 'error' : 'success'" small>{{ item.status }}</v-chip>
  19. </template>
  20. <template #actions="{ item }">
  21. <template v-if="item.directory_exists">
  22. <v-btn color="success" text @click="handleExecute(item.task_id)">执行</v-btn>
  23. <!-- <v-btn color="success" text @click="handleExecuteStep(item.task_id)">分步执行</v-btn> -->
  24. <v-btn color="primary" text @click="handleFindExecute(item.task_id)">执行进度</v-btn>
  25. <v-btn color="primary" text @click="handleTable(item.task_id)">表名清单</v-btn>
  26. <v-btn color="primary" text @click="handleFiles(item.task_id)">任务文件</v-btn>
  27. <v-btn color="primary" text @click="handleLog(item.task_id)">运行日志</v-btn>
  28. <v-btn color="error" text @click="handleDelete([item.task_id])">删除</v-btn>
  29. </template>
  30. <template v-else>
  31. <v-chip small>已删除</v-chip>
  32. </template>
  33. </template>
  34. </m-table>
  35. <ModelTrainEdit ref="modelTrainEditRefs" @success="init"></ModelTrainEdit>
  36. <ModelTrainStatus ref="modelTrainStatusRefs"></ModelTrainStatus>
  37. <ModelTrainTable ref="modelTrainTableRefs"></ModelTrainTable>
  38. <ModelTrainLog ref="modelTrainLogRefs"></ModelTrainLog>
  39. <ModelTrainFiles ref="modelTrainFilesRefs"></ModelTrainFiles>
  40. <ModelTrainStep ref="modelTrainStepRefs"></ModelTrainStep>
  41. </div>
  42. </template>
  43. <script>
  44. import MFilter from '@/components/Filter'
  45. import MTable from '@/components/List/table.vue'
  46. import ModelTrainEdit from './modelTrainEdit.vue'
  47. import ModelTrainStatus from './modelTrainStatus.vue'
  48. import ModelTrainTable from './modelTrainTable.vue'
  49. import ModelTrainLog from './modelTrainLog.vue'
  50. import ModelTrainFiles from './modelTrainFiles.vue'
  51. import ModelTrainStep from './modelTrainStep.vue'
  52. import {
  53. // createDataTasks,
  54. executeDataTasks,
  55. getDataTasksList,
  56. deleteDataTasks
  57. } from '@/api/dataChart'
  58. export default {
  59. name: 'modelTrain',
  60. components: {
  61. MFilter,
  62. MTable,
  63. ModelTrainEdit,
  64. ModelTrainStatus,
  65. ModelTrainTable,
  66. ModelTrainLog,
  67. ModelTrainFiles,
  68. ModelTrainStep
  69. },
  70. data () {
  71. return {
  72. loading: false,
  73. show: false,
  74. filter: {
  75. list: [
  76. { type: 'textField', value: '', label: '任务名称', key: 'task_name' }
  77. ]
  78. },
  79. queryData: {
  80. task_name: null
  81. },
  82. headers: [
  83. { text: '任务名称', align: 'start', value: 'task_name' },
  84. { text: '数据库名称', align: 'start', value: 'db_name' },
  85. { text: '上下文', align: 'start', value: 'business_context' },
  86. { text: '运行状态', align: 'center', value: 'status' },
  87. { text: '创建者', align: 'center', value: 'created_by' },
  88. { text: '操作', align: 'start', value: 'actions' }
  89. ],
  90. itemData: {},
  91. items: [],
  92. orders: [],
  93. pageInfo: {
  94. size: 10,
  95. current: 1
  96. },
  97. total: 0
  98. }
  99. },
  100. created () {
  101. this.init()
  102. },
  103. methods: {
  104. async init () {
  105. this.loading = true
  106. try {
  107. const { data } = await getDataTasksList({
  108. ...this.queryData,
  109. page: this.pageInfo.current,
  110. page_size: this.pageInfo.size
  111. })
  112. this.items = data.tasks
  113. this.total = data.total
  114. } catch (error) {
  115. this.$snackbar.error(error)
  116. } finally {
  117. this.loading = false
  118. }
  119. },
  120. handleSearch (val) {
  121. Object.assign(this.queryData, val)
  122. this.pageInfo.current = 1
  123. this.init()
  124. },
  125. handleAdd () {
  126. this.$refs.modelTrainEditRefs.open()
  127. },
  128. // handleEdit (item) {
  129. // this.itemData = item
  130. // this.show = true
  131. // },
  132. handleFindExecute (id) {
  133. this.$refs.modelTrainStatusRefs.open(id)
  134. },
  135. handleTable (id) {
  136. this.$refs.modelTrainTableRefs.open(id)
  137. },
  138. // 查看任务文件
  139. handleFiles (id) {
  140. this.$refs.modelTrainFilesRefs.open(id)
  141. },
  142. handleLog (id) {
  143. this.$refs.modelTrainLogRefs.open(id)
  144. },
  145. async handleExecute (id) {
  146. try {
  147. const { data } = await executeDataTasks(id, {
  148. execution_mode: 'complete'
  149. })
  150. this.$snackbar.success(data.response)
  151. } catch (error) {
  152. this.$snackbar.error(error)
  153. }
  154. },
  155. handleExecuteStep (id) {
  156. this.$refs.modelTrainStepRefs.open(id)
  157. },
  158. handleDelete (ids) {
  159. if (Array.isArray(ids) && !ids.length) return this.$snackbar.warning('请选择要删除的选项')
  160. this.$confirm('提示', '是否删除该选项')
  161. .then(async () => {
  162. try {
  163. await deleteDataTasks({
  164. task_ids: ids,
  165. confirm: true
  166. })
  167. this.$snackbar.success('删除成功')
  168. this.init()
  169. } catch (error) {
  170. this.$snackbar.error('删除失败')
  171. }
  172. })
  173. },
  174. pageHandleChange (page) {
  175. this.pageInfo.current = page
  176. this.init()
  177. },
  178. handleSort (val) {
  179. this.orders = val
  180. this.init()
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. </style>