|
|
@ -18,7 +18,7 @@ |
|
|
@click="onExportXqjyxx">导出</el-button> |
|
|
@click="onExportXqjyxx">导出</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" |
|
|
: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: [10, 5, 10, 5], // 格式: [上, 右, 下, 左] (单位: mm) |
|
|
// 或者使用对象格式 |
|
|
// 或者使用对象格式 |
|
|
// margin: { top: 20, right: 15, bottom: 20, left: 15 }, |
|
|
// margin: { top: 20, right: 15, bottom: 20, left: 15 }, |
|
|
@ -37,7 +37,7 @@ |
|
|
format: 'a2', // 纸张大小 |
|
|
format: 'a2', // 纸张大小 |
|
|
orientation: 'landscape' // 方向 |
|
|
orientation: 'landscape' // 方向 |
|
|
} |
|
|
} |
|
|
}" ref="html2PdfXqjyxx" @progress="onProgressXqjyxx"> |
|
|
|
|
|
|
|
|
}" ref="html2PdfXqjyxx" @beforeDownload="handleBeforeDownload" @progress="onProgressXqjyxx"> |
|
|
<section slot="pdf-content"> |
|
|
<section slot="pdf-content"> |
|
|
<div v-for="(item, index) in formData.ybsmDataList" :key="item.id" |
|
|
<div v-for="(item, index) in formData.ybsmDataList" :key="item.id" |
|
|
class="template-form-item"> |
|
|
class="template-form-item"> |
|
|
@ -85,9 +85,9 @@ |
|
|
@click="onAdd('ecDataList')">新增</el-button> |
|
|
@click="onAdd('ecDataList')">新增</el-button> |
|
|
<el-button class="mt-20" v-if="fillType === 'actFill'" type="primary" |
|
|
<el-button class="mt-20" v-if="fillType === 'actFill'" type="primary" |
|
|
@click="onExportEcxsxx()">导出</el-button> |
|
|
@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" |
|
|
: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: [10, 5, 10, 5], // 格式: [上, 右, 下, 左] (单位: mm) |
|
|
// 或者使用对象格式 |
|
|
// 或者使用对象格式 |
|
|
// margin: { top: 20, right: 15, bottom: 20, left: 15 }, |
|
|
// margin: { top: 20, right: 15, bottom: 20, left: 15 }, |
|
|
@ -106,34 +106,34 @@ |
|
|
format: 'a2', // 纸张大小 |
|
|
format: 'a2', // 纸张大小 |
|
|
orientation: 'landscape' // 方向 |
|
|
orientation: 'landscape' // 方向 |
|
|
} |
|
|
} |
|
|
}" ref="html2PdfEcxsxx" @progress="onProgressEcxsxx"> |
|
|
|
|
|
|
|
|
}" ref="html2PdfEcxsxx" @beforeDownload="handleBeforeDownload" @progress="onProgressEcxsxx"> |
|
|
<section slot="pdf-content"> |
|
|
<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> |
|
|
</vue-html2pdf> |
|
|
<Step :ref="`stepRef`" :formData="formData.stepData || []"></Step> |
|
|
<Step :ref="`stepRef`" :formData="formData.stepData || []"></Step> |
|
|
|
|
|
|
|
|
@ -161,7 +161,9 @@ import { getuuid, justUpdateFilledFormData } from "@/utils/index"; |
|
|
import { isCommonUnit } from "@/utils/conTools"; |
|
|
import { isCommonUnit } from "@/utils/conTools"; |
|
|
import { convertConcentration } from "@/utils/conConverter";//浓度单位转换 |
|
|
import { convertConcentration } from "@/utils/conConverter";//浓度单位转换 |
|
|
import { volumeConverter } from "@/utils/volConverter";//体积单位转换 |
|
|
import { volumeConverter } from "@/utils/volConverter";//体积单位转换 |
|
|
|
|
|
import { getToken } from "@/utils/auth" |
|
|
import moment from "moment";//时间处理 |
|
|
import moment from "moment";//时间处理 |
|
|
|
|
|
import { studyFormFill_exportTbByFileUrl } from "@/api/business/study/studyFormFill" |
|
|
import { getBaseInfoFormConfig, getRemarkFormConfig, getYbsmFormConfig, getQyTableColumns, getJyTableColumns, getEcFormConfig } from "../../formConfig/gsp/gsp015"; |
|
|
import { getBaseInfoFormConfig, getRemarkFormConfig, getYbsmFormConfig, getQyTableColumns, getJyTableColumns, getEcFormConfig } from "../../formConfig/gsp/gsp015"; |
|
|
const refConfig = { |
|
|
const refConfig = { |
|
|
baseInfoRef: "baseInfoRef", |
|
|
baseInfoRef: "baseInfoRef", |
|
|
@ -213,12 +215,78 @@ export default { |
|
|
return { |
|
|
return { |
|
|
refConfig, |
|
|
refConfig, |
|
|
currentIndex: -1, |
|
|
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() { |
|
|
mounted() { |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
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) { |
|
|
onConfigComplete(e, type) { |
|
|
const { rowData, headerSelectFields } = e; |
|
|
const { rowData, headerSelectFields } = e; |
|
|
let params = { |
|
|
let params = { |
|
|
|