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