|
@@ -185,6 +185,13 @@ export default {
|
|
|
endOffset:'',
|
|
|
text:"",
|
|
|
type:"人工指定",
|
|
|
+ },
|
|
|
+ relationForm:{
|
|
|
+ taskId:"",
|
|
|
+ typeId:"",
|
|
|
+ startId:"",
|
|
|
+ endId:"",
|
|
|
+ type:"人工标注"
|
|
|
}
|
|
|
};
|
|
|
},
|
|
@@ -345,7 +352,7 @@ export default {
|
|
|
this.highlightedText = highlightedText;
|
|
|
},
|
|
|
saveRelation() {
|
|
|
- if (this.relation_flag != 1) {
|
|
|
+ if (this.relation_flag !== 1) {
|
|
|
this.$message({
|
|
|
message: '请先保存实体!',
|
|
|
type: 'warning'
|
|
@@ -366,15 +373,18 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 创建关系对象
|
|
|
- const relation = {
|
|
|
- startId: headEntity.id,
|
|
|
- endId: tailEntity.id,
|
|
|
- type: '人工标注'
|
|
|
- };
|
|
|
+ this.relationForm.startId = this.headEntityId;
|
|
|
+ this.relationForm.endId = this.tailEntityId;
|
|
|
+
|
|
|
+ // // 创建关系对象
|
|
|
+ // const relation = {
|
|
|
+ // startId: headEntity.id,
|
|
|
+ // endId: tailEntity.id,
|
|
|
+ // type: '人工标注'
|
|
|
+ // };
|
|
|
|
|
|
// 调用 addRelation 接口保存关系
|
|
|
- addRelation(relation).then(response => {
|
|
|
+ addRelation(this.relationForm).then(response => {
|
|
|
if (response.code === 200) {
|
|
|
// 保存成功,将关系添加到前端的关系列表中
|
|
|
// this.relations.push({
|
|
@@ -435,11 +445,18 @@ export default {
|
|
|
console.log("提交实体数据:", this.entityForm);
|
|
|
|
|
|
addEntity(this.entityForm).then(response => {
|
|
|
+
|
|
|
console.log("实体保存响应:",response);
|
|
|
- if (response.code === 200) {
|
|
|
+ if (this.highlightHistory.length === 1){
|
|
|
+ this.headEntityId = response.data.entityId;
|
|
|
+ } else {
|
|
|
+ this.tailEntityId = response.data.entityId;
|
|
|
+ }
|
|
|
+ console.log(this.headEntityId);
|
|
|
+ if (response.code === 200 && response.data) {
|
|
|
// // 实体保存成功后,更新 entities 数组
|
|
|
// const entity = {
|
|
|
- // id: response.data.id,
|
|
|
+ // id: response.data.entityId,// 使用后端返回的entity_id
|
|
|
// text: this.selectedText,
|
|
|
// startOffset: this.startOffset,
|
|
|
// endOffset: this.endOffset,
|
|
@@ -448,6 +465,21 @@ export default {
|
|
|
// };
|
|
|
// this.entities.push(entity);
|
|
|
|
|
|
+ // 获取后端返回的 entity_id
|
|
|
+ const entityId = response.data.entityId;
|
|
|
+
|
|
|
+ // 找到当前实体在entities数组中的索引
|
|
|
+ const entityIndex = this.entities.findIndex(
|
|
|
+ entity => entity.text === this.selectedText &&
|
|
|
+ entity.startOffset === this.startOffset &&
|
|
|
+ entity.endOffset === this.endOffset
|
|
|
+ );
|
|
|
+
|
|
|
+ if (entityIndex !== -1) {
|
|
|
+ //更新实体的id尾后端返回的entity_id
|
|
|
+ this.entities[entityIndex].id = entityId;
|
|
|
+ }
|
|
|
+
|
|
|
this.$message({
|
|
|
message: '成功提交',
|
|
|
type: 'success'
|