提交 3df44f93 authored 作者: caijian's avatar caijian

first commit

上级 a7a092f6
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"@/*": ["*"]
},
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"allowJs": true,
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
\ No newline at end of file
...@@ -199,6 +199,60 @@ export const saveEventsTable = async (params) => { ...@@ -199,6 +199,60 @@ export const saveEventsTable = async (params) => {
return data return data
} }
//获取chart prompt
export const getChartPrompt = async (params, type) => {
let data = await request.get(`/api/analysis/${type}?hyper_id=` + params.hyper_id)
return data
}
//保存chart prompt
export const saveChartPrompt = async (params, type) => {
let data = await request({
method: "post",
headers: {
'Content-Type': 'application/json'
},
url: "/api/analysis/" + type,
data: params
})
return data
}
export const getChartNewsList = async (params) => {
let data = await request.get('/api/analysis/get_chart_news_in_rag?hyper_id=' + params.hyper_id)
return data
}
export const getChartData = async (params) => {
let data = await request.get('/api/analysis/analysis_chart_in_rag?hyper_id=' + params.hyper_id)
return data
}
// http://8.140.26.4:10006/tech_hyper/api/analysis/get_matrix_news_in_rag?hyper_id=1
export const getMatrixNewsList = async (params) => {
let data = await request.get('/api/analysis/get_matrix_news_in_rag?hyper_id=' + params.hyper_id)
return data
}
// http://8.140.26.4:10006/tech_hyper/api/analysis/analysis_matrix_in_rag?hyper_id=1
export const getMatrixData = async (params) => {
let data = await request.get('/api/analysis/analysis_matrix_in_rag?hyper_id=' + params.hyper_id)
return data
}
// http://8.140.26.4:10006/tech_hyper/api/analysis/get_event_relation_news_in_rag?hyper_id=1
export const getEventNewsList = async (params) => {
let data = await request.get('/api/analysis/get_event_relation_news_in_rag?hyper_id=' + params.hyper_id)
return data
}
// http://8.140.26.4:10006/tech_hyper/api/analysis/analysis_event_relations_in_rag?hyper_id=1
export const getEventData = async (params) => {
let data = await request.get('/api/analysis/analysis_event_relations_in_rag?hyper_id=' + params.hyper_id)
return data
}
/** /**
* 上传文件,后端解析Excel文件 * 上传文件,后端解析Excel文件
* @param file 文件,表单数据 * @param file 文件,表单数据
......
...@@ -9,7 +9,7 @@ const BASE_API = "/" ...@@ -9,7 +9,7 @@ const BASE_API = "/"
// 创建axios实例 // 创建axios实例
const service = axios.create({ const service = axios.create({
baseURL: BASE_API, //所有的后端接口请求地址前缀部分(没有后端请求不用写) baseURL: BASE_API, //所有的后端接口请求地址前缀部分(没有后端请求不用写)
timeout: 15000 // 请求超时时间,这里15秒 timeout: 50000 // 请求超时时间,这里15秒
//withCredentials: true,// 异步请求携带cookie,true为携带,false为不携带 //withCredentials: true,// 异步请求携带cookie,true为携带,false为不携带
//请求头里面设置通用传参类型 //请求头里面设置通用传参类型
/*headers: { /*headers: {
...@@ -35,6 +35,13 @@ service.interceptors.request.use(config => { ...@@ -35,6 +35,13 @@ service.interceptors.request.use(config => {
service.interceptors.response.use( service.interceptors.response.use(
response => { response => {
//对数据返回做什么 //对数据返回做什么
if (response.data.code == 0) {
ElMessage({
message: response.data.message,
type: 'error',
duration: 3 * 1000
})
}
return response.data return response.data
}, },
error => { error => {
......
...@@ -17,11 +17,14 @@ ...@@ -17,11 +17,14 @@
</div> </div>
</div> </div>
<div class="extra-container"> <div class="extra-container">
<div class="location-text text-ellipsis"> <!-- <div class="location-text text-ellipsis">
<span :title="item.country">{{ item.country }}</span> <span :title="item.country">{{ item.country }}</span>
</div> </div>
<div class="date-text text-ellipsis"> <div class="date-text text-ellipsis">
<span :title="item.date">{{ item.date || '-' }}</span> <span :title="item.date">{{ item.date || '-' }}</span>
</div> -->
<div class="date-text text-ellipsis">
<span :title="item.content" v-if="item.content">{{ item.content.join(',') || '-' }}</span>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
<span>{{ index + 1 }}</span> <span>{{ index + 1 }}</span>
</div> </div>
<div class="name-text text-ellipsis"> <div class="name-text text-ellipsis">
<span :title="item.date + item.country" style="color: #AFD4F5;" >{{ "(" + item.date + "-" + item.country + ") " }}</span> <!-- <span :title="item.date + item.country" style="color: #AFD4F5;" >{{ "(" + item.date + "-" + item.country + ") " }}</span> -->
<span :title="item.title">{{ item.title || '-' }}</span> <span :title="item.title">{{ item.title || '-' }}</span>
</div> </div>
</div> </div>
<div class="extra-container"> <div class="extra-container">
<div class="location-text text-ellipsis"> <div class="location-text text-ellipsis">
<span :title="item.achievement">{{ item.achievement }}</span> <span :title="item.content">{{ item.content.join(',') }}</span>
</div> </div>
</div> </div>
</div> </div>
......
<template>
<el-dialog title="RAG 分析" v-model="visible" width="60%" :close-on-click-modal="false" @close="handleClose">
<el-form :model="form" label-width="80px" label-position="top">
<el-form-item label="Prompt">
<el-input
v-model="form.prompt"
type="textarea"
:rows="6"
placeholder="请输入prompt内容"
/>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="handleClose">取消</el-button>
<el-button type="primary" @click="handleSubmit">确定</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup>
import { ref, watch, getCurrentInstance, onMounted } from 'vue'
import { getChartPrompt, saveChartPrompt } from '@/api/graphApi'
const { appContext } = getCurrentInstance();
const globalProxy = appContext.config.globalProperties;
const props = defineProps({
modelValue: {
type: Boolean,
default: false
},
prompt: {
type: String,
default: ''
},
hyperId: {
type: Number,
default: 1
},
focusButton: {
type: Number,
default: false
}
})
const getUrlMap = {
0: 'get_chart_prompt',
1: 'get_matrix_prompt',
2: 'get_event_relation_prompt'
}
const saveUrlMap = {
0: 'save_chart_prompt',
1: 'save_matrix_prompt',
2: 'save_event_relation_prompt'
}
const emit = defineEmits(['update:modelValue', 'submit'])
const visible = ref(false)
const form = ref({
prompt: ''
})
// 监听props变化
watch(() => props.modelValue, async (newVal) => {
visible.value = newVal
if (newVal) {
// 当对话框打开时,获取prompt数据
await fetchPromptData()
}
})
// 移除对props.prompt的监听,现在直接从接口获取数据
// 监听visible变化,同步到父组件
watch(visible, (newVal) => {
emit('update:modelValue', newVal)
})
function handleClose() {
visible.value = false
}
// 获取prompt数据
async function fetchPromptData() {
try {
const params = {
hyper_id: props.hyperId
}
const response = await getChartPrompt(params, getUrlMap[props.focusButton])
if (response.code === 1 && response.data) {
form.value.prompt = response.data
}
} catch (error) {
console.error('获取prompt失败:', error)
globalProxy.$message({
message: '获取prompt数据失败',
type: 'error'
})
}
}
// 保存prompt数据
async function savePromptData() {
try {
const params = {
hyper_id: props.hyperId,
prompt: form.value.prompt
}
const response = await saveChartPrompt(params, saveUrlMap[props.focusButton])
return response
} catch (error) {
console.error('保存prompt失败:', error)
throw error
}
}
async function handleSubmit() {
console.log('RAG请求参数:', form.value.prompt)
if (!form.value.prompt.trim()) {
globalProxy.$message({
message: '请输入prompt内容',
type: 'warning'
})
return
}
try {
globalProxy.$message({
message: '正在保存prompt...',
type: 'info'
})
await savePromptData()
globalProxy.$message({
message: 'Prompt保存成功!',
type: 'success'
})
visible.value = false
emit('submit', form.value.prompt)
} catch (error) {
globalProxy.$message({
message: '保存prompt失败',
type: 'error'
})
}
}
// 组件挂载时获取数据
onMounted(() => {
if (visible.value) {
fetchPromptData()
}
})
</script>
<style scoped>
.dialog-footer {
display: flex;
justify-content: flex-end;
gap: 10px;
}
</style>
\ No newline at end of file
...@@ -232,6 +232,7 @@ function getEventGraphData(id) { ...@@ -232,6 +232,7 @@ function getEventGraphData(id) {
let paramsObj = { let paramsObj = {
id: id id: id
} }
if (!paramsObj.id) return
getHypermapById(paramsObj).then((res)=>{ getHypermapById(paramsObj).then((res)=>{
let leftTopLon = res.data.bounds.leftTop.lon; let leftTopLon = res.data.bounds.leftTop.lon;
let leftTopLat = res.data.bounds.leftTop.lat; let leftTopLat = res.data.bounds.leftTop.lat;
......
...@@ -185,11 +185,36 @@ function handleConfirmRelation() { ...@@ -185,11 +185,36 @@ function handleConfirmRelation() {
to, to,
relation_name relation_name
} = relationFormState.value; } = relationFormState.value;
if (from && to && relation_name) {
emit("handleConfirmRelation", relationFormState.value); // 详细的表单验证
} else { if (!from) {
globalProxy.$message.error("有未选择项"); globalProxy.$message.error("请选择起始节点");
return;
}
if (!to) {
globalProxy.$message.error("请选择目标节点");
return;
}
if (!relation_name || relation_name.trim() === '') {
globalProxy.$message.error("请输入关系名称");
return;
}
if (from === to) {
globalProxy.$message.error("起始节点和目标节点不能相同");
return;
} }
// 验证关系名称长度
if (relation_name.trim().length > 50) {
globalProxy.$message.error("关系名称不能超过50个字符");
return;
}
// 发送确认事件
emit("handleConfirmRelation", {
...relationFormState.value,
relation_name: relation_name.trim() // 去除首尾空格
});
} }
function handleExchange() { function handleExchange() {
......
...@@ -1198,33 +1198,63 @@ const handleQuery = (e) => { ...@@ -1198,33 +1198,63 @@ const handleQuery = (e) => {
// 建立节点与节点之间的关系 // 建立节点与节点之间的关系
function handleConfirmRelation(e) { function handleConfirmRelation(e) {
console.log("e", e); console.log("新增关系参数:", e);
console.log("graph_data", graph_data.value); console.log("当前图数据:", graph_data.value);
try {
// 验证必要参数
if (!e.from || !e.to || !e.relation_name) {
globalProxy.$message.error("关系参数不完整,请检查起始节点、目标节点和关系名称");
return;
}
let savedGraph = _.cloneDeep(graph_data.value); let savedGraph = _.cloneDeep(graph_data.value);
let graph = simplifyData(savedGraph); let graph = simplifyData(savedGraph);
let id = props.eventGraphId; let id = props.eventGraphId;
console.log("graph", graph); // 查找源节点和目标节点
const sourceNode = graph.nodes.find((item) => item.label === e.from);
const targetNode = graph.nodes.find((item) => item.label === e.to);
if (!sourceNode || !targetNode) {
globalProxy.$message.error("未找到对应的节点,请确认节点是否存在");
return;
}
// 检查是否已存在相同的关系
const existingEdge = graph.edges.find((edge) =>
edge.source === sourceNode.id &&
edge.target === targetNode.id &&
edge.label === e.relation_name
);
if (existingEdge) {
globalProxy.$message.warning("该关系已存在,无需重复添加");
handleCloseAddRelation();
return;
}
// 创建新的关系边
const newEdge = { const newEdge = {
id: `edge_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, // 生成唯一ID
date: null, date: null,
label: e.relation_name, label: e.relation_name,
source: graph.nodes.filter((item) => { source: sourceNode.id,
return item.label === e.from; target: targetNode.id,
})[0].id,
target: graph.nodes.filter((item) => {
return item.label === e.to;
})[0].id,
}; };
// 添加新关系到图数据
graph.edges = [...graph.edges, newEdge]; graph.edges = [...graph.edges, newEdge];
console.log("更新后的图数据:", graph);
// 获取当前视图中心点
let zoom_center = {}; let zoom_center = {};
emit("saveMap", (val) => { emit("saveMap", (val) => {
zoom_center = val; zoom_center = val;
}); });
// 构建保存参数
let params = { let params = {
hyper_id: id, hyper_id: id,
graph: { graph: {
...@@ -1232,24 +1262,43 @@ function handleConfirmRelation(e) { ...@@ -1232,24 +1262,43 @@ function handleConfirmRelation(e) {
zoom_center: zoom_center, zoom_center: zoom_center,
}, },
}; };
console.log("保存超图参数:", params);
// 调用保存接口
saveHypergraph(params) saveHypergraph(params)
.then((res) => { .then((res) => {
console.log("保存超图响应:", res);
if (res.code === 1) { if (res.code === 1) {
globalProxy.$message({ globalProxy.$message({
type: "success", type: "success",
message: "保存成功", message: "新增关系成功",
}); });
// 刷新图谱数据
emit("refreshGraph"); emit("refreshGraph");
handleCloseAddRelation();
} else {
globalProxy.$message({
type: "error",
message: res.message || "新增关系失败",
});
} }
}) })
.catch(() => { .catch((error) => {
console.error("保存超图失败:", error);
globalProxy.$message({ globalProxy.$message({
type: "error", type: "error",
message: "保存失败", message: "网络错误,新增关系失败,请稍后重试",
}); });
}); });
} catch (error) {
console.error("新增关系处理异常:", error);
globalProxy.$message({
type: "error",
message: "处理新增关系时发生异常,请稍后重试",
});
handleCloseAddRelation(); handleCloseAddRelation();
}
} }
// 融合图谱数据 // 融合图谱数据
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论