index.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. import { projectData, handleData, highlight } from '@/views/project/patentCollection/components/mixins'
  2. import { mapGetters } from "vuex";
  3. export const patentDetails = {
  4. mixins: [projectData, handleData, highlight],
  5. props: {
  6. patent: {
  7. default: () => {
  8. return {}
  9. }
  10. },
  11. evidence: {},
  12. signPatentNo: {},
  13. reportType: {},
  14. outside: {
  15. default: false
  16. },
  17. projectType: {
  18. type: [String,Number],
  19. default: 2//判断是不是从专题库进入专利详情1为专题库(专题库已传1)2为报告(报告未传2)
  20. },
  21. patentNo:{
  22. default:null
  23. },
  24. activeName:{
  25. default:'0'
  26. }
  27. },
  28. data() {
  29. return {
  30. name: this.activeName,
  31. anchorOffset: null,
  32. loading:false
  33. }
  34. },
  35. watch:{
  36. activeName(){
  37. this.name = this.activeName
  38. }
  39. },
  40. computed: {
  41. ...mapGetters(["contextMenu"]),
  42. textStyle() {
  43. return this.$store.state.patent.style
  44. },
  45. },
  46. methods: {
  47. //导入数据
  48. exportData(value){
  49. if(this.outside){
  50. return false
  51. }
  52. var dict = {
  53. 1:'',
  54. 2:'说明书文本',
  55. 3:'权利要求',
  56. 4:'附图',
  57. 5:'pdf文档'
  58. }
  59. var str = `确定刷新${dict[value]}?`
  60. this.$confirm(str, '提示', {
  61. confirmButtonText: '确定',
  62. cancelButtonText: '取消',
  63. type: 'warning'
  64. }).then(() => {
  65. var params = {
  66. patentNo:this.patent.patentNo,
  67. refreshContent:[value]
  68. }
  69. this.loading = true
  70. this.$api.refreshPatent(params).then(response=>{
  71. if(response.code == 200){
  72. this.$message.success('数据刷新成功')
  73. // this.loading = false
  74. this.getPatent(value)
  75. }
  76. }).catch(error=>{
  77. this.$message.error('数据刷新失败')
  78. this.loading = false
  79. })
  80. })
  81. },
  82. //获取专利信息
  83. getPatent(value) {
  84. var dict = {
  85. 1:'',
  86. 2:'publicFullText',
  87. 3:'claim',
  88. 4:'pictureGuid',
  89. 5:'pdf'
  90. }
  91. var params = {
  92. patentNo: this.patent.patentNo
  93. }
  94. var api = 'selectPatentDetail'
  95. this.loading = true
  96. this.$api[api](params).then(response => {
  97. if (response.code == 200) {
  98. this.$set(this.patent,dict[value],response.data[dict[value]])
  99. this.loading = false
  100. }
  101. }).catch(error => {
  102. this.loading = false
  103. })
  104. },
  105. setStyle() {
  106. if (!this.textStyle) {
  107. return false
  108. }
  109. return 'font-size:' + this.textStyle.size + 'px;line-height:' + this.textStyle.lineHeight + ';padding:' + this.textStyle.padding[0] + 'px ' + this.textStyle.padding[1] + 'px ' + this.textStyle.padding[2] + 'px ' + this.textStyle.padding[3] + 'px'
  110. },
  111. //鼠标弹起
  112. mouseup(e) {
  113. let selectObj = document.getSelection();
  114. this.anchorOffset = 0;
  115. let temSelectObj = this.getSelectobj(selectObj);
  116. var tempdt = this.getColumnName(selectObj.anchorNode);
  117. var currentSelectObj = {}
  118. if (tempdt != undefined && selectObj.toString() != '') {
  119. currentSelectObj = temSelectObj;
  120. currentSelectObj.color = this.contextMenu.mark.color;
  121. currentSelectObj.Type = 0;
  122. currentSelectObj.patentNo = this.patent.patentNo
  123. // rangeId(专题库id/报告id)
  124. currentSelectObj.projectId = this.projectId
  125. // 创建来源(默认0/专题库1/报告2)
  126. currentSelectObj.createFrom = this.outside ? 0 : this.projectType//来源0默认(专利)1专题库2报告
  127. currentSelectObj.remark = ''
  128. }
  129. if (currentSelectObj.Id) {
  130. var a = {}
  131. a.Id = currentSelectObj.Id//划词生成的ID
  132. a.patentNo = currentSelectObj.patentNo//专利号
  133. a.signPatentNo = this.signPatentNo//标的专利号
  134. a.text = currentSelectObj.text//选中的文本
  135. a.projectId = currentSelectObj.projectId//项目Id
  136. a.column = currentSelectObj.column//选中文本所在栏位
  137. a.position = currentSelectObj.index//选中文本开始位置
  138. a.id = null//对比记录Id
  139. a.remark = null//备注
  140. a.markType = 2//高亮类型
  141. a.markColor = '#ff0000'//高亮颜色
  142. a.permissionType = 1//高亮权限
  143. // a.color = this.currentSelectObj.color
  144. a.createFrom = this.outside ? 0 : this.projectType//来源0默认(专利)1专题库2报告
  145. a.literatureId = this.evidence ? this.evidence.id : null
  146. a.patentTitle=this.patent.title.find(item => item.if_origin).text_content
  147. this.showMenu(e)
  148. this.$store.commit("SET_PATENT_INDEX", a)
  149. }
  150. },
  151. //打开弹窗
  152. showMenu(e) {
  153. var menuContent = []
  154. if ((this.reportType == 1 || this.reportType == 2) && this.patent.patentNo!=this.signPatentNo) {
  155. menuContent = [
  156. {
  157. name: "对比",
  158. method: "contrast",
  159. }
  160. ]
  161. }
  162. this.$store.commit("SET_CONTEXT_MENU", {
  163. clientX: e.pageX,
  164. clientY: e.pageY,
  165. displayContextMenu: true,
  166. menuContent: menuContent
  167. })
  168. },
  169. //获取选中的文本信息
  170. getSelectobj(selectObj) {
  171. var temNode = selectObj.anchorNode;
  172. var a = temNode.parentElement
  173. NotIncludeDataType(a)
  174. function NotIncludeDataType(node) {
  175. if (!node) {
  176. return false
  177. }
  178. if (node.getAttribute("data-type") != null) {
  179. temNode = node
  180. } else {
  181. NotIncludeDataType(node.parentElement);
  182. }
  183. }
  184. this.getColumn(temNode, selectObj);
  185. if (temNode.nodeType == 3) {
  186. return false
  187. }
  188. this.isFirst = true
  189. return { "Id": this.uuid(), "column": temNode.getAttribute("data-type"), "index": this.anchorOffset, "text": selectObj.toString(), 'temNode': temNode.innerHTML };
  190. },
  191. //获取ID
  192. uuid() {
  193. var s = [];
  194. var hexDigits = "0123456789abcdef";
  195. for (var i = 0; i < 36; i++) {
  196. s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  197. }
  198. s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
  199. s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  200. s[8] = s[13] = s[18] = s[23] = "-";
  201. var uuid = s.join("");
  202. return uuid;
  203. },
  204. //获取开始位置
  205. getColumn(node, selectObj) {
  206. var baseNode = this.getColumnNode(node);
  207. var anchorNodePosition = this.getPosition(baseNode, selectObj.anchorNode, selectObj.anchorOffset);
  208. var focusNodePosition = this.getPosition(baseNode, selectObj.focusNode, selectObj.focusOffset);
  209. var num = Math.min(anchorNodePosition, focusNodePosition)
  210. this.anchorOffset = num
  211. return true;
  212. },
  213. //获取节点所在的栏位节点
  214. getColumnNode(node) {
  215. if (node != null) {
  216. if (node.nodeType == 9) {
  217. return false
  218. }
  219. if (node.nodeType != 3 && node.getAttribute("data-type") != null) {
  220. return node;
  221. } else {
  222. if (node == document.root) {
  223. return node;
  224. } else {
  225. return this.getColumnNode(node.parentNode);
  226. }
  227. }
  228. }
  229. },
  230. //根据节点获取给定node中offset位置在栏位中的实际位置
  231. getPosition(baseNode, node, offset) {
  232. let path = [];
  233. this.getNodes(baseNode, path);
  234. let retIdx = 0;
  235. for (let i = 0; i < path.length; i++) {
  236. if (path[i] == node) {
  237. retIdx += offset;
  238. return retIdx;
  239. } else {
  240. if (path[i].nodeType == 3) {
  241. retIdx += path[i].nodeValue.length;
  242. }
  243. }
  244. }
  245. },
  246. // 拿到所有类型的节点
  247. getNodes(baseNode, path) {
  248. var temPath = path;
  249. if (baseNode != null) {
  250. temPath.push(baseNode);
  251. if (baseNode.childNodes && baseNode.childNodes.length > 0) {
  252. for (let i = 0; i < baseNode.childNodes.length; i++) {
  253. this.getNodes(baseNode.childNodes[i], temPath);
  254. }
  255. }
  256. }
  257. },
  258. //获取所选文本所在节点
  259. getColumnName(el) {
  260. let root = el;
  261. if (el == undefined) {
  262. return undefined;
  263. }
  264. if (!(el instanceof HTMLElement)) {
  265. root = el.parentElement;
  266. }
  267. let dt = root.getAttribute("data-Type");
  268. if (dt != undefined) {
  269. return root;
  270. }
  271. return dt = this.getColumnName(root.parentElement);
  272. },
  273. },
  274. }