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

Commit 8dc8d4e4 by Wang Yuhang

我的任务、已完成任务、待审核任务的导出功能

parent ae0f9799
export function download (url, relationId) {
url = 'http://localhost:9100/api' + url + '/' + relationId
var a = document.createElement('a')
a.href = url
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
}
......@@ -20,6 +20,8 @@
<span>{{item.nickname}}</span>
<el-button v-if="!item.state" type="primary" size="mini" plain @click="goto(item)">待审核</el-button>
<el-button v-else type="success" size="mini" plain @click="goto(item)">修改</el-button>
<el-button type="primary" size="mini" plain
@click="exportFile(item.relation_id)" >导出</el-button>
</li>
</ul>
</el-dialog>
......@@ -28,6 +30,7 @@
<script>
import PiecesTable from './PiecesTable'
import {download} from '@/assets/js/Download.js'
export default {
name: 'check-detail',
components: {
......@@ -88,6 +91,14 @@ export default {
case '图片': goto('imageShow'); break
case '图层': goto('layerShow')
}
},
exportFile (relationId) {
var piece = this.piece
if (piece.type === '文本') {
download('/files/downloadZip', relationId)
} else {
download('/image/export/zip', relationId)
}
}
}
}
......@@ -116,9 +127,16 @@ export default {
}
li{
list-style: none;
display: flex;
justify-content: space-between;
margin-bottom: 10px;
overflow: hidden;
span{
float: left;
line-height: 28px;
}
.el-button{
float: right;
margin-left: 10px;
}
}
}
}
......
......@@ -7,8 +7,7 @@
<div>{{item.name}}</div>
<div>发布者:{{item.creator}}&emsp;&emsp;发布时间:{{item.date|formatDate}}&emsp;&emsp;任务状态:已完成
</div>
<el-button class="task-enter-btn2" type="primary" @click="detail(item)" plain>查看任务</el-button>
<el-button class="task-enter-btn1" type="primary" plain>导出任务</el-button>
<el-button class="task-enter-btn1" type="primary" @click="detail(item)" plain>查看任务</el-button>
</div>
</div>
<navigator v-model="tasks" :condition="condition"></navigator>
......
......@@ -7,12 +7,10 @@
<el-divider></el-divider>
<pieces-table :task-id="task.id" withExecutor>
<template v-slot:option="slotProps">
<el-button
type="primary"
size="mini"
plain
@click="doOption(slotProps.file,slotProps.piece)"
>详情</el-button>
<el-button type="primary" size="mini" plain
@click="doOption(slotProps.file,slotProps.piece)">详情</el-button>
<el-button type="primary" size="mini" plain
@click="exportFile(slotProps.file,slotProps.piece)">导出</el-button>
</template>
</pieces-table>
</div>
......@@ -21,6 +19,7 @@
<script>
import PiecesTable from './PiecesTable'
import {download} from '@/assets/js/Download.js'
export default {
name: 'task',
......@@ -56,6 +55,14 @@ export default {
case '图片': goto('imageShow'); break
case '图层': goto('layerShow')
}
},
exportFile (file, piece) {
var relationId = file.relation_id
if (piece.type === '文本') {
download('/files/downloadZip', relationId)
} else {
download('/image/export/zip', relationId)
}
}
}
}
......
......@@ -15,33 +15,19 @@
@click="doOption(slotProps.file,slotProps.piece)"
>修改</el-button>
<el-button type="primary" size="mini" plain
@click="showExport(slotProps.file,slotProps.piece)"
@click="exportFile(slotProps.file,slotProps.piece)"
>导出</el-button>
</template>
</template>
</pieces-table>
</div>
<el-dialog title="选择导出类型" :visible.sync="dialogVisible" width="40%" >
<el-button v-show="dialogVisible && piece.type !== '文本'" type="primary" size="mini" plain @click="exportOriginal">原始图片</el-button>
<el-button v-show="dialogVisible && piece.type !== '文本'" type="primary" size="mini" plain @click="exportJson">JSON文件</el-button>
<el-button v-show="dialogVisible && piece.type !== '文本'" type="primary" size="mini" plain @click="exportLabel">标注后的图片</el-button>
<el-button v-show="dialogVisible && piece.type === '文本'" type="primary" size="mini" plain @click="exportText">文本文件</el-button>
<el-button v-show="dialogVisible && piece.type === '文本'" type="primary" size="mini" plain @click="exportLabelText">标注文件</el-button>
</el-dialog>
</div>
</template>
<script>
import PiecesTable from './PiecesTable'
import FileSaver from 'file-saver'
import {download} from '@/assets/js/Download.js'
function download (url) {
var a = document.createElement('a')
a.href = url
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
}
export default {
name: 'on-going-task-detail',
components: {
......@@ -49,10 +35,7 @@ export default {
},
data () {
return {
task: null,
dialogVisible: false,
file: null,
piece: null
task: null
}
},
beforeMount () {
......@@ -79,47 +62,13 @@ export default {
case '图层': goto('layer')
}
},
showExport (file, piece) {
this.dialogVisible = true
this.file = file
this.piece = piece
},
exportOriginal () {
var relationId = this.file.relation_id
download(`http://localhost:9100/api/image/export/original/${relationId}`)
},
exportJson () {
var relationId = this.file.relation_id
download(`http://localhost:9100/api/image/export/json/${relationId}`)
},
exportLabel () {
var relationId = this.file.relation_id
download(`http://localhost:9100/api/image/export/label/${relationId}`)
},
// 文本组的下载参数比较复杂,放在这里更方便设置参数
async downloadText (url) {
var { file, piece } = this, self = this,
res = await this.axios.post('/textAnnotation/insertDocument', { // 拿到result_id
templateId: piece.template,
annotatorId: self.$store.state.userInfo.userId,
creatorId: self.task.creator_id,
textUrl: file.url,
type: piece.type === '文本' ? 'text' : 'xlsx',
fileId: file.id
})
res = await this.axios.post(url, { documentId: res.result })
let blob // 保存文件
if (url === '/files/downloadContent') blob = new Blob([res], {type: 'text/plain'})
else blob = new Blob([JSON.stringify(res.result)], {type: 'application/json'})
FileSaver.saveAs(blob)
},
exportText () {
this.downloadText('/files/downloadContent')
},
exportLabelText () {
this.downloadText('/textAnnotation/getTokenList')
exportFile (file, piece) {
var relationId = file.relation_id
if (piece.type === '文本') {
download('/files/downloadZip', relationId)
} else {
download('/image/export/zip', relationId)
}
}
}
}
......
[{'word': '具体信息', 'begin': 19, 'end': 23, 'entityId': '', 'attribute': [], 'tokenId': 'bdff507ed0c511eab562fa2819d635b1'}]
\ No newline at end of file
[{'word': 'urn ', 'begin': 286, 'end': 290, 'entityId': '', 'attribute': [], 'tokenId': 'dcc13392d0e011eab507e442a67d6c47'}]
\ No newline at end of file
......@@ -297,12 +297,9 @@ def downloadFile():
# 下载压缩包接口
@uploadDownload.route('/downloadZip', methods=['POST'])
def downloadZip():
get_Data = request.get_data()
get_Data = json.loads(get_Data)
relationId = get_Data.get('relationId')
@uploadDownload.route('/downloadZip/<relationId>', methods=['GET'])
def downloadZip(relationId):
relationId = int(relationId)
result = mongodbApi.findOne(collectionTest, {"relationId": relationId})
url = result.get('textUrl')
......
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