PatentRight.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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-loading="loading" 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. patentNo() {
  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. name(){
  90. if(this.name!=2){
  91. this.show = false
  92. }
  93. },
  94. },
  95. created() {
  96. window.addEventListener("resize", this.handleResize);
  97. },
  98. mounted() {
  99. this.handleResize();
  100. this.initData();
  101. },
  102. methods: {
  103. handleClick(tab, event) {
  104. this.tabItem = this.tabs.find(item=>{
  105. return item.name == this.name
  106. })
  107. this.show = true
  108. if (this.name == 2 && !this.patent.patentRightTree) {
  109. let params = {
  110. patentNo: this.patent.patentNo,
  111. appNo: this.patent.rowApplicationNo,
  112. }
  113. this.$api
  114. .getPatentRightTree(params)
  115. .then((response) => {
  116. if (response.code == 200) {
  117. this.$set(this.patent, "patentRightTree", response.data.data);
  118. this.$nextTick(()=>{
  119. this.getEchart();
  120. })
  121. }
  122. });
  123. } else if(this.name == 2 && this.patent.patentRightTree) {
  124. this.$nextTick(()=>{
  125. this.getEchart();
  126. })
  127. }
  128. },
  129. imageDownLoad(){
  130. var dom = document.getElementById('charts')
  131. html2canvas(dom).then(canvas => {
  132. // 转成图片,生成图片地址
  133. var imgUrl = canvas.toDataURL("image/png");
  134. var blob = this.base64ToBlob(imgUrl)
  135. var eleLink = document.createElement("a");
  136. eleLink.href = URL.createObjectURL(blob); // 转换后的图片地址
  137. eleLink.download = "权要树";
  138. document.body.appendChild(eleLink);
  139. // 触发点击
  140. eleLink.click();
  141. // 然后移除
  142. document.body.removeChild(eleLink);
  143. // const link = document.createElement('a')
  144. // let url = URL.createObjectURL(blob)
  145. // link.href = url
  146. // link.download = item.url.substring(0,item.url.indexOf('?'))
  147. // link.click()
  148. });
  149. },
  150. base64ToBlob(data){
  151. var dataUrl = data.replace('data:image/png;base64,','')
  152. let bstr = window.atob(dataUrl)
  153. let n = bstr.length
  154. let u8arr = new Uint8Array(n)
  155. while (n--) {
  156. u8arr[n] = bstr.charCodeAt(n);
  157. }
  158. return new Blob([u8arr], { type: "image/png" });
  159. },
  160. getData(data) {
  161. data.forEach((item) => {
  162. item.name = Number(item.sort) + 1;
  163. if (item.children && item.children.length > 0) {
  164. this.getData(item.children);
  165. }
  166. });
  167. },
  168. getEchart() {
  169. var data = JSON.parse(JSON.stringify(this.patent.patentRightTree));
  170. this.getData(data);
  171. var that = this
  172. data.forEach((item,index) => {
  173. var option = {
  174. // height: "100%",
  175. backgroundColor: "#fbfbfb",
  176. series: [
  177. {
  178. itemStyle: {
  179. normal: {
  180. color: "#06c",
  181. borderColor: "#06c",
  182. },
  183. emphasis: {
  184. borderColor: "#06c",
  185. color: "#06c",
  186. },
  187. },
  188. lineStyle: {
  189. color: "#2979ff",
  190. },
  191. type: "tree",
  192. data: [item],
  193. // top: "1%",
  194. left: "100px",
  195. // bottom: "1%",
  196. right: "100px",
  197. symbolSize: 0,
  198. symbol: "emptyCircle",
  199. label: {
  200. position: "left",
  201. verticalAlign: "middle",
  202. align: "right",
  203. color: "#293c55",
  204. margin: [2, 4],
  205. borderWidth: 1,
  206. borderColor: "#aaa",
  207. backgroundColor: "white",
  208. borderRadius: 2,
  209. padding: [5, 4],
  210. rich: {
  211. keywords: {
  212. color: "red",
  213. fontSize: "12",
  214. },
  215. index: {
  216. fontSize: 12,
  217. color: "#2979ff",
  218. position: "10%",
  219. },
  220. },
  221. formatter: function(data, data1) {
  222. // rgb(178, 215, 255)
  223. if(data.data.sort+'' == that.isClickId){
  224. data.data.label = {
  225. fontSize: 12,
  226. padding: [5, 4],
  227. backgroundColor: 'rgb(178, 215, 255)',
  228. borderColor: '#aaa',
  229. color: '#293c55',
  230. }
  231. // }else{
  232. // data.data.label = {
  233. // fontSize: 12,
  234. // padding: [5, 4],
  235. // backgroundColor: 'white',
  236. // borderColor: '#aaa',
  237. // color: '#293c55',
  238. // }
  239. }
  240. },
  241. },
  242. leaves: {
  243. label: {
  244. position: "right",
  245. verticalAlign: "middle",
  246. align: "left",
  247. },
  248. },
  249. expandAndCollapse: false,
  250. animationDuration: 550,
  251. animationDurationUpdate: 750,
  252. }
  253. ],
  254. };
  255. this.sendingChart(option,index);
  256. });
  257. },
  258. sendingChart(option,index) {
  259. var myChart = this.$echarts.init(document.getElementById("chart"+index));
  260. myChart.clear();
  261. var option = option;
  262. option && myChart.setOption(option);
  263. myChart.on("click", (param) => {
  264. this.showRightPosition(param.data.sort);
  265. var dom = document.getElementById("chart")
  266. if(!this.isClick){
  267. this.scrollTop = dom.scrollTop
  268. }
  269. this.isClick = true
  270. this.show = false
  271. this.$nextTick(()=>{
  272. this.show = true
  273. this.$nextTick(()=>{
  274. this.getEchart()
  275. this.isClick = false
  276. document.getElementById("chart").scrollTop = this.scrollTop
  277. })
  278. })
  279. });
  280. const eleArr = Array.from(new Set(myChart._chartsViews[0]._data._graphicEls))
  281. const itemHeight = 50
  282. const currentHeight = itemHeight * (eleArr.length-1) || itemHeight
  283. const newHeight = Math.max(currentHeight,itemHeight)
  284. myChart.resize({
  285. height:newHeight+50
  286. })
  287. },
  288. showRightPosition(id) {
  289. var index = this.expends.indexOf(id);
  290. if (index == -1) {
  291. this.expends.push(id);
  292. }else{
  293. this.expends.splice(1,index)
  294. this.expends.push(id);
  295. }
  296. if (this.isClickId + "") {
  297. var dom1 = document.getElementById("right" + this.isClickId);
  298. dom1.style.background = "";
  299. }
  300. this.isClickId = id;
  301. var dom = document.getElementById("right" + id);
  302. dom.style.background = "rgb(178, 215, 255)";
  303. this.$nextTick(()=>{
  304. this.tiaozhuan(id)
  305. })
  306. },
  307. tiaozhuan(id) {
  308. const href = `#right${id}`
  309. const anchor = document.createElement('a');
  310. anchor.href = href;
  311. anchor.style.display = "none";
  312. document.body.appendChild(anchor);
  313. setTimeout(function () {
  314. anchor.click();
  315. document.body.removeChild(anchor);
  316. }, 66);
  317. return true;
  318. },
  319. initData() {
  320. if (this.outside) {
  321. var params = {
  322. // patentCell: 1,
  323. appNo: this.patent.rowApplicationNo,
  324. // pageNum: 1,
  325. // pageSize:10,
  326. // appNo: this.patent.applicationNo,
  327. };
  328. this.loading = true
  329. this.$api.queryExternalClaim(params).then((response) => {
  330. if (response.code == 200) {
  331. this.$set(this.patent, "claim", response.data.claimContent);
  332. this.loading = false
  333. }
  334. }).catch(error=>{
  335. this.loading = false
  336. })
  337. }
  338. },
  339. handleResize(event) {
  340. this.fullHeight = document.documentElement.clientHeight;
  341. this.height = this.fullHeight - 350;
  342. },
  343. },
  344. };
  345. </script>
  346. <style lang="scss">
  347. .patent-articles-patent-right {
  348. // margin-bottom: 20px;
  349. .common {
  350. // font-size: 14px;
  351. margin-top: 0;
  352. padding-right: 5px;
  353. word-break: break-all;
  354. }
  355. .title {
  356. font-weight: bold;
  357. border-bottom: 1px solid #e6e6e6;
  358. padding-bottom: 5px;
  359. margin-top: 0;
  360. }
  361. }
  362. </style>
  363. <style lang="scss" scoped>
  364. </style>