实验报告导出

master
yujialong 2 months ago
parent 8672caf66d
commit 16dd01927b
  1. 2
      src/api/index.js
  2. 2
      src/config/index.js
  3. 31
      src/views/Report.vue

@ -30,7 +30,7 @@ export default {
batchDeletion: `occupationlab/occupationlab/python/file/data/batchDeletion`, batchDeletion: `occupationlab/occupationlab/python/file/data/batchDeletion`,
myData: `occupationlab/occupationlab/python/file/data/myData`, myData: `occupationlab/occupationlab/python/file/data/myData`,
updateReport: `occupationlab/occupationlab/achievement/updateReport`, updateReport: `occupationlab/occupationlab/achievement/updateReport`,
exportLabReport: `occupationlab/occupationlab/achievement/exportLabReport`, exportLabReport: `${config.host}occupationlab/occupationlab/achievement/exportLabReport`,
reportDetail: `occupationlab/occupationlab/achievement/reportDetail`, reportDetail: `occupationlab/occupationlab/achievement/reportDetail`,
getCompetition: `competition/competition/management/getCompetition`, getCompetition: `competition/competition/management/getCompetition`,
whetherCanPaste: `nakadai/nakadai/model/demo/whetherCanPaste`, whetherCanPaste: `nakadai/nakadai/model/demo/whetherCanPaste`,

@ -14,7 +14,7 @@ let bankPath = `${location.origin}/systembank` // 银行系统
// occupationlab.com | 192.168.31.151 // occupationlab.com | 192.168.31.151
if (isDev) { if (isDev) {
host = 'http://192.168.31.217:9000/' host = 'http://192.168.31.217:9000/'
host = 'https://occupationlab.com/' // host = 'https://occupationlab.com/'
// host = 'https://izhixinyun.com/' // host = 'https://izhixinyun.com/'
bankPath = `http://${location.hostname}:8093` bankPath = `http://${location.hostname}:8093`
} else if (isTest) { } else if (isTest) {

@ -147,8 +147,10 @@
</template> </template>
<script> <script>
import Cookie from 'js-cookie'
import { Loading } from "element-ui"; import { Loading } from "element-ui";
import util from '@/util' import Util from '@/util'
import Axios from 'axios'
import breadcrumb from '@/components/breadcrumb' import breadcrumb from '@/components/breadcrumb'
import quill from "@/components/quill"; import quill from "@/components/quill";
import Editor from '@tinymce/tinymce-vue' import Editor from '@tinymce/tinymce-vue'
@ -156,6 +158,9 @@ import editorConfig from '@/components/tinymceConfig'
export default { export default {
data () { data () {
return { return {
headers: {
token: Cookie.get('admin-token'),
},
editorConfig, editorConfig,
reportId: this.$route.query.reportId, reportId: this.$route.query.reportId,
title: "实验报告", title: "实验报告",
@ -239,7 +244,7 @@ export default {
} }
this.expData = list this.expData = list
}, },
exportPage () { async exportPage () {
const form = Object.assign(this.form, this.infoData) const form = Object.assign(this.form, this.infoData)
const list = JSON.parse(JSON.stringify(this.expData)) const list = JSON.parse(JSON.stringify(this.expData))
list.map((e, i) => { list.map((e, i) => {
@ -258,17 +263,21 @@ export default {
this.loadIns = Loading.service({ this.loadIns = Loading.service({
background: "#fff" background: "#fff"
}); });
this.$post(this.project ? this.api.exportBankExperimentReport : this.api.exportLabReport, {
...form, try {
experimentalData: list const res = await Axios.post(this.api[this.project ? 'exportBankExperimentReport' : 'exportLabReport'], {
}).then(res => { ...form,
this.loadIns.close(); experimentalData: list
this.loading = false; }, {
util.downloadFileDirect(`实验报告.docx`, new Blob([res])) headers: this.headers,
}).catch(res => { responseType: 'blob'
})
const name = res.headers['content-disposition']
Util.downloadFileDirect(name ? decodeURI(name) : `实验报告.docx`, new Blob([res.data]))
} finally {
this.loadIns.close(); this.loadIns.close();
this.loading = false; this.loading = false;
}) }
}, },
editReport () { // editReport () { //
if (this.editing) { if (this.editing) {

Loading…
Cancel
Save