增加下载pdf按钮

This commit is contained in:
Mrking 2024-09-24 23:50:58 +08:00
parent 7550592b8a
commit 0af809a013
1 changed files with 31 additions and 0 deletions

View File

@ -94,6 +94,7 @@
</el-form-item>
</el-form>
<template #footer>
<el-button @click="downpdf" type="primary" v-if="formData.id" :disabled="formLoading"> </el-button>
<el-button @click="preview" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
@ -228,6 +229,36 @@ const resetForm = () => {
}
const downpdf = async () => {
const id = formData.value.id;
if (id) {
formData.value = await ProduceOrderApi.getProduceOrder(id)
}
//
formData.value.contractDateStr = formatDate(formData.value.contractDate,'YYYY-MM-DD')
formData.value.reportDateStr = formatDate(formData.value.reportDate,'YYYY-MM-DD')
formData.value.reportTimeStr = formatDate(formData.value.reportDate,'HH:mm:ss')
formData.value.produceDateStr = formatDate(formData.value.produceDate,'YYYY-MM-DD')
formData.value.inspectionDateStr = formatDate(formData.value.inspectionDate,'YYYY-MM-DD')
formData.value.deliverydateStr = formatDate(formData.value.deliverydate,'YYYY-MM-DD')
//formData.value.saleContractNo = formData.value.orderNo
let printData = JSON.stringify(formData.value)
printData = JSON.parse(printData)
let hiprintTemplate = new hiprint.PrintTemplate({template: template1});
// name
// hiprintTemplate.print(hiprintTemplate);
//let html = hiprintTemplate.getHtml(printData);
//previewRef.value.showModal(html);
hiprintTemplate.toPdf(printData, '生产制单_' + formData.value.billno).then((res) => {
console.log('type:', 'pdfobjectnewwindow');
console.log(res);
});
}
const preview = async () => {
const id = formData.value.id;
if (id) {