|
@@ -1,242 +1,165 @@
|
|
|
<template>
|
|
|
- <div class="content white">
|
|
|
- <v-banner class="mb-3">
|
|
|
- 训练数据统计
|
|
|
- <template v-slot:actions>
|
|
|
- <v-btn
|
|
|
- text
|
|
|
- color="primary"
|
|
|
- @click="getStatistics"
|
|
|
- >
|
|
|
- <v-icon left>mdi-refresh</v-icon>
|
|
|
- 刷新
|
|
|
- </v-btn>
|
|
|
- <!-- <v-btn
|
|
|
- text
|
|
|
- color="deep-purple accent-4"
|
|
|
- @click="onClearRedisCache"
|
|
|
- >
|
|
|
- 清除对话缓存
|
|
|
- </v-btn> -->
|
|
|
+ <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"
|
|
|
+ @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>
|
|
|
- </v-banner>
|
|
|
- <v-container v-loading="loading">
|
|
|
- <v-row >
|
|
|
- <v-col
|
|
|
- v-for="elevation in elevations"
|
|
|
- :key="elevation.value"
|
|
|
- >
|
|
|
- <v-card
|
|
|
- class="pa-2"
|
|
|
- tile
|
|
|
- height="150"
|
|
|
- >
|
|
|
- <div class="d-flex align-center justify-center flex-column" style="height: 100%;">
|
|
|
- <div class="text-h3" :class="`${elevation.textColor}--text`">{{ itemData[elevation.value] }}</div>
|
|
|
- <div>
|
|
|
- {{ elevation.text }}
|
|
|
- <span class="success--text">
|
|
|
- {{ itemData.type_percentages?.[elevation.value] ? `( ${itemData.type_percentages?.[elevation.value]}% )` : null }}
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </v-card>
|
|
|
- </v-col>
|
|
|
- </v-row>
|
|
|
-
|
|
|
- </v-container>
|
|
|
- <v-divider class="my-3"></v-divider>
|
|
|
- <div class="pa-3">
|
|
|
- <MSearch class="mb-3" :option="filter" @search="handleSearch"></MSearch>
|
|
|
- <MTable
|
|
|
- :headers="headers"
|
|
|
- :items="items"
|
|
|
- :loading="tableLoading"
|
|
|
- :total="total"
|
|
|
- :page-info="pageInfo"
|
|
|
- @edit="handleEdit"
|
|
|
- @delete="handleDelete"
|
|
|
- @pageHandleChange="pageHandleChange"
|
|
|
- @sort="handleSort"
|
|
|
- @add="handleAdd"
|
|
|
- >
|
|
|
- <template #question="{ item }">
|
|
|
- <span style="max-width: 300px;" class="d-inline-block text-truncate">{{ item.question }}</span>
|
|
|
- </template>
|
|
|
- <template #content="{ item }">
|
|
|
- <!-- <tooltip width="300" :text="item.content" /> -->
|
|
|
- <span style="max-width: 300px;" class="d-inline-block text-truncate">{{ item.content }}</span>
|
|
|
- </template>
|
|
|
- <template #actions="{ item }">
|
|
|
- <v-btn text color="primary" @click="handleDetails(item)">查看</v-btn>
|
|
|
- <!-- <v-btn text color="primary" @click="handleEdit(item)">编辑</v-btn> -->
|
|
|
- <v-btn text color="error" @click="handleDelete([item.id])">删除</v-btn>
|
|
|
- </template>
|
|
|
- </MTable>
|
|
|
- </div>
|
|
|
- <ModelTrainEdit ref="modelTrainEditRefs" @success="onOpen"></ModelTrainEdit>
|
|
|
+ <template #actions="{ item }">
|
|
|
+ <v-btn color="success" text @click="handleExecute(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="handleLog(item.task_id)">查看日志</v-btn>
|
|
|
+ <v-btn color="error" text @click="handleDelete([item.task_id])">删除</v-btn>
|
|
|
+ </template>
|
|
|
+ </m-table>
|
|
|
+ <ModelTrainEdit ref="modelTrainEditRefs" @success="init"></ModelTrainEdit>
|
|
|
+ <ModelTrainStatus ref="modelTrainStatusRefs"></ModelTrainStatus>
|
|
|
+ <ModelTrainTable ref="modelTrainTableRefs"></ModelTrainTable>
|
|
|
+ <ModelTrainLog ref="modelTrainLogRefs"></ModelTrainLog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {
|
|
|
- getTrainingData,
|
|
|
- getTrainingDataList,
|
|
|
- deleteTrainingData
|
|
|
-} from '@/api/dataChart'
|
|
|
+import MFilter from '@/components/Filter'
|
|
|
import MTable from '@/components/List/table.vue'
|
|
|
-import MSearch from '@/components/Filter'
|
|
|
import ModelTrainEdit from './modelTrainEdit.vue'
|
|
|
+import ModelTrainStatus from './modelTrainStatus.vue'
|
|
|
+import ModelTrainTable from './modelTrainTable.vue'
|
|
|
+import ModelTrainLog from './modelTrainLog.vue'
|
|
|
+import {
|
|
|
+ // createDataTasks,
|
|
|
+ executeDataTasks,
|
|
|
+ getDataTasksList,
|
|
|
+ deleteDataTasks
|
|
|
+} from '@/api/dataChart'
|
|
|
export default {
|
|
|
- name: 'ModelTrain',
|
|
|
+ name: 'modelTrain',
|
|
|
components: {
|
|
|
+ MFilter,
|
|
|
MTable,
|
|
|
- MSearch,
|
|
|
- ModelTrainEdit
|
|
|
+ ModelTrainEdit,
|
|
|
+ ModelTrainStatus,
|
|
|
+ ModelTrainTable,
|
|
|
+ ModelTrainLog
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
- searchValues: {},
|
|
|
+ loading: false,
|
|
|
+ show: false,
|
|
|
filter: {
|
|
|
list: [
|
|
|
- { type: 'textField', value: null, label: '关键词', key: 'search_keyword', placeholder: '请输入关键词' },
|
|
|
- {
|
|
|
- type: 'autocomplete',
|
|
|
- key: 'training_data_type',
|
|
|
- value: null,
|
|
|
- label: '类型 *',
|
|
|
- placeholder: '请选择类型',
|
|
|
- items: [
|
|
|
- { label: 'sql', value: 'sql' },
|
|
|
- { label: 'documentation', value: 'documentation' },
|
|
|
- { label: 'ddl', value: 'ddl' },
|
|
|
- { label: 'error_sql', value: 'error_sql' }
|
|
|
- ]
|
|
|
- }
|
|
|
+ { type: 'textField', value: '', label: '任务名称', key: 'task_name' }
|
|
|
]
|
|
|
},
|
|
|
- loading: false,
|
|
|
- elevations: [
|
|
|
- { text: '总数据量', value: 'total_count', textColor: 'primary' },
|
|
|
- { text: 'DDL类型', value: 'ddl', textColor: 'info' },
|
|
|
- { text: 'SQL类型', value: 'sql', textColor: 'info' },
|
|
|
- { text: '文档类型', value: 'documentation', textColor: 'info' },
|
|
|
- { text: '错误SQL类型', value: 'error_sql', textColor: 'error' }
|
|
|
- ],
|
|
|
- itemData: {},
|
|
|
- tableLoading: false,
|
|
|
+ queryData: {
|
|
|
+ task_name: null
|
|
|
+ },
|
|
|
headers: [
|
|
|
- { text: 'ID', value: 'id' },
|
|
|
- { text: '问题', value: 'question' },
|
|
|
- { text: '类型', value: 'training_data_type' },
|
|
|
- { text: '内容', value: 'content' },
|
|
|
- { text: '操作', value: 'actions' }
|
|
|
+ { 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: [],
|
|
|
- total: 0,
|
|
|
orders: [],
|
|
|
pageInfo: {
|
|
|
- size: 5,
|
|
|
+ size: 10,
|
|
|
current: 1
|
|
|
- }
|
|
|
+ },
|
|
|
+ total: 0
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
- this.onOpen()
|
|
|
+ this.init()
|
|
|
},
|
|
|
methods: {
|
|
|
- onOpen () {
|
|
|
- this.init()
|
|
|
- this.getStatistics()
|
|
|
- },
|
|
|
- async getStatistics () {
|
|
|
- this.loading = true
|
|
|
- try {
|
|
|
- const { data } = await getTrainingData()
|
|
|
- this.itemData = {
|
|
|
- ...data,
|
|
|
- ...data.type_breakdown
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- this.$snackbar.error(error)
|
|
|
- } finally {
|
|
|
- this.loading = false
|
|
|
- }
|
|
|
- },
|
|
|
async init () {
|
|
|
- this.tableLoading = true
|
|
|
- const orders = {
|
|
|
- sort_by: undefined,
|
|
|
- sort_order: undefined
|
|
|
- }
|
|
|
- if (this.orders.length) {
|
|
|
- console.log(this.orders[0])
|
|
|
- Object.assign(orders, {
|
|
|
- sort_by: this.orders[0].column.replace(/`/g, ''),
|
|
|
- sort_order: this.orders[0].asc ? 'asc' : 'desc'
|
|
|
- })
|
|
|
- }
|
|
|
+ this.loading = true
|
|
|
try {
|
|
|
- const { data } = await getTrainingDataList({
|
|
|
+ const { data } = await getDataTasksList({
|
|
|
+ ...this.queryData,
|
|
|
page: this.pageInfo.current,
|
|
|
- page_size: this.pageInfo.size,
|
|
|
- ...this.searchValues,
|
|
|
- ...orders
|
|
|
+ page_size: this.pageInfo.size
|
|
|
})
|
|
|
- this.items = data.records
|
|
|
- this.total = data.pagination.total
|
|
|
+ this.items = data.tasks
|
|
|
+ this.total = data.total
|
|
|
} catch (error) {
|
|
|
this.$snackbar.error(error)
|
|
|
} finally {
|
|
|
- this.tableLoading = false
|
|
|
+ this.loading = false
|
|
|
}
|
|
|
},
|
|
|
- handleSearch (v) {
|
|
|
- this.searchValues = v
|
|
|
+ handleSearch (val) {
|
|
|
+ Object.assign(this.queryData, val)
|
|
|
this.pageInfo.current = 1
|
|
|
this.init()
|
|
|
},
|
|
|
handleAdd () {
|
|
|
this.$refs.modelTrainEditRefs.open()
|
|
|
},
|
|
|
- handleDetails (item) {
|
|
|
- this.$refs.modelTrainEditRefs.open(item, true)
|
|
|
+ // handleEdit (item) {
|
|
|
+ // this.itemData = item
|
|
|
+ // this.show = true
|
|
|
+ // },
|
|
|
+ handleFindExecute (id) {
|
|
|
+ this.$refs.modelTrainStatusRefs.open(id)
|
|
|
},
|
|
|
- pageHandleChange (index) {
|
|
|
- this.pageInfo.current = index
|
|
|
- this.init()
|
|
|
+ handleTable (id) {
|
|
|
+ this.$refs.modelTrainTableRefs.open(id)
|
|
|
},
|
|
|
- handleSort (v) {
|
|
|
- this.orders = v
|
|
|
- this.init()
|
|
|
+ handleLog (id) {
|
|
|
+ this.$refs.modelTrainLogRefs.open(id)
|
|
|
},
|
|
|
- handleEdit (item) {
|
|
|
- this.$refs.modelTrainEditRefs.open(item)
|
|
|
+ async handleExecute (id) {
|
|
|
+ try {
|
|
|
+ const { data } = await executeDataTasks(id, {
|
|
|
+ execution_mode: 'complete'
|
|
|
+ })
|
|
|
+ this.$snackbar.success(data.response)
|
|
|
+ } catch (error) {
|
|
|
+ this.$snackbar.error(error)
|
|
|
+ }
|
|
|
},
|
|
|
handleDelete (ids) {
|
|
|
- if (Array.isArray(ids) && !ids.length) {
|
|
|
- this.$snackbar.warning('请选择要删除的数据')
|
|
|
- return
|
|
|
- }
|
|
|
- this.$confirm('提示', '确定删除吗?').then(async () => {
|
|
|
- try {
|
|
|
- await deleteTrainingData({
|
|
|
- ids,
|
|
|
- confirm: true
|
|
|
- })
|
|
|
- this.$snackbar.success('删除成功')
|
|
|
- this.onOpen()
|
|
|
- } catch (error) {
|
|
|
- this.$snackbar.error(error)
|
|
|
- }
|
|
|
- })
|
|
|
+ if (Array.isArray(ids) && !ids.length) return this.$snackbar.warning('请选择要删除的选项')
|
|
|
+ this.$confirm('提示', '是否删除该选项')
|
|
|
+ .then(async () => {
|
|
|
+ try {
|
|
|
+ await deleteDataTasks({ ids })
|
|
|
+ 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>
|
|
|
-.content {
|
|
|
- font-size: 16px;
|
|
|
-}
|
|
|
+
|
|
|
</style>
|