index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. data() {
  29. return {
  30. }
  31. },
  32. mounted() {
  33. },
  34. methods: {
  35. // 点击专利号
  36. handleClick(row,key){},
  37. },
  38. }
  39. export const handleData = {
  40. // mixins: [highlight],
  41. props: {
  42. selected: {
  43. type: Array
  44. },
  45. patentNoList:{
  46. type: Array
  47. }
  48. },
  49. data() {
  50. return {
  51. refresh: true,
  52. click: false,
  53. projectId:''
  54. }
  55. },
  56. mounted() {
  57. },
  58. methods: {
  59. getViewDom2(row, key, field) {
  60. let text = ""
  61. const change = row.change
  62. text = !change ? row[key][0].text_content : row[key][1].text_content
  63. return this.getViewDom(text,field)
  64. },
  65. getView(row,key,type,prop,data) {
  66. var obj = {
  67. type: type?type:'String',
  68. value: key
  69. }
  70. var text = this.$commonJS.getColumnData(row, obj,prop,data)
  71. return this.getViewDom(text,key)
  72. },
  73. getViewDom(text, field) {
  74. if(!text){
  75. return ""
  76. }
  77. // if (this.contrastList.length > 0) {
  78. // for (let i = 0; i < this.contrastList.length; i++) {
  79. // if (this.contrastList[i].patentNo == this.patent.patentNo) {
  80. // if (this.contrastList[i].scratchField.indexOf(field) != -1) {
  81. // var a = {
  82. // color: this.contrastList[i].color,
  83. // Type: this.contrastList[i].scratchType,
  84. // Id: this.contrastList[i].id,
  85. // column: this.contrastList[i].scratchField,
  86. // index: Number(this.contrastList[i].position),
  87. // text: this.contrastList[i].text,
  88. // remark: this.contrastList[i].remark,
  89. // temNode: text
  90. // }
  91. // text = this.AddClass1(a);
  92. // }
  93. // }
  94. // }
  95. // }
  96. // if (!this.highlight.enable || !text) {
  97. // return text
  98. // }
  99. // try {
  100. // this.highlight.configs.map(item => {
  101. // const keywords = item.keywords.split(';')
  102. // for (let keyword of keywords) {
  103. // if (!keyword) {
  104. // continue
  105. // }
  106. // let sText = text
  107. // let num = -1
  108. // const rStr = new RegExp(keyword, "g")
  109. // const rHtml = new RegExp("\<.*?\>", "ig")
  110. // const sKey = `<span style="background: ${item.color};color: #fff">${keyword}</span>`
  111. // const aHtml = sText.match(rHtml)
  112. // sText = sText.replace(rHtml, '{~}')
  113. // sText = sText.replace(rStr, sKey)
  114. // sText = sText.replace(/{~}/g, () => {
  115. // num++
  116. // return aHtml[num]
  117. // })
  118. // text = sText
  119. // }
  120. // })
  121. // } catch (e) {
  122. // }
  123. return text
  124. },
  125. //切换原文译文
  126. handleChange(row, key) {
  127. switch (key) {
  128. case "name":
  129. row.change = !row.change
  130. break
  131. case "abstractStr":
  132. row.change2 = !row.change2
  133. break
  134. }
  135. },
  136. // 点击专利号进行跳转
  137. handleLink(row) {
  138. // window.open(router.href, '_blank');
  139. },
  140. // 勾选中专利进行处理
  141. changeSelect(patent) {
  142. this.click = true
  143. const index1 = this.patentNoList.indexOf(patent.patentNo)
  144. if (index1 === -1) {
  145. if(this.projectId){
  146. this.patentNoList.push(patent.patentNo)
  147. }else{
  148. this.patentNoList.push(patent.applicationNo)
  149. }
  150. } else {
  151. this.patentNoList.splice(index1, 1)
  152. }
  153. if(patent.id){
  154. const index = this.selected.indexOf(patent.id)
  155. if (index === -1) {
  156. this.selected.push(patent.id)
  157. } else {
  158. this.selected.splice(index, 1)
  159. }
  160. }
  161. this.$emit('select-change', this.selected)
  162. this.$emit('addSelect',patent.applicationNo)
  163. },
  164. },
  165. }
  166. export const highlight = {
  167. data() {
  168. return {
  169. }
  170. },
  171. methods: {
  172. AddClass1(selectObject) {
  173. let el = selectObject.temNode;
  174. // 将当前页面获取到的字符串进行处理,返回当前页面所有的标签及文本
  175. var splitStrings = this.SplitHtmlTag1(el);
  176. let bgColor = selectObject.color;
  177. // 添加线及高亮
  178. let startTag = '<span class="' + selectObject.Id + '" id="' + selectObject.Id + '" style="background-color:' + selectObject.color + '">';
  179. if (selectObject.Type == 0) {
  180. startTag = '<span class="' + selectObject.Id + '" id="' + selectObject.Id + '" style="border-bottom:2px solid ' + selectObject.color + '">';
  181. }
  182. if (selectObject.Type == 2) {
  183. startTag = '<span class = "' + selectObject.Id + '" id="' + selectObject.Id + '" style = "text-decoration-line: underline;text-decoration-style: wavy ;text-decoration-color: ' + selectObject.color + '">';
  184. }
  185. // let imgTag = '<span class="' + selectObject.Id + '" style="background-color:white !important;"><i class="el-icon-location-outline" style="vertical-align: super;background-color:white !important;" onclick="selectMark(\'' + selectObject.Id + '\')" onmouseenter="mouseenter1(event,\'' + selectObject.Id + '\')" onmouseleave="mouseleave1(event,\'' + selectObject.Id + '\')"></i></span>';
  186. let imgTag = '<span class="' + selectObject.Id + '" style="background-color:white !important;"><i class="iconfont icon-xinxi3" style="vertical-align: super;background-color:white !important;" onclick="selectMark(\'' + selectObject.Id + '\')" onmouseenter="mouseenter1(event,\'' + selectObject.Id + '\')" onmouseleave="mouseleave1(event,\'' + selectObject.Id + '\')"></i></span>';
  187. let endTag = '</span>';
  188. let elText = '';
  189. splitStrings.forEach(function (item) {
  190. if (item.type == 'text') {
  191. elText = elText + item.text;
  192. }
  193. });
  194. let Indexs = [];
  195. let i = 0
  196. if (selectObject.index < 0) {
  197. let pattern = new RegExp(selectObject.text.replace(/[\r\n]/g, "").replace(/\ +/g, ""), "g");
  198. while ((match = pattern.exec(elText)) != null) {
  199. Indexs[i] = match;
  200. i++;
  201. }
  202. } else {
  203. Indexs[i] = [selectObject.text];
  204. Indexs[i].index = selectObject.index;
  205. }
  206. Indexs.forEach(function (match) {
  207. let currentIndex = 0;
  208. let temSplitStrings = new Array();
  209. splitStrings.forEach(function (item) {
  210. if (item.type == 'text') {
  211. if (item.text) {
  212. if (match.index >= currentIndex && match.index < (currentIndex + item.text.length)) {
  213. if (selectObject.column.indexOf('权利要求') != -1) {
  214. item.text = item.text.replace(/\r/g, ' ')
  215. if (item.text.match(/\r/g)) {
  216. match.index -= 1
  217. }
  218. }
  219. if (selectObject.column.indexOf('说明书') != -1) {
  220. item.text = item.text.replace(/\r/g, "")
  221. }
  222. if ((match.index + match[0].length) <= (currentIndex + item.text.length) && item.text.indexOf(match[0]) != -1) {
  223. if (match.index > currentIndex) {
  224. temSplitStrings.push({ text: item.text.substring(0, match.index - currentIndex), type: 'text' });
  225. }
  226. temSplitStrings.push({ text: startTag, type: 'tag' });
  227. temSplitStrings.push({ text: match[0], type: 'text' });
  228. temSplitStrings.push({ text: imgTag, type: 'tag' });
  229. // }
  230. temSplitStrings.push({ text: endTag, type: 'tag' });
  231. if ((match.index + match[0].length) < (currentIndex + item.text.length)) {
  232. temSplitStrings.push({ text: item.text.substring((match.index + match[0].length) - currentIndex), type: 'text' });
  233. }
  234. } else {
  235. if (item.text.indexOf(match[0]) != -1) {
  236. if (match.index > currentIndex) {
  237. temSplitStrings.push({ text: item.text.substring(0, match.index - currentIndex), type: 'text' });
  238. }
  239. if (temSplitStrings.length > 1) {
  240. temSplitStrings.push({ text: startTag, type: 'tag' });
  241. } else {
  242. temSplitStrings.push({ text: startTag, type: 'tag' });
  243. }
  244. temSplitStrings.push({ text: item.text.substring(match.index - currentIndex), type: 'text' });
  245. temSplitStrings.push({ text: endTag, type: 'tag' });
  246. } else {
  247. temSplitStrings.push({ text: item.text.substring(0, match.index - currentIndex), type: 'text' });
  248. temSplitStrings.push({ text: startTag, type: 'tag' });
  249. temSplitStrings.push({ text: item.text.substring( match.index - currentIndex,item.text.length), type: 'text' });
  250. temSplitStrings.push({ text: endTag, type: 'tag' });
  251. }
  252. }
  253. } else {
  254. if ((match.index + match[0].length) <= (currentIndex + item.text.length) && (match.index + match[0].length) > currentIndex) {
  255. temSplitStrings.push({ text: startTag, type: 'tag' });
  256. temSplitStrings.push({ text: item.text.substring(0, match.index + match[0].length - currentIndex), type: 'text' });
  257. temSplitStrings.push({ text: imgTag, type: 'tag' });
  258. temSplitStrings.push({ text: endTag, type: 'tag' });
  259. if ((match.index + match[0].length) < (currentIndex + item.text.length)) {
  260. temSplitStrings.push({ text: item.text.substring((match.index + match[0].length - currentIndex)), type: 'text' });
  261. }
  262. } else {
  263. if (match.index < currentIndex && (match.index + match[0].length) >= (currentIndex + item.text.length)) {
  264. temSplitStrings.push({ text: startTag, type: 'tag' });
  265. temSplitStrings.push(item);
  266. temSplitStrings.push({ text: endTag, type: 'tag' });
  267. } else {
  268. temSplitStrings.push(item);
  269. }
  270. }
  271. }
  272. currentIndex = currentIndex + item.text.length;
  273. } else {
  274. temSplitStrings.push(item);
  275. }
  276. } else {
  277. temSplitStrings.push(item);
  278. }
  279. });
  280. splitStrings = temSplitStrings;
  281. });
  282. let temInnerHtml = '';
  283. splitStrings.forEach(function (item) {
  284. temInnerHtml = temInnerHtml + item.text;
  285. });
  286. return temInnerHtml;
  287. },
  288. },
  289. }