index.js 12 KB

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