Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DA-Platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
文档服务地址:
http://47.92.0.57:3000/
周报索引地址:
http://47.92.0.57:3000/s/NruNXRYmV
Open sidebar
Berlin
DA-Platform
Commits
89a9b233
Commit
89a9b233
authored
Sep 05, 2020
by
郭婉茹
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug in table
parent
1a21ec3b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
606 additions
and
41 deletions
+606
-41
SelectText.vue
...atform-front/src/components/textAnnotation/SelectText.vue
+19
-18
Table-before.vue
...form-front/src/components/textAnnotation/Table-before.vue
+575
-0
Table.vue
DAPlatform-front/src/components/textAnnotation/Table.vue
+12
-23
No files found.
DAPlatform-front/src/components/textAnnotation/SelectText.vue
View file @
89a9b233
...
...
@@ -39,16 +39,9 @@
</div>
</el-aside>
<!-- 文本界面 -->
<el-main
class=
"filter-container1"
style=
"background-color: #FFFFFF"
>
<el-main
class=
"filter-container1"
style=
"background-color: #FFFFFF"
>
<div
style=
"overflow-y:auto;height:100%;"
>
<div
class=
"content1"
@
mouseup=
"select()"
v-html=
"content"
></div>
<div
class=
"content1"
@
mouseup=
"select()"
v-html=
"content"
></div>
<div
class=
"content_left"
>
<div
class=
"tokenList1"
...
...
@@ -63,10 +56,7 @@
:disable-transitions=
"false"
@
close=
"deleteToken(it)"
>
<a
class=
"token1"
v-html=
"it.word"
></a>
<a
class=
"token1"
v-html=
"it.word"
></a>
</el-tag>
</div>
</div>
...
...
@@ -117,7 +107,7 @@ export default {
children
:
"children"
,
label
:
"label"
,
},
treeToArray
:
[],
treeToArray
:
[],
};
},
beforeMount
()
{
...
...
@@ -250,7 +240,10 @@ export default {
// 属性
this
.
treeData
=
res
.
result
.
entityList
;
for
(
var
i
=
0
;
i
<
this
.
treeData
.
length
;
i
++
)
{
this
.
treeToArray
.
push
({
"id"
:
this
.
treeData
[
i
].
id
,
"label"
:
this
.
treeData
[
i
].
label
});
// 属性
this
.
treeToArray
.
push
({
id
:
this
.
treeData
[
i
].
id
,
label
:
this
.
treeData
[
i
].
label
,
});
// 属性
if
(
this
.
treeData
[
i
].
children
!=
[])
{
this
.
transfer
(
this
.
treeData
[
i
].
children
);
}
...
...
@@ -266,6 +259,15 @@ export default {
// 定位原文token
select
()
{
if
(
window
.
getSelection
().
toString
()
!=
""
)
{
for
(
var
i
=
0
;
i
<
this
.
tokenList
.
length
;
i
++
)
{
if
(
window
.
getSelection
().
toString
()
==
this
.
tokenList
[
i
].
word
)
{
this
.
$message
({
message
:
"“"
+
window
.
getSelection
().
toString
()
+
"”已标注"
,
type
:
"info"
,
});
return
;
}
}
//console.log(" token select" + JSON.stringify(this.token));
this
.
token
.
tokenId
=
"0"
;
this
.
token
.
word
=
window
.
getSelection
().
toString
();
...
...
@@ -410,10 +412,9 @@ export default {
this
.
$refs
.
tree
.
setCheckedNodes
(
res
);
},
transfer
(
children
)
{
if
(
children
==
[])
return
;
if
(
children
==
[])
return
;
for
(
var
i
=
0
;
i
<
children
.
length
;
i
++
)
{
this
.
treeToArray
.
push
({
"id"
:
children
[
i
].
id
,
"label"
:
children
[
i
].
label
});
this
.
treeToArray
.
push
({
id
:
children
[
i
].
id
,
label
:
children
[
i
].
label
});
if
(
children
[
i
]
!=
[])
{
this
.
transfer
(
children
[
i
].
children
);
}
...
...
DAPlatform-front/src/components/textAnnotation/Table-before.vue
0 → 100644
View file @
89a9b233
<
template
>
<div
class=
"select-container"
>
<el-container>
<el-aside
class=
"sidebar3"
>
<!-- 表单列表 -->
<div
class=
"sidebar-box3"
>
<div>
<div
class=
"img-list-title3"
>
表单列表
</div>
<div
class=
"img-title-list-box3"
>
<div
style=
"user-select:none; float:left; padding: 5px;"
>
<div
v-for=
"item in allContent"
:key=
"item.tablename"
@
click=
"changeSheet(item.tablename)"
>
<el-link
icon=
"el-icon-edit"
type=
"primary"
>
{{
item
.
tablename
}}
</el-link>
</div>
</div>
</div>
</div>
</div>
<!-- 实体列表 -->
<div
class=
"sidebar-box3"
>
<div>
<div
class=
"img-list-title3"
>
实体/属性模板
</div>
<div
class=
"img-title-list-box4"
>
<div>
<div
style=
"overflow: auto;height: calc(100vh - 61px - 100px - 180px - 50px);"
>
<p
v-html=
"'实体:'+ value"
/>
<el-tree
:data=
"treeData"
show-checkbox
default-expand-all
node-key=
"id"
ref=
"tree"
highlight-current
:props=
"defaultProps"
></el-tree>
</div>
<el-button
type=
"primary"
style=
"margin-top: 9px;margin-right: 20px;float:right"
@
click=
"submit()"
size=
"small"
plain
>
提交
</el-button>
<el-button
type=
"primary"
style=
"margin-top: 9px;margin-right: 20px;float:right"
@
click=
"uploadToken"
size=
"small"
plain
>
保存
</el-button>
</div>
</div>
</div>
</div>
</el-aside>
<!-- 文件界面 -->
<el-main
class=
"filter-container2"
style=
"background-color: #FFFFFF"
>
<div
style=
"overflow-y:auto;height:100%;"
>
<!-- 表格界面 -->
<div
class=
"content2"
>
<el-table
:data=
"nowContent.tableData"
:cell-style=
"cellStyle"
border
style=
"width: 100%,height:200px"
@
cell-click=
"select"
:cell-class-name=
"getCellIndex"
>
<el-table-column
v-for=
"col in nowContent.name"
:key=
"col"
:prop=
"col.value"
:label=
"col.value"
></el-table-column>
</el-table>
</div>
<!-- 表格界面 -->
<div
class=
"content_left"
>
<div
class=
"tokenList3"
v-for=
"it in tokenList"
:key=
"it"
style=
"user-select:none; float: left;"
>
<el-tag
size=
"small"
@
click=
"changeToken(it)"
closable
:disable-transitions=
"false"
@
close=
"deleteToken(it)"
>
<a
class=
"token3"
v-html=
"it.word"
></a>
</el-tag>
</div>
</div>
</div>
</el-main>
</el-container>
</div>
</
template
>
<
script
>
import
FileSaver
from
"file-saver"
;
export
default
{
data
()
{
return
{
documentId
:
""
,
// 文章
file
:
null
,
// 任务
task
:
null
,
// 文章内容
content
:
""
,
//实体属性
tokenInit
:
{
tokenId
:
""
,
word
:
""
,
begin
:
0
,
end
:
0
,
entityId
:
""
,
attribute
:
[],
},
token
:
{
tokenId
:
""
,
// 编号
word
:
""
,
// 标注
begin
:
0
,
// row
end
:
0
,
// 终止位置
entityId
:
""
,
// column
attribute
:
[],
// 属性
},
row
:
[],
column
:
{},
// 实体属性列表
tokenList
:
[],
// 文章列表
textData
:
[],
// templete
treeData
:
[],
defaultProps
:
{
children
:
"children"
,
label
:
"label"
,
},
//count: 1,
ifAlert
:
false
,
// 弹窗
// 实体
value
:
""
,
// table
nowContent
:
{
tablename
:
""
,
tableData
:
[],
name
:
[],
},
allContent
:
[],
numOfSheet
:
0
,
};
},
beforeMount
()
{
this
.
file
=
this
.
$route
.
params
.
file
;
this
.
task
=
this
.
$route
.
params
.
task
;
this
.
relationId
=
this
.
$route
.
params
.
relationId
;
this
.
piece
=
this
.
$route
.
params
.
piece
;
},
methods
:
{
// 插入数据库
insertDocument
()
{
// console.log("userId" + this.$store.state.userInfo.userId);
//console.log("file" + JSON.stringify(this.file));
//console.log("task" + JSON.stringify(this.task));
this
.
axios
({
method
:
"post"
,
url
:
"/textAnnotation/insertDocument"
,
data
:
{
templateId
:
this
.
piece
.
template
,
// TODO 模板id
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
creatorId
:
this
.
task
.
creator_id
,
relationId
:
this
.
relationId
,
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"
,
});
}
});
},
//获取内容
getContent
()
{
this
.
axios
({
method
:
"post"
,
url
:
"/files/getExcelContent"
,
data
:
{
documentId
:
this
.
documentId
,
},
}).
then
((
res
)
=>
{
if
(
res
.
return_code
==
200
)
{
var
i
;
var
nowContent
=
{};
this
.
numOfSheet
=
res
.
result
.
numOfSheet
;
for
(
i
=
0
;
i
<
res
.
result
.
numOfSheet
;
i
++
)
{
nowContent
.
tablename
=
res
.
result
.
content
[
i
].
sheetName
;
nowContent
.
tableData
=
res
.
result
.
content
[
i
].
content
;
nowContent
.
name
=
res
.
result
.
content
[
i
].
name
;
this
.
allContent
.
push
(
nowContent
);
nowContent
=
{};
}
this
.
nowContent
=
this
.
allContent
[
0
];
//默认打开第一个
}
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
,
});
}
});
},
// 获得已标注信息
getTokenList
()
{
console
.
log
(
"getTokenList"
);
console
.
log
(
" this.tokenList: "
+
JSON
.
stringify
(
this
.
tokenList
));
this
.
axios
({
method
:
"post"
,
url
:
"/textAnnotation/getTokenList"
,
data
:
{
documentId
:
this
.
documentId
,
},
}).
then
((
res
)
=>
{
if
(
res
.
return_code
==
200
)
{
res
.
result
.
forEach
((
element
)
=>
{
this
.
tokenInit
=
element
;
console
.
log
(
" token: "
+
JSON
.
stringify
(
this
.
tokenInit
));
this
.
tokenList
.
push
(
this
.
tokenInit
);
});
console
.
log
(
" this.tokenList: "
+
JSON
.
stringify
(
this
.
tokenList
));
}
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
,
});
}
});
},
//获取模板
getTemplate
()
{
//console.log("getTemplate");
this
.
axios
({
method
:
"post"
,
url
:
"/textAnnotation/getOneTemplate"
,
data
:
{
templateId
:
parseInt
(
this
.
piece
.
template
),
},
}).
then
((
res
)
=>
{
if
(
res
.
return_code
==
200
)
{
//console.log(res.result)
// 实体
this
.
value
=
res
.
result
.
templateName
;
// 现在的实体与模板相近,所以就先固定了
// 属性
this
.
treeData
=
res
.
result
.
entityList
;
}
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
,
});
}
});
},
// 更改表单
changeSheet
(
name
)
{
for
(
var
i
=
0
;
i
<
this
.
numOfSheet
;
i
++
)
{
// console.log("in " + name + " " + this.nowContent.tablename)
if
(
name
==
this
.
allContent
[
i
].
tablename
)
{
// console.log("match " + JSON.stringify(this.allContent[i]))
this
.
nowContent
=
this
.
allContent
[
i
];
}
}
},
// 定位原文token
select
:
function
(
row
,
column
)
{
this
.
row
=
row
;
this
.
column
=
column
;
this
.
token
.
tokenId
=
"0"
;
this
.
token
.
word
=
row
[
column
.
property
];
this
.
token
.
begin
=
row
.
index
;
this
.
token
.
end
=
column
.
index
;
for
(
var
i
=
0
;
i
<
this
.
tokenList
.
length
;
i
++
)
{
if
(
this
.
token
.
begin
==
this
.
tokenList
[
i
].
begin
&&
this
.
token
.
end
==
this
.
tokenList
[
i
].
end
)
{
this
.
$message
({
message
:
"选中单元格已标记"
,
type
:
"info"
,
});
return
;
}
}
console
.
log
(
" token select"
+
JSON
.
stringify
(
this
.
token
));
console
.
log
(
" tokenList select"
+
JSON
.
stringify
(
this
.
tokenList
));
},
getCellIndex
:
function
({
row
,
column
,
rowIndex
,
columnIndex
})
{
row
.
index
=
rowIndex
;
column
.
index
=
columnIndex
;
},
// 表格标注颜色
cellStyle
:
function
(
row
,
column
,
rowIndex
,
columnIndex
)
{
for
(
var
i
=
0
;
i
<
this
.
tokenList
.
length
;
i
++
)
{
// console.log("draw token" + JSON.stringify(this.tokenList[i]));
// console.log("draw rowindex" + JSON.stringify(this.tokenList[i].begin));
// console.log("draw columnindex" + JSON.stringify(this.tokenList[i].end));
// console.log("draw rowindex" + JSON.stringify(row.rowIndex));
// console.log("draw columnindex" + JSON.stringify(row.columnIndex));
if
(
row
.
rowIndex
===
this
.
tokenList
[
i
].
begin
&&
row
.
columnIndex
===
this
.
tokenList
[
i
].
end
)
{
// console.log("draw token" + JSON.stringify(this.token));
return
"background: #d9ecff;"
;
}
}
return
""
;
},
// 添加标注
uploadToken
()
{
let
res
=
this
.
$refs
.
tree
.
getCheckedNodes
();
let
arr
=
[];
res
.
forEach
((
item
)
=>
{
arr
.
push
(
item
.
label
);
// 属性
});
if
(
arr
.
length
==
0
)
{
this
.
$message
({
message
:
"未选择属性"
,
type
:
"info"
,
});
}
else
{
// 删除原有
console
.
log
(
"deleteToken"
);
this
.
axios
({
method
:
"post"
,
url
:
"/textAnnotation/deleteToken"
,
data
:
{
documentId
:
this
.
documentId
,
tokenId
:
this
.
token
.
tokenId
,
},
}).
then
((
res
)
=>
{
if
(
res
.
return_code
==
200
)
{
this
.
tokenList
.
splice
(
this
.
tokenList
.
indexOf
(
this
.
token
),
1
);
}
});
// 保存token
this
.
axios
({
method
:
"post"
,
url
:
"/textAnnotation/addToken"
,
data
:
{
documentId
:
this
.
documentId
,
token
:
{
word
:
this
.
token
.
word
,
begin
:
this
.
token
.
begin
,
end
:
this
.
token
.
end
,
entityId
:
this
.
token
.
entityId
,
attribute
:
arr
,
},
},
}).
then
((
res
)
=>
{
if
(
res
.
return_code
==
200
)
{
this
.
tokenList
=
[];
this
.
getTokenList
();
this
.
cellStyle
(
this
.
row
,
this
.
column
);
this
.
$message
({
message
:
"已保存"
,
type
:
"success"
,
});
}
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
,
});
}
});
}
return
;
},
// 删除实体属性
deleteToken
(
tag
)
{
console
.
log
(
"deleteToken"
);
this
.
axios
({
method
:
"post"
,
url
:
"/textAnnotation/deleteToken"
,
data
:
{
documentId
:
this
.
documentId
,
tokenId
:
tag
.
tokenId
,
},
}).
then
((
res
)
=>
{
if
(
res
.
return_code
==
200
)
{
this
.
$message
({
type
:
"info"
,
message
:
"已删除"
,
});
this
.
tokenList
.
splice
(
this
.
tokenList
.
indexOf
(
tag
),
1
);
this
.
content
=
this
.
contentWithoutColor
;
console
.
log
(
" this.tokenList: "
+
JSON
.
stringify
(
this
.
tokenList
));
console
.
log
(
" this.content: "
+
this
.
content
);
}
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
,
});
}
});
},
// 修改实体属性=删除+添加(如果选择属性弹窗没有点提交直接关掉的话会删除,也就是双击直接删除,也许这里后期需要改)
changeToken
(
tag
)
{
this
.
token
.
tokenId
=
tag
.
tokenId
;
this
.
token
.
word
=
tag
.
word
;
this
.
token
.
begin
=
tag
.
begin
;
this
.
token
.
end
=
tag
.
end
;
this
.
token
.
entityId
=
tag
.
entityId
;
},
// 提交已标注文档
submit
()
{
// console.log("hello" + JSON.stringify(this.task))
this
.
axios
({
method
:
"post"
,
url
:
"/textAnnotation/revDocumentState"
,
data
:
{
documentId
:
this
.
documentId
,
},
}).
then
((
res
)
=>
{
if
(
res
.
return_code
==
200
)
{
this
.
$message
({
message
:
"已保存"
,
type
:
"success"
,
});
}
else
{
this
.
$message
({
message
:
res
.
return_info
,
type
:
"error"
,
});
}
});
this
.
$router
.
replace
({
name
:
"ongoingtaskdetail"
,
params
:
{
task
:
encodeURIComponent
(
JSON
.
stringify
(
this
.
task
))
},
});
},
},
mounted
:
function
()
{
this
.
insertDocument
();
},
};
</
script
>
<
style
lang=
'scss'
>
@import
"@/assets/scss/config.scss"
;
@import
"@/assets/scss/mixin.scss"
;
.sidebar3
{
padding
:
0
0
0
0
;
margin-left
:
50px
;
margin-top
:
40px
;
width
:
30%
;
.img-list-title3
{
padding
:
0
0
0
0
;
width
:
300px
;
height
:
40px
;
line-height
:
40px
;
background
:
#409eff
;
color
:
white
;
box-shadow
:
0px
0px
10px
#dbdbdb
;
}
.img-title-list-box3
{
padding
:
0
0
0
0
;
width
:
300px
;
height
:
100px
;
overflow
:
auto
;
background-color
:
white
;
box-shadow
:
0px
0px
10px
#dbdbdb
;
}
.img-title-list-box4
{
padding
:
0
0
0
0
;
width
:
300px
;
height
:
calc
(
100vh
-
61px
-
100px
-
180px
);
overflow
:
auto
;
background-color
:
white
;
box-shadow
:
0px
0px
10px
#dbdbdb
;
}
}
.filter-container2
{
margin-right
:
40px
;
margin-left
:
20px
;
margin-top
:
40px
;
height
:
calc
(
100vh
-
61px
-
100px
);
//
float
:
center
;
width
:
100%
;
@include
whiteBoard;
.content2
{
overflow
:
auto
;
height
:
calc
(
100vh
-
61px
-
100px
-
110px
);
text-align
:
left
;
font-size
:
20px
;
line-height
:
30px
;
}
.content_left
{
overflow
:
auto
;
height
:
60px
;
margin-top
:
1px
;
.tokenList3
{
margin
:
3px
;
}
.token3
{
font-size
:
16px
;
}
}
.button1
{
overflow
:
auto
;
float
:
right
;
margin-right
:
10px
;
margin-top
:
10px
;
}
}
.el-table
.warning-row
{
background
:
oldlace
;
}
.el-table
.success-row
{
background
:
#f0f9eb
;
}
.highlights-text
{
color
:
#ff5134
;
text-decoration
:
underline
;
//
background-color
:
rgb
(
255
,
255
,
0
);
}
.mark
{
font-size
:
14px
;
color
:
rgb
(
128
,
138
,
135
);
text-decoration
:
none
;
//
background-color
:
rgb
(
255
,
227
,
132
);
}
.addTag
{
width
:
30%
;
height
:
500px
;
background-color
:
#ffffff
;
position
:
fixed
;
top
:
50%
;
margin-top
:
-250px
;
left
:
55%
;
margin-left
:
-25%
;
border
:
1px
solid
darkgrey
;
border-radius
:
10px
;
padding
:
10px
;
}
.addTagTitle
{
margin-top
:
15px
;
margin-bottom
:
10px
;
}
.add-file-btn-group
>>>
button
{
margin-top
:
3px
;
margin-bottom
:
3px
;
}
</
style
>
\ No newline at end of file
DAPlatform-front/src/components/textAnnotation/Table.vue
View file @
89a9b233
...
...
@@ -60,13 +60,12 @@
<el-main
class=
"filter-container2"
style=
"background-color: #FFFFFF"
>
<div
style=
"overflow-y:auto;height:100%;"
>
<!-- 表格界面 -->
<div
class=
"content2"
>
<div
class=
"content2"
@
mouseup=
"select()"
>
<el-table
:data=
"nowContent.tableData"
:cell-style=
"cellStyle"
border
style=
"width: 100%,height:200px"
@
cell-click=
"select"
:cell-class-name=
"getCellIndex"
>
<el-table-column
...
...
@@ -175,7 +174,7 @@ export default {
method
:
"post"
,
url
:
"/textAnnotation/insertDocument"
,
data
:
{
templateId
:
this
.
piece
.
template
,
// TODO 模板id
templateId
:
this
.
piece
.
template
,
annotatorId
:
this
.
$store
.
state
.
userInfo
.
userId
,
creatorId
:
this
.
task
.
creator_id
,
relationId
:
this
.
relationId
,
...
...
@@ -290,27 +289,17 @@ export default {
}
},
// 定位原文token
select
:
function
(
row
,
column
)
{
this
.
row
=
row
;
this
.
column
=
column
;
this
.
token
.
tokenId
=
"0"
;
this
.
token
.
word
=
row
[
column
.
property
];
this
.
token
.
begin
=
row
.
index
;
this
.
token
.
end
=
column
.
index
;
for
(
var
i
=
0
;
i
<
this
.
tokenList
.
length
;
i
++
)
{
if
(
this
.
token
.
begin
==
this
.
tokenList
[
i
].
begin
&&
this
.
token
.
end
==
this
.
tokenList
[
i
].
end
)
{
this
.
$message
({
message
:
"选中单元格已标记"
,
type
:
"info"
,
});
return
;
}
select
()
{
if
(
window
.
getSelection
().
toString
()
!=
""
)
{
//console.log(" token select" + JSON.stringify(this.token));
this
.
token
.
tokenId
=
"0"
;
this
.
token
.
word
=
window
.
getSelection
().
toString
();
this
.
token
.
begin
=
window
.
getSelection
().
anchorOffset
;
//开始位置
this
.
token
.
end
=
window
.
getSelection
().
focusOffset
;
//结束位置
this
.
$refs
.
tree
.
setCheckedNodes
([]);
//console.log(" token select" + JSON.stringify(this.token));
//console.log(" tokenList select" + JSON.stringify(this.tokenList));
}
console
.
log
(
" token select"
+
JSON
.
stringify
(
this
.
token
));
console
.
log
(
" tokenList select"
+
JSON
.
stringify
(
this
.
tokenList
));
},
getCellIndex
:
function
({
row
,
column
,
rowIndex
,
columnIndex
})
{
row
.
index
=
rowIndex
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment