|
|
@@ -1,23 +1,45 @@
|
|
|
<script setup>
|
|
|
import html2canvas from 'html2canvas';
|
|
|
-import { jsPDF } from 'jspdf';
|
|
|
+import {jsPDF} from 'jspdf';
|
|
|
+import {ElLoading} from "element-plus";
|
|
|
+import request from "@/utils/request.js";
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ creditCode: String,
|
|
|
+});
|
|
|
|
|
|
const printContent = async () => {
|
|
|
+ const loading = ElLoading.service({
|
|
|
+ lock: true,
|
|
|
+ text: '处理中',
|
|
|
+ background: 'rgba(0, 0, 0, 0.7)',
|
|
|
+ })
|
|
|
+ //每当加上下一个元素后如果内容超过了1188px则填充空白的div直到满足1188px
|
|
|
+ const e = document.querySelectorAll(".page .page-content");
|
|
|
+ let t = 0;
|
|
|
+ for (let j = 0; j < e.length; j++) {
|
|
|
+ t += e[j].scrollHeight;
|
|
|
+ if (j <= 1) continue;
|
|
|
+ if (t > 1188) {
|
|
|
+ const d = document.createElement("div");
|
|
|
+ d.classList.add("s");
|
|
|
+ d.style.height = 1188 - (t - e[j].scrollHeight) + 'px';
|
|
|
+ e[j - 1].appendChild(d);
|
|
|
+ t = e[j].scrollHeight;
|
|
|
+ }
|
|
|
+ }
|
|
|
const elements = document.querySelectorAll('.page');
|
|
|
-
|
|
|
- // 创建 jsPDF 实例
|
|
|
const pdf = new jsPDF('p', 'mm', 'a4');
|
|
|
|
|
|
const pdfWidth = pdf.internal.pageSize.getWidth();
|
|
|
const pdfHeight = pdf.internal.pageSize.getHeight();
|
|
|
+ console.log(pdfHeight);
|
|
|
for (let i = 0; i < elements.length; i++) {
|
|
|
const element = elements[i];
|
|
|
-
|
|
|
// 使用 html2canvas 将 HTML 元素截图
|
|
|
const canvas = await html2canvas(element, {
|
|
|
scale: 2, // 提高截图质量
|
|
|
});
|
|
|
-
|
|
|
// 将 canvas 转换为图片数据 URL
|
|
|
const imgData = canvas.toDataURL('image/png');
|
|
|
// 计算图片在 PDF 中的位置
|
|
|
@@ -28,7 +50,7 @@ const printContent = async () => {
|
|
|
pdf.addPage();
|
|
|
}
|
|
|
pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pageHeight);
|
|
|
- if(canvas.height/2 >1188){
|
|
|
+ if (canvas.height / 2 > 1188) {
|
|
|
//如果高度超过一页,则分页
|
|
|
//将canvas对象分为(element.scrollHeight / 1188)份
|
|
|
//每份高度1188
|
|
|
@@ -38,49 +60,47 @@ const printContent = async () => {
|
|
|
const canvas2 = await html2canvas(element, {
|
|
|
scale: 2, // 提高截图质量
|
|
|
});
|
|
|
- // console.log(canvas2);
|
|
|
//将截取的图片转成图片数据 URL
|
|
|
const imgData2 = canvas2.toDataURL('image/png');
|
|
|
//添加图片到 PDF
|
|
|
pdf.addPage();
|
|
|
- console.log(pageHeight);
|
|
|
- pdf.addImage(imgData2, 'PNG', 0, -297*j, pdfWidth, pageHeight);
|
|
|
+ pdf.addImage(imgData2, 'PNG', 0, -297 * j, pdfWidth, pageHeight);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 保存 PDF
|
|
|
+// 保存 PDF
|
|
|
pdf.save('report.pdf');
|
|
|
+ const allS = document.querySelectorAll('.s');
|
|
|
+ // 删除所有s元素
|
|
|
+ allS.forEach((e) => e.remove());
|
|
|
+ loading.close();
|
|
|
}
|
|
|
-
|
|
|
-const tableData = [
|
|
|
- {
|
|
|
- position: '法定代表人',
|
|
|
- name: '性与暴力',
|
|
|
- phone: '12345678910',
|
|
|
- },
|
|
|
- {
|
|
|
- position: '董事长',
|
|
|
- name: '性与暴力',
|
|
|
- phone: '12345678910',
|
|
|
- },
|
|
|
- {
|
|
|
- position: '总经理',
|
|
|
- name: '性与暴力',
|
|
|
- phone: '12345678910',
|
|
|
- },
|
|
|
- {
|
|
|
- position: '财务负责人',
|
|
|
- name: '性与暴力',
|
|
|
- phone: '12345678910',
|
|
|
+const basicData = ref({
|
|
|
+ a:[],
|
|
|
+ b:{
|
|
|
+ addr:null,
|
|
|
+ site:null,
|
|
|
+ weixin:null
|
|
|
},
|
|
|
- {
|
|
|
- position: '信用专干',
|
|
|
- name: '性与暴力',
|
|
|
- phone: '12345678910',
|
|
|
- },
|
|
|
-]
|
|
|
-const columnData = [
|
|
|
+ c:{
|
|
|
+ enterpriseName:null,
|
|
|
+ uniCode:null,
|
|
|
+ addr:null,
|
|
|
+ registeredCapital:null,
|
|
|
+ paidInCapital:null,
|
|
|
+ legalRepresentative:null,
|
|
|
+ companyType:null,
|
|
|
+ establishedTime:null,
|
|
|
+ businessTerm:null,
|
|
|
+ sector:null,
|
|
|
+ industryCode:null,
|
|
|
+ compantStatus:null,
|
|
|
+ registrationAuthority:null,
|
|
|
+ businessScope:null
|
|
|
+ }
|
|
|
+});
|
|
|
+const CD1 = [
|
|
|
{
|
|
|
label: '序号',
|
|
|
prop: 'id',
|
|
|
@@ -102,13 +122,32 @@ const columnData = [
|
|
|
width: '150'
|
|
|
}
|
|
|
]
|
|
|
+const getReport = async ()=>{
|
|
|
+ const res = await request.get('/report/queryByUniCode',{
|
|
|
+ params:{
|
|
|
+ uniCode:props.creditCode
|
|
|
+ }
|
|
|
+ });
|
|
|
+ basicData.value = res.data;
|
|
|
+ console.log(basicData.value);
|
|
|
+}
|
|
|
+const init = ()=>{
|
|
|
+ getReport()
|
|
|
+}
|
|
|
+init()
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <el-row class="report-container w-840px w-100% h-1188px overflow-auto">
|
|
|
- <el-col :span="24" class="page w-840px h-1188px border p-20px pb-0 font-songti border-black border-solid border-7px justify-between">
|
|
|
- <div class="w-full text-center h-150px line-height-150px mt-150px tracking-widest text-black font-black text-44px">性与暴力企业综合信用报告</div>
|
|
|
- <div class="w-full text-center h-150px line-height-150px mt-30px tracking-wider font-500 text-black text-30px">湖南性与暴力有限公司</div>
|
|
|
+ <el-row class="report-container w-840px w-100% h-full overflow-auto">
|
|
|
+ <el-col :span="24"
|
|
|
+ class="page w-840px h-1188px border p-20px pb-0 font-songti border-black border-solid border-7px justify-between">
|
|
|
+ <div
|
|
|
+ class="w-full text-center h-150px line-height-150px mt-150px tracking-widest text-black font-black text-44px">
|
|
|
+ 性与暴力企业综合信用报告
|
|
|
+ </div>
|
|
|
+ <div class="w-full text-center h-150px line-height-150px mt-30px tracking-wider font-500 text-black text-30px">
|
|
|
+ 湖南性与暴力有限公司
|
|
|
+ </div>
|
|
|
<div class="w-full text-center h-100px mt-100px tracking-wider font-900 text-24px text-black">
|
|
|
<div class="line-height-50px text-left pl-250px">企业信用等级: ZZZ级</div>
|
|
|
<div class="line-height-50px text-left pl-250px">信用评分情况: 0分</div>
|
|
|
@@ -122,24 +161,67 @@ const columnData = [
|
|
|
</div>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="page w-840px text-black p-20px tracking-widest font-songti">
|
|
|
- <div v-for="q in 5"><!--测试-->
|
|
|
- <div class="text-center text-30px mt-30px font-800">一、企业基本信息{{q}}</div>
|
|
|
+ <div class="page-content pt-30px">
|
|
|
+ <div class="text-center text-30px font-800">一、企业基本信息</div>
|
|
|
<div class="w-80% mx-a line-height-50px text-24px text-black">1、联系信息</div>
|
|
|
- <div class="w-80% mx-a line-height-24px text-16px">1.1 实际经营地址:<span class="underline">麓谷诈骗园区</span></div>
|
|
|
- <div class="w-80% mx-a line-height-24px text-16px">1.2 企业网址:<span class="underline">www.zhapian.com</span> 微信公众号:<span class="underline">割肾之家</span></div>
|
|
|
+ <div class="w-80% mx-a line-height-24px text-16px">1.1 实际经营地址:<span
|
|
|
+ class="underline">{{basicData.b.addr}}</span></div>
|
|
|
+ <div class="w-80% mx-a line-height-24px text-16px">1.2 企业网址:<span
|
|
|
+ class="underline">{{basicData.b.site}}</span> 微信公众号:<span class="underline">{{basicData.b.weixin}}</span></div>
|
|
|
<div class="w-80% mx-a line-height-24px text-16px">1.3 主要人物联系信息</div>
|
|
|
<div class="w-80% mx-a grid grid-cols-4 border-black border-solid border-1px">
|
|
|
- <div v-for="(item, index) in columnData" :key="index" class="border-black border-solid border-1px text-center bg-gray">{{item.label}}</div>
|
|
|
+ <div v-for="(item, index) in CD1" :key="index"
|
|
|
+ class="border-black border-solid border-1px text-center bg-gray h-25px"><span
|
|
|
+ class="line-height-25px">{{ item.label }}</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="w-80% mx-a">
|
|
|
- <div v-for="(item, index) in tableData" :key="index" class="grid grid-cols-4 border-black border-solid border-1px text-center">
|
|
|
- <div class="border-black border-b-solid border-l-solid border-r-solid border-0.1px">{{index + 1}}</div>
|
|
|
- <div class="border-black border-b-solid border-l-solid border-r-solid border-0.1px">{{item.position}}</div>
|
|
|
- <div class="border-black border-b-solid border-l-solid border-r-solid border-0.1px">{{item.name}}</div>
|
|
|
- <div class="border-black border-b-solid border-l-solid border-r-solid border-0.1px">{{item.phone}}</div>
|
|
|
+ <div v-for="(item, index) in basicData.a" :key="index"
|
|
|
+ class="grid grid-cols-4 border-black border-solid border-1px text-center">
|
|
|
+ <div class="border-black border-b-solid border-l-solid border-r-solid border-0.1px h-25px"><span
|
|
|
+ class="line-height-25px">{{ index + 1 }}</span></div>
|
|
|
+ <div class="border-black border-b-solid border-l-solid border-r-solid border-0.1px h-25px"><span
|
|
|
+ class="line-height-25px">{{ item.position }}</span></div>
|
|
|
+ <div class="border-black border-b-solid border-l-solid border-r-solid border-0.1px h-25px"><span
|
|
|
+ class="line-height-25px">{{ item.name }}</span></div>
|
|
|
+ <div class="border-black border-b-solid border-l-solid border-r-solid border-0.1px h-25px"><span
|
|
|
+ class="line-height-25px">{{ item.phone }}</span></div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="page-content pt-30px">
|
|
|
+ <div class="w-80% mx-a line-height-50px text-24px text-black">2、工商注册信息</div>
|
|
|
+ <div class="w-80% mx-a grid grid-cols-4 border-black border-solid border-1px">
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">企业名称</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.enterpriseName}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">统一社会信用代码</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.uniCode}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">住所</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center col-span-3">{{basicData.c.addr}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">注册资本</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.registeredCapital}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">实收资本</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.paidInCapital}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">法定代表人姓名</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.legalRepresentative}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">公司类型</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.companyType}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">成立日期</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.establishedTime}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">营业期限</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.businessTerm}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">所属行业</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.sector}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">行业代码</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.industryCode}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">企业状态</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.compantStatus}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">登记机关</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center">{{basicData.c.registrationAuthority}}</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center bg-gray">经营范围</div>
|
|
|
+ <div class="line-height-25px border-black border-solid border-1px text-center col-span-3">{{basicData.c.businessScope}}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</el-col>
|
|
|
<el-button @click="printContent">导出 PDF</el-button>
|
|
|
</el-row>
|