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