文档服务地址: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 @@ ...@@ -20,6 +20,8 @@
<span>{{item.nickname}}</span> <span>{{item.nickname}}</span>
<el-button v-if="!item.state" type="primary" size="mini" plain @click="goto(item)">待审核</el-button> <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 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> </li>
</ul> </ul>
</el-dialog> </el-dialog>
...@@ -28,6 +30,7 @@ ...@@ -28,6 +30,7 @@
<script> <script>
import PiecesTable from './PiecesTable' import PiecesTable from './PiecesTable'
import {download} from '@/assets/js/Download.js'
export default { export default {
name: 'check-detail', name: 'check-detail',
components: { components: {
...@@ -88,6 +91,14 @@ export default { ...@@ -88,6 +91,14 @@ export default {
case '图片': goto('imageShow'); break case '图片': goto('imageShow'); break
case '图层': goto('layerShow') 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 { ...@@ -116,9 +127,16 @@ export default {
} }
li{ li{
list-style: none; list-style: none;
display: flex;
justify-content: space-between;
margin-bottom: 10px; margin-bottom: 10px;
overflow: hidden;
span{
float: left;
line-height: 28px;
}
.el-button{
float: right;
margin-left: 10px;
}
} }
} }
} }
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
<div>{{item.name}}</div> <div>{{item.name}}</div>
<div>发布者:{{item.creator}}&emsp;&emsp;发布时间:{{item.date|formatDate}}&emsp;&emsp;任务状态:已完成 <div>发布者:{{item.creator}}&emsp;&emsp;发布时间:{{item.date|formatDate}}&emsp;&emsp;任务状态:已完成
</div> </div>
<el-button class="task-enter-btn2" type="primary" @click="detail(item)" plain>查看任务</el-button> <el-button class="task-enter-btn1" type="primary" @click="detail(item)" plain>查看任务</el-button>
<el-button class="task-enter-btn1" type="primary" plain>导出任务</el-button>
</div> </div>
</div> </div>
<navigator v-model="tasks" :condition="condition"></navigator> <navigator v-model="tasks" :condition="condition"></navigator>
......
...@@ -7,12 +7,10 @@ ...@@ -7,12 +7,10 @@
<el-divider></el-divider> <el-divider></el-divider>
<pieces-table :task-id="task.id" withExecutor> <pieces-table :task-id="task.id" withExecutor>
<template v-slot:option="slotProps"> <template v-slot:option="slotProps">
<el-button <el-button type="primary" size="mini" plain
type="primary" @click="doOption(slotProps.file,slotProps.piece)">详情</el-button>
size="mini" <el-button type="primary" size="mini" plain
plain @click="exportFile(slotProps.file,slotProps.piece)">导出</el-button>
@click="doOption(slotProps.file,slotProps.piece)"
>详情</el-button>
</template> </template>
</pieces-table> </pieces-table>
</div> </div>
...@@ -21,6 +19,7 @@ ...@@ -21,6 +19,7 @@
<script> <script>
import PiecesTable from './PiecesTable' import PiecesTable from './PiecesTable'
import {download} from '@/assets/js/Download.js'
export default { export default {
name: 'task', name: 'task',
...@@ -56,6 +55,14 @@ export default { ...@@ -56,6 +55,14 @@ export default {
case '图片': goto('imageShow'); break case '图片': goto('imageShow'); break
case '图层': goto('layerShow') 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 @@ ...@@ -15,33 +15,19 @@
@click="doOption(slotProps.file,slotProps.piece)" @click="doOption(slotProps.file,slotProps.piece)"
>修改</el-button> >修改</el-button>
<el-button type="primary" size="mini" plain <el-button type="primary" size="mini" plain
@click="showExport(slotProps.file,slotProps.piece)" @click="exportFile(slotProps.file,slotProps.piece)"
>导出</el-button> >导出</el-button>
</template> </template>
</template> </template>
</pieces-table> </pieces-table>
</div> </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> </div>
</template> </template>
<script> <script>
import PiecesTable from './PiecesTable' 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 { export default {
name: 'on-going-task-detail', name: 'on-going-task-detail',
components: { components: {
...@@ -49,10 +35,7 @@ export default { ...@@ -49,10 +35,7 @@ export default {
}, },
data () { data () {
return { return {
task: null, task: null
dialogVisible: false,
file: null,
piece: null
} }
}, },
beforeMount () { beforeMount () {
...@@ -79,47 +62,13 @@ export default { ...@@ -79,47 +62,13 @@ export default {
case '图层': goto('layer') case '图层': goto('layer')
} }
}, },
showExport (file, piece) { exportFile (file, piece) {
this.dialogVisible = true var relationId = file.relation_id
this.file = file if (piece.type === '文本') {
this.piece = piece download('/files/downloadZip', relationId)
}, } else {
exportOriginal () { download('/image/export/zip', relationId)
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')
} }
} }
} }
......
[{'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(): ...@@ -297,12 +297,9 @@ def downloadFile():
# 下载压缩包接口 # 下载压缩包接口
@uploadDownload.route('/downloadZip', methods=['POST']) @uploadDownload.route('/downloadZip/<relationId>', methods=['GET'])
def downloadZip(): def downloadZip(relationId):
get_Data = request.get_data() relationId = int(relationId)
get_Data = json.loads(get_Data)
relationId = get_Data.get('relationId')
result = mongodbApi.findOne(collectionTest, {"relationId": relationId}) result = mongodbApi.findOne(collectionTest, {"relationId": relationId})
url = result.get('textUrl') 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