123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- import {projectData,handleData,highlight} from '@/views/project/patentCollection/components/mixins'
- import { mapGetters } from "vuex";
- export const patentDetails={
- mixins:[projectData,handleData,highlight],
- props:{
- patent:{
- default:()=>{
- return {}
- }
- },
- evidence:{},
- signPatentNo:{},
- reportType:{}
- },
- data() {
- return {
- name:'0',
- anchorOffset:null
- }
- },
- computed:{
- ...mapGetters(["contextMenu"]),
- textStyle(){
- return this.$store.state.patent.style
- },
- },
- methods: {
- setStyle(){
- if(!this.textStyle){
- return false
- }
- 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'
- },
- //鼠标弹起
- mouseup(e){
- let selectObj = document.getSelection();
- this.anchorOffset = 0;
- let temSelectObj = this.getSelectobj(selectObj);
- var tempdt = this.getColumnName(selectObj.anchorNode);
- var currentSelectObj = {}
- if (tempdt != undefined && selectObj.toString() != '') {
- currentSelectObj = temSelectObj;
- currentSelectObj.color = this.contextMenu.mark.color;
- currentSelectObj.Type = 0;
- currentSelectObj.patentNo = this.patent.patentNo
- // rangeId(专题库id/报告id)
- currentSelectObj.projectId = this.projectId
- // 创建来源(默认0/专题库1/报告2)
- currentSelectObj.createFrom = 1
- currentSelectObj.remark = ''
- }
- if (currentSelectObj.Id) {
- var a = {}
- a.Id = currentSelectObj.Id//划词生成的ID
- a.patentNo = currentSelectObj.patentNo//专利号
- a.signPatentNo = this.signPatentNo//标的专利号
- a.text = currentSelectObj.text//选中的文本
- a.projectId = currentSelectObj.projectId//项目Id
- a.column = currentSelectObj.column//选中文本所在栏位
- a.position = currentSelectObj.index//选中文本开始位置
- a.id = null//对比记录Id
- a.remark=null//备注
- a.markType = 1//高亮类型
- a.markColor = ''//高亮类型
- // a.color = this.currentSelectObj.color
- a.createFrom =this.projectId? 1:0//来源
- a.literatureId = this.evidence?this.evidence.id:null
- this.showMenu(e)
-
- this.$store.commit("SET_PATENT_INDEX", a)
- }
- },
- //打开弹窗
- showMenu(e){
- var menuContent = null
- if(this.reportType == 1 || this.reportType == 2){
- menuContent=[
- {
- name: "对比",
- method: "contrast",
- }
- ]
- }
- this.$store.commit("SET_CONTEXT_MENU", {
- clientX:e.pageX,
- clientY:e.pageY,
- displayContextMenu:true,
- menuContent:menuContent
- })
- },
- //获取选中的文本信息
- getSelectobj(selectObj) {
- var temNode = selectObj.anchorNode;
- var a = temNode.parentElement
- NotIncludeDataType(a)
- function NotIncludeDataType(node) {
- if(!node){
- return false
- }
- if (node.getAttribute("data-type") != null) {
- temNode = node
- } else {
- NotIncludeDataType(node.parentElement);
- }
- }
- this.getColumn(temNode, selectObj);
- if(temNode.nodeType == 3){
- return false
- }
- this.isFirst = true
- return { "Id": this.uuid(), "column": temNode.getAttribute("data-type"), "index": this.anchorOffset, "text": selectObj.toString(), 'temNode': temNode.innerHTML };
- },
- //获取ID
- uuid() {
- var s = [];
- var hexDigits = "0123456789abcdef";
- for (var i = 0; i < 36; i++) {
- s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
- }
- s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
- s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
- s[8] = s[13] = s[18] = s[23] = "-";
- var uuid = s.join("");
- return uuid;
- },
- //获取开始位置
- getColumn(node, selectObj) {
- var baseNode = this.getColumnNode(node);
- var anchorNodePosition = this.getPosition(baseNode, selectObj.anchorNode, selectObj.anchorOffset);
- var focusNodePosition = this.getPosition(baseNode, selectObj.focusNode, selectObj.focusOffset);
- var num = Math.min(anchorNodePosition, focusNodePosition)
- this.anchorOffset = num
- return true;
- },
- //获取节点所在的栏位节点
- getColumnNode(node) {
- if (node != null) {
- if(node.nodeType == 9){
- return false
- }
- if (node.nodeType != 3 && node.getAttribute("data-type") != null) {
- return node;
- }else {
- if (node == document.root) {
- return node;
- } else {
- return this.getColumnNode(node.parentNode);
- }
- }
- }
- },
- //根据节点获取给定node中offset位置在栏位中的实际位置
- getPosition(baseNode, node, offset) {
- let path = [];
- this.getNodes(baseNode, path);
- let retIdx = 0;
- for (let i = 0; i < path.length; i++){
- if (path[i] == node) {
- retIdx += offset;
- return retIdx;
- } else {
- if (path[i].nodeType == 3) {
- retIdx += path[i].nodeValue.length;
- }
- }
- }
- },
- // 拿到所有类型的节点
- getNodes(baseNode, path) {
- var temPath = path;
- if(baseNode != null){
- temPath.push(baseNode);
- if(baseNode.childNodes && baseNode.childNodes.length >0){
- for(let i=0;i<baseNode.childNodes.length;i++){
- this.getNodes(baseNode.childNodes[i],temPath);
- }
- }
- }
- },
- //获取所选文本所在节点
- getColumnName(el) {
- let root = el;
- if (el == undefined) {
- return undefined;
- }
- if (!(el instanceof HTMLElement)) {
- root = el.parentElement;
- }
- let dt = root.getAttribute("data-Type");
- if (dt != undefined) {
- return root;
- }
- return dt = this.getColumnName(root.parentElement);
- },
- },
- }
|