index.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. export const projectData = {
  2. props: {
  3. // 视图数据源
  4. tableData: {
  5. type: Array,
  6. default: () => {
  7. return []
  8. }
  9. },
  10. // 分页信息
  11. queryParams: {
  12. type: Object,
  13. default: () => {
  14. return {
  15. current: 1,
  16. size: 10
  17. }
  18. }
  19. },
  20. // 栏位
  21. column: {
  22. type: Array,
  23. default: () => {
  24. return []
  25. }
  26. },
  27. //专利号
  28. projectId: {
  29. default: 0
  30. },
  31. //选择专利
  32. refresh: {
  33. default: false
  34. },
  35. patentNoList: {
  36. type: Array,
  37. default: () => {
  38. return []
  39. }
  40. },
  41. outside: {
  42. default: false
  43. },
  44. },
  45. data() {
  46. return {
  47. }
  48. },
  49. mounted() {
  50. },
  51. methods: {
  52. // 点击专利号
  53. handleClick(row, index) {
  54. var location = (index + 1) + ((this.queryParams.current - 1) * this.queryParams.size)
  55. this.$emit('clickPatentNo', row, location)
  56. },
  57. changeSelect(patent) {
  58. const index1 = this.patentNoList.indexOf(patent.patentNo)
  59. if (index1 === -1) {
  60. if (this.projectId) {
  61. this.patentNoList.push(patent.patentNo)
  62. } else {
  63. this.patentNoList.push(patent.appNo)
  64. }
  65. } else {
  66. this.patentNoList.splice(index1, 1)
  67. }
  68. this.$emit('addSelect', patent.patentNo)
  69. }
  70. },
  71. }
  72. import { mapGetters } from "vuex"
  73. export const handleData = {
  74. // mixins: [highlight],
  75. props: {
  76. },
  77. data() {
  78. return {
  79. //专利类型
  80. patentType: {
  81. 1: '发明',
  82. 8: '发明',
  83. 2: '实用新型',
  84. 9: '实用新型',
  85. 3: '外观',
  86. },
  87. // 专利状态
  88. simpleStatus: {
  89. 1: '有效',
  90. 2: '无效',
  91. 3: '审中',
  92. },
  93. // 法律状态(暂定)
  94. legalStatus: {
  95. 1: '有效',
  96. 2: '无效',
  97. 3: '审中',
  98. },
  99. }
  100. },
  101. computed: {
  102. ...mapGetters(['highlight'])
  103. },
  104. mounted() {
  105. },
  106. methods: {
  107. getView(row, key, type, prop, data) {
  108. var obj = {
  109. type: type ? type : 'String',
  110. value: key
  111. }
  112. if (row) {
  113. const change2 = row.change2
  114. const change = row.change
  115. switch (key) {
  116. case "title":
  117. // prop = !change ? "content" : "contentOut"
  118. // obj.type = 'Object'
  119. var arr = row.title
  120. if (!arr) {
  121. text = ''
  122. break
  123. }
  124. if (!change) {
  125. var obj = arr.find(item => {
  126. return item.if_origin
  127. })
  128. var text = ''
  129. if (obj) {
  130. text = obj.text_content
  131. }
  132. } else {
  133. var obj = arr.find(item => {
  134. return !item.if_origin && item.language == 'CN'
  135. })
  136. var text = ''
  137. if (obj) {
  138. text = obj.text_content
  139. }
  140. }
  141. break
  142. case "abstractStr":
  143. // prop = !change2 ? "content" : "contentOut"
  144. // obj.type = 'Object'
  145. var arr = row.abstractStr
  146. if (!arr) {
  147. text = ''
  148. break
  149. }
  150. if (!change2) {
  151. var obj = arr.find(item => {
  152. return item.if_origin
  153. })
  154. var text = ''
  155. if (obj) {
  156. text = obj.text_content
  157. }
  158. } else {
  159. var obj = arr.find(item => {
  160. return !item.if_origin && item.language == 'CN'
  161. })
  162. var text = ''
  163. if (obj) {
  164. text = obj.text_content
  165. }
  166. }
  167. break;
  168. case "mipc"://ipc
  169. case 'inventor'://发明人
  170. case 'applicant'://申请人
  171. case 'rightHolder'://权利人
  172. let ipcArr = []
  173. for (let k in row[key]) {
  174. ipcArr.push(row[key][k])
  175. }
  176. row[`${key}2`] = ipcArr
  177. obj.value = `${key}2`
  178. obj.type = 'Array'
  179. var text = this.$commonJS.getColumnData(row, obj, prop, data)
  180. break;
  181. case 'legalStatus'://法律状态
  182. case 'simpleStatus'://专利状态
  183. case 'patentType'://专利类型
  184. var text = this[key][row[key]]
  185. break;
  186. default:
  187. var text = this.$commonJS.getColumnData(row, obj, prop, data)
  188. break
  189. }
  190. // var text = this.$commonJS.getColumnData(row, obj, prop, data)
  191. // console.log(text,key);
  192. return this.getViewDom(text, type)
  193. }
  194. },
  195. getViewDom(text, field,) {
  196. if (!text) {
  197. return ""
  198. }
  199. var obj = null
  200. switch (field) {
  201. case '权利要求原文':
  202. obj = text.find(item => {
  203. return item.if_origin
  204. })
  205. text = obj ? obj.text_content : ''
  206. break;
  207. case '权利要求译文':
  208. obj = text.find(item => {
  209. return item.if_origin == false
  210. })
  211. text = obj ? obj.text_content : ''
  212. break;
  213. case '说明书文本原文':
  214. obj = text.find(item => {
  215. return item.if_origin
  216. })
  217. var data = obj.text_content.split('\r\n').join('<br/>')
  218. text = data ? data : ''
  219. break;
  220. case '说明书文本译文':
  221. obj = text.find(item => {
  222. return item.if_origin == false
  223. })
  224. var data = obj.text_content.split('\r\n').join('<br/>')
  225. text = data ? data : ''
  226. break;
  227. default:
  228. break;
  229. }
  230. if (this.patent && this.patent.patentNo && field) {
  231. // SET_PATENT_OPINION_CONTRAST
  232. var arr = ['piZhuContrastList', 'contrastList', 'opinionContrastList']
  233. arr.forEach((item, index) => {
  234. if (this.highlight[item].length > 0) {
  235. text = this.getObject(item, index, text, field)
  236. }
  237. });
  238. }
  239. if (!this.highlight.patentHightLight.ifEnable || !text) {
  240. return text
  241. }
  242. try {
  243. this.highlight.patentHightLight.configs.map(item => {
  244. const keywords = item.keywords.split(';')
  245. for (let keyword of keywords) {
  246. if (!keyword) {
  247. continue
  248. }
  249. let sText = text
  250. let num = -1
  251. const rStr = new RegExp(keyword, "g")
  252. const rHtml = new RegExp("\<.*?\>", "ig")
  253. const sKey = `<span style="background: ${item.color};color: #fff">${keyword}</span>`
  254. const aHtml = sText.match(rHtml)
  255. sText = sText.replace(rHtml, '{~}')
  256. sText = sText.replace(rStr, sKey)
  257. sText = sText.replace(/{~}/g, () => {
  258. num++
  259. return aHtml[num]
  260. })
  261. text = sText
  262. }
  263. })
  264. } catch (e) {
  265. }
  266. // console.log(text);
  267. return text
  268. },
  269. getObject(key, index, text, field) {
  270. var arr1 = ['color', 'Type', 'Id', 'column', 'index', 'text', 'remark', 'temNode', 'selectType']
  271. var obj = {
  272. // 'piZhuContrastList': ['color', 'scratchType', 'id', 'scratchField', 'position', 'text', 'remark'],
  273. 'piZhuContrastList': ['markColor', 'markType', 'id', 'markSelectField', 'markSite', 'markSelectText', 'markNoteText'],
  274. 'contrastList': ['markColor', 'markType', 'id', 'fieldName', 'position', 'evidenceText'],
  275. // 'opinionContrastList': ['color', 'scratchType', 'id', 'scratchField', 'position', 'content'],
  276. 'opinionContrastList': ['markColor', 'markType', 'id', 'scratchField', 'position', 'content'],
  277. }
  278. var selectType = ['p', 'c', 'o']
  279. var row = this.highlight[key]
  280. if (row.length > 0) {
  281. for (let i = 0; i < row.length; i++) {
  282. if (row[i].patentNo == this.patent.patentNo || (key == 'contrastList'&& (this.patent.patentNo != this.signPatentNo) && this.evidence && row[i].literatureId == this.evidence.id)) {
  283. if (row[i][obj[key][3]].indexOf(field) != -1) {
  284. var a = {}
  285. a.Type = 1
  286. obj[key].forEach((item, index1) => {
  287. if (item) {
  288. if (arr1[index1] == 'index') {
  289. a[arr1[index1]] = Number(row[i][item])
  290. } else {
  291. a[arr1[index1]] = row[i][item]
  292. }
  293. }
  294. });
  295. a.temNode = text
  296. a.selectType = selectType[index]
  297. text = this.AddClass1(a);
  298. }
  299. }
  300. }
  301. return text
  302. }
  303. },
  304. //切换原文译文
  305. handleChange(row, key) {
  306. switch (key) {
  307. case "title":
  308. this.$set(row, 'change', !row.change)
  309. break
  310. case "abstractStr":
  311. this.$set(row, 'change2', !row.change2)
  312. // row.change2 = !row.change2
  313. break
  314. }
  315. },
  316. },
  317. }
  318. export const highlight = {
  319. data() {
  320. return {
  321. }
  322. },
  323. computed: {
  324. // piZhuContrastList() {
  325. // return this.$store.state.highlight.piZhuContrastList
  326. // },
  327. // contrastList() {
  328. // return this.$store.state.highlight.contrastList
  329. // },
  330. // opinionContrastList() {
  331. // return this.$store.state.highlight.opinionContrastList
  332. // },
  333. },
  334. mounted() {
  335. window.mouseenter1 = this.mouseenter1
  336. window.mouseleave1 = this.mouseleave1
  337. },
  338. methods: {
  339. mouseenter1(e, id, selectType) {
  340. var dom = document.getElementsByClassName(id)
  341. var message = this.getMessage(id, selectType)
  342. // 普通for循环可以拿到dom节点,forEach是拿不到dom节点
  343. for (let i = 0; i < dom.length - 1; i++) {
  344. dom[i].classList.add('greenColor')
  345. this.getChildNodesAdd(dom[i].childNodes)
  346. }
  347. // e.target是获取当前的,dom获取的是所有的class相同的节点
  348. e.target.parentNode.classList.add("pizhuLightHeigh");
  349. if (message.remark) {
  350. e.target.parentNode.appendChild(this.addPara(message.remark, e));
  351. }
  352. },
  353. getMessage(id, selectType) {
  354. var Id = id.substring(1, id.length)
  355. var messageItem = {}
  356. if (selectType == 'p') {//批注
  357. var messageItem = this.highlight.piZhuContrastList.find(item => {
  358. return item.id == Id
  359. })
  360. } else if (selectType == 'c') {//对比
  361. var messageItem = this.highlight.contrastList.find(item => {
  362. return item.id == Id
  363. })
  364. } else if (selectType == 'o') {//
  365. var messageItem = this.highlight.opinionContrastList.find(item => {
  366. return item.id == Id
  367. })
  368. }
  369. return messageItem
  370. },
  371. // 添加背景色
  372. getChildNodesAdd(dom) {
  373. if (dom.length > 0) {
  374. for (let m = 0; m < dom.length; m++) {
  375. if (dom[m].nodeType == 1) {
  376. dom[m].classList.add('greenColor')
  377. }
  378. if (dom[m].childNodes.length > 0) {
  379. this.getChildNodesAdd(dom[m].childNodes)
  380. }
  381. }
  382. }
  383. },
  384. addPara(val, e) {
  385. //创建div标签
  386. var p = document.createElement("div");
  387. //添加class
  388. p.classList.add('showPiZhu')
  389. if (e.clientY - 200 < 200 && e.clientX + 200 > document.documentElement.clientWidth) {
  390. p.setAttribute('style', 'left:-200px')
  391. } else if ((e.clientX + 200 > document.documentElement.clientWidth && e.clientY + 200 > document.documentElement.clientHeight) || e.clientX + 200 > document.documentElement.clientWidth) {
  392. p.setAttribute('style', 'bottom:25px;left:-200px;')
  393. } else if ((e.clientY + 200 > document.documentElement.clientHeight && e.clientX - 200 < 200) || (e.clientY + 200 > document.documentElement.clientHeight && e.clientX - 200 > 200)) {
  394. p.setAttribute('style', 'bottom:20px;left:10px')
  395. }
  396. //创建文本节点
  397. var text = document.createTextNode(val);
  398. //将文本节点追加到元素节点中
  399. p.appendChild(text);
  400. return p
  401. },
  402. mouseleave1(e, id, selectType) {
  403. var dom = document.getElementsByClassName(id)
  404. e.target.parentNode.classList.remove("pizhuLightHeigh");
  405. var message = this.getMessage(id, selectType)
  406. if (message.remark) {
  407. document.getElementsByClassName('showPiZhu')[0].remove()
  408. }
  409. for (let i = 0; i < dom.length - 1; i++) {
  410. dom[i].classList.remove('greenColor')
  411. this.getChildNodesRemove(dom[i].childNodes)
  412. }
  413. },
  414. // 删除背景色
  415. getChildNodesRemove(dom) {
  416. if (dom.length > 0) {
  417. for (let m = 0; m < dom.length; m++) {
  418. if (dom[m].nodeType == 1) {
  419. dom[m].classList.remove('greenColor')
  420. }
  421. if (dom[m].childNodes.length > 0) {
  422. this.getChildNodesRemove(dom[m].childNodes)
  423. }
  424. }
  425. }
  426. },
  427. AddClass1(selectObject) {
  428. let el = selectObject.temNode;
  429. // 将当前页面获取到的字符串进行处理,返回当前页面所有的标签及文本
  430. var splitStrings = this.SplitHtmlTag1(el);
  431. let bgColor = selectObject.color;
  432. if (!bgColor) {
  433. selectObject.color = 'yellow'
  434. }
  435. // 添加线及高亮(2:波浪线,0:下划线,1:高亮)
  436. var style = ''
  437. switch (selectObject.Type + '') {
  438. case '0'://下划线
  439. style = `text-decoration-line: underline;text-decoration-color: ${selectObject.color}`
  440. break;
  441. case '1'://高亮
  442. style = `background-color:${selectObject.color}`
  443. break;
  444. case '2'://波浪线
  445. style = `text-decoration-line: underline;text-decoration-style: wavy ;text-decoration-color: ${selectObject.color}`
  446. break;
  447. }
  448. let startTag = `<span class="${selectObject.selectType + selectObject.Id}" id="${selectObject.selectType + selectObject.Id}" style="${style}">`
  449. //图标
  450. var a = 'icon-xinxi3'
  451. switch (selectObject.selectType) {
  452. case 'p'://批注
  453. a = 'iconfont icon-xinxi3'
  454. break;
  455. case 'c'://对比
  456. a = 'el-icon-location-outline'
  457. break;
  458. case 'o'://陈述意见
  459. a = 'iconfont icon-xinxi2'
  460. break;
  461. case 'r'://特征
  462. break
  463. }
  464. var imgTag = `<span class="${selectObject.selectType + selectObject.Id}" style="background-color:white !important;"><i class="${a}" style="vertical-align: super;background-color:white !important;" onclick="vm.selectMark('${selectObject.selectType + selectObject.Id}','${selectObject.selectType}')" onmouseenter="mouseenter1(event,'${selectObject.selectType + selectObject.Id}','${selectObject.selectType}')" onmouseleave="mouseleave1(event,'${selectObject.selectType + selectObject.Id}','${selectObject.selectType}')"></i></span>`
  465. if (selectObject.selectType == 'r') {//特征
  466. imgTag = `<span class="${selectObject.selectType + selectObject.Id}" style="background-color:white !important;"><i class="el-icon-delete" style="vertical-align: super;background-color:white !important;" onclick="deleteFeature('${selectObject.selectType + selectObject.Id}','${selectObject.selectType}')"></i></span>`
  467. }
  468. let endTag = '</span>';
  469. let elText = '';
  470. splitStrings.forEach(function (item) {
  471. if (item.type == 'text') {
  472. elText = elText + item.text;
  473. }
  474. });
  475. let Indexs = [];
  476. let i = 0
  477. if (selectObject.index < 0) {
  478. let pattern = new RegExp(selectObject.text.replace(/[\r\n]/g, "").replace(/\ +/g, ""), "g");
  479. while ((match = pattern.exec(elText)) != null) {
  480. Indexs[i] = match;
  481. i++;
  482. }
  483. } else {
  484. Indexs[i] = [selectObject.text];
  485. Indexs[i].index = selectObject.index;
  486. }
  487. Indexs.forEach(function (match) {
  488. let currentIndex = 0;
  489. let temSplitStrings = new Array();
  490. splitStrings.forEach(function (item) {
  491. if (item.type == 'text') {
  492. if (item.text) {
  493. if (match.index >= currentIndex && match.index < (currentIndex + item.text.length)) {
  494. if ((match.index + match[0].length) <= (currentIndex + item.text.length) && item.text.indexOf(match[0]) != -1) {
  495. if (match.index > currentIndex) {
  496. temSplitStrings.push({ text: item.text.substring(0, match.index - currentIndex), type: 'text' });
  497. }
  498. temSplitStrings.push({ text: startTag, type: 'tag' });
  499. temSplitStrings.push({ text: match[0], type: 'text' });
  500. temSplitStrings.push({ text: imgTag, type: 'tag' });
  501. // }
  502. temSplitStrings.push({ text: endTag, type: 'tag' });
  503. if ((match.index + match[0].length) < (currentIndex + item.text.length)) {
  504. temSplitStrings.push({ text: item.text.substring((match.index + match[0].length) - currentIndex), type: 'text' });
  505. }
  506. } else {
  507. if (item.text.indexOf(match[0]) != -1) {
  508. if (match.index > currentIndex) {
  509. temSplitStrings.push({ text: item.text.substring(0, match.index - currentIndex), type: 'text' });
  510. }
  511. if (temSplitStrings.length > 1) {
  512. temSplitStrings.push({ text: startTag, type: 'tag' });
  513. } else {
  514. temSplitStrings.push({ text: startTag, type: 'tag' });
  515. }
  516. temSplitStrings.push({ text: item.text.substring(match.index - currentIndex), type: 'text' });
  517. temSplitStrings.push({ text: endTag, type: 'tag' });
  518. } else {
  519. // console.log(temSplitStrings,match.index,item.text,currentIndex,match[0])
  520. // debugger
  521. temSplitStrings.push({ text: item.text.substring(0, match.index - currentIndex), type: 'text' });
  522. temSplitStrings.push({ text: startTag, type: 'tag' });
  523. temSplitStrings.push({ text: item.text.substring(match.index - currentIndex, item.text.length), type: 'text' });
  524. // temSplitStrings.push({ text: imgTag, type: 'tag' });
  525. temSplitStrings.push({ text: endTag, type: 'tag' });
  526. // return false
  527. // temSplitStrings.push(item);
  528. }
  529. }
  530. } else {
  531. if ((match.index + match[0].length) <= (currentIndex + item.text.length) && (match.index + match[0].length) > currentIndex) {
  532. temSplitStrings.push({ text: startTag, type: 'tag' });
  533. temSplitStrings.push({ text: item.text.substring(0, match.index + match[0].length - currentIndex), type: 'text' });
  534. temSplitStrings.push({ text: imgTag, type: 'tag' });
  535. temSplitStrings.push({ text: endTag, type: 'tag' });
  536. if ((match.index + match[0].length) < (currentIndex + item.text.length)) {
  537. temSplitStrings.push({ text: item.text.substring((match.index + match[0].length - currentIndex)), type: 'text' });
  538. }
  539. } else {
  540. if (match.index < currentIndex && (match.index + match[0].length) >= (currentIndex + item.text.length)) {
  541. temSplitStrings.push({ text: startTag, type: 'tag' });
  542. temSplitStrings.push(item);
  543. temSplitStrings.push({ text: endTag, type: 'tag' });
  544. } else {
  545. temSplitStrings.push(item);
  546. }
  547. }
  548. }
  549. currentIndex = currentIndex + item.text.length;
  550. } else {
  551. temSplitStrings.push(item);
  552. }
  553. } else {
  554. temSplitStrings.push(item);
  555. }
  556. });
  557. splitStrings = temSplitStrings;
  558. });
  559. let temInnerHtml = '';
  560. splitStrings.forEach(function (item) {
  561. temInnerHtml = temInnerHtml + item.text;
  562. });
  563. return temInnerHtml;
  564. },
  565. SplitHtmlTag1(el) {
  566. let temInnerHtml = el.trim();
  567. let pattern = /<[^>]+>/g;
  568. let Indexs = [];
  569. let i = 0
  570. var match = null
  571. while ((match = pattern.exec(temInnerHtml)) != null) {
  572. Indexs[i] = match;
  573. i++;
  574. }
  575. var splitStrings = new Array();
  576. i = 0;
  577. var currentIndex = 0;
  578. for (var index = 0; index < Indexs.length; index++) {
  579. if (Indexs[index].index > currentIndex) {
  580. splitStrings[i] = { "text": temInnerHtml.substring(currentIndex, Indexs[index].index), "type": "text" };
  581. i++;
  582. splitStrings[i] = { "text": Indexs[index][0], "type": "tag" };
  583. i++;
  584. } else {
  585. splitStrings[i] = { "text": Indexs[index][0], "type": "tag" };
  586. i++;
  587. }
  588. currentIndex = Indexs[index].index + Indexs[index][0].length;
  589. }
  590. if (currentIndex < temInnerHtml.length) {
  591. splitStrings[i] = { "text": temInnerHtml.substring(currentIndex, temInnerHtml.length), "type": "text" };
  592. }
  593. return splitStrings;
  594. },
  595. },
  596. }