chore(config): 添加项目配置文件和隐私协议
- 新增 .editorconfig 文件统一代码风格配置 - 新增 .env 环境变量配置文件 - 添加开发和生产环境的环境变量配置 - 配置 ESLint 忽略规则文件 - 设置代码检查配置文件 .eslintrc.js - 添加 Git 忽略文件规则 - 创建 Prettier 格式化忽略规则 - 添加隐私政策和服务协议HTML文件 - 实现访问密钥编辑组件基础结构
This commit is contained in:
402
src/views/pwl/pwlProjectLibrary/index.vue
Normal file
402
src/views/pwl/pwlProjectLibrary/index.vue
Normal file
@@ -0,0 +1,402 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="pwlProjectLibraryId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@batchMove="openMove"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'type'">
|
||||
<a-tag v-if="record.type === 'biz'" color="blue">行业库</a-tag>
|
||||
<a-tag v-if="record.type === 'pub'" color="green">公共库</a-tag>
|
||||
<span v-if="!record.type || (record.type !== 'biz' && record.type !== 'pub')">未设置</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'image'">
|
||||
<a-image :src="record.image" :width="50" />
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<!-- 文档管理按钮 -->
|
||||
<a
|
||||
:class="{ 'disabled-text': !record.kbId }"
|
||||
:style="!record.kbId ? 'cursor: not-allowed; color: #999' : ''"
|
||||
@click="record.kbId && openDocManage(record)"
|
||||
>文档管理</a>
|
||||
<a-divider type="vertical"/>
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<PwlProjectLibraryEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
|
||||
<!-- 文档管理弹窗 -->
|
||||
<a-modal
|
||||
v-model:visible="showDocManage"
|
||||
:title="`文档管理 - ${currentKbName}`"
|
||||
width="800px"
|
||||
:footer="null"
|
||||
>
|
||||
<div style="margin-bottom: 16px;">
|
||||
<a-button type="primary" @click="openImport">新增文档</a-button>
|
||||
</div>
|
||||
<a-table
|
||||
:dataSource="docList"
|
||||
:columns="docColumns"
|
||||
:loading="docLoading"
|
||||
rowKey="id"
|
||||
:pagination="{
|
||||
current: currentPage,
|
||||
pageSize: 10,
|
||||
total: total,
|
||||
showSizeChanger: false,
|
||||
showTotal: (total) => `共 ${total} 条`
|
||||
}"
|
||||
@change="(pag) => { currentPage = pag.current; loadDocuments(); }"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-popconfirm
|
||||
title="确定要删除此文档吗?"
|
||||
@confirm="deleteDoc(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-modal>
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<Import v-model:visible="showImport" @done="loadDocuments" :kbId="currentKbId"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import {toDateString} from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import PwlProjectLibraryEdit from './components/pwlProjectLibraryEdit.vue';
|
||||
import { pagePwlProjectLibrary, removePwlProjectLibrary, removeBatchPwlProjectLibrary } from '@/api/pwl/pwlProjectLibrary';
|
||||
import type { PwlProjectLibrary, PwlProjectLibraryParam } from '@/api/pwl/pwlProjectLibrary/model';
|
||||
import Import from '@/views/oa/oaCompany/components/Import.vue';
|
||||
import {getKnowledgeBaseDocuments, deleteKnowledgeBaseDocument} from '@/api/ai/knowledgeBase';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<PwlProjectLibrary[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<PwlProjectLibrary | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 文档管理相关响应式变量
|
||||
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
||||
const showImport = ref(false); // 是否显示导入弹窗
|
||||
// 新增分页状态变量
|
||||
const currentPage = ref(1);
|
||||
const total = ref(0);
|
||||
|
||||
// 文档管理相关变量
|
||||
const currentKbId = ref(''); // 当前知识库ID
|
||||
const currentKbName = ref(''); // 当前知识库名称
|
||||
const docList = ref<any[]>([]); // 文档列表数据
|
||||
const docLoading = ref(false); // 文档加载状态
|
||||
// 文档表格列配置
|
||||
const docColumns = ref([
|
||||
{
|
||||
title: '文件名',
|
||||
dataIndex: 'name', // 改为接口返回的name字段
|
||||
key: 'fileName',
|
||||
},
|
||||
{
|
||||
title: '文件大小',
|
||||
dataIndex: 'size', // 改为接口返回的size字段
|
||||
key: 'fileSize',
|
||||
},
|
||||
{
|
||||
title: '上传时间',
|
||||
dataIndex: 'gmtModified', // 改为接口返回的gmtModified字段
|
||||
key: 'createTime',
|
||||
customRender: ({ text }) => toDateString(text) // 添加时间格式化
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 100,
|
||||
}
|
||||
]);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
return pagePwlProjectLibrary({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
align: 'center',
|
||||
width: 90,
|
||||
},
|
||||
{
|
||||
title: '资料库',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
align: 'center',
|
||||
},
|
||||
// {
|
||||
// title: '关联知识库ID',
|
||||
// dataIndex: 'kbId',
|
||||
// key: 'kbId',
|
||||
// align: 'center',
|
||||
// },
|
||||
// {
|
||||
// title: '资料库图标',
|
||||
// dataIndex: 'image',
|
||||
// key: 'image',
|
||||
// align: 'center',
|
||||
// },
|
||||
// {
|
||||
// title: '是否推荐',
|
||||
// dataIndex: 'recommend',
|
||||
// key: 'recommend',
|
||||
// align: 'center',
|
||||
// },
|
||||
// {
|
||||
// title: '状态',
|
||||
// dataIndex: 'status',
|
||||
// key: 'status',
|
||||
// align: 'center',
|
||||
// },
|
||||
// {
|
||||
// title: '备注',
|
||||
// dataIndex: 'comments',
|
||||
// key: 'comments',
|
||||
// align: 'center',
|
||||
// },
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sort',
|
||||
key: 'sort',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: PwlProjectLibraryParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: PwlProjectLibrary) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开批量移动弹窗 */
|
||||
const openMove = () => {
|
||||
showMove.value = true;
|
||||
};
|
||||
|
||||
// 打开文档管理弹窗
|
||||
const openDocManage = (record: PwlProjectLibrary) => {
|
||||
currentKbId.value = record.kbId; // 使用record中的kbId
|
||||
currentKbName.value = record.name; // 使用单位名称作为知识库名称
|
||||
currentPage.value = 1;
|
||||
showDocManage.value = true;
|
||||
loadDocuments();
|
||||
};
|
||||
|
||||
// 加载文档列表
|
||||
const loadDocuments = async () => {
|
||||
docLoading.value = true;
|
||||
try {
|
||||
const response = await getKnowledgeBaseDocuments(
|
||||
currentKbId.value,
|
||||
10,
|
||||
currentPage.value
|
||||
);
|
||||
docList.value = Array.isArray(response?.list) ? response.list : [];
|
||||
total.value = response?.count || 0;
|
||||
} catch (error) {
|
||||
message.error('加载文档列表失败');
|
||||
console.error('加载文档错误:', error);
|
||||
} finally {
|
||||
docLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 删除文档
|
||||
const deleteDoc = async (record: any) => {
|
||||
try {
|
||||
// 执行删除操作
|
||||
await deleteKnowledgeBaseDocument(currentKbId.value, record.id);
|
||||
|
||||
// 立即本地删除(核心修改)
|
||||
const index = docList.value.findIndex(item => item.id === record.id);
|
||||
if (index > -1) {
|
||||
docList.value.splice(index, 1);
|
||||
total.value -= 1;
|
||||
}
|
||||
message.success('删除成功');
|
||||
// 阿里云异步删除,需等待异步删除完成再重新查询
|
||||
// await loadDocuments();
|
||||
} catch (error) {
|
||||
message.error('删除失败');
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
// 打开导入弹窗
|
||||
const openImport = () => {
|
||||
showImport.value = true;
|
||||
};
|
||||
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: PwlProjectLibrary) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removePwlProjectLibrary(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchPwlProjectLibrary(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: PwlProjectLibrary) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'PwlProjectLibrary'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
Reference in New Issue
Block a user