更新
This commit is contained in:
@ -1,78 +0,0 @@
|
||||
// import jsPDF from 'jspdf';
|
||||
// import html2canvas from 'html2canvas';
|
||||
|
||||
|
||||
// export function useExportToPDF() {
|
||||
// const exportToImage = async (element, filename = 'screenshot.png') => {
|
||||
// const canvas = await html2canvas(element, {
|
||||
// scale: 2,
|
||||
// useCORS: true,
|
||||
// });
|
||||
|
||||
// // 转换为图片并下载
|
||||
// const link = document.createElement('a');
|
||||
// link.download = filename;
|
||||
// link.href = canvas.toDataURL('image/png');
|
||||
// link.click();
|
||||
// };
|
||||
|
||||
// // 将div导出为PDF的方法
|
||||
// const exportDivToPDF = async (element, filename = 'document.pdf') => {
|
||||
// try {
|
||||
// // 使用html2canvas将div转换为canvas
|
||||
// const canvas = await html2canvas(element, {
|
||||
// scale: 2, // 提高清晰度
|
||||
// useCORS: true, // 允许跨域图片
|
||||
// logging: false, // 关闭日志
|
||||
// width: element.offsetWidth,
|
||||
// height: element.offsetHeight,
|
||||
// windowWidth: element.scrollWidth,
|
||||
// windowHeight: element.scrollHeight,
|
||||
// backgroundColor: '#ffffff' // 设置背景色为白色
|
||||
// });
|
||||
|
||||
// // 获取canvas的宽高
|
||||
// const imgWidth = 210; // A4纸宽度(mm)
|
||||
// const pageHeight = 297; // A4纸高度(mm)
|
||||
// const imgHeight = canvas.height * imgWidth / canvas.width;
|
||||
// let heightLeft = imgHeight;
|
||||
// let position = 0;
|
||||
|
||||
// // 创建PDF文档
|
||||
// const pdf = new jsPDF({
|
||||
// orientation: 'portrait',
|
||||
// unit: 'mm',
|
||||
// format: 'a4'
|
||||
// });
|
||||
|
||||
// // 将canvas转换为图片并添加到PDF
|
||||
// const imgData = canvas.toDataURL('image/png');
|
||||
// pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
||||
// heightLeft -= pageHeight;
|
||||
|
||||
// // 如果内容超出一页,添加新页面
|
||||
// while (heightLeft > 0) {
|
||||
// position = heightLeft - imgHeight;
|
||||
// pdf.addPage();
|
||||
// pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
||||
// heightLeft -= pageHeight;
|
||||
// }
|
||||
|
||||
// // 下载PDF
|
||||
// pdf.save(filename);
|
||||
// } catch (error) {
|
||||
// console.error('导出PDF失败:', error);
|
||||
// alert('导出PDF失败,请稍后重试');
|
||||
// }
|
||||
// };
|
||||
|
||||
// return {
|
||||
// exportToImage,
|
||||
// exportDivToPDF
|
||||
// };
|
||||
// }
|
||||
// exportToImage
|
||||
// };
|
||||
// }
|
||||
export function exportDivToPDF(divId, filename) {
|
||||
}
|
@ -124,19 +124,15 @@
|
||||
|
||||
<script setup>
|
||||
import PageTitle from "@/components/aboutTable/PageTitle.vue";
|
||||
// import { useExportToPDF } from './components/a.js';
|
||||
import Search from "@/components/aboutTable/Search.vue";
|
||||
import html2canvas from 'html2canvas';
|
||||
import jsPDF from 'jspdf';
|
||||
|
||||
|
||||
import MaleNightingalePicture from './components/maleNightingalePicture.vue'
|
||||
import Histogram from './components/histogram.vue'
|
||||
import { timeValidate } from '@/utils/tools.js'
|
||||
import { getItem, setItem } from '@/utils/storage'
|
||||
import { fxbgDywdtj, getDictItem, fxbgJqlxtj, fxbgJqlytj, fxbgYdfx, fxbgXsfx, fxgbCljgf, fxgbCzlfx, fxbgTj } from '@/api/semanticAnalysis'
|
||||
// import AddForm from './components/a/addForm.vue'
|
||||
import { qcckGet, qcckPost } from "@/api/qcckApi.js";
|
||||
// import ItemXs from './components/itemXs/itemXs.vue'
|
||||
import { reactive, ref, onMounted, getCurrentInstance, nextTick, computed, watch } from "vue";
|
||||
const { proxy } = getCurrentInstance();
|
||||
const { D_GS_XS_LX } = proxy.$dict("D_GS_XS_LX"); //获取字典数据
|
||||
@ -403,68 +399,9 @@ watch(() => dictItemList.value, (val) => {
|
||||
}, { deep: true })
|
||||
getDictItemList()
|
||||
|
||||
|
||||
const tableBox = ref(null);
|
||||
|
||||
async function generatePDF(filename = 'document.pdf') {
|
||||
// try {
|
||||
const element = tableBox.value;
|
||||
console.log();
|
||||
|
||||
// // 保存原始滚动位置和样式
|
||||
// const originalScrollTop = element.scrollTop;
|
||||
// const originalOverflow = element.style.overflow;
|
||||
|
||||
// // 临时允许元素滚动并获取完整高度
|
||||
// element.style.overflow = 'visible';
|
||||
|
||||
// const canvas = await html2canvas(element, {
|
||||
// scale: 2, // 提高清晰度
|
||||
// useCORS: true, // 允许跨域图片
|
||||
// logging: false, // 关闭日志
|
||||
// scrollY: 0, // 禁止窗口滚动
|
||||
// scrollX: 0,
|
||||
// windowWidth: element.scrollWidth, // 设置窗口大小为元素大小
|
||||
// windowHeight: element.scrollHeight,
|
||||
// width: element.scrollWidth, // 设置canvas大小为元素大小
|
||||
// height: element.scrollHeight
|
||||
// });
|
||||
|
||||
// // 恢复原始样式和滚动位置
|
||||
// element.style.overflow = originalOverflow;
|
||||
// element.scrollTop = originalScrollTop;
|
||||
|
||||
// const imgData = canvas.toDataURL('image/png');
|
||||
// const pdf = new jsPDF('p', 'mm', 'a4');
|
||||
|
||||
// const imgProps = pdf.getImageProperties(imgData);
|
||||
// const pdfWidth = pdf.internal.pageSize.getWidth();
|
||||
// const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
|
||||
|
||||
// // 计算需要多少页
|
||||
// const pageHeight = pdf.internal.pageSize.getHeight();
|
||||
// let heightLeft = pdfHeight;
|
||||
// let position = 0;
|
||||
|
||||
// // 添加第一页
|
||||
// pdf.addImage(imgData, 'PNG', 0, position, pdfWidth, pdfHeight);
|
||||
// heightLeft -= pageHeight;
|
||||
|
||||
// // 添加更多页(如果需要)
|
||||
// while (heightLeft > 0) {
|
||||
// position = -heightLeft;
|
||||
// pdf.addPage();
|
||||
// pdf.addImage(imgData, 'PNG', 0, position, pdfWidth, pdfHeight);
|
||||
// heightLeft -= pageHeight;
|
||||
// }
|
||||
|
||||
// pdf.save(filename);
|
||||
|
||||
// } catch (error) {
|
||||
// console.error('生成PDF时出错:', error);
|
||||
// alert('生成PDF时出错,请查看控制台获取详细信息');
|
||||
// }
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -22,7 +22,7 @@
|
||||
<div class="infoItem flex nowrap">
|
||||
<span class="smllbtn" @click.stop="handleQsFk(props.item,'签收')" v-if="props.item.yjJb != 10 && props.item.czzt == '01' && deptLevel=='40' ">签收</span>
|
||||
<span class="smllbtn" @click.stop="handleQsFk(props.item,'反馈')" v-if="props.item.yjJb != 10 && props.item.czzt == '02' && deptLevel=='40'"> 反馈 </span>
|
||||
<span class="smllbtn" @click.stop="handleQsFk(props.item,'查看反馈')" v-if="props.item.yjJb != 10 && props.item.czzt == '03' && deptLevel=='40' "> 查看反馈 </span>
|
||||
<span class="smllbtn" @click.stop="handleQsFk(props.item,'查看反馈')" v-if="props.item.yjJb != 10 && props.item.czzt == '03'"> 查看反馈 </span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="items">
|
||||
@ -82,7 +82,7 @@ const rules = reactive({
|
||||
fknr: [{ required: true, message: "请输入反馈内容", trigger: "blur" }],
|
||||
})
|
||||
onMounted(() => {
|
||||
deptLevel.value = localStorage.getItem("deptId") ? JSON.parse(localStorage.getItem("deptId"))[0].deptLevel : null;
|
||||
// deptLevel.value = localStorage.getItem("deptId") ? JSON.parse(localStorage.getItem("deptId"))[0].deptLevel : null;
|
||||
});
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user