更新开发环境API服务地址至192.168.3.30,调整ESLint配置以忽略特定变量,添加数据集和文档相关的创建与更新接口,优化错误处理和用户反馈,移除模拟数据,增强代码可读性。
This commit is contained in:
@@ -133,8 +133,8 @@ const openDialog = async (row?: any) => {
|
||||
ruleForm.embeddingModel = data.embeddingModel || 'text-embedding-ada-002';
|
||||
ruleForm.documentCount = data.documentCount || 0;
|
||||
ruleForm.charCount = data.charCount || 0;
|
||||
} catch (error) {
|
||||
console.error('获取数据集详情失败:', error);
|
||||
} catch (_error) {
|
||||
ElMessage.error('获取数据集详情失败');
|
||||
// 使用传入的row数据
|
||||
ruleForm.id = row.id || '';
|
||||
ruleForm.name = row.name || '';
|
||||
@@ -183,12 +183,8 @@ const onSubmit = async () => {
|
||||
|
||||
isShowDialog.value = false;
|
||||
emit('getDatasetList');
|
||||
} catch (error) {
|
||||
console.error('提交失败:', error);
|
||||
// 模拟成功
|
||||
ElMessage.success(isEdit.value ? '保存成功' : '创建成功');
|
||||
isShowDialog.value = false;
|
||||
emit('getDatasetList');
|
||||
} catch (_error) {
|
||||
ElMessage.error(isEdit.value ? '保存失败,请重试' : '创建失败,请重试');
|
||||
} finally {
|
||||
submitLoading.value = false;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<el-icon><ele-Refresh /></el-icon>
|
||||
重置
|
||||
</el-button>
|
||||
<el-button size="default" type="success" @click="onOpenAdd">
|
||||
<el-button size="default" type="success" @click="onOpenAdd" v-auth="'api/v1/knowledge/dataset/create'">
|
||||
<el-icon><ele-Plus /></el-icon>
|
||||
新增
|
||||
</el-button>
|
||||
@@ -63,6 +63,7 @@
|
||||
active-text="启"
|
||||
inactive-text="停"
|
||||
@change="onStatusChange(scope.row)"
|
||||
v-auth="'api/v1/knowledge/dataset/updateStatus'"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -70,9 +71,9 @@
|
||||
<el-table-column prop="updatedAt" label="更新时间" width="170" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="200" fixed="right" align="center">
|
||||
<template #default="scope">
|
||||
<el-button size="small" text type="primary" @click="onEdit(scope.row)">编辑</el-button>
|
||||
<el-button size="small" text type="primary" @click="onEdit(scope.row)" v-auth="'api/v1/knowledge/dataset/update'">编辑</el-button>
|
||||
<el-button size="small" text type="success" @click="onManageDocuments(scope.row)">文档</el-button>
|
||||
<el-button size="small" text type="danger" @click="onRowDel(scope.row)">删除</el-button>
|
||||
<el-button size="small" text type="danger" @click="onRowDel(scope.row)" v-auth="'api/v1/knowledge/dataset/delete'">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -137,48 +138,10 @@ const getDatasetList = async () => {
|
||||
statusEnabled: item.status === 'enable',
|
||||
}));
|
||||
tableData.total = res.data?.total || 0;
|
||||
} catch (error) {
|
||||
console.error('获取数据集列表失败:', error);
|
||||
// 模拟数据
|
||||
tableData.data = [
|
||||
{
|
||||
id: '1',
|
||||
name: '产品知识库',
|
||||
type: 'text',
|
||||
documentCount: 15,
|
||||
charCount: 125000,
|
||||
embeddingModel: 'text-embedding-ada-002',
|
||||
status: 'enable',
|
||||
statusEnabled: true,
|
||||
createdAt: '2024-01-15 10:30:00',
|
||||
updatedAt: '2024-01-20 14:20:00',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
name: '常见问题FAQ',
|
||||
type: 'qa',
|
||||
documentCount: 50,
|
||||
charCount: 85000,
|
||||
embeddingModel: 'text-embedding-ada-002',
|
||||
status: 'enable',
|
||||
statusEnabled: true,
|
||||
createdAt: '2024-01-10 09:00:00',
|
||||
updatedAt: '2024-01-18 16:45:00',
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
name: '数据报表',
|
||||
type: 'table',
|
||||
documentCount: 8,
|
||||
charCount: 45000,
|
||||
embeddingModel: 'text-embedding-ada-002',
|
||||
status: 'disable',
|
||||
statusEnabled: false,
|
||||
createdAt: '2024-01-05 11:20:00',
|
||||
updatedAt: '2024-01-12 10:30:00',
|
||||
},
|
||||
];
|
||||
tableData.total = 3;
|
||||
} catch (_error) {
|
||||
tableData.data = [];
|
||||
tableData.total = 0;
|
||||
ElMessage.error('获取数据集列表失败');
|
||||
} finally {
|
||||
tableData.loading = false;
|
||||
}
|
||||
@@ -257,9 +220,9 @@ const onStatusChange = async (row: any) => {
|
||||
try {
|
||||
await updateDatasetStatus({ id: row.id, status: newStatus });
|
||||
ElMessage.success(`${statusText}成功`);
|
||||
} catch (error) {
|
||||
console.error('状态更新失败:', error);
|
||||
ElMessage.success(`${statusText}成功`);
|
||||
} catch (_error) {
|
||||
row.statusEnabled = !row.statusEnabled;
|
||||
ElMessage.error(`${statusText}失败`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -274,10 +237,8 @@ const onRowDel = (row: any) => {
|
||||
await deleteDataset(row.id);
|
||||
ElMessage.success('删除成功');
|
||||
getDatasetList();
|
||||
} catch (error) {
|
||||
console.error('删除失败:', error);
|
||||
ElMessage.success('删除成功');
|
||||
getDatasetList();
|
||||
} catch (_error) {
|
||||
ElMessage.error('删除失败');
|
||||
}
|
||||
}).catch(() => {});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user