Commit 4bd9bc9d authored by jiaxu.yan's avatar jiaxu.yan

feat: 检查报告

parent c98a7cad
......@@ -185,7 +185,7 @@
type="primary"
plain
size="mini"
@click="goNext(item.id)"
@click="downloadPdf(item.id)"
>检查报告</el-button
>
<el-button
......@@ -249,6 +249,7 @@
</template>
<script>
import page from '@/mixins/page'
import { pdfDownload } from '@/api/task/task'
import { mapGetters } from 'vuex'
export default {
dicts: ['sys_scene_type', 'task_type', 'inspection_item'],
......@@ -270,6 +271,47 @@ export default {
this.$store.dispatch('standard/setStandardList')
},
methods: {
/**
* 检验报告
*/
downloadPdf(id) {
pdfDownload({
taskId: id,
type: 0
}).then(res => {
const fileUrl =
process.env.VUE_APP_IMAGE_API +
'/vehicle-quality-review-oss/' +
res.data
this.download(fileUrl)
})
},
/**
* 下载pdf
*/
download(fileUrl) {
// 根据pdf文件地址下载
// window.location.href = this.fileUrl
const xhr = new XMLHttpRequest()
xhr.open('GET', fileUrl, true)
xhr.responseType = 'blob'
xhr.onload = () => {
if (xhr.status === 200) {
const blob = new Blob([xhr.response], { type: 'application/pdf' })
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '检查报告.pdf'
link.click()
URL.revokeObjectURL(url)
}
}
xhr.send()
},
/* 跳转到问卷详情*/
goNext(url) {
this.$router.push({ path: url })
......
......@@ -183,7 +183,7 @@
type="primary"
plain
size="mini"
@click="goNext(item.id)"
@click="downloadPdf(item.id)"
>检查报告</el-button
>
<el-button
......@@ -220,6 +220,7 @@
<script>
import page from '@/mixins/page'
import { mapGetters } from 'vuex'
import { pdfDownload } from '@/api/task/task'
export default {
mixins: [page],
dicts: ['inspection_item'],
......@@ -237,6 +238,47 @@ export default {
this.$store.dispatch('standard/setStandardList')
},
methods: {
/**
* 检验报告
*/
downloadPdf(id) {
pdfDownload({
taskId: id,
type: 0
}).then(res => {
const fileUrl =
process.env.VUE_APP_IMAGE_API +
'/vehicle-quality-review-oss/' +
res.data
this.download(fileUrl)
})
},
/**
* 下载pdf
*/
download(fileUrl) {
// 根据pdf文件地址下载
// window.location.href = this.fileUrl
const xhr = new XMLHttpRequest()
xhr.open('GET', fileUrl, true)
xhr.responseType = 'blob'
xhr.onload = () => {
if (xhr.status === 200) {
const blob = new Blob([xhr.response], { type: 'application/pdf' })
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '检查报告.pdf'
link.click()
URL.revokeObjectURL(url)
}
}
xhr.send()
},
/* 跳转到问卷详情*/
goNext(url) {
this.$router.push({ path: url })
......
......@@ -448,7 +448,7 @@
type="primary"
plain
size="mini"
@click="goNext(item.id)"
@click="downloadPdf(item.id)"
>检查报告</el-button
>
<el-button
......@@ -486,11 +486,7 @@
import page from '@/mixins/page'
import { getHourDiff } from '@/utils/diff'
import { mapGetters } from 'vuex'
import {
reviewTaskStart,
reviewCarTaskStart,
removeTask
} from '@/api/task/task'
import { reviewTaskStart, pdfDownload, removeTask } from '@/api/task/task'
import request from '@/utils/request'
export default {
dicts: [
......@@ -545,6 +541,47 @@ export default {
this.$store.dispatch('standard/setStandardList')
},
methods: {
/**
* 检验报告
*/
downloadPdf(id) {
pdfDownload({
taskId: id,
type: 0
}).then(res => {
const fileUrl =
process.env.VUE_APP_IMAGE_API +
'/vehicle-quality-review-oss/' +
res.data
this.download(fileUrl)
})
},
/**
* 下载pdf
*/
download(fileUrl) {
// 根据pdf文件地址下载
// window.location.href = this.fileUrl
const xhr = new XMLHttpRequest()
xhr.open('GET', fileUrl, true)
xhr.responseType = 'blob'
xhr.onload = () => {
if (xhr.status === 200) {
const blob = new Blob([xhr.response], { type: 'application/pdf' })
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '检查报告.pdf'
link.click()
URL.revokeObjectURL(url)
}
}
xhr.send()
},
loadData() {
this.loading = true
if (this.active === '0') {
......
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