|
@@ -7,7 +7,7 @@
|
|
|
<el-table-column show-overflow-tooltip prop="text" align="center" label="标注文本" />
|
|
|
<el-table-column prop="state" align="center" label="状态" width="70">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-tag size="mini" :type="scope.row.state?'success':'danger'">{{ scope.row.state?'已标注':'未标注' }}</el-tag>
|
|
|
+ <el-tag size="mini" :type="scope.row.state ? 'success' : 'danger'">{{ scope.row.state ? '已标注' : '未标注' }}</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -79,41 +79,37 @@
|
|
|
<el-table :data="markRelationList" style="width: 100%" row-key="id">
|
|
|
<el-table-column prop="subject" align="center" label="主体">
|
|
|
<template slot-scope="scope">
|
|
|
- <span style="margin-right: 8px;">{{ scope.row.subject }}</span>
|
|
|
+ <span style="margin-right: 8px">{{ scope.row.subject }}</span>
|
|
|
<!-- <el-button icon="el-icon-plus" size="mini" circle /> -->
|
|
|
<i class="el-icon-circle-plus-outline addIcon" @click="addRelation(scope.row)" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="object" align="center" label="客体">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-select v-model="scope.row.object" clearable placeholder="请选择客体" size="mini" @change="((value)=>{handleObject(value, scope.row)})">
|
|
|
- <el-option
|
|
|
- v-for="item in markTextList"
|
|
|
- :key="item.mark_id"
|
|
|
- :label="item.mark_content"
|
|
|
- :value="item.mark_content"
|
|
|
- />
|
|
|
+ <el-select
|
|
|
+ v-model="scope.row.object"
|
|
|
+ clearable
|
|
|
+ placeholder="请选择客体"
|
|
|
+ size="mini"
|
|
|
+ @change="
|
|
|
+ (value) => {
|
|
|
+ handleObject(value, scope.row)
|
|
|
+ }
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <el-option v-for="item in markTextList" :key="item.mark_id" :label="item.mark_content" :value="item.mark_content" />
|
|
|
</el-select>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="relation" align="center" label="关系">
|
|
|
<template slot-scope="scope">
|
|
|
<el-select v-model="scope.row.relation" clearable placeholder="请选择关系" size="mini">
|
|
|
- <el-option
|
|
|
- v-for="item in relationOption"
|
|
|
- :key="item.relationshipId"
|
|
|
- :label="item.name"
|
|
|
- :value="item.name"
|
|
|
- />
|
|
|
+ <el-option v-for="item in relationOption" :key="item.relationshipId" :label="item.name" :value="item.name" />
|
|
|
</el-select>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
|
|
|
- <el-table-column
|
|
|
- fixed="right"
|
|
|
- label="操作"
|
|
|
- width="100"
|
|
|
- >
|
|
|
+ <el-table-column fixed="right" label="操作" width="100">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button type="text" size="small" @click="handleDeleteRelation(scope.row)">删除</el-button>
|
|
|
</template>
|
|
@@ -210,7 +206,7 @@ export default {
|
|
|
const newData = this.dataList[0]
|
|
|
this.setNewData(newData)
|
|
|
} else {
|
|
|
- const flag = this.dataList.findIndex(item => {
|
|
|
+ const flag = this.dataList.findIndex((item) => {
|
|
|
return item.id === Number(this.queryParams.id)
|
|
|
})
|
|
|
if (flag !== -1) {
|
|
@@ -256,16 +252,18 @@ export default {
|
|
|
handleCurrentChange(val) {
|
|
|
// this.queryParams.id = val.id
|
|
|
// this.loading = true
|
|
|
- const isSave = this.ifCompare(JSON.stringify(this.markRelationList), this.markData.markInfo)
|
|
|
+ const isSave = this.ifCompare(this.markRelationList, this.markData.markInfo)
|
|
|
if (!isSave) {
|
|
|
this.$confirm('标注内容未保存,请保存后再继续', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
- }).then(() => {}).catch(() => {})
|
|
|
+ })
|
|
|
+ .then(() => {})
|
|
|
+ .catch(() => {})
|
|
|
} else {
|
|
|
document.getElementById('text-container').innerHTML = ''
|
|
|
- const flag = this.dataList.findIndex(item => {
|
|
|
+ const flag = this.dataList.findIndex((item) => {
|
|
|
return item.id === val.id
|
|
|
})
|
|
|
if (flag !== -1) {
|
|
@@ -349,7 +347,7 @@ export default {
|
|
|
const markId = uuidv4()
|
|
|
this.strNum = null
|
|
|
|
|
|
- const repeatFlag = this.markTextList.findIndex(item => {
|
|
|
+ const repeatFlag = this.markTextList.findIndex((item) => {
|
|
|
return item.mark_content === this.selectedText.content
|
|
|
})
|
|
|
if (repeatFlag !== -1) {
|
|
@@ -441,7 +439,7 @@ export default {
|
|
|
this.cancelTagInfo.visible = false
|
|
|
|
|
|
if (!this.selectMarkedId) return
|
|
|
- const selectMarkItem = this.markTextList.find(list => list.mark_id === this.selectMarkedId)
|
|
|
+ const selectMarkItem = this.markTextList.find((list) => list.mark_id === this.selectMarkedId)
|
|
|
// console.log('item', item)
|
|
|
|
|
|
const textContainer = document.getElementById('text-container')
|
|
@@ -497,18 +495,16 @@ export default {
|
|
|
message: '主体与客体不能相同,请重新选择',
|
|
|
type: 'warning'
|
|
|
})
|
|
|
- this.markRelationList.forEach(item => {
|
|
|
+ this.markRelationList.forEach((item) => {
|
|
|
if (item === row) {
|
|
|
item.object = ''
|
|
|
}
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- const selectOptions = this.markTextList.filter((item) =>
|
|
|
- selectVal.includes(item.mark_content)
|
|
|
- )
|
|
|
+ const selectOptions = this.markTextList.filter((item) => selectVal.includes(item.mark_content))
|
|
|
const selectItem = selectOptions[0]
|
|
|
- this.markRelationList.forEach(item => {
|
|
|
+ this.markRelationList.forEach((item) => {
|
|
|
if (item === row) {
|
|
|
item.objectClass = selectItem.entityName
|
|
|
item.objectPosition = [selectItem.start, selectItem.end]
|
|
@@ -516,7 +512,8 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
addRelation(row) {
|
|
|
- let selectOptions = {}; let indexPos
|
|
|
+ let selectOptions = {}
|
|
|
+ let indexPos
|
|
|
this.markRelationList.forEach((item, index) => {
|
|
|
if (item === row) {
|
|
|
selectOptions = { ...row }
|
|
@@ -556,7 +553,7 @@ export default {
|
|
|
// 标注回显
|
|
|
handleBackShow(itemMarkInfo, index) {
|
|
|
const marker = new Mark(document.getElementById('text-container'))
|
|
|
- const entityData = this.tagLabelList.find(item => {
|
|
|
+ const entityData = this.tagLabelList.find((item) => {
|
|
|
return item.name === itemMarkInfo.subjectClass
|
|
|
})
|
|
|
const markId = uuidv4()
|
|
@@ -636,15 +633,17 @@ export default {
|
|
|
|
|
|
// 上一条
|
|
|
handlePrev() {
|
|
|
- const isSave = this.ifCompare(JSON.stringify(this.markRelationList), this.markData.markInfo)
|
|
|
+ const isSave = this.ifCompare(this.markRelationList, this.markData.markInfo)
|
|
|
if (!isSave) {
|
|
|
this.$confirm('标注内容未保存,请保存后再继续', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
- }).then(() => {}).catch(() => {})
|
|
|
+ })
|
|
|
+ .then(() => {})
|
|
|
+ .catch(() => {})
|
|
|
} else {
|
|
|
- const flag = this.dataList.findIndex(item => {
|
|
|
+ const flag = this.dataList.findIndex((item) => {
|
|
|
return item.id === this.markData.id
|
|
|
})
|
|
|
if (flag !== -1 && flag === 0) {
|
|
@@ -671,15 +670,17 @@ export default {
|
|
|
|
|
|
// 下一条
|
|
|
handleNext() {
|
|
|
- const isSave = this.ifCompare(JSON.stringify(this.markRelationList), this.markData.markInfo)
|
|
|
+ const isSave = this.ifCompare(this.markRelationList, this.markData.markInfo)
|
|
|
if (!isSave) {
|
|
|
this.$confirm('标注内容未保存,请保存后再继续', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
- }).then(() => {}).catch(() => {})
|
|
|
+ })
|
|
|
+ .then(() => {})
|
|
|
+ .catch(() => {})
|
|
|
} else {
|
|
|
- const flag = this.dataList.findIndex(item => {
|
|
|
+ const flag = this.dataList.findIndex((item) => {
|
|
|
return item.id === this.markData.id
|
|
|
})
|
|
|
if (flag !== -1 && flag === this.dataList.length - 1) {
|
|
@@ -706,15 +707,28 @@ export default {
|
|
|
|
|
|
// 比较两个对象是否全等
|
|
|
ifCompare(object1, object2) {
|
|
|
- var o1keys = Object.keys(object1)
|
|
|
- var o2keys = Object.keys(object2)
|
|
|
- if (o2keys.length !== o1keys.length) return false
|
|
|
- for (let i = 0; i <= o1keys.length - 1; i++) {
|
|
|
- const key = o1keys[i]
|
|
|
- if (!o2keys.includes(key)) return false
|
|
|
- if (object2[key] !== object1[key]) return false
|
|
|
+ if (object1.length === 0) {
|
|
|
+ if (!object2 || JSON.parse(object2).length === 0) {
|
|
|
+ return true
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const data1 = JSON.stringify(object1)
|
|
|
+ if (!object2 || JSON.parse(object2).length === 0) {
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ if (data1 === object2) return true
|
|
|
+ else return false
|
|
|
+ }
|
|
|
}
|
|
|
- return true
|
|
|
+ // if (o2keys.length !== o1keys.length) return false
|
|
|
+ // for (let i = 0; i <= o1keys.length - 1; i++) {
|
|
|
+ // const key = o1keys[i]
|
|
|
+ // if (!o2keys.includes(key)) return false
|
|
|
+ // if (object2[key] !== object1[key]) return false
|
|
|
+ // }
|
|
|
+ // return true
|
|
|
},
|
|
|
|
|
|
// 清空标记
|
|
@@ -755,7 +769,7 @@ export default {
|
|
|
|
|
|
// 删除该条关系
|
|
|
handleDeleteRelation(row) {
|
|
|
- const delIndex = this.markRelationList.findIndex(item => {
|
|
|
+ const delIndex = this.markRelationList.findIndex((item) => {
|
|
|
return item === row
|
|
|
})
|
|
|
if (delIndex !== -1) {
|
|
@@ -766,14 +780,14 @@ export default {
|
|
|
}).then(() => {
|
|
|
this.markRelationList.splice(delIndex, 1)
|
|
|
// 判断删除后,标注中还有没有该主体,没有的话在回显中也取消标注
|
|
|
- const lastFlag = this.markTextList.forEach(item => {
|
|
|
+ const lastFlag = this.markTextList.forEach((item) => {
|
|
|
if (item.mark_content === row.subject) {
|
|
|
// true代表还有
|
|
|
return true
|
|
|
}
|
|
|
})
|
|
|
if (lastFlag !== true) {
|
|
|
- const selectMarkItem = this.markTextList.find(list => list.mark_content === row.subject)
|
|
|
+ const selectMarkItem = this.markTextList.find((list) => list.mark_content === row.subject)
|
|
|
const bigContainer = document.getElementById(selectMarkItem.mark_id)
|
|
|
|
|
|
const textSpan = bigContainer.firstElementChild.innerText
|
|
@@ -781,7 +795,7 @@ export default {
|
|
|
markEl.unmark()
|
|
|
bigContainer.insertAdjacentText('beforebegin', textSpan)
|
|
|
bigContainer.remove()
|
|
|
- this.markTextList = this.markTextList.filter(item => item.mark_content !== row.subject)
|
|
|
+ this.markTextList = this.markTextList.filter((item) => item.mark_content !== row.subject)
|
|
|
}
|
|
|
})
|
|
|
}
|