文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit d93380d3 by 李景熙

Merge branch 'develop' of https://gitlab.redhtc.com/Berlincen/DA-Platform into develop

parents 37067ecf a07a7af0
...@@ -51,15 +51,6 @@ ...@@ -51,15 +51,6 @@
<!-- 文本界面 --> <!-- 文本界面 -->
<div class="content" @mouseup="highlight()" v-html="content"></div> <div class="content" @mouseup="highlight()" v-html="content"></div>
<!-- 文本界面 --> <!-- 文本界面 -->
<!-- 表格界面 -->
<div @click="highlight()">
<el-table :data="tableData" border style="width: 100%">
<el-table-column prop="date" label="日期" width="180"></el-table-column>
<el-table-column prop="name" label="姓名" width="180"></el-table-column>
<el-table-column prop="address" label="地址"></el-table-column>
</el-table>
</div>
<!-- 表格界面 -->
<br /> <br />
<div> <div>
<el-button type="primary" @click="submit()">提交</el-button> <el-button type="primary" @click="submit()">提交</el-button>
...@@ -122,34 +113,36 @@ export default { ...@@ -122,34 +113,36 @@ export default {
// 文章列表 // 文章列表
textData: [], textData: [],
// templete // templete
treeDataExample:[{ // treeDataExample: [
label: "宏观稳定性", // {
children: [ // label: "宏观稳定性",
{ // children: [
label: "不稳定" // {
}, // label: "不稳定"
{ // },
label: "基本稳定" // {
}, // label: "基本稳定"
{ // },
label: "稳定" // {
} // label: "稳定"
] // }
}, // ]
{ // },
label: "确定性程度", // {
children: [ // label: "确定性程度",
{ // children: [
label: "确定" // {
}, // label: "确定"
{ // },
label: "基本确定" // {
}, // label: "基本确定"
{ // },
label: "不确定" // {
} // label: "不确定"
] // }
}], // ]
// }
// ],
treeData: [], treeData: [],
defaultProps: { defaultProps: {
...@@ -160,34 +153,67 @@ export default { ...@@ -160,34 +153,67 @@ export default {
ifAlert: false, // 弹窗 ifAlert: false, // 弹窗
// 实体 // 实体
value: "", value: "",
optionsExample: [{ // optionsExample: [
value: "选项1", // {
label: "滑坡" // value: "选项1",
}, // label: "滑坡"
{ // },
value: "选项2", // {
label: "山体" // value: "选项2",
}, // label: "山体"
{ // },
value: "选项3", // {
label: "河流" // value: "选项3",
}, // label: "河流"
{ // },
value: "选项4", // {
label: "时间" // value: "选项4",
}], // label: "时间"
// }
// ],
options: [], options: [],
// table // table
tableData: [] tableData: []
}; };
}, },
beforeMount() { beforeMount() {
// 从通用传来文本信息 // TODO 区分text和table // 从通用传来文本信息
// TODO quary instead of params to fix the bug during refreshing // TODO quary instead of params to fix the bug during refreshing
this.file = JSON.parse(decodeURIComponent(this.$route.params.file)); this.file = JSON.parse(decodeURIComponent(this.$route.params.file));
this.task = JSON.parse(decodeURIComponent(this.$route.params.task)); this.task = JSON.parse(decodeURIComponent(this.$route.params.task));
}, },
methods: { methods: {
// 分出表格
checkTable() {
console.log(this.file.url);
if (
this.file.url
.split("")
.reverse()
.join("")
.substring(0, 4)
.split("")
.reverse()
.join("") == "xlsx"
) {
var params = {
file: encodeURIComponent(JSON.stringify(this.file)),
task: encodeURIComponent(JSON.stringify(this.task))
};
this.$router.push({ name: "table", params });
} else if (
this.file.url
.split("")
.reverse()
.join("")
.substring(0, 3)
.split("")
.reverse()
.join("") == "txt"
) {
this.insertDocument();
}
},
// 插入数据库 // 插入数据库
insertDocument() { insertDocument() {
console.log("userId" + this.$store.state.userInfo.userId); console.log("userId" + this.$store.state.userInfo.userId);
...@@ -198,7 +224,7 @@ export default { ...@@ -198,7 +224,7 @@ export default {
url: "/textAnnotation/insertDocument", url: "/textAnnotation/insertDocument",
data: { data: {
templateId: 1, // TODO 模板id templateId: 1, // TODO 模板id
annotatorId: this.$store.state.userInfo.userId, // TODO 标注者信息 annotatorId: this.$store.state.userInfo.userId,
textUrl: this.file.url, textUrl: this.file.url,
type: "text", type: "text",
fileId: this.file.id fileId: this.file.id
...@@ -278,17 +304,12 @@ export default { ...@@ -278,17 +304,12 @@ export default {
} }
}).then(res => { }).then(res => {
if (res.return_code == 200) { if (res.return_code == 200) {
console.log(res.result) //console.log(res.result)
// 实体 // 实体
this.token.entityId = JSON.stringify(res.result.templateId) // 现在的实体与模板相近,所以就先固定了 this.token.entityId = JSON.stringify(res.result.templateId); // 现在的实体与模板相近,所以就先固定了
this.options.push(res.result.templateName) this.options.push(res.result.templateName);
// 属性 // 属性
this.treeData = res.result.entityList this.treeData = res.result.entityList;
console.log("hello");
console.log(this.optionsExample)
console.log(this.treeDataExample)
console.log(this.options)
console.log(this.treeData)
} else { } else {
this.$message({ this.$message({
message: res.return_info, message: res.return_info,
...@@ -301,8 +322,7 @@ export default { ...@@ -301,8 +322,7 @@ export default {
highlight() { highlight() {
if (window.getSelection().toString() != "") { if (window.getSelection().toString() != "") {
// 禁止重复标注 // 禁止重复标注
var i; for (var i = 0; i < this.tokenList.length; i++) {
for (i = 0; i < this.tokenList.length; i++) {
if (window.getSelection().toString() == this.tokenList[i].word) if (window.getSelection().toString() == this.tokenList[i].word)
return; return;
} }
...@@ -310,10 +330,10 @@ export default { ...@@ -310,10 +330,10 @@ export default {
this.token.word = window.getSelection().toString(); this.token.word = window.getSelection().toString();
this.token.begin = window.getSelection().anchorOffset; //开始位置 this.token.begin = window.getSelection().anchorOffset; //开始位置
this.token.end = window.getSelection().focusOffset; //结束位置 this.token.end = window.getSelection().focusOffset; //结束位置
console.log("token: " + JSON.stringify(this.token)); //console.log("token: " + JSON.stringify(this.token));
} }
}, },
// 添加标注 // TODO templete列表传输 // 添加标注
handleCheckChange() { handleCheckChange() {
this.ifAlert = false; this.ifAlert = false;
this.token.entityId = this.value; // 实体 this.token.entityId = this.value; // 实体
...@@ -504,7 +524,7 @@ export default { ...@@ -504,7 +524,7 @@ export default {
} }
}, },
mounted: function() { mounted: function() {
this.insertDocument(); this.checkTable();
} }
}; };
</script> </script>
......
<template> <template>
<div class="select-container"> <div class="select-container">
<el-container style="margin-top: 40px" :style="{ height : height_res-40+'px'}"> <el-container style="margin-top: 40px">
<el-aside <el-aside
class="sidebar" class="sidebar"
style="background-color: rgba(255,255,255,0);box-shadow: 0px 0px 0px rgba(255,255,255,0);padding-right: 20px" style="background-color: rgba(255,255,255,0);box-shadow: 0px 0px 0px rgba(255,255,255,0);padding-right: 20px"
> >
<!-- 实体列表 -->
<div class="sidebar-box"> <div class="sidebar-box">
<div @click="highlight()"> <div>
<div class="img-list-title">实体列表</div> <div class="img-list-title">实体列表</div>
<div class="img-title-list-box"> <div class="img-title-list-box">
<div id="img-title-list" style="user-select:none; float: left;"> <div class="img-title-list">
<div <div
class="tokenList" class="tokenList"
v-for="it in tokenList" v-for="it in tokenList"
...@@ -31,38 +32,37 @@ ...@@ -31,38 +32,37 @@
</div> </div>
</div> </div>
</div> </div>
<!-- 文本列表 -->
<div class="sidebar-box"> <div class="sidebar-box">
<div> <div>
<div class="img-list-title">表格列表</div> <div class="img-list-title">文本列表</div>
<div class="img-title-list-box"> <div class="img-title-list-box">
<div id="img-title-list" style="user-select:none"> <div
<el-tree :data="textData" :props="defaultProps" @node-click="handleNodeClick"></el-tree> id="img-title-list"
</div> style="user-select:none; float:left; padding: 5px;"
>{{file.name}}</div>
</div> </div>
</div> </div>
</div> </div>
</el-aside> </el-aside>
<!-- 文件界面 -->
<el-main class="filter-container" style="background-color: #FFFFFF"> <el-main class="filter-container" style="background-color: #FFFFFF">
<div style="overflow-y:auto;height:100%;" > <div style="overflow-y:auto;height:100%;">
<!-- 表格界面 -->
<div @click="highlight()"> <div @click="highlight()">
<v-table <el-table :data="tableData" border style="width: 100%">
is-horizontal-resize <el-table-column prop="date" label="日期" width="180"></el-table-column>
style="width:100%" <el-table-column prop="name" label="姓名" width="180"></el-table-column>
:columns="columns" <el-table-column prop="address" label="地址"></el-table-column>
:table-data="tableData" </el-table>
:row-click="rowClick"
:column-cell-class-name="columnCellClass"
row-hover-color="#eee"
row-click-color="#edf7ff"
></v-table>
</div> </div>
<!-- 表格界面 -->
<br />
<div> <div>
<br />
<el-button type="primary" @click="submit()">提交</el-button> <el-button type="primary" @click="submit()">提交</el-button>
</div> </div>
<!-- 弹窗-->
<!-- 弹窗-->
<el-dialog title="请标注" :visible.sync="ifAlert"> <el-dialog title="请标注" :visible.sync="ifAlert">
<div style="overflow: auto;height: 50vh"> <div style="overflow: auto;height: 50vh">
<el-select v-model="value" placeholder="选择标注对象"> <el-select v-model="value" placeholder="选择标注对象">
...@@ -73,9 +73,9 @@ ...@@ -73,9 +73,9 @@
:value="item.label" :value="item.label"
></el-option> ></el-option>
</el-select> </el-select>
<el-button type="primary" @click="handleOption">新建</el-button> <!--el-button type="primary" @click="handleOption">新建</el-button-->
<el-tree <el-tree
:data="treedata" :data="treeData"
show-checkbox show-checkbox
default-expand-all default-expand-all
node-key="id" node-key="id"
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
<div style="width: 100%;height: 5px"></div> <div style="width: 100%;height: 5px"></div>
<el-button type="primary" style="margin-top: 30px" @click="handleCheckChange">确定</el-button> <el-button type="primary" style="margin-top: 30px" @click="handleCheckChange">确定</el-button>
</el-dialog> </el-dialog>
<!-- 弹窗--> <!-- 弹窗-->
</div> </div>
</el-main> </el-main>
</el-container> </el-container>
...@@ -97,741 +97,329 @@ ...@@ -97,741 +97,329 @@
<script> <script>
export default { export default {
data() { data() {
const item = {
date: "星期1",
name: "小明",
address: "表格内容"
};
return { return {
tableData: [ documentId: "",
{ // 文章
name: "赵伟", file: null,
tel: "156*****1987", // 任务
hobby: "钢琴、书法、唱歌", task: null,
address: "上海市黄浦区金陵东路569号17楼" // 文章内容
}, content: "",
{ //实体属性
name: "李伟", token: {
tel: "182*****1538", tokenId: "", // 编号
hobby: "钢琴、书法、唱歌", word: "", // 标注
address: "上海市奉贤区南桥镇立新路12号2楼" begin: 0, // 起始位置
}, end: 0, // 终止位置
{ entityId: "", // 实体
name: "孙伟", attribute: [] // 属性
tel: "161*****0097", },
hobby: "钢琴、书法、唱歌", // 实体属性列表
address: "上海市崇明县城桥镇八一路739号" tokenList: [],
}, // 文章列表
{ textData: [],
name: "周伟", // templete
tel: "197*****1123",
hobby: "钢琴、书法、唱歌", treeData: [],
address: "上海市青浦区青浦镇章浜路24号"
},
{
name: "吴伟",
tel: "183*****6678",
hobby: "钢琴、书法、唱歌",
address: "上海市松江区乐都西路867-871号"
},
{
name: "赵伟",
tel: "156*****1987",
hobby: "钢琴、书法、唱歌",
address: "上海市黄浦区金陵东路569号17楼"
},
{
name: "李伟",
tel: "182*****1538",
hobby: "钢琴、书法、唱歌",
address: "上海市奉贤区南桥镇立新路12号2楼"
},
{
name: "孙伟",
tel: "161*****0097",
hobby: "钢琴、书法、唱歌",
address: "上海市崇明县城桥镇八一路739号"
},
{
name: "周伟",
tel: "197*****1123",
hobby: "钢琴、书法、唱歌",
address: "上海市青浦区青浦镇章浜路24号"
},
{
name: "赵伟",
tel: "156*****1987",
hobby: "钢琴、书法、唱歌",
address: "上海市黄浦区金陵东路569号17楼"
},
{
name: "李伟",
tel: "182*****1538",
hobby: "钢琴、书法、唱歌",
address: "上海市奉贤区南桥镇立新路12号2楼"
},
{
name: "孙伟",
tel: "161*****0097",
hobby: "钢琴、书法、唱歌",
address: "上海市崇明县城桥镇八一路739号"
},
{
name: "周伟",
tel: "197*****1123",
hobby: "钢琴、书法、唱歌",
address: "上海市青浦区青浦镇章浜路24号"
},
{
name: "赵伟",
tel: "156*****1987",
hobby: "钢琴、书法、唱歌",
address: "上海市黄浦区金陵东路569号17楼"
},
{
name: "李伟",
tel: "182*****1538",
hobby: "钢琴、书法、唱歌",
address: "上海市奉贤区南桥镇立新路12号2楼"
},
{
name: "孙伟",
tel: "161*****0097",
hobby: "钢琴、书法、唱歌",
address: "上海市崇明县城桥镇八一路739号"
},
{
name: "周伟",
tel: "197*****1123",
hobby: "钢琴、书法、唱歌",
address: "上海市青浦区青浦镇章浜路24号"
},
{
name: "赵伟",
tel: "156*****1987",
hobby: "钢琴、书法、唱歌",
address: "上海市黄浦区金陵东路569号17楼"
},
{
name: "李伟",
tel: "182*****1538",
hobby: "钢琴、书法、唱歌",
address: "上海市奉贤区南桥镇立新路12号2楼"
},
{
name: "孙伟",
tel: "161*****0097",
hobby: "钢琴、书法、唱歌",
address: "上海市崇明县城桥镇八一路739号"
},
{
name: "周伟",
tel: "197*****1123",
hobby: "钢琴、书法、唱歌",
address: "上海市青浦区青浦镇章浜路24号"
},
{
name: "赵伟",
tel: "156*****1987",
hobby: "钢琴、书法、唱歌",
address: "上海市黄浦区金陵东路569号17楼"
},
{
name: "李伟",
tel: "182*****1538",
hobby: "钢琴、书法、唱歌",
address: "上海市奉贤区南桥镇立新路12号2楼"
},
{
name: "孙伟",
tel: "161*****0097",
hobby: "钢琴、书法、唱歌",
address: "上海市崇明县城桥镇八一路739号"
},
{
name: "周伟",
tel: "197*****1123",
hobby: "钢琴、书法、唱歌",
address: "上海市青浦区青浦镇章浜路24号"
},
{
name: "赵伟",
tel: "156*****1987",
hobby: "钢琴、书法、唱歌",
address: "上海市黄浦区金陵东路569号17楼"
},
{
name: "李伟",
tel: "182*****1538",
hobby: "钢琴、书法、唱歌",
address: "上海市奉贤区南桥镇立新路12号2楼"
},
{
name: "孙伟",
tel: "161*****0097",
hobby: "钢琴、书法、唱歌",
address: "上海市崇明县城桥镇八一路739号"
},
{
name: "周伟",
tel: "197*****1123",
hobby: "钢琴、书法、唱歌",
address: "上海市青浦区青浦镇章浜路24号"
},
{
name: "赵伟",
tel: "156*****1987",
hobby: "钢琴、书法、唱歌",
address: "上海市黄浦区金陵东路569号17楼"
},
{
name: "李伟",
tel: "182*****1538",
hobby: "钢琴、书法、唱歌",
address: "上海市奉贤区南桥镇立新路12号2楼"
},
{
name: "孙伟",
tel: "161*****0097",
hobby: "钢琴、书法、唱歌",
address: "上海市崇明县城桥镇八一路739号"
},
{
name: "周伟",
tel: "197*****1123",
hobby: "钢琴、书法、唱歌",
address: "上海市青浦区青浦镇章浜路24号"
},
{
name: "赵伟",
tel: "156*****1987",
hobby: "钢琴、书法、唱歌",
address: "上海市黄浦区金陵东路569号17楼"
},
{
name: "李伟",
tel: "182*****1538",
hobby: "钢琴、书法、唱歌",
address: "上海市奉贤区南桥镇立新路12号2楼"
},
{
name: "孙伟",
tel: "161*****0097",
hobby: "钢琴、书法、唱歌",
address: "上海市崇明县城桥镇八一路739号"
},
{
name: "周伟",
tel: "197*****1123",
hobby: "钢琴、书法、唱歌",
address: "上海市青浦区青浦镇章浜路24号"
},
{
name: "赵伟",
tel: "156*****1987",
hobby: "钢琴、书法、唱歌",
address: "上海市黄浦区金陵东路569号17楼"
},
{
name: "李伟",
tel: "182*****1538",
hobby: "钢琴、书法、唱歌",
address: "上海市奉贤区南桥镇立新路12号2楼"
},
{
name: "孙伟",
tel: "161*****0097",
hobby: "钢琴、书法、唱歌",
address: "上海市崇明县城桥镇八一路739号"
},
{
name: "周伟",
tel: "197*****1123",
hobby: "钢琴、书法、唱歌",
address: "上海市青浦区青浦镇章浜路24号"
}
],
columns: [
{
field: "name",
title: "姓名",
width: 150,
titleAlign: "center",
columnAlign: "center"
},
{
field: "tel",
title: "手机号码",
width: 350,
titleAlign: "center",
columnAlign: "center"
},
{
field: "hobby",
title: "爱好",
width: 430,
titleAlign: "center",
columnAlign: "center"
},
{
field: "address",
title: "地址",
titleAlign: "center",
columnAlign: "left"
}
],
textData: [
{
label: "表格1",
children: [
{
label: "表格1.1"
},
{
label: "表格1.2"
}
]
},
{
label: "表格2",
children: [
{
label: "表格2.1"
},
{
label: "表格2.2"
}
]
}
],
treedata: [
// 基本信息
{
label: "滑坡名称"
},
{
label: "地理位置"
},
{
label: "行政位置"
},
{
label: "坐标",
children: [
{
label: "经度"
},
{
label: "维度"
}
]
},
{
label: "滑坡年代",
children: [
{
label: "古滑坡"
},
{
label: "老滑坡"
},
{
label: "新滑坡"
}
]
},
{
label: "滑动时间",
children: [
{
label: "yyyy-MM-dd"
},
{
label: "HH:mm:ss"
}
]
},
{
label: "运动形式",
children: [
{
label: "旋转"
},
{
label: "平移"
},
{
label: "流动"
},
{
label: "侧向扩展"
},
{
label: "复合"
}
]
},
{
label: "滑体类型",
children: [
{
label: "岩质"
},
{
label: "土质"
},
{
label: "碎屑"
},
{
label: "堆积层"
}
]
},
{
label: "规模等级",
children: [
{
label: "巨型"
},
{
label: "特大型"
},
{
label: "大型"
},
{
label: "中型"
},
{
label: "小型"
}
]
},
{
label: "宏观稳定性",
children: [
{
label: "不稳定"
},
{
label: "基本稳定"
},
{
label: "稳定"
}
]
},
{
label: "确定性程度",
children: [
{
label: "确定"
},
{
label: "基本确定"
},
{
label: "不确定"
}
]
},
//基本特征
{
label: "前缘高程(m)"
},
{
label: "后缘高程(m)"
},
{
label: "滑体平均厚度(m)"
},
{
label: "滑坡面积(㎡)"
},
{
label: "滑体体积(m³)"
},
{
label: "坡度(°)"
},
{
label: "主滑方向(°)"
}
],
defaultProps: { defaultProps: {
children: "children", children: "children",
label: "label" label: "label"
}, },
count: 1, //count: 1,
//tableData: Array(20).fill(item), ifAlert: false, // 弹窗
ifAlert: false, // 实体
options: [ value: "",
{
value: "选项1", options: [],
label: "滑坡" // table
}, tableData: []
{
value: "选项2",
label: "山体"
},
{
value: "选项3",
label: "河流"
},
{
value: "选项4",
label: "时间"
}
],
token: {
entityId: "",
word: "",
begin: 0,
end: 0,
attribute: "",
tokenId: ""
},
tokenList: []
}; };
}, },
beforeMount() {
// 从文本分出表格
// TODO quary instead of params to fix the bug during refreshing
this.file = JSON.parse(decodeURIComponent(this.$route.params.file));
this.task = JSON.parse(decodeURIComponent(this.$route.params.task));
},
methods: { methods: {
//点击当前行事件 // 插入数据库
rowClick(rowIndex, rowData, column) { insertDocument() {
//通过cloumn来判断点击的是哪个 console.log("userId" + this.$store.state.userInfo.userId);
if ( //console.log("file" + JSON.stringify(this.file));
column.field == "Parts1Material" || //console.log("task" + JSON.stringify(this.task));
column.field == "Parts2Material" this.axios({
) { method: "post",
//再用vuex来临时存储当前点击的内容 url: "/textAnnotation/insertDocument",
this.changeMaterial(rowData[column.field]); data: {
//跳转路由到其他页面并使用 templateId: 1, // TODO 模板id
} annotatorId: this.$store.state.userInfo.userId,
textUrl: this.file.url,
type: "xlsx",
fileId: this.file.id
}
}).then(res => {
if (res.return_code == 200) {
this.documentId = res.result;
//console.log("this.documentId: " + this.documentId);
this.getContent();
// 获得实体属性
this.getTokenList();
// 获得标注模板
this.getTemplate();
} else {
this.$message({
message: res.return_info,
type: "error"
});
}
});
}, },
columnCellClass(rowIndex, columnName, rowData) { //获取内容
// 给三行column为‘hobby’的列设置className getContent() {
if (rowIndex === 1 && columnName === "hobby") { // TODO
return "column-cell-class-name-test2";
}
// 给第二行设置className
if (rowIndex === 1) {
return "column-cell-class-name-test";
}
// 给姓名为‘周伟’的行设置className
if (rowData.name === "周伟") {
return "column-cell-class-name-test2";
}
}, },
// 获得实体属性列表
//设置class getTokenList() {
_columnCellClass(rowIndex, columnName, rowData) { //console.log("getTokenList");
// 给三行column为‘Parts1Material’和‘Parts2Material’的列设置className this.axios({
/*根据你自己的cloumn设置*/ method: "post",
if (columnName === "Parts1Material" || columnName === "Parts2Material") { url: "/textAnnotation/getTokenList",
return "column-cell-class-name-cailiao"; //这是你的css名字 data: {
} documentId: this.documentId
}
}).then(res => {
if (res.return_code == 200) {
res.result.forEach(element => {
console.log("this.token: " + element);
this.tokenList.push(element);
});
} else {
this.$message({
message: res.return_info,
type: "error"
});
}
});
}, },
// 暂时不用 //获取模板
tableRowClassName({ row, rowIndex }) { getTemplate() {
if (rowIndex === 1) { //console.log("getTemplate");
return "success-row"; this.axios({
} else if (rowIndex === 3) { method: "post",
return "success-row"; url: "/textAnnotation/getOneTemplate",
} else if (rowIndex === 4) { data: {
return "success-row"; templateId: 6
} else if (rowIndex === 7) { }
return "success-row"; }).then(res => {
} else if (rowIndex === 12) { if (res.return_code == 200) {
return "success-row"; //console.log(res.result)
} else if (rowIndex === 16) { // 实体
return "success-row"; this.token.entityId = JSON.stringify(res.result.templateId); // 现在的实体与模板相近,所以就先固定了
} this.options.push(res.result.templateName);
return ""; // 属性
this.treeData = res.result.entityList;
} else {
this.$message({
message: res.return_info,
type: "error"
});
}
});
}, },
handleNodeClick(data) { // 定位原文token
console.log(data); highlight() {
// TODO
}, },
// 添加标注
// 标注
handleCheckChange() { handleCheckChange() {
console.log(this.$refs.tree.getCheckedNodes()); this.ifAlert = false;
this.ifAlert = 0; this.token.entityId = this.value; // 实体
let res = this.$refs.tree.getCheckedNodes(); let res = this.$refs.tree.getCheckedNodes();
let arr = []; let arr = [];
let token = {}; let token = {};
res.forEach(item => { res.forEach(item => {
arr.push(item.label); arr.push(item.label);
}); });
console.log("111" + arr); this.token.attribute = arr; // 属性
this.token.attribute = arr[0]; //console.log("entity: " + JSON.stringify(this.token.entityId));
this.msg = this.msg.map(item => { //console.log("attribute: " + JSON.stringify(this.token.attribute));
let replaceReg = new RegExp(this.token.word, "g"); // 匹配关键字正则 // 渲染文本
let replaceString = let replaceReg = new RegExp(this.token.word, "g"); // 匹配关键字正则
'<span class="highlights-text">' + let replaceString =
this.token.word + '<span class="highlights-text">' +
"</span>" + this.token.word +
'<span class="mark">' + "</span>" +
"(实体:" + '<span class="mark">' +
this.token.entityId + "(实体:" +
";属性:" + this.token.entityId +
arr + ";属性:" +
")" + this.token.attribute +
"</span>"; // 高亮替换v-html值 ")" +
// 保存实体 "</span>"; // 高亮替换v-html值
if (this.token.entityId == "" && arr == []) { console.log("文本渲染" + replaceReg + replaceString);
return; if (this.token.entityId == "" && this.token.attribute.length == 0) return;
} // 保存token
this.axios({ this.axios({
method: "post", method: "post",
url: "http://127.0.0.1:9100/textAnnotation/addToken", url: "/textAnnotation/addToken",
data: { data: {
documentId: "a55a28d4a25811ea93c354e1ad87433a", //改成通用跳转传过来的documentId documentId: this.file.id,
token: { token: {
entityId: this.token.entityId, // 这里类型似乎是string word: this.token.word,
word: this.token.word, begin: this.token.begin,
begin: this.token.begin, end: this.token.end,
end: this.token.end, entityId: this.token.entityId,
attribute: arr[0] attribute: this.token.attribute
}
}
}).then(res => {
if (res.return_code == 200) {
this.token.tokenId = res.result;
token = this.token;
this.token = {};
this.tokenList.push(token);
} else {
this.$message({
message: res.return_info,
type: "error"
});
} }
}); }
// 不知道为啥有缓存不能清除 }).then(res => {
this.$nextTick(() => { if (res.return_code == 200) {
this.$refs.tree.setCheckedKeys([]); this.token.tokenId = res.result;
}); token = this.token;
this.token.entityId = ""; this.token = {};
return item.replace(replaceReg, replaceString); this.tokenList.push(token);
}); this.$message({
this.$message({ message: "已保存",
message: "保存成功!", type: "success"
type: "success" });
} else {
this.$message({
message: res.return_info,
type: "error"
});
}
}); });
// 不知道为啥有缓存不能清除
// this.$nextTick(() => {
// this.$refs.tree.setCheckedKeys([]);
//});
this.value = "";
return (this.content = this.content.replace(replaceReg, replaceString));
}, },
// 修改实体属性=删除+添加(如果选择属性弹窗没有点提交直接关掉的话会删除)
handleTokenChange(tag) { handleTokenChange(tag) {
this.ifAlert = true; this.ifAlert = true;
this.token = tag; this.token = tag;
this.tokenList.splice(this.tokenList.indexOf(tag), 1); this.tokenList.splice(this.tokenList.indexOf(tag), 1);
this.$options.methods.handleTokenClose(tag);
},
// 直接调用修改接口(因为选择属性弹窗的提交会触发保存标注操作所以会再次产生一个标注,修改也不会成功)
// handleTokenChange(tag) {
// this.ifAlert = true;
// let token = tag;
// this.token = tag;
// tag = {};
// this.axios({
// method: "post",
// url: "http://127.0.0.1:9100/textAnnotation/revToken",
// data: {
// documentId: "a55a28d4a25811ea93c354e1ad87433a",//改成通用跳转传过来的documentId
// token:{
// entityId: this.token.entityId, // 这里类型似乎是string
// word: this.token.word,
// begin: this.token.begin,
// end: this.token.end,
// attribute: arr[0],
// // 修改实体时待改正
// tokenId: this.token.tokenId
// }
// }
// }).then(res => {
// if(res.return_code == 200){
// console.log("123" + res.return_info);
// this.token.attribute = arr[0];
// arr = [];
// this.tokenList.splice(this.tokenList.indexOf(token), 1);
// this.tokenList.push(this.token);
// }
// });
// },
// 删除实体属性
handleTokenClose(tag) {
this.tokenList.splice(this.tokenList.indexOf(tag), 1);
this.token = tag;
let replaceReg = new RegExp(
'<span class="highlights-text">' +
this.token.word +
"</span>" +
'<span class="mark">' +
"(实体:" +
this.token.entityId +
";属性:" +
this.token.attribute +
")" +
"</span>",
"g"
); // 匹配关键字正则
let replaceString = this.token.word;
this.content = this.content.replace(replaceReg, replaceString);
console.log("hello");
console.log("hello");
console.log("hello");
console.log(this.content);
console.log(replaceReg);
if (this.token.entityId == "" && this.token.attribute == []) return;
this.axios({ this.axios({
method: "post", method: "post",
url: "http://127.0.0.1:9100/textAnnotation/deleteToken", //改成通用跳转传过来的documentId url: "/textAnnotation/deleteToken",
data: { data: {
documentId: "a55a28d4a25811ea93c354e1ad87433a", documentId: this.file.id,
tokenId: this.token.tokenId tokenId: this.token.tokenId
} }
}).then(res => { }).then(res => {
if (res.return_code == 200) console.log("123" + res.return_info); if (res.return_code == 200) {
else { this.$message({
type: "info",
message: "已删除"
});
} else {
this.$message({ this.$message({
message: res.return_info, message: res.return_info,
type: "error" type: "error"
}); });
} }
}); });
// 不知道为啥不清除
//this.$nextTick(() => {
// this.$refs.tree.setCheckedKeys([]);
//});
//this.value = "";
return (this.content = this.content.replace(replaceReg, replaceString));
}, },
handleTokenClose(tag) {
this.tokenList.splice(this.tokenList.indexOf(tag), 1); // 提交已标注文档
this.token = tag; submit() {
this.msg = this.msg.map(item => { // console.log("hello" + JSON.stringify(this.task))
let replaceReg = new RegExp( this.axios
'<span class="highlights-text">' + this.token.word + "</span>", .post({
"g"
); // 匹配关键字正则
let replaceString = this.token.word;
//
if (this.token.entityId == "" && this.token.attribute == []) {
return;
}
this.axios({
method: "post", method: "post",
url: "http://127.0.0.1:9100/textAnnotation/deleteToken", url: "/textAnnotation/revDocumentState",
data: { data: {
documentId: "a55a28d4a25811ea93c354e1ad87433a", //改成通用跳转传过来的documentId documentId: this.documentId
tokenId: this.token.tokenId
} }
}).then(res => { })
if (res.return_code == 200) console.log("123" + res.return_info); .then(res => {
else { if (res.return_code == 200) {
this.$message({
type: "success",
message: "已提交"
});
} else {
this.$message({ this.$message({
message: res.return_info, message: res.return_info,
type: "error" type: "error"
}); });
} }
}); });
// 不知道为啥不清除 this.$router.replace({
this.$nextTick(() => { name: "ongoingtaskdetail",
this.$refs.tree.setCheckedKeys([]); params: { task: encodeURIComponent(JSON.stringify(this.task)) }
});
this.token.entityId = "";
return item.replace(replaceReg, replaceString);
});
this.$message({
type: "info",
message: "已删除"
});
},
setCheckedNodes() {
this.$refs.tree.setCheckedNodes([
{
id: 5,
label: "二级 2-1"
},
{
id: 9,
label: "三级 1-1-1"
}
]);
},
highlight(row) {
this.ifAlert = true;
return "success-row";
},
// 提交本次标注
submit() {
this.$message({
message: "保存成功!",
type: "success"
});
this.$router.replace("/completed");
},
// 放到边栏的token边栏
getTokenList() {
this.axios({
method: "post",
url: "http://127.0.0.1:9100/textAnnotation/getTokenList",
data: {
documentId: "a55a28d4a25811ea93c354e1ad87433a"
}
}).then(res => {
if (res.return_code == 200) {
res.result.forEach(element => {
this.tokenList.push(element);
});
} else {
this.$message({
message: res.return_info,
type: "error"
});
}
}); });
} }
}, },
mounted: function() { mounted: function() {
this.getTokenList(); //需要触发的函数 this.insertDocument();
} }
}; };
</script> </script>
...@@ -853,7 +441,7 @@ export default { ...@@ -853,7 +441,7 @@ export default {
@include whiteBoard; @include whiteBoard;
} }
} }
.msg { .content {
text-align: left; text-align: left;
font-size: 20px; font-size: 20px;
line-height: 30px; line-height: 30px;
...@@ -911,37 +499,4 @@ export default { ...@@ -911,37 +499,4 @@ export default {
.token { .token {
font-size: 18px; font-size: 18px;
} }
.el-table .warning-row {
background: oldlace;
}
.el-table .success-row {
background: #f0f9eb;
}
.column-cell-class-name-cailiao .v-table-body-cell:hover {
color: white;
background-color: darkmagenta;
text-underline: gold;
cursor: pointer;
}
.column-cell-class-name-cailiao .v-table-body-cell:hover span {
border-bottom: 1px solid white;
}
.title-cell-class-name-test {
background-color: #f60;
color: #fff;
}
.column-cell-class-name-test {
background-color: #187;
}
.column-cell-class-name-test .v-table-body-cell {
border-color: #187;
}
.column-cell-class-name-test2 {
background-color: #2db7f5;
font-weight: bold;
}
.column-cell-class-name-test2 .v-table-body-cell {
border-color: #2db7f5;
}
</style> </style>
...@@ -18,3 +18,8 @@ class DevelopmentConfig(object): ...@@ -18,3 +18,8 @@ class DevelopmentConfig(object):
'username': 'admin', 'username': 'admin',
'password': 'admin' 'password': 'admin'
} }
# MONGODB_SETTINGS = {
# 'host': 'localhost',
# 'port': 27017,
# }
...@@ -99,42 +99,42 @@ def create_images(image_list): ...@@ -99,42 +99,42 @@ def create_images(image_list):
return res return res
# 图层实体 # # 图层实体
class LayerEntity(db.EmbeddedDocument): # class LayerEntity(db.EmbeddedDocument):
layerId = db.IntField(required=True) # layerId = db.IntField(required=True)
layerName = db.StringField(required=True) # layerName = db.StringField(required=True)
layerUrl = db.StringField(required=True) # layerUrl = db.StringField(required=True)
#
def to_json(self): # def to_json(self):
return {'layerId': self.layerId, # return {'layerId': self.layerId,
'layerName': self.layerName, # 'layerName': self.layerName,
'layerUrl': self.layerUrl} # 'layerUrl': self.layerUrl}
# 图层标注的数据库 # 图层标注的数据库
class Layer(db.Document): class Layer(db.Document):
relationId = db.IntField(required=True, unique=True) relationId = db.IntField(required=True, unique=True)
layerEntityList = db.ListField(db.EmbeddedDocumentField(LayerEntity)) # layerEntityList = db.ListField(db.EmbeddedDocumentField(LayerEntity))
labelList = db.ListField(db.EmbeddedDocumentField(Label)) labelList = db.ListField(db.EmbeddedDocumentField(Label))
def to_json(self): def to_json(self):
return {'relationId': self.relationId, return {'relationId': self.relationId,
'layerEntityList': [i.to_json() for i in self.layerEntityList], # 'layerEntityList': [i.to_json() for i in self.layerEntityList],
'labelList': [i.to_json() for i in self.labelList] 'labelList': [i.to_json() for i in self.labelList]
} }
# 根据json列表创建对象列表 # # 根据json列表创建对象列表
def create_layer_entities(layer_entity_list): # def create_layer_entities(layer_entity_list):
res = [] # res = []
for i in layer_entity_list: # for i in layer_entity_list:
layer_entity = LayerEntity( # layer_entity = LayerEntity(
layerId=i['layerId'], # layerId=i['layerId'],
layerName=i['layerName'], # layerName=i['layerName'],
layerUrl=i['layerUrl'] # layerUrl=i['layerUrl']
) # )
res.append(layer_entity) # res.append(layer_entity)
return res # return res
# 根据json列表创建对象列表 # 根据json列表创建对象列表
...@@ -147,7 +147,7 @@ def create_layers(layer_list): ...@@ -147,7 +147,7 @@ def create_layers(layer_list):
obj.delete() obj.delete()
layer = Layer( layer = Layer(
relationId=i['relationId'], relationId=i['relationId'],
layerEntityList=create_layer_entities(i['layerEntityList']), # layerEntityList=create_layer_entities(i['layerEntityList']),
labelList=create_labels(i['labelList']) labelList=create_labels(i['labelList'])
) )
layer.save() layer.save()
...@@ -172,12 +172,12 @@ class LandmarkEntity(db.EmbeddedDocument): ...@@ -172,12 +172,12 @@ class LandmarkEntity(db.EmbeddedDocument):
# 地标存储表 # 地标存储表
class Landmark(db.Document): class Landmark(db.Document):
relationId = db.IntField(required=True, unique=True) relationId = db.IntField(required=True, unique=True)
layerEntityList = db.ListField(db.EmbeddedDocumentField(LayerEntity)) # layerEntityList = db.ListField(db.EmbeddedDocumentField(LayerEntity))
landmarkEntityList = db.ListField(db.EmbeddedDocumentField(LandmarkEntity)) landmarkEntityList = db.ListField(db.EmbeddedDocumentField(LandmarkEntity))
def to_json(self): def to_json(self):
return {'relationId': self.relationId, return {'relationId': self.relationId,
'layerEntityList': [i.to_json() for i in self.layerEntityList], # 'layerEntityList': [i.to_json() for i in self.layerEntityList],
'landmarkEntityList': [i.to_json() for i in self.landmarkEntityList] 'landmarkEntityList': [i.to_json() for i in self.landmarkEntityList]
} }
...@@ -200,9 +200,13 @@ def create_landmark_entities(landmark_entity_list): ...@@ -200,9 +200,13 @@ def create_landmark_entities(landmark_entity_list):
def create_landmarks(landmark_list): def create_landmarks(landmark_list):
res = [] res = []
for i in landmark_list: for i in landmark_list:
rid = i['relationId']
obj = Landmark.objects(relationId=rid)
if obj:
obj.delete()
landmark = Landmark( landmark = Landmark(
relationId=i['relationId'], relationId=i['relationId'],
layerEntityList=create_layer_entities(i['layerEntityList']), # layerEntityList=create_layer_entities(i['layerEntityList']),
landmarkEntityList=create_landmark_entities(i['landmarkEntityList']) landmarkEntityList=create_landmark_entities(i['landmarkEntityList'])
) )
res.append(landmark) res.append(landmark)
...@@ -232,25 +236,37 @@ def saveImage(image_list): ...@@ -232,25 +236,37 @@ def saveImage(image_list):
# 获取图层 # 获取图层
def getLayer(relation_list): def getLayer(relation_id):
try: try:
layer_list = Layer.objects(relationId__in=relation_list) layer_info = Layer.objects(relationId=relation_id).first()
landmark_list = Landmark.objects(relationId__in=relation_list) layer_data = None
layer_data = [layer.to_json() for layer in layer_list] if layer_info:
landmark_data = [landmark.to_json() for landmark in landmark_list] layer_data = layer_info.to_json()
return Result(1, [{'layer num': len(layer_data), 'landmark num': len(landmark_data)}],
{'layerList': layer_data, 'landmarkList': landmark_data}) landmark_info = Landmark.objects(relationId=relation_id).first()
landmark_data = None
if landmark_info:
landmark_data = landmark_info.to_json()
return Result(1, "success", {'layerInfo': layer_data, 'landmarkList': landmark_data})
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
return Result(0, repr(e), {}) return Result(0, repr(e), {})
# 保存图层标注结果 # 保存图层标注结果
def saveLayer(layer_list, landmark_list): def saveLayer(layer_info, landmark_info):
try: try:
layers = create_layers(layer_list) layer_list = [layer_info]
landmarks = create_landmarks(landmark_list) layer_data = create_layers(layer_list)[0]
return Result(1, [{'layer num': len(layers), 'landmark num': len(landmarks)}], {})
if landmark_info is not None:
landmark_list = [landmark_info]
landmark_data = create_landmarks(landmark_list)[0]
# print(landmark_data.to_json())
# print(layer_data.to_json())
return Result(1, "success", {})
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
return Result(0, repr(e), {}) return Result(0, repr(e), {})
...@@ -3,11 +3,11 @@ from flask import Blueprint, jsonify, request ...@@ -3,11 +3,11 @@ from flask import Blueprint, jsonify, request
from dao import Image from dao import Image
image = Blueprint("image", __name__, url_prefix="/api/image") image = Blueprint("image", __name__, url_prefix="/api")
# 获取图片 # 获取图片
@image.route("/getImage", methods=["POST"]) @image.route("/image/getImage", methods=["POST"])
def get_image(): def get_image():
data = json.loads(request.data) data = json.loads(request.data)
relation_list = data['relationList'] relation_list = data['relationList']
...@@ -22,7 +22,7 @@ def get_image(): ...@@ -22,7 +22,7 @@ def get_image():
# 保存图片标注结果 # 保存图片标注结果
@image.route("/saveImage", methods=["POST"]) @image.route("/image/saveImage", methods=["POST"])
def save_image(): def save_image():
data = json.loads(request.data) data = json.loads(request.data)
image_list = data['imageList'] image_list = data['imageList']
...@@ -36,10 +36,10 @@ def save_image(): ...@@ -36,10 +36,10 @@ def save_image():
# 获取图层 # 获取图层
@image.route("/getLayer", methods=["POST"]) @image.route("/layer/getLayer", methods=["POST"])
def get_layer(): def get_layer():
data = json.loads(request.data) data = json.loads(request.data)
relation_list = data['relationList'] relation_list = data['relationId']
layer = Image.getLayer(relation_list) layer = Image.getLayer(relation_list)
res = { res = {
'code': layer.code, 'code': layer.code,
...@@ -50,12 +50,14 @@ def get_layer(): ...@@ -50,12 +50,14 @@ def get_layer():
# 保存图层标注结果 # 保存图层标注结果
@image.route("/saveLayer", methods=["POST"]) @image.route("/layer/saveLayer", methods=["POST"])
def save_layer(): def save_layer():
data = json.loads(request.data) data = json.loads(request.data)
layer_list = data['layerList'] layer_info = data['layerInfo']
landmark_list = data['landmarkList'] landmark_info = None
ret = Image.saveLayer(layer_list, landmark_list) if 'landmarkInfo' in data:
landmark_info = data['landmarkInfo']
ret = Image.saveLayer(layer_info, landmark_info)
res = { res = {
'code': ret.code, 'code': ret.code,
'message': ret.message, 'message': ret.message,
...@@ -105,49 +107,31 @@ def save_layer(): ...@@ -105,49 +107,31 @@ def save_layer():
# 保存图层标注结果的测试数据 # 保存图层标注结果的测试数据
# { # {
# "layerList": [ # "layerInfo": {
# { # "relationId": 8,
# "relationId": 8, # "labelList": [
# "layerEntityList": [ # {
# { # "labelId": 181,
# "layerId": 7, # "labelName": "label01",
# "layerName": "layerNo1", # "pointList": [
# "layerUrl": "www.layerNo1.com" # {
# } # "pointId": 21,
# ], # "X": 211.01,
# "labelList": [ # "Y": 211.02
# { # }
# "labelId": 181, # ]
# "labelName": "label01", # }
# "pointList": [ # ]
# { # },
# "pointId": 21, # "landmarkInfo": {
# "X": 211.01, # "relationId": 181,
# "Y": 211.02 # "landmarkEntityList": [
# } # {
# ] # "landmarkId": 31,
# } # "landmarkName": "landmark31",
# ] # "X": 31.1,
# } # "Y": 31.2
# ], # }
# "landmarkList": [ # ]
# { # }
# "relationId": 1, # }
# "layerEntityList": [ \ No newline at end of file
# {
# "layerId": 3,
# "layerName": "layerNo3",
# "layerUrl": "www.layerNo3.com"
# }
# ],
# "landmarkEntityList": [
# {
# "landmarkId": 31,
# "landmarkName": "landmark31",
# "X": 31.1,
# "Y": 31.2
# }
# ]
# }
# ]
# }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment