PatentRight.vue 11 KB

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