Commit d47fc120 by Lin

feat: 素材列表及分组接口联调

1 parent f3a5f760
import { gscPost} from '@/utils/gscRequest';
/**
* 素材分组列表
*/
export async function findCategoryList(data: any) {
try {
const response = await gscPost('/knowledgeCategory/findCategoryList', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 素材分组新增
*/
export async function addCategory(data: any) {
try {
const response = await gscPost('/knowledgeCategory/addCategory', data, { returnAll:true });
return response;
} catch (error) {
throw error;
}
}
/**
* 素材分组修改
*/
export async function updateCategory(data: any) {
try {
const response = await gscPost('/knowledgeCategory/updateCategory', data, { returnAll:true });
return response;
} catch (error) {
throw error;
}
}
/**
* 分组列表包含的素材列表
*/
export async function findCategoryWithMaterialList(data: any) {
try {
const response = await gscPost('/knowledgeCategory/findCategoryWithMaterialList', data, { returnAll:true });
return response;
} catch (error) {
throw error;
}
}
/**
* 素材列表
*/
export async function findPageKnowledgeMaterial(data: any) {
try {
const response = await gscPost('/knowledgeMaterial/findPageKnowledgeMaterial', data, { returnAll:true });
return response;
} catch (error) {
throw error;
}
}
/**
* 素材编辑
*/
export async function updateKnowledgeMaterial(data: any) {
try {
const response = await gscPost('/knowledgeMaterial/updateKnowledgeMaterial', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 素材上传
*/
export async function saveKnowledgeMaterial(data: any) {
try {
const response = await gscPost('/knowledgeMaterial/saveKnowledgeMaterial', data);
return response;
} catch (error) {
throw error;
}
}
/**
* 素材删除
*/
export async function deleteKnowledgeMaterial(data: any) {
try {
const response = await gscPost('/knowledgeMaterial/deleteKnowledgeMaterial', data, { returnAll:true });
return response;
} catch (error) {
throw error;
}
}
...@@ -41,17 +41,11 @@ const getList = async () => { ...@@ -41,17 +41,11 @@ const getList = async () => {
}; };
const res = await assistantList(requestData); const res = await assistantList(requestData);
console.log('getList', res); console.log('getList', res);
// 根据实际接口返回结构解析数据 // 根据实际接口返回结构解析数据
let records = []; let records = [];
let total = 0; let total = 0;
let current = 1; let current = 1;
if (res && Array.isArray(res.records)) {
if (res && res.data) {
records = res.data.records || res.data.list || [];
total = res.data.total || 0;
current = res.data.current || res.data.currentPage || 1;
} else if (res && Array.isArray(res.records)) {
// 兼容直接返回分页数据的情况 // 兼容直接返回分页数据的情况
records = res.records || []; records = res.records || [];
total = res.total || 0; total = res.total || 0;
...@@ -67,7 +61,6 @@ const getList = async () => { ...@@ -67,7 +61,6 @@ const getList = async () => {
pagination.total = total; pagination.total = total;
pagination.currentPage = current; pagination.currentPage = current;
} catch (error) { } catch (error) {
console.error('获取列表失败:', error);
ElMessage.error('获取列表失败,请稍后重试'); ElMessage.error('获取列表失败,请稍后重试');
tableData.value = []; tableData.value = [];
pagination.total = 0; pagination.total = 0;
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
</div> </div>
<div <div
class="flex items-center justify-center edit-btn w-[68px] h-[28px] rounded-[4px] bg-[#1956FE] cursor-pointer hover:bg-[#0d47d9] transition-colors" class="flex items-center justify-center edit-btn w-[68px] h-[28px] rounded-[4px] bg-[#1956FE] cursor-pointer hover:bg-[#0d47d9] transition-colors"
v-if="!isEditing"
@click="toggleEdit" @click="toggleEdit"
> >
<img class="w-[14px] h-[14px]" src="/images/icon-edit.png" alt="" srcset=""> <img class="w-[14px] h-[14px]" src="/images/icon-edit.png" alt="" srcset="">
...@@ -82,7 +83,7 @@ ...@@ -82,7 +83,7 @@
<p class="text-[12px] text-[#969AA3] font-normal mt-[4px]">提示词将指导AI如何进行对话分析,可根据需求调整分析重点和输出格式</p> <p class="text-[12px] text-[#969AA3] font-normal mt-[4px]">提示词将指导AI如何进行对话分析,可根据需求调整分析重点和输出格式</p>
<div class="btn-group flex items-center gap-[12px] mt-[32px]" v-if="isEditing"> <div class="btn-group flex items-center gap-[12px] mt-[32px]" v-if="isEditing">
<el-button type="primary">保存</el-button> <el-button type="primary">保存</el-button>
<el-button>取消</el-button> <el-button @click="toggleEdit">取消</el-button>
</div> </div>
</div> </div>
</section> </section>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<!-- 标题头 --> <!-- 标题头 -->
<div class="flex items-center h-[42px] mb-4 border-b border-gray-100"> <div class="flex items-center h-[42px] mb-4 border-b border-gray-100">
<!-- <div class="w-1 h-4 bg-blue-600 rounded-sm mr-2"></div> --> <!-- <div class="w-1 h-4 bg-blue-600 rounded-sm mr-2"></div> -->
<img src="../../../../images/icon-title.png" alt="title" class="w-[4px] h-[18px] rounded-sm"> <img src="/images/icon-title.png" alt="title" class="w-[4px] h-[18px] rounded-sm">
<p class="text-[14px] font-medium text-[#2F3133] ml-[12px]">智能体概况</p> <p class="text-[14px] font-medium text-[#2F3133] ml-[12px]">智能体概况</p>
</div> </div>
......
...@@ -81,10 +81,10 @@ const sidebarItems = [ ...@@ -81,10 +81,10 @@ const sidebarItems = [
<div <div
class="mr-4" class="mr-4"
> >
<img v-if="index === 0" src="../../../public/images/icon-agentic-quality.png" class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full transition-colors" /> <img v-if="index === 0" src="/images/icon-agentic-quality.png" class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full transition-colors" />
<img v-if="index === 1" src="../../../public/images/icon-agentic-practice.png" class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full transition-colors" /> <img v-if="index === 1" src="/images/icon-agentic-practice.png" class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full transition-colors" />
<img v-if="index === 2" src="../../../public/images/icon-agentic-replay.png" class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full transition-colors" /> <img v-if="index === 2" src="/images/icon-agentic-replay.png" class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full transition-colors" />
<img v-if="index === 3" src="../../../public/images/icon-agentic-train.png" class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full transition-colors" /> <img v-if="index === 3" src="/images/icon-agentic-train.png" class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full transition-colors" />
</div> </div>
<!-- 文本 --> <!-- 文本 -->
......
...@@ -71,9 +71,12 @@ ...@@ -71,9 +71,12 @@
<span class="text-gray-600 font-medium">所属分组</span> <span class="text-gray-600 font-medium">所属分组</span>
</template> </template>
<el-select v-model="formData.group" placeholder="请选择" class="custom-form-select" size="large"> <el-select v-model="formData.group" placeholder="请选择" class="custom-form-select" size="large">
<el-option label="未分组" value="ungrouped" /> <el-option
<el-option label="营销素材" value="marketing" /> v-for="category in categories"
<el-option label="产品图片" value="product" /> :key="category.id"
:label="category.name"
:value="category.id"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -179,9 +182,10 @@ ...@@ -179,9 +182,10 @@
</template> </template>
<script setup> <script setup>
import { ref, reactive, watch } from 'vue'; import { ref, reactive, watch, onMounted } from 'vue';
import { Close, UploadFilled, Folder } from '@element-plus/icons-vue'; import { Close, UploadFilled, Folder } from '@element-plus/icons-vue';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import { findCategoryList } from '@/api/knowledge';
// 定义 props // 定义 props
const props = defineProps({ const props = defineProps({
...@@ -206,10 +210,30 @@ const uploadRef = ref(null); ...@@ -206,10 +210,30 @@ const uploadRef = ref(null);
const formData = reactive({ const formData = reactive({
files: [], files: [],
name: '', name: '',
group: '未分组', group: '',
departments: [] departments: []
}); });
// --- Categories Data ---
const categories = ref([]);
// 获取分类列表
const getCategoryList = async () => {
try {
const res = await findCategoryList({});
if (res?.length) {
categories.value = res.map((item) => ({
id: item.id,
name: item.name,
count: item.materialCount || 0,
}));
}
} catch (error) {
console.error('获取分类列表失败:', error);
ElMessage.error('获取分类列表失败');
}
};
// 文件变化处理 // 文件变化处理
const handleFileChange = (file, fileList) => { const handleFileChange = (file, fileList) => {
formData.files = fileList; formData.files = fileList;
...@@ -223,14 +247,10 @@ const handleFileRemove = (file, fileList) => { ...@@ -223,14 +247,10 @@ const handleFileRemove = (file, fileList) => {
// 监听 material 变化,填充表单数据 // 监听 material 变化,填充表单数据
watch(() => props.material, (newMaterial) => { watch(() => props.material, (newMaterial) => {
if (newMaterial) { if (newMaterial) {
// 填充素材名称 formData.name = newMaterial.title || newMaterial.name || '';
formData.name = newMaterial.title || '';
// 如果有文件URL,创建文件对象用于显示
if (newMaterial.fileUrl) { if (newMaterial.fileUrl) {
// 从URL提取文件名
const fileName = newMaterial.title || newMaterial.fileUrl.split('/').pop() || '文件'; const fileName = newMaterial.title || newMaterial.fileUrl.split('/').pop() || '文件';
// 创建文件对象(用于显示,实际可能需要从服务器获取文件)
formData.files = [{ formData.files = [{
name: fileName, name: fileName,
url: newMaterial.fileUrl, url: newMaterial.fileUrl,
...@@ -240,16 +260,12 @@ watch(() => props.material, (newMaterial) => { ...@@ -240,16 +260,12 @@ watch(() => props.material, (newMaterial) => {
formData.files = []; formData.files = [];
} }
// 如果有分组信息,可以在这里设置 formData.group = newMaterial.categoryId || newMaterial.group || '';
// formData.group = newMaterial.group || '未分组'; formData.departments = newMaterial.departments || [];
// 如果有部门信息,可以在这里设置
// formData.departments = newMaterial.departments || [];
} else { } else {
// 清空表单(新增模式)
formData.name = ''; formData.name = '';
formData.files = []; formData.files = [];
formData.group = '未分组'; formData.group = '';
formData.departments = []; formData.departments = [];
} }
}, { immediate: true }); }, { immediate: true });
...@@ -402,6 +418,11 @@ const closeModal = () => { ...@@ -402,6 +418,11 @@ const closeModal = () => {
const handleClose = () => { const handleClose = () => {
closeModal(); closeModal();
}; };
// 组件挂载时获取分类列表
onMounted(() => {
getCategoryList();
});
</script> </script>
<style scoped> <style scoped>
......
...@@ -12,7 +12,7 @@ VITE_SUBAPP_REACT_ENTRY=http://localhost:8082 ...@@ -12,7 +12,7 @@ VITE_SUBAPP_REACT_ENTRY=http://localhost:8082
VITE_BASE_URL=/ VITE_BASE_URL=/
VITE_USE_MOCK=true VITE_USE_MOCK=false
VITE_DEBUG=true VITE_DEBUG=true
......
// / <reference types="vite/client" /> /// <reference types="vite/client" />
declare module '*.vue' { declare module '*.vue' {
import type { DefineComponent } from 'vue'; import type { DefineComponent } from 'vue';
......
...@@ -9,8 +9,6 @@ let baseConfig: any = {}; ...@@ -9,8 +9,6 @@ let baseConfig: any = {};
let routerConfig: any = {}; let routerConfig: any = {};
// GSC API 请求实例(模块级单例,不挂载到 window) // GSC API 请求实例(模块级单例,不挂载到 window)
let gscApiInstance: null | Request = null; let gscApiInstance: null | Request = null;
// 错误信息存储:用于将 error 事件中的错误信息传递到实际请求处
const errorStore = new Map<string, { error: any; requestConfig: any; timestamp: number }>();
// 配置加载完成的 Promise // 配置加载完成的 Promise
let configReadyPromise: null | Promise<void> = null; let configReadyPromise: null | Promise<void> = null;
......
...@@ -8,10 +8,10 @@ import { defaultTopMenus, getMenuParentPaths } from '@/config/menus'; ...@@ -8,10 +8,10 @@ import { defaultTopMenus, getMenuParentPaths } from '@/config/menus';
import { microApps } from '@/qiankun/apps'; import { microApps } from '@/qiankun/apps';
import { communicationManager } from '@/qiankun/communication'; import { communicationManager } from '@/qiankun/communication';
import { useMenuStore } from '@/stores'; import { useMenuStore } from '@/stores';
import { Download } from '@element-plus/icons-vue'; // import { Download } from '@element-plus/icons-vue';
import Breadcrumb from './components/Breadcrumb.vue'; import Breadcrumb from './components/Breadcrumb.vue';
import NotificationCenter from './components/NotificationCenter.vue'; // import NotificationCenter from './components/NotificationCenter.vue';
import SidebarMenuItem from './components/SidebarMenuItem.vue'; import SidebarMenuItem from './components/SidebarMenuItem.vue';
import UserInfo from './components/UserInfo.vue'; import UserInfo from './components/UserInfo.vue';
...@@ -347,7 +347,7 @@ watch( ...@@ -347,7 +347,7 @@ watch(
.collapse-button { .collapse-button {
position: fixed; position: fixed;
top: 30%; top: 30%;
z-index: 10001; z-index: 1;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
......
<script setup lang="ts"> <script setup lang="ts">
import type { MenuItem } from '@/types/menu'; import type { MenuItem } from '@/types/menu';
import { computed, ref, onMounted, nextTick } from 'vue'; import { computed, ref, nextTick } from 'vue';
import { ArrowDown, ArrowRight } from '@element-plus/icons-vue'; import { ArrowDown, ArrowRight } from '@element-plus/icons-vue';
...@@ -140,7 +140,7 @@ const handleChildClick = (child: MenuItem) => { ...@@ -140,7 +140,7 @@ const handleChildClick = (child: MenuItem) => {
<img <img
v-if="menu?.level == 1" v-if="menu?.level == 1"
class="menu-icon" class="menu-icon"
src="/public/images/icon-menu-agentic.png" src="/images/icon-menu-agentic.png"
alt="" alt=""
srcset="" srcset=""
/> />
...@@ -156,7 +156,7 @@ const handleChildClick = (child: MenuItem) => { ...@@ -156,7 +156,7 @@ const handleChildClick = (child: MenuItem) => {
<img <img
v-if="menu?.level == 1" v-if="menu?.level == 1"
class="menu-icon" class="menu-icon"
src="/public/images/icon-menu-agentic.png" src="/images/icon-menu-agentic.png"
alt="" alt=""
srcset="" srcset=""
/> />
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!