|
@@ -0,0 +1,115 @@
|
|
|
|
+<script setup>
|
|
|
|
+ import {
|
|
|
|
+ onMounted,
|
|
|
|
+ ref
|
|
|
|
+ } from 'vue'
|
|
|
|
+ import {
|
|
|
|
+ Plus
|
|
|
|
+ } from '@element-plus/icons-vue'
|
|
|
|
+ import {
|
|
|
|
+ getDatasetList,
|
|
|
|
+ insertDataset,
|
|
|
|
+ getDatasetFileList,
|
|
|
|
+ deleteFileById
|
|
|
|
+ } from '@/api/ai'
|
|
|
|
+
|
|
|
|
+ import {
|
|
|
|
+ useUserStore
|
|
|
|
+ } from '@/store'
|
|
|
|
+ import dayjs from 'dayjs'
|
|
|
|
+ import DataSetUpload from '@/components/Admin/DataSetUpload.vue'
|
|
|
|
+ const tableData = ref([]);
|
|
|
|
+ const userStore = useUserStore().userData;
|
|
|
|
+ const datasetId = ref('');
|
|
|
|
+ const dataSetUploadRef = ref(null);
|
|
|
|
+ const total = ref(0);
|
|
|
|
+ const init = async () => {
|
|
|
|
+ let list = await getDatasetList({
|
|
|
|
+ organizationId: userStore.organization.id
|
|
|
|
+ });
|
|
|
|
+ if (list.state) {
|
|
|
|
+ if (list.data.length === 0) return insertDatasetFunc();
|
|
|
|
+ datasetId.value = list.data[0].datasetId;
|
|
|
|
+ getFileData();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const insertDatasetFunc = async () => {
|
|
|
|
+ let insertData = await insertDataset({
|
|
|
|
+ description: userStore.organization.name,
|
|
|
|
+ name: String(userStore.organization.id),
|
|
|
|
+ organizationId: userStore.organization.id,
|
|
|
|
+ userId: userStore.userId
|
|
|
|
+ })
|
|
|
|
+ // if (insertData.state) init();
|
|
|
|
+ }
|
|
|
|
+ const getFileData = async () => {
|
|
|
|
+ let fileData = await getDatasetFileList(datasetId.value)
|
|
|
|
+ console.log(fileData);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ const upload = () => {
|
|
|
|
+ dataSetUploadRef.value.handleUpload();
|
|
|
|
+ }
|
|
|
|
+ const uploadImage = () => {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ const testWordCount = (num) => {
|
|
|
|
+ return num < 1000 ? num : parseFloat(num / 1000).toFixed(1) + 'K'
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const formatTime = (time) => {
|
|
|
|
+ if (String(time).length === 10) time *= 1000;
|
|
|
|
+ let date = new Date(time)
|
|
|
|
+ return dayjs(date).format('YYYY-MM-DD HH:mm:ss')
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ onMounted(() => {
|
|
|
|
+ init();
|
|
|
|
+ })
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<template>
|
|
|
|
+ <div class="wui-flex wui-table">
|
|
|
|
+ <div class="wui-table-operation">
|
|
|
|
+ <el-button type="primary" :icon="Plus" @click="upload">添加文件</el-button>
|
|
|
|
+ <DataSetUpload v-if="datasetId" :action="`/api/ai/dataset/file/${datasetId}`" ref="dataSetUploadRef"
|
|
|
|
+ accept=".TXT,.MARKDOWN,.MDX,.PDF,.HTML,.XLSX,.XLS,.DOCX,.CSV,.VTT,.PROPERTIES,.MD,.HTM" v-show="false"
|
|
|
|
+ @uploadImage="uploadImage">
|
|
|
|
+ </DataSetUpload>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="wui-flex-box">
|
|
|
|
+ <el-table :data="tableData" height="100%">
|
|
|
|
+ <el-table-column label="序号" width="80">
|
|
|
|
+ <template #default="{ $index }">{{ $index + 1 }}</template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column prop="name" label="名称"></el-table-column>
|
|
|
|
+ <el-table-column label="字符数" width="180">
|
|
|
|
+ <template #default="scope">{{ testWordCount(scope.row.word_count)}}</template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="上传时间" width="180">
|
|
|
|
+ <template #default="scope">{{ formatTime(scope.row.created_at)}}</template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" width="180">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <div class="">
|
|
|
|
+ <el-button type="danger" size="small">删除</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <template #empty>
|
|
|
|
+ <el-empty description="暂无文档" />
|
|
|
|
+ </template>
|
|
|
|
+ </el-table>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="wui-table-pagination">
|
|
|
|
+ <el-pagination background layout="prev, pager, next" :total="total"></el-pagination>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+<style lang="scss">
|
|
|
|
+ .reading-box {
|
|
|
|
+ padding: 10px;
|
|
|
|
+ }
|
|
|
|
+</style>
|