123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <template>
- <div class="pa-3 white">
- <m-filter :option="filter" @search="handleSearch" />
- <m-table
- class="mt-3"
- :loading="loading"
- :headers="headers"
- :items="items"
- :total="total"
- :page-info="pageInfo"
- item-key="task_id"
- @add="handleAdd"
- @delete="handleDelete"
- @pageHandleChange="pageHandleChange"
- @sort="handleSort"
- >
- <template #status="{item}">
- <v-chip :color="item.status === 'failed' ? 'error' : 'success'" small>{{ item.status }}</v-chip>
- </template>
- <template #actions="{ item }">
- <template v-if="item.directory_exists">
- <v-btn color="success" text @click="handleExecute(item.task_id)">执行</v-btn>
- <!-- <v-btn color="success" text @click="handleExecuteStep(item.task_id)">分步执行</v-btn> -->
- <v-btn color="primary" text @click="handleFindExecute(item.task_id)">执行进度</v-btn>
- <v-btn color="primary" text @click="handleTable(item.task_id)">表名清单</v-btn>
- <v-btn color="primary" text @click="handleFiles(item.task_id)">任务文件</v-btn>
- <v-btn color="primary" text @click="handleLog(item.task_id)">运行日志</v-btn>
- <v-btn color="error" text @click="handleDelete([item.task_id])">删除</v-btn>
- </template>
- <template v-else>
- <v-chip small>已删除</v-chip>
- </template>
- </template>
- </m-table>
- <ModelTrainEdit ref="modelTrainEditRefs" @success="init"></ModelTrainEdit>
- <ModelTrainStatus ref="modelTrainStatusRefs"></ModelTrainStatus>
- <ModelTrainTable ref="modelTrainTableRefs"></ModelTrainTable>
- <ModelTrainLog ref="modelTrainLogRefs"></ModelTrainLog>
- <ModelTrainFiles ref="modelTrainFilesRefs"></ModelTrainFiles>
- <ModelTrainStep ref="modelTrainStepRefs"></ModelTrainStep>
- </div>
- </template>
- <script>
- import MFilter from '@/components/Filter'
- import MTable from '@/components/List/table.vue'
- import ModelTrainEdit from './modelTrainEdit.vue'
- import ModelTrainStatus from './modelTrainStatus.vue'
- import ModelTrainTable from './modelTrainTable.vue'
- import ModelTrainLog from './modelTrainLog.vue'
- import ModelTrainFiles from './modelTrainFiles.vue'
- import ModelTrainStep from './modelTrainStep.vue'
- import {
- // createDataTasks,
- executeDataTasks,
- getDataTasksList,
- deleteDataTasks
- } from '@/api/dataChart'
- export default {
- name: 'modelTrain',
- components: {
- MFilter,
- MTable,
- ModelTrainEdit,
- ModelTrainStatus,
- ModelTrainTable,
- ModelTrainLog,
- ModelTrainFiles,
- ModelTrainStep
- },
- data () {
- return {
- loading: false,
- show: false,
- filter: {
- list: [
- { type: 'textField', value: '', label: '任务名称', key: 'task_name' }
- ]
- },
- queryData: {
- task_name: null
- },
- headers: [
- { text: '任务名称', align: 'start', value: 'task_name' },
- { text: '数据库名称', align: 'start', value: 'db_name' },
- { text: '上下文', align: 'start', value: 'business_context' },
- { text: '运行状态', align: 'center', value: 'status' },
- { text: '创建者', align: 'center', value: 'created_by' },
- { text: '操作', align: 'start', value: 'actions' }
- ],
- itemData: {},
- items: [],
- orders: [],
- pageInfo: {
- size: 10,
- current: 1
- },
- total: 0
- }
- },
- created () {
- this.init()
- },
- methods: {
- async init () {
- this.loading = true
- try {
- const { data } = await getDataTasksList({
- ...this.queryData,
- page: this.pageInfo.current,
- page_size: this.pageInfo.size
- })
- this.items = data.tasks
- this.total = data.total
- } catch (error) {
- this.$snackbar.error(error)
- } finally {
- this.loading = false
- }
- },
- handleSearch (val) {
- Object.assign(this.queryData, val)
- this.pageInfo.current = 1
- this.init()
- },
- handleAdd () {
- this.$refs.modelTrainEditRefs.open()
- },
- // handleEdit (item) {
- // this.itemData = item
- // this.show = true
- // },
- handleFindExecute (id) {
- this.$refs.modelTrainStatusRefs.open(id)
- },
- handleTable (id) {
- this.$refs.modelTrainTableRefs.open(id)
- },
- // 查看任务文件
- handleFiles (id) {
- this.$refs.modelTrainFilesRefs.open(id)
- },
- handleLog (id) {
- this.$refs.modelTrainLogRefs.open(id)
- },
- async handleExecute (id) {
- try {
- const { data } = await executeDataTasks(id, {
- execution_mode: 'complete'
- })
- this.$snackbar.success(data.response)
- } catch (error) {
- this.$snackbar.error(error)
- }
- },
- handleExecuteStep (id) {
- this.$refs.modelTrainStepRefs.open(id)
- },
- handleDelete (ids) {
- if (Array.isArray(ids) && !ids.length) return this.$snackbar.warning('请选择要删除的选项')
- this.$confirm('提示', '是否删除该选项')
- .then(async () => {
- try {
- await deleteDataTasks({
- task_ids: ids,
- confirm: true
- })
- this.$snackbar.success('删除成功')
- this.init()
- } catch (error) {
- this.$snackbar.error('删除失败')
- }
- })
- },
- pageHandleChange (page) {
- this.pageInfo.current = page
- this.init()
- },
- handleSort (val) {
- this.orders = val
- this.init()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|