UnisKB/ui/src/views/dataset/index.vue

133 lines
3.5 KiB
Vue
Raw Normal View History

2023-10-16 10:58:51 +00:00
<template>
2023-11-02 10:25:09 +00:00
<div class="dataset-list-container p-24">
2023-11-02 01:56:14 +00:00
<div class="flex-between">
<h3>数据集</h3>
2023-11-07 11:04:59 +00:00
<el-input v-model="filterText" placeholder="搜索内容" prefix-icon="Search" class="w-240" />
2023-11-02 01:56:14 +00:00
</div>
2023-11-03 08:12:57 +00:00
<div v-loading.fullscreen.lock="loading">
2023-11-02 01:56:14 +00:00
<el-row
:gutter="15"
v-infinite-scroll="loadDataset"
:infinite-scroll-disabled="disabledScroll"
>
2023-11-03 08:12:57 +00:00
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="4" class="mt-8">
2023-11-02 01:56:14 +00:00
<CardAdd title="创建数据集" @click="router.push({ path: '/dataset/create' })" />
</el-col>
<el-col
:xs="24"
:sm="12"
2023-11-03 08:12:57 +00:00
:md="8"
:lg="6"
2023-11-02 01:56:14 +00:00
:xl="4"
v-for="(item, index) in datasetList"
:key="index"
2023-11-02 10:25:09 +00:00
class="mt-8"
2023-10-25 10:35:28 +00:00
>
2023-11-07 07:30:15 +00:00
<CardBox
:title="item.name"
:description="item.desc"
class="cursor"
2023-11-07 11:04:59 +00:00
@click="router.push({ path: `/dataset/${item.id}/document` })"
2023-11-07 07:30:15 +00:00
>
2023-11-02 01:56:14 +00:00
<template #mouseEnter>
2023-11-03 08:12:57 +00:00
<el-tooltip effect="dark" content="删除" placement="top">
<el-button text @click.stop="deleteDateset(item)" class="delete-button">
2023-11-02 01:56:14 +00:00
<el-icon><Delete /></el-icon>
</el-button>
2023-11-03 08:12:57 +00:00
</el-tooltip>
2023-11-02 01:56:14 +00:00
</template>
2023-10-25 10:35:28 +00:00
2023-11-02 01:56:14 +00:00
<template #footer>
<div class="footer-content">
2023-11-03 08:12:57 +00:00
<span class="bold">{{ item?.document_count || 0 }}</span>
文档<el-divider direction="vertical" />
<span class="bold">{{ numberFormat(item?.char_length) || 0 }}</span>
字符<el-divider direction="vertical" />
<span class="bold">{{ item?.char_length || 0 }}</span>
关联应用
2023-11-02 01:56:14 +00:00
</div>
</template>
</CardBox>
</el-col>
</el-row>
2023-09-15 09:40:35 +00:00
</div>
2023-11-02 01:56:14 +00:00
</div>
2023-09-15 09:40:35 +00:00
</template>
<script setup lang="ts">
2023-10-25 10:35:28 +00:00
import { ref, onMounted } from 'vue'
import datasetApi from '@/api/dataset'
import type { datasetListRequest } from '@/api/type/dataset'
2023-10-26 10:37:13 +00:00
import { MsgSuccess, MsgConfirm } from '@/utils/message'
2023-10-27 09:49:06 +00:00
import { useRouter } from 'vue-router'
2023-11-07 07:30:15 +00:00
import { numberFormat } from '@/utils/utils'
2023-10-27 09:49:06 +00:00
const router = useRouter()
2023-10-25 10:35:28 +00:00
const loading = ref(false)
const filterText = ref('')
const datasetList = ref<any[]>([])
const disabledScroll = ref(false)
const pageConfig = ref<datasetListRequest>({
current_page: 1,
page_size: 20,
search_text: ''
})
2023-10-27 09:49:06 +00:00
function loadDataset() {}
2023-10-26 10:37:13 +00:00
function deleteDateset(row: any) {
2023-10-27 09:49:06 +00:00
MsgConfirm(
2023-11-10 03:36:04 +00:00
`是否删除数据集:${row.name} ?`,
2023-11-08 11:08:54 +00:00
`此数据集关联 ${row.char_length} 个应用,删除后无法恢复,请谨慎操作。`,
2023-10-27 09:49:06 +00:00
{
2023-11-08 11:08:54 +00:00
confirmButtonText: '删除',
2023-10-27 09:49:06 +00:00
confirmButtonClass: 'danger'
}
)
2023-10-26 10:37:13 +00:00
.then(() => {
loading.value = true
2023-10-27 09:49:06 +00:00
datasetApi
.delDateset(row.id)
2023-10-26 10:37:13 +00:00
.then(() => {
MsgSuccess('删除成功')
getList()
})
.catch(() => {
loading.value = false
})
})
.catch(() => {})
}
2023-10-25 10:35:28 +00:00
function getList() {
loading.value = true
datasetApi
.getDateset(pageConfig.value)
.then((res) => {
datasetList.value = res.data
loading.value = false
})
.catch(() => {
loading.value = false
})
}
2023-09-15 09:40:35 +00:00
2023-10-25 10:35:28 +00:00
onMounted(() => {
getList()
})
2023-09-15 09:40:35 +00:00
</script>
2023-10-25 10:35:28 +00:00
<style lang="scss" scoped>
.dataset-list-container {
.delete-button {
position: absolute;
2023-11-03 08:12:57 +00:00
right: 12px;
top: 18px;
height: auto;
}
.footer-content {
.bold {
color: var(--app-text-color-primary);
}
2023-10-25 10:35:28 +00:00
}
}
</style>