PatentRight.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <div class="patent-articles-patent-right height_100" @mouseup="mouseup">
  3. <el-container>
  4. <el-header class="basic_header">
  5. <el-tabs v-model="name" @tab-click="handleClick" style="width:100%">
  6. <el-tab-pane v-for="item in tabs" :key="item.label" :label="item.label" :name="item.name"></el-tab-pane>
  7. </el-tabs>
  8. </el-header>
  9. <el-main>
  10. <div class="height_100" v-if="name != 2" v-html="getViewDom(patent.claim, '权利要求'+tabItem.label, 'column')" :style="setStyle()" :data-type="'权利要求'+tabItem.label"></div>
  11. <div v-else class="height_100">
  12. <my-view>
  13. <div slot="left">
  14. <myTree :list="patent.patentRightTree" style="height: 100%" :props="{
  15. name:'content',
  16. children:'children'
  17. }" nodeKey="sort" :expends="expends"></myTree>
  18. </div>
  19. <div slot="right" style="position: relative;">
  20. <div id="charts" style="max-width: 100%; min-width: 300px;position:relative;padding-top: 10px;" v-if="show">
  21. <div v-for="(item,index) in this.patent.patentRightTree" :key="index" :id="'chart'+index" style="width:500px;margin:0 auto;"></div>
  22. </div>
  23. <div style="position:absolute;top:10px;right:20px;">
  24. <el-link type="primary" @click="imageDownLoad">下载为图片</el-link>
  25. </div>
  26. </div>
  27. </my-view>
  28. </div>
  29. </el-main>
  30. </el-container>
  31. </div>
  32. </template>
  33. <script>
  34. import { patentDetails } from './mixins';
  35. import html2canvas from "html2canvas"
  36. export default {
  37. mixins: [patentDetails],
  38. data() {
  39. return {
  40. expends: [],
  41. show:false,
  42. isClickId: "",
  43. height: null,
  44. fullHeight: document.documentElement.clientHeight,
  45. records: {
  46. original: [],
  47. translation: [],
  48. },
  49. scrollTop:0,
  50. isClick:false,
  51. tabs:[
  52. {
  53. label:'原文',
  54. name:'0',
  55. field:'content'
  56. },
  57. {
  58. label:'译文',
  59. name:'1',
  60. field:'contentOut'
  61. },
  62. {
  63. label:'权要树',
  64. name:'2',
  65. field:'contentOut'
  66. },
  67. ],
  68. tabItem:{
  69. label:'原文',
  70. name:'0',
  71. },
  72. };
  73. },
  74. watch: {
  75. // fullHeight() {
  76. // this.refresh();
  77. // },
  78. patentId() {
  79. this.initData();
  80. if(this.name == 2){
  81. this.show = false
  82. this.expends = []
  83. this.isClickId = ''
  84. this.$nextTick(()=>{
  85. this.handleClick()
  86. })
  87. }
  88. },
  89. patentNo() {
  90. if (!this.patentId) {
  91. this.initData();
  92. if(this.name == 2){
  93. this.show = false
  94. this.expends = []
  95. this.isClickId = ''
  96. this.$nextTick(()=>{
  97. this.handleClick()
  98. })
  99. }
  100. }
  101. },
  102. name(){
  103. if(this.name!=2){
  104. this.show = false
  105. }
  106. },
  107. },
  108. created() {
  109. window.addEventListener("resize", this.handleResize);
  110. },
  111. mounted() {
  112. this.handleResize();
  113. this.initData();
  114. },
  115. methods: {
  116. handleClick(tab, event) {
  117. this.tabItem = this.tabs.find(item=>{
  118. return item.name == this.name
  119. })
  120. this.show = true
  121. if (this.name == 2 && !this.patent.patentRightTree) {
  122. let params = {
  123. patentNo: this.patent.patentNo,
  124. appNo: this.patent.rowApplicationNo,
  125. }
  126. this.$api
  127. .getPatentRightTree(params)
  128. .then((response) => {
  129. if (response.code == 200) {
  130. this.$set(this.patent, "patentRightTree", response.data.data);
  131. this.$nextTick(()=>{
  132. this.getEchart();
  133. })
  134. }
  135. });
  136. } else if(this.name == 2 && this.patent.patentRightTree) {
  137. this.$nextTick(()=>{
  138. this.getEchart();
  139. })
  140. }
  141. },
  142. imageDownLoad(){
  143. var dom = document.getElementById('charts')
  144. html2canvas(dom).then(canvas => {
  145. // 转成图片,生成图片地址
  146. var imgUrl = canvas.toDataURL("image/png");
  147. var blob = this.base64ToBlob(imgUrl)
  148. var eleLink = document.createElement("a");
  149. eleLink.href = URL.createObjectURL(blob); // 转换后的图片地址
  150. eleLink.download = "权要树";
  151. document.body.appendChild(eleLink);
  152. // 触发点击
  153. eleLink.click();
  154. // 然后移除
  155. document.body.removeChild(eleLink);
  156. // const link = document.createElement('a')
  157. // let url = URL.createObjectURL(blob)
  158. // link.href = url
  159. // link.download = item.url.substring(0,item.url.indexOf('?'))
  160. // link.click()
  161. });
  162. },
  163. base64ToBlob(data){
  164. var dataUrl = data.replace('data:image/png;base64,','')
  165. let bstr = window.atob(dataUrl)
  166. let n = bstr.length
  167. let u8arr = new Uint8Array(n)
  168. while (n--) {
  169. u8arr[n] = bstr.charCodeAt(n);
  170. }
  171. return new Blob([u8arr], { type: "image/png" });
  172. },
  173. getData(data) {
  174. data.forEach((item) => {
  175. item.name = Number(item.sort) + 1;
  176. if (item.children && item.children.length > 0) {
  177. this.getData(item.children);
  178. }
  179. });
  180. },
  181. getEchart() {
  182. var data = JSON.parse(JSON.stringify(this.patent.patentRightTree));
  183. this.getData(data);
  184. var that = this
  185. data.forEach((item,index) => {
  186. var option = {
  187. // height: "100%",
  188. backgroundColor: "#fbfbfb",
  189. series: [
  190. {
  191. itemStyle: {
  192. normal: {
  193. color: "#06c",
  194. borderColor: "#06c",
  195. },
  196. emphasis: {
  197. borderColor: "#06c",
  198. color: "#06c",
  199. },
  200. },
  201. lineStyle: {
  202. color: "#2979ff",
  203. },
  204. type: "tree",
  205. data: [item],
  206. // top: "1%",
  207. left: "100px",
  208. // bottom: "1%",
  209. right: "100px",
  210. symbolSize: 0,
  211. symbol: "emptyCircle",
  212. label: {
  213. position: "left",
  214. verticalAlign: "middle",
  215. align: "right",
  216. color: "#293c55",
  217. margin: [2, 4],
  218. borderWidth: 1,
  219. borderColor: "#aaa",
  220. backgroundColor: "white",
  221. borderRadius: 2,
  222. padding: [5, 4],
  223. rich: {
  224. keywords: {
  225. color: "red",
  226. fontSize: "12",
  227. },
  228. index: {
  229. fontSize: 12,
  230. color: "#2979ff",
  231. position: "10%",
  232. },
  233. },
  234. formatter: function(data, data1) {
  235. // rgb(178, 215, 255)
  236. if(data.data.sort+'' == that.isClickId){
  237. data.data.label = {
  238. fontSize: 12,
  239. padding: [5, 4],
  240. backgroundColor: 'rgb(178, 215, 255)',
  241. borderColor: '#aaa',
  242. color: '#293c55',
  243. }
  244. // }else{
  245. // data.data.label = {
  246. // fontSize: 12,
  247. // padding: [5, 4],
  248. // backgroundColor: 'white',
  249. // borderColor: '#aaa',
  250. // color: '#293c55',
  251. // }
  252. }
  253. },
  254. },
  255. leaves: {
  256. label: {
  257. position: "right",
  258. verticalAlign: "middle",
  259. align: "left",
  260. },
  261. },
  262. expandAndCollapse: false,
  263. animationDuration: 550,
  264. animationDurationUpdate: 750,
  265. }
  266. ],
  267. };
  268. this.sendingChart(option,index);
  269. });
  270. },
  271. sendingChart(option,index) {
  272. var myChart = this.$echarts.init(document.getElementById("chart"+index));
  273. myChart.clear();
  274. var option = option;
  275. option && myChart.setOption(option);
  276. myChart.on("click", (param) => {
  277. this.showRightPosition(param.data.sort);
  278. var dom = document.getElementById("chart")
  279. if(!this.isClick){
  280. this.scrollTop = dom.scrollTop
  281. }
  282. this.isClick = true
  283. this.show = false
  284. this.$nextTick(()=>{
  285. this.show = true
  286. this.$nextTick(()=>{
  287. this.getEchart()
  288. this.isClick = false
  289. document.getElementById("chart").scrollTop = this.scrollTop
  290. })
  291. })
  292. });
  293. const eleArr = Array.from(new Set(myChart._chartsViews[0]._data._graphicEls))
  294. const itemHeight = 50
  295. const currentHeight = itemHeight * (eleArr.length-1) || itemHeight
  296. const newHeight = Math.max(currentHeight,itemHeight)
  297. myChart.resize({
  298. height:newHeight+50
  299. })
  300. },
  301. showRightPosition(id) {
  302. var index = this.expends.indexOf(id);
  303. if (index == -1) {
  304. this.expends.push(id);
  305. }else{
  306. this.expends.splice(1,index)
  307. this.expends.push(id);
  308. }
  309. if (this.isClickId + "") {
  310. var dom1 = document.getElementById("right" + this.isClickId);
  311. dom1.style.background = "";
  312. }
  313. this.isClickId = id;
  314. var dom = document.getElementById("right" + id);
  315. dom.style.background = "rgb(178, 215, 255)";
  316. this.$nextTick(()=>{
  317. this.tiaozhuan(id)
  318. })
  319. },
  320. tiaozhuan(id) {
  321. const href = `#right${id}`
  322. const anchor = document.createElement('a');
  323. anchor.href = href;
  324. anchor.style.display = "none";
  325. document.body.appendChild(anchor);
  326. setTimeout(function () {
  327. anchor.click();
  328. document.body.removeChild(anchor);
  329. }, 66);
  330. return true;
  331. },
  332. initData() {
  333. if (this.outside) {
  334. var params = {
  335. // patentCell: 1,
  336. appNo: this.patent.rowApplicationNo,
  337. // pageNum: 1,
  338. // pageSize:10,
  339. // appNo: this.patent.applicationNo,
  340. };
  341. this.$api.queryExternalClaim(params).then((response) => {
  342. if (response.code == 200) {
  343. this.$set(this.patent, "claim", response.data.claimContent);
  344. }
  345. });
  346. }
  347. },
  348. handleResize(event) {
  349. this.fullHeight = document.documentElement.clientHeight;
  350. this.height = this.fullHeight - 350;
  351. },
  352. },
  353. };
  354. </script>
  355. <style lang="scss">
  356. .patent-articles-patent-right {
  357. // margin-bottom: 20px;
  358. .common {
  359. // font-size: 14px;
  360. margin-top: 0;
  361. padding-right: 5px;
  362. word-break: break-all;
  363. }
  364. .title {
  365. font-weight: bold;
  366. border-bottom: 1px solid #e6e6e6;
  367. padding-bottom: 5px;
  368. margin-top: 0;
  369. }
  370. }
  371. </style>
  372. <style lang="scss" scoped>
  373. </style>