Commit b0dfe3cc by liudx

联调导出接口

parent a776e5f0
No preview for this file type
......@@ -6,7 +6,7 @@ export const patentselect = p => post('/api/patent/patents',p);
//专利详情页面
export const patentDetail = p => get('/api/patent/patentDetail/'+p.id);
//导出word给后端传递base64
export const exportword = p => post('/api/patent/patentDetail/125',p);
export const exportword = p => post('/api/users/enterprisePatentExport',p);
//专利智能推荐
export const Recommend = p => post('/api/patent/intelligentRecommendation/'+p.id,p);
// 企业搜索接口
......
......@@ -74,12 +74,13 @@
@onCancel="closeModal"
>
<p>报告格式&nbsp;&nbsp;&nbsp;<span class="PDF">PDF</span></p>
<a-form :model="formState">
<a-form :model="formState" ref="form">
<a-form-item
:name="'email'"
label="发送给"
:rules="[
{ type: 'email', required: true, message: '请输入正确的邮箱' },
{ required: true, message: '请输入邮箱' },
{ type: 'email', message: '邮箱不合法' },
]"
>
<a-input
......@@ -112,6 +113,8 @@
></EchartsCloud>
<EchartsCon :option="option7" :id="'apply'"></EchartsCon>
<EchartsCon :option="option8" :id="'purchase'"></EchartsCon>
<EchartsCon :option="option9" :id="'radar'"></EchartsCon>
<EchartsCon :option="option10" :id="'yibiao'"></EchartsCon>
</div>
</div>
</template>
......@@ -131,7 +134,7 @@ import {
} from "../../utils/indexApi.js";
import overview from "./overview.vue";
import { message } from "ant-design-vue";
import { userFollow,cancelFollow } from "../../utils/userAPI";
import { userFollow, cancelFollow } from "../../utils/userAPI";
import cooperation from "./cooperation.vue";
import technology from "./technology.vue";
import docxtemplater from "docxtemplater";
......@@ -847,226 +850,396 @@ export default {
},
],
};
},
//导出.overview
daochu() {
this.visible = false;
var that = this;
let share_holders = that.baseinfo.share_holders;
//对模板中股东信息进行修改
that.baseinfo.share_holders.forEach((item, index) => {
item.percent = (item.percent * 100).toFixed(2) + "%";
item.amount = Number(item.amount) + "万元";
});
//主要人员
let company_marjor = that.baseinfo.company_marjor;
//对外投资
let company_invest = that.baseinfo.company_invest;
//融资信息
let company_finance = that.baseinfo.company_finance;
let date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
month = month > 9 ? month : "0" + month;
day = day < 10 ? "0" + day : day;
var today = year + "年" + month + "月" + day + "日";
var chartDom1 = document.getElementById("applyTrend1");
var chartDom2 = document.getElementById("patentAuthorize1");
var chartDom3 = document.getElementById("echartsone1");
var chartDom4 = document.getElementById("echartstwo1");
var chartDom5 = document.getElementById("echartsthree1");
var chartDom6 = document.getElementById("TechnicalField1");
var chartDom7 = document.getElementById("apply");
var chartDom8 = document.getElementById("purchase");
let myChart1 = null;
let myChart2 = null;
let myChart3 = null;
let myChart4 = null;
let myChart5 = null;
let myChart6 = null;
let myChart7 = null;
let myChart8 = null;
myChart1 = echarts.init(chartDom1);
myChart2 = echarts.init(chartDom2);
myChart3 = echarts.init(chartDom3);
myChart4 = echarts.init(chartDom4);
myChart5 = echarts.init(chartDom5);
myChart6 = echarts.init(chartDom6);
myChart7 = echarts.init(chartDom7);
myChart8 = echarts.init(chartDom8);
// myChart2 = echarts.init(chartDom2);
this.option9 = {
tooltip: {
trigger: "item",
// formatter: function (params) {
// console.log(params);
// },
},
radar: [
{
indicator: [
{ name: "公司竞争力", max: 30 },
{ name: "技术质量", max: 30 },
{ name: "技术体量", max: 40 },
],
center: ["50%", "50%"],
// // 第一个echrts
myChart1.setOption(this.option1);
myChart2.setOption(this.option2);
myChart3.setOption(this.option3);
myChart4.setOption(this.option4);
myChart5.setOption(this.option5);
myChart7.setOption(this.option7);
myChart8.setOption(this.option8);
radius: 120,
triggerEvent: true,
},
{
indicator: [
{ name: "公司竞争力", max: 30 },
{ name: "技术质量", max: 30 },
{ name: "技术体量", max: 40 },
],
center: ["50%", "50%"],
//技术领域云图
myChart6.setOption({
radius: 120,
},
],
series: [
{
type: "wordCloud",
gridSize: 10,
sizeRange: [14, 60],
rotationRange: [0, 0],
//随机生成字体颜色
// maskImage: maskImage,
textStyle: {
color: function () {
return (
"rgb(" +
Math.round(Math.random() * 255) +
", " +
Math.round(Math.random() * 255) +
", " +
Math.round(Math.random() * 255) +
")"
);
type: "radar",
radarIndex: 0,
symbol: "none",
data: [
{
value: [20, 10, 25],
name: "均值",
areaStyle: {
color: "#F7B46A",
},
lineStyle: {
color: "#F7B46A",
},
itemStyle: {
color: "#F7B46A",
},
},
],
},
{
type: "radar",
radarIndex: 0,
symbol: "none",
data: [
{
value: [10, 20, 10],
name: "科创能力分值",
areaStyle: {
color: "#5A95F7",
},
lineStyle: {
color: "#5A95F7",
},
itemStyle: {
color: "#5A95F7",
},
},
},
left: "center",
top: "center",
right: null,
bottom: null,
width: "200%",
height: "200%",
//数据
data: that.techArr1,
],
},
],
});
};
var data = [
{
name: "技术体量",
value: 30,
},
{
name: "技术质量",
value: 30,
},
{
name: "公司竞争力",
value: 30,
},
]; //已排序好的数组
setTimeout(() => {
// 加setTimeout是为了让echarts渲染完成后生成图片
JSZipUtils.getBinaryContent("company.docx", function (error, content) {
// 抛出异常
if (error) {
throw error;
}
const opts = {
centered: false,
fileType: "docx",
};
opts.getImage = function (tagValue) {
if (tagValue.size && tagValue.data) {
return base64DataURLToArrayBuffer(tagValue.data);
}
return base64DataURLToArrayBuffer(tagValue);
};
opts.getSize = function (_, tagValue) {
if (tagValue.size && tagValue.data) {
return tagValue.size;
}
return [600, 200];
};
// 创建一个JSZip实例,内容为模板的内容
const zip = new PizZip(content);
// 创建并加载docxtemplater实例对象
const doc = new docxtemplater().loadZip(zip);
var ydata = [];
for (var i = 0; i < data.length; i++) {
ydata.push(data[i].name);
}
var datalength = [];
for (var i = 0; i < data.length; i++) {
datalength.push(0);
}
doc.setOptions({
nullGetter: function () {
//设置空值 undefined 为''
return "";
this.option10 = {
tooltip: {
formatter: "{a} <br/>{b} : {c}",
},
series: [
{
name: "总分",
startAngle: 180,
endAngle: 0,
min: 0,
max: 100,
radius: "160",
center: ["50%", "60%"],
type: "gauge",
progress: {
show: true,
},
detail: {
valueAnimation: true,
formatter: "{value}",
},
data: [
{
value: 50,
name: "科创能力总分值",
},
],
},
],
};
},
//导出.overview
daochu() {
this.$refs.form
.validate("email")
.then(() => {
this.visible = false;
var that = this;
let share_holders = that.baseinfo.share_holders;
//对模板中股东信息进行修改
that.baseinfo.share_holders.forEach((item, index) => {
item.percent = (item.percent * 100).toFixed(2) + "%";
item.amount = Number(item.amount) + "万元";
});
// 设置图片模块
doc.attachModule(new ImageModule(opts));
//主要人员
let company_marjor = that.baseinfo.company_marjor;
//对外投资
let company_invest = that.baseinfo.company_invest;
//融资信息
let company_finance = that.baseinfo.company_finance;
let date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
month = month > 9 ? month : "0" + month;
day = day < 10 ? "0" + day : day;
var today = year + "年" + month + "月" + day + "日";
// 设置模板变量的值
doc.setData({
...that.baseinfo,
share_holders,
company_marjor,
company_invest,
company_finance,
...that.developmentOverview,
...that.deveSustain,
...that.structureData,
...that.jointData,
...that.patentPurchaseData,
today,
image1: myChart1.getDataURL({
pixelRatio: 2, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image2: myChart2.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image3: myChart3.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image4: myChart4.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image5: myChart5.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image6: myChart6.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image7: myChart7.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image8: myChart8.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
});
try {
// 用模板变量的值替换所有模板变量
doc.render();
} catch (error) {
console.error("导出报表失败");
throw error;
}
// 生成一个代表docxtemplater对象的zip文件(不是一个真实的文件,而是在内存中的表示)
let out = doc.getZip().generate({
type: "blob",
mimeType:
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
var chartDom1 = document.getElementById("applyTrend1");
var chartDom2 = document.getElementById("patentAuthorize1");
var chartDom3 = document.getElementById("echartsone1");
var chartDom4 = document.getElementById("echartstwo1");
var chartDom5 = document.getElementById("echartsthree1");
var chartDom6 = document.getElementById("TechnicalField1");
var chartDom7 = document.getElementById("apply");
var chartDom8 = document.getElementById("purchase");
var chartDom9 = document.getElementById("radar");
var chartDom10 = document.getElementById("yibiao");
let myChart1 = null;
let myChart2 = null;
let myChart3 = null;
let myChart4 = null;
let myChart5 = null;
let myChart6 = null;
let myChart7 = null;
let myChart8 = null;
let myChart9 = null;
let myChart10 = null;
myChart1 = echarts.init(chartDom1);
myChart2 = echarts.init(chartDom2);
myChart3 = echarts.init(chartDom3);
myChart4 = echarts.init(chartDom4);
myChart5 = echarts.init(chartDom5);
myChart6 = echarts.init(chartDom6);
myChart7 = echarts.init(chartDom7);
myChart8 = echarts.init(chartDom8);
myChart9 = echarts.init(chartDom9);
myChart10 = echarts.init(chartDom10);
// myChart2 = echarts.init(chartDom2);
// // 第一个echrts
myChart1.setOption(this.option1);
myChart2.setOption(this.option2);
myChart3.setOption(this.option3);
myChart4.setOption(this.option4);
myChart5.setOption(this.option5);
myChart7.setOption(this.option7);
myChart8.setOption(this.option8);
myChart9.setOption(this.option9);
myChart10.setOption(this.option10);
//技术领域云图
myChart6.setOption({
series: [
{
type: "wordCloud",
gridSize: 10,
sizeRange: [14, 60],
rotationRange: [0, 0],
//随机生成字体颜色
// maskImage: maskImage,
textStyle: {
color: function () {
return (
"rgb(" +
Math.round(Math.random() * 255) +
", " +
Math.round(Math.random() * 255) +
", " +
Math.round(Math.random() * 255) +
")"
);
},
},
left: "center",
top: "center",
right: null,
bottom: null,
width: "200%",
height: "200%",
//数据
data: that.techArr1,
},
],
});
//formData文件流
// that.blobToBase64(out);
// 将目标文件对象保存为目标类型的文件,并命名
saveAs(out, `企业科创能力报告.docx`);
setTimeout(() => {
// 加setTimeout是为了让echarts渲染完成后生成图片
JSZipUtils.getBinaryContent(
"company.docx",
function (error, content) {
// 抛出异常
if (error) {
throw error;
}
const opts = {
centered: false,
fileType: "docx",
};
opts.getImage = function (tagValue) {
if (tagValue.size && tagValue.data) {
return base64DataURLToArrayBuffer(tagValue.data);
}
return base64DataURLToArrayBuffer(tagValue);
};
opts.getSize = function (_, tagValue) {
if (tagValue.size && tagValue.data) {
return tagValue.size;
}
return [600, 200];
};
// 创建一个JSZip实例,内容为模板的内容
const zip = new PizZip(content);
// 创建并加载docxtemplater实例对象
const doc = new docxtemplater().loadZip(zip);
doc.setOptions({
nullGetter: function () {
//设置空值 undefined 为''
return "";
},
});
// 设置图片模块
doc.attachModule(new ImageModule(opts));
// 设置模板变量的值
doc.setData({
...that.baseinfo,
share_holders,
company_marjor,
company_invest,
company_finance,
...that.developmentOverview,
...that.deveSustain,
...that.structureData,
...that.jointData,
...that.patentPurchaseData,
today,
image1: myChart1.getDataURL({
pixelRatio: 2, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image2: myChart2.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image3: myChart3.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image4: myChart4.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image5: myChart5.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image6: myChart6.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image7: myChart7.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image8: myChart8.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image9: myChart9.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
image10: myChart10.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
});
try {
// 用模板变量的值替换所有模板变量
doc.render();
} catch (error) {
console.error("导出报表失败");
throw error;
}
// 生成一个代表docxtemplater对象的zip文件(不是一个真实的文件,而是在内存中的表示)
let out = doc.getZip().generate({
type: "blob",
mimeType:
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
});
//formData文件流
that.blobToBase64(out,that.formState.email);
// 将目标文件对象保存为目标类型的文件,并命名
// saveAs(out, `企业科创能力报告.docx`);
}
);
}, 1000);
})
.catch((err) => {
console.log(err);
// return false;
// 处理验证失败的情况
});
}, 1000);
},
blobToBase64(blob) {
blobToBase64(blob,email) {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.onload = (e) => {
setTimeout(function () {
exportword({ file: e.target.result }).then((res) => {});
exportword({
report_data: e.target.result,
email: email,
}).then((res) => {
if (res.code == 0) {
message.success(res.msg);
} else {
message.error(res.msg);
}
});
}, 300);
};
// readAsDataURL
......
......@@ -119,6 +119,7 @@ export default {
{
type: "radar",
radarIndex: 0,
symbol: 'none',
data: [
{
value: [20, 10, 25],
......@@ -139,6 +140,7 @@ export default {
{
type: "radar",
radarIndex: 0,
symbol: 'none',
data: [
{
value: [10, 20, 10],
......@@ -159,37 +161,6 @@ export default {
],
};
chart.setOption(option1);
//在name上移动
// let that = this;
// chart.on("mousemove", function (params) {
// that.hover = true;
// if (params.name == "技术质量") {
// that.$nextTick(() => {
// that.$refs.hover.style.left = params.event.offsetX + "px";
// that.$refs.hover.style.top = params.event.offsetY + "px";
// });
// that.con =
// "从有效专利占专利申请总量比例、有效发明专利占有效专利比例和风险专利占全部申请专利的比例分析";
// } else if (params.name == "公司竞争力") {
// that.$nextTick(() => {
// that.$refs.hover.style.left = params.event.offsetX + "px";
// that.$refs.hover.style.top = params.event.offsetY + "px";
// });
// that.con = "从公司资质类别、公司规模、对外投资和公司融资分析";
// } else if (params.name == "技术体量") {
// that.$nextTick(() => {
// that.$refs.hover.style.left = params.event.offsetX + "px";
// that.$refs.hover.style.top = params.event.offsetY + "px";
// });
// that.con = "从专利申请总量、有效专利总量和近3年专利申请增速分析";
// } else {
// that.hover = false;
// }
// });
// chart.on("mouseout", function (params) {
// that.hover = false;
// });
},
getOption2() {
var data = [
......@@ -218,11 +189,11 @@ export default {
this.option2 = {
tooltip: {
formatter: "{a} <br/>{b} : {c}%",
formatter: "{a} <br/>{b} : {c}",
},
series: [
{
name: "Pressure",
name: "总分",
startAngle: 180,
endAngle: 0,
min: 0,
......@@ -240,7 +211,7 @@ export default {
data: [
{
value: 50,
name: "总分",
name: "科创能力总分值",
},
],
},
......@@ -254,6 +225,7 @@ export default {
<style lang="less" scoped>
.company_con {
clear: both;
// min-height: 900px;
position: relative;
display: flex;
justify-content: flex-start;
......
......@@ -35,15 +35,6 @@
:rules="formRules"
>
<a-form-item name="phone">
<!-- :rules="[
{ required: true, message: '请输入手机号!' },
{
pattern:
/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
message: '手机号格式不正确!',
validateTrigger: 'onBlur',
},
]" -->
<a-input v-model:value="formState.phone" placeholder="请输入手机号">
<template #prefix>
<img src="../../static/login/icon-user.png" alt="" />
......
......@@ -11,8 +11,8 @@
</a-breadcrumb>
<div class="back_btn" @click="backbtn">返回</div>
<div class="details_title">
<div class="patent_num">{{ zlcode?zlcode:details.gkh }}</div>
<div class="patent_title">{{ title?title:details.title }}</div>
<div class="patent_num">{{ zlcode ? zlcode : details.gkh }}</div>
<div class="patent_title">{{ title ? title : details.title }}</div>
</div>
<div class="btn_group">
<span style="cursor: pointer" @click="openModal"
......@@ -227,7 +227,6 @@
回到顶部
</div>
</a-back-top>
</div>
</div>
<div class="patent_con_right">
......@@ -336,12 +335,13 @@
@onCancel="closeModal"
>
<p>报告格式&nbsp;&nbsp;&nbsp;PDF</p>
<a-form :model="formState">
<a-form :model="formState" ref="form">
<a-form-item
:name="'email'"
label="发送给"
:rules="[
{ type: 'email', required: true, message: '请输入正确的邮箱' },
{ required: true, message: '请输入邮箱' },
{ type: 'email', message: '邮箱不合法' },
]"
>
<a-input v-model:value="formState.email" />
......@@ -355,7 +355,7 @@ import * as echarts from "echarts";
import "echarts-wordcloud";
import { DownOutlined } from "@ant-design/icons-vue";
import { patentDetail, exportword, Recommend } from "../../utils/indexApi";
import { userFollow,cancelFollow } from "../../utils/userAPI";
import { userFollow, cancelFollow } from "../../utils/userAPI";
import EchartsCloud from "../../components/EchartsCloud.vue";
import docxtemplater from "docxtemplater";
import PizZip from "pizzip";
......@@ -418,16 +418,16 @@ export default {
},
methods: {
//取消关注
async cancelFun(){
async cancelFun() {
let cancelRes = await cancelFollow({
f_type:"patent",
ent_or_pat_id:this.id
})
if(cancelRes.code == 0){
this.$router.go(0)
message.success(cancelRes.msg)
}else{
message.error(cancelRes.msg)
f_type: "patent",
ent_or_pat_id: this.id,
});
if (cancelRes.code == 0) {
this.$router.go(0);
message.success(cancelRes.msg);
} else {
message.error(cancelRes.msg);
}
},
//关注接口
......@@ -437,11 +437,11 @@ export default {
ent_or_pat_id: this.id,
name: this.details.gkh,
});
if(Follow.code == 0){
this.$router.go(0)
message.success(Follow.msg)
}else{
message.error(Follow.msg)
if (Follow.code == 0) {
this.$router.go(0);
message.success(Follow.msg);
} else {
message.error(Follow.msg);
}
},
......@@ -513,150 +513,170 @@ export default {
},
//导出word
daochu(details) {
var that = this;
let date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
month = month > 9 ? month : "0" + month;
day = day < 10 ? "0" + day : day;
var today = year + "年" + month + "月" + day + "日";
var chartDom1 = document.getElementById("tech");
this.$refs.form
.validate("email")
.then(() => {
// 邮箱号码格式正确,可以发送
var that = this;
let date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
month = month > 9 ? month : "0" + month;
day = day < 10 ? "0" + day : day;
var today = year + "年" + month + "月" + day + "日";
var chartDom1 = document.getElementById("tech");
let myChart1 = null;
let myChart1 = null;
myChart1 = echarts.init(chartDom1);
//技术领域云图
myChart1.setOption({
series: [
{
type: "wordCloud",
gridSize: 10,
sizeRange: [14, 60],
rotationRange: [0, 0],
//随机生成字体颜色
// maskImage: maskImage,
textStyle: {
color: function () {
return (
"rgb(" +
Math.round(Math.random() * 255) +
", " +
Math.round(Math.random() * 255) +
", " +
Math.round(Math.random() * 255) +
")"
);
myChart1 = echarts.init(chartDom1);
//技术领域云图
myChart1.setOption({
series: [
{
type: "wordCloud",
gridSize: 10,
sizeRange: [14, 60],
rotationRange: [0, 0],
//随机生成字体颜色
// maskImage: maskImage,
textStyle: {
color: function () {
return (
"rgb(" +
Math.round(Math.random() * 255) +
", " +
Math.round(Math.random() * 255) +
", " +
Math.round(Math.random() * 255) +
")"
);
},
},
left: "center",
top: "center",
right: null,
bottom: null,
width: "200%",
height: "200%",
//数据
data: that.techArr,
},
},
left: "center",
top: "center",
right: null,
bottom: null,
width: "200%",
height: "200%",
//数据
data: that.techArr,
},
],
});
],
});
setTimeout(() => {
// 加setTimeout是为了让echarts渲染完成后生成图片
JSZipUtils.getBinaryContent("patent.docx", function (error, content) {
// 抛出异常
if (error) {
throw error;
}
const opts = {
centered: false,
fileType: "docx",
};
opts.getImage = function (tagValue) {
if (tagValue.size && tagValue.data) {
return base64DataURLToArrayBuffer(tagValue.data);
}
return base64DataURLToArrayBuffer(tagValue);
};
opts.getSize = function (_, tagValue) {
if (tagValue.size && tagValue.data) {
return tagValue.size;
}
return [600, 200];
};
// 创建一个JSZip实例,内容为模板的内容
const zip = new PizZip(content);
// 创建并加载docxtemplater实例对象
const doc = new docxtemplater().loadZip(zip);
setTimeout(() => {
// 加setTimeout是为了让echarts渲染完成后生成图片
JSZipUtils.getBinaryContent(
"patent.docx",
function (error, content) {
// 抛出异常
if (error) {
throw error;
}
const opts = {
centered: false,
fileType: "docx",
};
opts.getImage = function (tagValue) {
if (tagValue.size && tagValue.data) {
return base64DataURLToArrayBuffer(tagValue.data);
}
return base64DataURLToArrayBuffer(tagValue);
};
opts.getSize = function (_, tagValue) {
if (tagValue.size && tagValue.data) {
return tagValue.size;
}
return [600, 200];
};
// 创建一个JSZip实例,内容为模板的内容
const zip = new PizZip(content);
// 创建并加载docxtemplater实例对象
const doc = new docxtemplater().loadZip(zip);
doc.setOptions({
nullGetter: function () {
//设置空值 undefined 为''
return "";
},
});
// 设置图片模块
doc.attachModule(new ImageModule(opts));
doc.setOptions({
nullGetter: function () {
//设置空值 undefined 为''
return "";
},
});
// 设置图片模块
doc.attachModule(new ImageModule(opts));
let list = that.list;
let qualif = [];
list.forEach((item) => {
if (item.high_new == 1) {
qualif.push("高新技术企业");
} else if (item.zjtg == 1) {
qualif.push("专精特新企业");
} else if (item.zjtg_sjxjr == 1) {
qualif.push("专精特新小巨人企业");
} else if (item.quoted_company == 1) {
qualif.push("上市企业");
}
});
that.list.qualif = qualif;
// that.list.patents = this.submitInfo.auditResult.split('\n')
// 设置模板变量的值
doc.setData({
...details,
today,
list,
qualif,
// business_scope,
// patent,
image1: myChart1.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
});
try {
// 用模板变量的值替换所有模板变量
doc.render();
} catch (error) {
console.error("导出报表失败");
throw error;
}
// 生成一个代表docxtemplater对象的zip文件(不是一个真实的文件,而是在内存中的表示)
let out = doc.getZip().generate({
type: "blob",
mimeType:
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
});
//formData文件流
// that.blobToBase64(out);
// 将目标文件对象保存为目标类型的文件,并命名
saveAs(out, `专利成果转移转化智能推荐报告.docx`);
that.visible = false;
let list = that.list;
let qualif = [];
list.forEach((item) => {
if (item.high_new == 1) {
qualif.push("高新技术企业");
} else if (item.zjtg == 1) {
qualif.push("专精特新企业");
} else if (item.zjtg_sjxjr == 1) {
qualif.push("专精特新小巨人企业");
} else if (item.quoted_company == 1) {
qualif.push("上市企业");
}
});
that.list.qualif = qualif;
// that.list.patents = this.submitInfo.auditResult.split('\n')
// 设置模板变量的值
doc.setData({
...details,
today,
list,
qualif,
// business_scope,
// patent,
image1: myChart1.getDataURL({
pixelRatio: 5, //导出的图片分辨率比率,默认是1
backgroundColor: "#fff", //图表背景色
excludeComponents: ["toolbox"], //忽略组件的列表
type: "png", //图片类型支持png和jpeg
}),
});
try {
// 用模板变量的值替换所有模板变量
doc.render();
} catch (error) {
console.error("导出报表失败");
throw error;
}
// 生成一个代表docxtemplater对象的zip文件(不是一个真实的文件,而是在内存中的表示)
let out = doc.getZip().generate({
type: "blob",
mimeType:
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
});
//formData文件流
that.blobToBase64(out,that.formState.email);
// 将目标文件对象保存为目标类型的文件,并命名
// saveAs(out, `专利成果转移转化智能推荐报告.docx`);
that.visible = false;
}
);
}, 1000);
})
.catch((err) => {
console.log(err);
// return false;
// 处理验证失败的情况
});
}, 1000);
},
blobToBase64(blob) {
blobToBase64(blob,email) {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.onload = (e) => {
console.log(e.target.result);
// resolve(e.target.result);
setTimeout(function () {
exportword({ file: e.target.result }).then((res) => {});
exportword({
report_data: e.target.result,
email: email,
}).then((res) => {
if (res.code == 0) {
message.success(res.msg);
} else {
message.error(res.msg);
}
});
}, 300);
};
// readAsDataURL
......@@ -789,7 +809,7 @@ export default {
}
.company_con_anchor {
margin-top: 15px;
font-weight: bold;
color: #1c1c28;
:deep(.ant-anchor-link-title) {
......@@ -828,9 +848,8 @@ export default {
line-height: 60px;
border-radius: 8px;
}
}
.patent_con_right {
margin-top: 15px;
width: 610px;
......
......@@ -195,23 +195,21 @@ export default {
file.type === "image/gif" ||
file.type === "image/jpg";
if (!isJpgOrPng) {
return this.$message.error("请上传正确的图片格式!");
return message.error("请上传正确的图片格式!");
}
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isLt2M) {
return this.$message.error("图片大小必须小于2MB!");
return message.error("图片大小必须小于2MB!");
}
},
imageUpload(file) {
console.log(file);
let data = new FormData();
data.append("head_img", file.file);
console.log(data);
uploadFile(data).then((res) => {
if (res.code == 0) {
message.success(res.msg);
this.img = res.data.file_url;
// console.log( this.img)
} else {
message.error(res.msg);
......@@ -224,7 +222,7 @@ export default {
if (res.code == 0) {
this.formState.name = res.data.name;
this.img = res.data.head_img;
this.login_name = res.data.account_number;
this.login_name = res.data.account_number;
this.formState.phone = res.data.phone;
this.phone = res.data.phone;
console.log(this.img);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment