Browse Source

fix:[模板管理]导出

luojie
15881625488@163.com 2 weeks ago
parent
commit
9aac4f1418
2 changed files with 109 additions and 31 deletions
  1. +10
    -0
      src/api/business/study/studyFormFill.js
  2. +99
    -31
      src/views/business/comps/template/comps/gsp/GSP015.vue

+ 10
- 0
src/api/business/study/studyFormFill.js View File

@ -24,6 +24,16 @@ export function studyFormFill_exportDetail(query) {
params: query
})
}
export function studyFormFill_exportTbByFileUrl(query) {
return request({
url: '/system/business/studyFormFill/exportTbByFileUrl',
method: 'get',
params: query
})
}
export function studyFormFill_exportByFileUrl(query) {
return request({
url: '/system/business/studyFormFill/exportByFileUrl',

+ 99
- 31
src/views/business/comps/template/comps/gsp/GSP015.vue View File

@ -18,7 +18,7 @@
@click="onExportXqjyxx">导出</el-button>
<vue-html2pdf :show-layout="true" pdf-content-width="100%" pdf-format="a2" :pdf-quality="2"
:float-layout="false" pdf-orientation="landscape" :paginate-elements-by-height="0"
:enable-download="true" :preview-modal="false" filename="取样进样信息" :html-to-pdf-options="{
:enable-download="false" :preview-modal="false" filename="取样进样信息" :html-to-pdf-options="{
margin: [10, 5, 10, 5], // : [, , , ] (: mm)
// 使
// margin: { top: 20, right: 15, bottom: 20, left: 15 },
@ -37,7 +37,7 @@
format: 'a2', //
orientation: 'landscape' //
}
}" ref="html2PdfXqjyxx" @progress="onProgressXqjyxx">
}" ref="html2PdfXqjyxx" @beforeDownload="handleBeforeDownload" @progress="onProgressXqjyxx">
<section slot="pdf-content">
<div v-for="(item, index) in formData.ybsmDataList" :key="item.id"
class="template-form-item">
@ -85,9 +85,9 @@
@click="onAdd('ecDataList')">新增</el-button>
<el-button class="mt-20" v-if="fillType === 'actFill'" type="primary"
@click="onExportEcxsxx()">导出</el-button>
<vue-html2pdf :show-layout="true" pdf-content-width="100%" pdf-format="a2" :pdf-quality="2"
<vue-html2pdf :show-layout="true" pdf-content-width="100%" pdf-format="a2" :pdf-quality="2"
:float-layout="false" pdf-orientation="landscape" :paginate-elements-by-height="0"
:enable-download="true" :preview-modal="false" filename="二次稀释信息" :html-to-pdf-options="{
:enable-download="false" :preview-modal="false" filename="二次稀释信息" :html-to-pdf-options="{
margin: [10, 5, 10, 5], // : [, , , ] (: mm)
// 使
// margin: { top: 20, right: 15, bottom: 20, left: 15 },
@ -106,34 +106,34 @@
format: 'a2', //
orientation: 'landscape' //
}
}" ref="html2PdfEcxsxx" @progress="onProgressEcxsxx">
}" ref="html2PdfEcxsxx" @beforeDownload="handleBeforeDownload" @progress="onProgressEcxsxx">
<section slot="pdf-content">
<div v-for="(item, index) in formData.ecDataList" :key="item.id" class="template-form-item">
<div class="config-header">
<div></div>
<el-popconfirm title="确认删除当前数据?" @confirm="deleteConfig(item, 'ecDataList')">
<el-button slot="reference" v-if="fillType === 'preFill'" type="text"
icon="el-icon-delete">{{
$t('template.common.deleteBtn')
}}</el-button>
</el-popconfirm>
</div>
<BaseInfoFormPackage fieldItemLabel="二次稀释信息" :ref="`ecFormPackageRef${index}`"
:formConfig="ecFormConfig" :formData="item" />
<CustomTable :ref="`ecTableRef${index}`" :columns="yjColumns" prefix="ec"
fieldItemLabel="二次稀释信息" @blur="(e) => onHandleTableBlur(e, index, 'ecTableRef')"
:showOperation="fillType === 'preFill' || fillType === 'actFill'"
@onAddRow="() => addEcTableRow(index, 'ecTableRef')" :formData="item">
<template slot="operation" slot-scope="{ row, rowIndex, columns }">
<TableOpertaion :row="row" :rowIndex="rowIndex" :columns="columns"
@configComplete="(e) => onConfigComplete(e, 'jy')" @printTag="(e) => onPrintTag(e, index)"
:fillType="fillType" :showFz="false" :showKspz="false"
@deleteRow="() => deleteTableRow(rowIndex, index)">
</TableOpertaion>
</template>
</CustomTable>
</div>
</section>
<div v-for="(item, index) in formData.ecDataList" :key="item.id" class="template-form-item">
<div class="config-header">
<div></div>
<el-popconfirm title="确认删除当前数据?" @confirm="deleteConfig(item, 'ecDataList')">
<el-button slot="reference" v-if="fillType === 'preFill'" type="text"
icon="el-icon-delete">{{
$t('template.common.deleteBtn')
}}</el-button>
</el-popconfirm>
</div>
<BaseInfoFormPackage fieldItemLabel="二次稀释信息" :ref="`ecFormPackageRef${index}`"
:formConfig="ecFormConfig" :formData="item" />
<CustomTable :ref="`ecTableRef${index}`" :columns="yjColumns" prefix="ec"
fieldItemLabel="二次稀释信息" @blur="(e) => onHandleTableBlur(e, index, 'ecTableRef')"
:showOperation="fillType === 'preFill' || fillType === 'actFill'"
@onAddRow="() => addEcTableRow(index, 'ecTableRef')" :formData="item">
<template slot="operation" slot-scope="{ row, rowIndex, columns }">
<TableOpertaion :row="row" :rowIndex="rowIndex" :columns="columns"
@configComplete="(e) => onConfigComplete(e, 'jy')"
@printTag="(e) => onPrintTag(e, index)" :fillType="fillType" :showFz="false"
:showKspz="false" @deleteRow="() => deleteTableRow(rowIndex, index)">
</TableOpertaion>
</template>
</CustomTable>
</div>
</section>
</vue-html2pdf>
<Step :ref="`stepRef`" :formData="formData.stepData || []"></Step>
@ -161,7 +161,9 @@ import { getuuid, justUpdateFilledFormData } from "@/utils/index";
import { isCommonUnit } from "@/utils/conTools";
import { convertConcentration } from "@/utils/conConverter";//
import { volumeConverter } from "@/utils/volConverter";//
import { getToken } from "@/utils/auth"
import moment from "moment";//
import { studyFormFill_exportTbByFileUrl } from "@/api/business/study/studyFormFill"
import { getBaseInfoFormConfig, getRemarkFormConfig, getYbsmFormConfig, getQyTableColumns, getJyTableColumns, getEcFormConfig } from "../../formConfig/gsp/gsp015";
const refConfig = {
baseInfoRef: "baseInfoRef",
@ -213,12 +215,78 @@ export default {
return {
refConfig,
currentIndex: -1,
appTitle: process.env.VUE_APP_TITLE,
baseUrl: process.env.VUE_APP_FILE_DOMAIN,
uploadFileUrl: process.env.VUE_APP_BASE_API + '/file/upload', //
};
},
mounted() {
},
methods: {
//blog
async handleBeforeDownload({ html2pdf, options, pdfContent }) {
this.$modal.loading()
// 1. 使 html2pdf PDF jsPDF
const pdf = await html2pdf()
.set(options) //
.from(pdfContent) // PDF
.toPdf() // PDF
.get('pdf'); // jsPDF
// 2. jsPDF Blob
const blob = pdf.output('blob');
// 3. Blob
await this.uploadPdfToServer(blob);
// .save()
// pdf.save('my-document.pdf');
},
//
async uploadPdfToServer(blob) {
let that=this
const formData = new FormData();
formData.append('file', blob, 'hxhq-export-form.pdf');
try {
const response = await fetch(this.uploadFileUrl, {
method: 'POST',
headers: {
Authorization: "Bearer " + getToken(),
},
body: formData
});
//
if (!response.ok) {
//
const errorData = await response.json().catch(() => ({}));
throw new Error(errorData.message || `HTTP error! status: ${response.status}`);
}
// JSON
const data = await response.json();
// console.log('JSON:', data);
if (data.code == 200) {
studyFormFill_exportTbByFileUrl(
{
url: data.data.url,
studyFormFillId:that.formData.id,
version: that.appTitle,
lang: that.$store.getters.language.split("_")[0]
}
).then(response => {
window.open(that.baseUrl + response.msg)
}).finally(() => {
this.$modal.closeLoading()
})
} else {
this.$modal.msgError(data.msg)
this.$modal.closeLoading()
}
} catch (error) {
this.$modal.msgError("导出失败,稍后再试")
this.$modal.closeLoading()
}
},
onConfigComplete(e, type) {
const { rowData, headerSelectFields } = e;
let params = {

Loading…
Cancel
Save