Bläddra i källkod

Merge branch 'product' into shaoyin

zhuliu 7 månader sedan
förälder
incheckning
11aff3fe15

+ 2 - 2
src/main.js

@@ -58,8 +58,8 @@ import vmFunction from './utils/window'
 Vue.use(vmFunction)
 
 //el-table滚动加载
-import elTableInfiniteScroll from 'el-table-infinite-scroll'
-Vue.use(elTableInfiniteScroll)
+// import elTableInfiniteScroll from 'el-table-infinite-scroll'
+// Vue.use(elTableInfiniteScroll)
 
 
 Vue.config.productionTip = false

+ 29 - 8
src/utils/axios.js

@@ -73,14 +73,14 @@ _axios.interceptors.response.use(
       return Promise.reject(response.data)
     }
     if (code === 402  || code===201) {
-      Notification.error({
+      Notification_error({
         title: '权限不足',
         message: message
       })
       return Promise.reject(response.data)
     }
     if(code == 806){
-      Notification.error({
+      Notification_error({
         title: '账号未启用',
         message: message
       })
@@ -93,15 +93,25 @@ _axios.interceptors.response.use(
           path: `/login`
         }).then(r => {})
       }
+      Notification_error({
+        title: '请求错误',
+        message: message
+      })
       return Promise.reject(response.data)
-    } else if (code === 0) {
+    } else if (code === 708) {//系统错误
       isRefreshing = false
-      Notification.error({
+      Notification_error({
+        title: '请求错误',
+        message: message
+      })
+      return Promise.reject(response.data)
+    } else{
+      isRefreshing = false
+      Notification_error({
         title: '请求错误',
         message: message
       })
       return Promise.reject(response.data)
-    } else if (code !== 401) {
     }
     // Do something with response data
     // return response;
@@ -126,19 +136,18 @@ _axios.interceptors.response.use(
   
       // 返回Promise,以便Axios知道我们已经处理了错误
       return backoff.then((txt) => {
-        console.log(txt)
         obj.url = obj.url.replace('/api','')
         return _axios(obj)
       })
     }
     if(error.response.status == 404){
-      Notification.error({
+      Notification_error({
         title: '接口不存在',
         message: error.response.data.message
       })
     }else{
       // Do something with response error
-      Notification.error({
+      Notification_error({
         title: '系统错误',
         message: error.response.data.message
       })
@@ -150,6 +159,18 @@ _axios.interceptors.response.use(
   }
 );
 
+function Notification_error(obj){
+  let {title,message} = obj
+  if(!message || message.length>35 ){
+    message = '系统错误'
+  }
+  Notification.error({
+    title: title,
+    message: message
+  })
+}
+
+
 Plugin.install = function (Vue) {
   Vue.axios = _axios;
   window.axios = _axios;

+ 23 - 0
src/utils/common.js

@@ -6,6 +6,9 @@ import showPermissionDialog from "@/utils/model/noPermission/index";
 import { Base64 } from 'js-base64';
 import Config from '@/config'
 import moment from "moment";
+
+import * as XLSX from 'xlsx';
+import { saveAs } from 'file-saver';
 export default {
   //滚动到顶部
   scrollToTop(){
@@ -231,6 +234,26 @@ treeToArray(data,prop={children:children}){
   },
 
   /**
+   * 导出为excel
+   * @param {Array} data 需要导出的数据
+   * @param {String} name 文件名称
+   */
+  exportToExcel(data=[],name='export'){
+    // 将数据转换为工作表
+      const worksheet = XLSX.utils.aoa_to_sheet(data);
+ 
+      // 创建工作簿并添加工作表
+      const workbook = XLSX.utils.book_new();
+      XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
+ 
+      // 生成Excel文件
+      const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
+ 
+      // 使用blob和FileReader创建一个URL然后下载
+      const dataBlob = new Blob([excelBuffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8' });
+      saveAs(dataBlob, name+'.xlsx');
+  },
+  /**
    * 导出Excel
    * @param {string} head excel头,可为空
    * @param {String} body excel体,可为空

+ 3 - 2
src/utils/direct/index.js

@@ -344,7 +344,7 @@ const equal_heights = {
       },
 }
 
-
+import elTableInfiniteScroll from './tableInfiniteScroll.js'
 
 const directives = {
     draggable,
@@ -353,7 +353,8 @@ const directives = {
     DivHeight, 
     equal_heights,
     shake,
-    dialogDrag
+    dialogDrag,
+    elTableInfiniteScroll
 };
 // 这种写法可以批量注册指令
 export default {

+ 41 - 0
src/utils/direct/tableInfiniteScroll.js

@@ -0,0 +1,41 @@
+
+import elInfiniteScroll from 'element-ui/lib/infinite-scroll';
+
+const elInserted = elInfiniteScroll.inserted;
+const elUnbind = elInfiniteScroll.unbind;
+const elScope = 'ElInfiniteScroll';
+
+export default {
+  inserted(el, binding, ...params) {
+    // 获取 table 中的滚动层
+    const scrollElem = el.querySelector('.el-table__body-wrapper');
+
+    // 如果没找到元素,返回错误
+    if (!scrollElem) {
+      throw 'table-infinite-scroll: 找不到 .el-table__body-wrapper 容器';
+    }
+
+    // 设置自动滚动
+    scrollElem.style.overflowY = 'auto';
+
+    // 加入滚动路基
+    setTimeout(() => {
+      elInserted(scrollElem, binding, ...params);
+
+      // 将子集的引用放入 el 上,用于 unbind 中销毁事件
+      el[elScope] = scrollElem[elScope];
+    });
+  },
+  unbind: function unbind(el) {
+        var _el$scope = el[elScope]
+        if(!_el$scope){
+            return
+        }
+           var container = _el$scope.container,
+            onScroll = _el$scope.onScroll;
+    
+        if (container) {
+          container.removeEventListener('scroll', onScroll);
+        }
+    }
+};

+ 23 - 23
src/utils/permissions.js

@@ -22,7 +22,7 @@ export default {
         return true
     }
   const role = Store.state.user.userinfo
-    if(role.roleType === 1){
+    if(role.roleType === 1 || user.roleType == 2){
         return true
     }
     const permissions = Store.getters && Store.getters.permissions
@@ -49,16 +49,16 @@ export default {
    */
   async projectPermission(projectId){
     const user = Store.state.user.userinfo
-    if(user.roleType == 1){
+    if(user.roleType == 1 || user.roleType == 2){
       return true
     }
     if(!projectId){
       return true
     }
     var data = {}
-    if(sessionStorage.getItem('projectPermission')){
-      data = JSON.parse(sessionStorage.getItem('projectPermission'))
-    }
+    // if(sessionStorage.getItem('projectPermission')){
+    //   data = JSON.parse(sessionStorage.getItem('projectPermission'))
+    // }
     var obj = data[projectId]
     if(!obj){
       var projectIds = [projectId]
@@ -66,7 +66,7 @@ export default {
         if(response.code == 200){
           var d = response.data.data[projectId]
           data[projectId] = d
-          sessionStorage.setItem('projectPermission',JSON.stringify(data))
+          // sessionStorage.setItem('projectPermission',JSON.stringify(data))
           obj = d
         }
       })
@@ -105,24 +105,24 @@ export default {
    */
   async producePermission(id,type){
     const user = Store.state.user.userinfo
-    if(user.roleType = 1){
+    if(user.roleType = 1 || user.roleType == 2){
       return true
     }
     if(!id || !type){
       return false
     }
     var data = {}
-    if(type == 2){
-      var str = sessionStorage.getItem('product')
-      if(str){
-        data = JSON.parse(str)
-      }
-    }else if(type == 1){
-      var str = sessionStorage.getItem('productCategory')
-      if(str){
-        data = JSON.parse(str)
-      }
-    }
+    // if(type == 2){
+    //   var str = sessionStorage.getItem('product')
+    //   if(str){
+    //     data = JSON.parse(str)
+    //   }
+    // }else if(type == 1){
+    //   var str = sessionStorage.getItem('productCategory')
+    //   if(str){
+    //     data = JSON.parse(str)
+    //   }
+    // }
     var obj = data[id]
     if(!obj){
       
@@ -143,11 +143,11 @@ export default {
           var d = response.data.data
           if(d && d.length>0){
             data[d[0].id] = d[0]
-            if(type == 2){
-              sessionStorage.setItem('product',JSON.stringify(data))
-            }else if(type == 1){
-              sessionStorage.setItem('productCategory',JSON.stringify(data))
-            }
+            // if(type == 2){
+            //   sessionStorage.setItem('product',JSON.stringify(data))
+            // }else if(type == 1){
+            //   sessionStorage.setItem('productCategory',JSON.stringify(data))
+            // }
             obj = d[0]
           }
         }

+ 25 - 1
src/views/noveltySearch/components/noveltySearchCard.vue

@@ -8,7 +8,7 @@
                     </mySearch>
                   </div>
                   <div class="head_right">
-                      
+                      <!-- <el-button @click="exportReport">导出</el-button> -->
                   </div>
               </div>
           </el-header>
@@ -110,6 +110,30 @@ import createNoveltySearch from './dialog/createNoveltySearch.vue';
         this.getList()
     },
     methods: {
+      exportReport(){
+        console.log(this.tableData)
+        var data = []
+        var head = [
+          '序号','姓名','数量'
+        ]
+        data.push(head)
+        const unique = {};
+        this.tableData.forEach(item => {
+          if (unique[item.createName]) {
+            unique[item.createName].count += 1;
+          } else {
+            unique[item.createName] = { name: item.createName, count: 1 };
+          }
+        });
+        var num = 1
+        for(let key in unique){
+          var arr = []
+          arr.push(num,unique[key].name,unique[key].count)
+          data.push(arr)
+          num ++ 
+        }
+        this.$commonJS.exportToExcel(data,'查新检索报告')
+      },
          //获取检索字段和分组字段
     async getColumn() {
       let params = ['noveltyProject']

+ 35 - 42
src/views/patentMining/components/dialog/addAndEditProject.vue

@@ -655,60 +655,52 @@ export default {
 
 
     //打开弹窗
-    async open(form) {
+    async open(form={}){
+      this.form = JSON.parse(JSON.stringify(form))
       this.personnelList.data = []
-      if (form && form.id) {
-        this.form = JSON.parse(JSON.stringify(form))
-        // 负责人
-        if (this.form.headId) {
-          this.personnelList.queryParams.id = this.form.headId
-          await this.getPermissionPersonnel(1)
-          this.personnelList.queryParams.id = null
-        }
-        // 部门委托客户
-        if (this.form.entrustId) {
-          
-          // this.personnelList.queryParams.id = this.form.entrustId
-          // await this.getPermissionPersonnel(1)
-          // this.personnelList.queryParams.id = null
-        }
-        // 参与人
-        if (this.form.involvedPersons && this.form.involvedPersons.length) {
-          this.form.adminPersons = []
-          this.form.adminIds = []
-          this.form.involvedPersons.forEach(item => {
-            let a = {
-              id: item.personId,
-              name: item.personName
-            }
-            this.form.adminPersons.push(a)
-            this.form.adminIds.push(a.id)
-          })
-        }
+
+      //获取title
+      if(this.form.id){
         this.title = '编辑专利挖掘项目'
-      } else {
-        // this.eventList.disabled = false
-        // if (this.form.eventId) {
-        //   this.eventList.disabled = true
-        //   this.eventList.data.push({
-        //     id: this.form.eventId,
-        //     name: this.form.eventName,
-        //   })
-        // }
+      }else{
         this.title = '新增专利挖掘项目'
       }
+      //负责人
+      if (this.form.headId) {
+        this.personnelList.queryParams.id = this.form.headId
+        await this.getPermissionPersonnel(1)
+        this.personnelList.queryParams.id = null
+      }
+      // 部门委托客户
+      if (this.form.entrustId) {
+      }
+      // 参与人
+      if (this.form.involvedPersons && this.form.involvedPersons.length) {
+        this.form.adminPersons = []
+        this.form.adminIds = []
+        this.form.involvedPersons.forEach(item => {
+          let a = {
+            id: item.personId,
+            name: item.personName
+          }
+          this.form.adminPersons.push(a)
+          this.form.adminIds.push(a.id)
+        })
+      }
+
+      //事件
       this.eventList.data = []
       this.eventList.name = ''
       this.eventList.disabled = false
       var hasEvent = false
-      if(this.form.eventId){
-        this.eventList.disabled = true
-        hasEvent = true
-      }
       if(this.form.eventIds && this.form.eventIds.length>0){
         this.form.eventId = this.form.eventIds[0]
         hasEvent = true
       }
+      if(this.form.eventId){
+        this.eventList.disabled = true
+        hasEvent = true
+      }
       if(hasEvent){
         if(this.form.eventId){
           let params = {
@@ -738,6 +730,7 @@ export default {
       }
       this.getPermissionPersonnel()
       this.dialogVisible = true
+
     },
     //关闭弹窗
     handleClose() {

+ 1 - 1
src/views/patentMining/components/viewIndex.vue

@@ -320,7 +320,7 @@ export default {
         eventName:this.eventName,
         eventId:this.eventId
       }
-      this.$refs.addAndEditProject.open()
+      this.$refs.addAndEditProject.open(form)
     },
     // 创建项目按钮下拉菜单内容
     handleCommand(ev) {

+ 35 - 185
src/views/product/components/jsMind/components/mind.vue

@@ -447,8 +447,6 @@ export default {
     init() {
       this.jm.view.minZoom = 0.1;
       this.jm.view.maxZoom = 5;
-      // this.jm.expand_all()
-      // this.setColor()
       // 重写编辑完成事件
       this.jm.view.edit_node_end = () => {
         const node = this.jm.view.get_editing_node();
@@ -473,117 +471,11 @@ export default {
       const selectedNode = this.jm.get_selected_node();
       if (selectedNode) {
         if (selectedNode.children.length == 0) {
-          // if (selectedNode.data.rowType == 1) {//查询产品
-          //   var queryParams = {
-          //     productCategoryId: selectedNode.data.ids,
-          //   };
-          //   this.$api.queryProducts(queryParams).then((res) => {
-          //     if (res.code == 200) {
-          //       this.jm.enable_edit();
-          //       res.data.list.forEach((item) => {
-          //         var data = {
-          //           expanded: false,
-          //           rowType: 2,
-          //           ids: item.id,
-          //           productName:item.productName,
-          //           children: [],
-          //         };
-          //         this.jm.toggle_node(selectedNode.id);
-          //         data.children = item.children ? item.children : [];
-          //         item.type = 2;
-          //         this.jm.add_node(
-          //           selectedNode.id,
-          //           "产品" + item.id,
-          //           this.getModelCardDom(item),
-          //           data
-          //         );
-          //       });
-          //       this.jm.disable_edit();
-          //     }
-          //   });
-          // } else if (selectedNode.data.rowType == 2) {//查询产品架构
-          //   var queryParams = {
-          //     productId: selectedNode.data.ids,
-          //     structureId: 0,
-          //   };
-          //   this.$api.queryStructures(queryParams).then((res) => {
-          //     if (res.code == 200) {
-          //       this.jm.enable_edit();
-
-          //       res.data.children.forEach((item) => {
-          //         var data = {
-          //           expanded: false,
-          //           rowType: 3,
-          //           ids: item.id,
-          //           productId: selectedNode.data.ids,
-          //           productName:selectedNode.data.productName,
-          //         };
-          //         this.jm.toggle_node(selectedNode.id);
-          //         data.children = item.children ? item.children : [];
-          //         item.productName=selectedNode.data.productName,
-          //         item.type = 3;
-          //         this.jm.add_node(
-          //           selectedNode.id,
-          //           "架构" + item.id,
-          //           this.getModelCardDom(item),
-          //           data
-          //         );
-          //         // if(item.children&& item.children.length>0){
-          //         //     this.deepChildren(item.id,item.children)
-          //         // }
-          //       });
-
-          //       this.jm.disable_edit();
-          //     }
-          //   });
-          // } else {
-          //   if ((selectedNode.data.children&&selectedNode.data.children.length==0) ||( selectedNode.data.hasChildren && selectedNode.data.hasChildren.length==0)) {
-          //     return false;
-          //   }
-          //   var queryParams = {
-          //     structureId: selectedNode.data.ids,
-          //     productId: selectedNode.data.productId,
-          //   };
-          //   this.$api.queryStructures(queryParams).then((res) => {
-          //     if (res.code == 200) {
-          //       this.jm.enable_edit();
-
-          //       res.data.children.forEach((item) => {
-          //         var data = {
-          //           expanded: false,
-          //           rowType: 3,
-          //           ids: item.id,
-          //           productId: selectedNode.data.productId,
-          //           productName:selectedNode.data.productName,
-          //         };
-          //         this.jm.toggle_node(selectedNode.id);
-          //         data.children = item.children ? item.children : [];
-          //         item.productName=selectedNode.data.productName,
-          //         item.type = 3;
-          //         this.jm.add_node(
-          //           selectedNode.id,
-          //           "架构" + item.id,
-          //           this.getModelCardDom(item),
-          //           data
-          //         );
-          //         // if(item.children&& item.children.length>0){
-          //         //     this.deepChildren(item.id,item.children)
-          //         // }
-          //       });
-
-          //       this.jm.disable_edit();
-          //     }
-          //   });
-          // }
+          
         } else {
           this.jm.toggle_node(selectedNode.id);
         }
-
-        //   return selectedNode.id
       }
-      // else {
-      //   return null
-      // }
     },
 
     // 拖拽
@@ -702,6 +594,7 @@ export default {
     },
 
 
+    //获取当前数据
    async getData() {
     if (this.type == 1) {//产品类别
       let params = {
@@ -743,8 +636,9 @@ export default {
   async LoadData(currentData){
     if(currentData.MindType == 1){//产品类别
       var data1 = currentData
-      //装载产品
-      const [products] = await Promise.allSettled([this.initData(data1)])
+      //装载产品和架构
+      const [products,classificationNode] = await Promise.allSettled([this.initData(data1),this.initData(data1,2)])
+      //产品的装载
       var productList = products.status =='fulfilled'?products.value:[]
       if(productList.length>0){
         data1.hasChildren = true
@@ -756,10 +650,25 @@ export default {
           item.topic = this.getModelCardDom(item)
           return item
         })     
+      }else{
+
       }
+
+      // 产品类别架构的装载
+      var classificationNodes = classificationNode.status =='fulfilled'?classificationNode.value:[]
+      if(classificationNodes && classificationNodes.length){
+        data1.hasChildren = true
+        if(!data1.children){
+          data1.children = []
+        }
+        this.deepChildren(classificationNodes,data1)
+        data1.children.push(...classificationNodes)
+      }
+
+
       data1.topic = this.getModelCardDom(data1)
 
-      //装载架构
+      //判断产品类别是否有产品
       var data2 = data1.children
       if(!data2){
         return
@@ -767,11 +676,20 @@ export default {
       // 获取需要返回的架构数组以及funList
       var treeList = [], funList = []
       for(var i = 0;i<data2.length;i++){
+        if(data2[i].MindType!=2){
+          continue
+        }
         treeList.push(`tree${i+1}`)
         funList.push(this.initData(data2[i]))
       }
+      if(treeList.length == 0){
+        return
+      }
       treeList = await Promise.allSettled(funList)
       for(var i = 0;i<data2.length;i++){
+        if(data2[i].MindType!=2){
+          continue
+        }
         var trees = treeList[i].status =='fulfilled'?treeList[i].value:[]
         if(trees.length>0){
           data2[i].hasChildren = true
@@ -792,7 +710,7 @@ export default {
       }
       data1.topic = this.getModelCardDom(data1)
       data1.children = trees
-    }else if(currentData.MindType == 0){//全部
+    }else if(currentData.MindType == 0){//全部,有错误
       var data1 = currentData
       //装载产品类别
       const [category] = await Promise.allSettled([this.initData(data1)])
@@ -859,19 +777,19 @@ export default {
     }
   },
   //初始化JsMind数据
-  async initData(currentData){
-      if(currentData.MindType == 1){
+  async initData(currentData,type){
+      if(currentData.MindType == 1 && type!=2){//查询产品
         let params = {
           searchQuery:`category_id=${currentData.MindId}`,//检索条件
         }
         return await this.$api.queryProduct(params).then(response=> response.data.data)
-      }else if(currentData.MindType == 2){//产品
+      }else if(currentData.MindType == 2 || type == 2){//查询产品架构
         var params = {
           type: currentData.MindType,
           typeId: currentData.MindId
         }
         return await this.$api.queryTreeNodeTree(params).then(response=> response.data.data)
-      }else if(currentData.MindType == 0){
+      }else if(currentData.MindType == 0){//查询产品类别
         let params = {
           searchQuery:'',//检索条件
         }
@@ -879,72 +797,6 @@ export default {
       }
       
     },
-    // //初始化JsMind数据
-    // async initData(currentData){
-    //   if(currentData.MindType == 1){
-    //     let params = {
-    //       searchQuery:`product_id=${currentData.id}`,//检索条件
-    //     }
-    //     await this.$api.queryProduct(params).then(response=>{
-    //       if(response.code == 200){
-    //         if(response.data.data.length>0){
-    //           currentData.hasChildren = true
-    //           currentData.children = response.data.data.map(item=>{
-    //             item.MindId = `产品${item.id}`
-    //             item.MindType = 2
-    //             item.expanded = false
-    //             item.topic = this.getModelCardDom(item)
-    //             // this.jm.enable_edit();
-    //             // this.jm.update_node(item.MindId,this.getModelCardDom(item) )
-    //             // this.jm.disable_edit();
-    //             return item
-    //           })
-              
-              
-    //         }
-    //       }
-    //     })
-    //   }else if(currentData.MindType == 2){
-    //     var params = {
-    //       type: currentData.MindType,
-    //       typeId: currentData.id
-    //     }
-    //     await this.$api.queryTreeNodeTree(params).then(res => {
-    //       if (res.code == 200) {
-    //         var data = res.data.data
-    //         if(data.length>0){
-    //           currentData.hasChildren = true
-    //           var data = this.deepChildren(data,currentData)
-    //         }
-    //         currentData.children = data
-    //       }
-    //     })
-    //   }else if(currentData.MindType == 0){
-    //     let params = {
-    //       searchQuery:'',//检索条件
-    //     }
-    //     await this.$api.queryProductCategory(params).then(response=>{
-    //       if(response.code == 200){
-    //         if(response.data.data.length>0){
-    //           currentData.hasChildren = true
-    //           currentData.children = response.data.data.map(item=>{
-    //             item.MindId = `产品类别${item.id}`
-    //             item.MindType = 1
-    //             item.expanded = false
-    //             item.topic = this.getModelCardDom(item)
-    //             // this.jm.enable_edit();
-    //             // this.jm.update_node(item.MindId,this.getModelCardDom(item) )
-    //             // this.jm.disable_edit();
-    //             return item
-    //           })
-             
-    //         }
-    //       }
-    //     })
-    //   }
-      
-    // },
-
     //递归
     deepChildren(data,currentData){
       for(var i = 0;i<data.length;i++){
@@ -974,7 +826,6 @@ export default {
  async mounted() {
     window.check = this.check;
     await this.getData()
-    // await this.initData(this.currentData)
     this.mind.data = this.currentData
     this.jm = jsMind.show(this.options, this.mind);
 
@@ -984,7 +835,6 @@ export default {
         //   this.handleDrop(nextParentId, srcNode.id)
         // }
         this.editor = this.jm.view.e_editor;
-        //   this.init()
         this.toggleStucture("side");
         this.mouseWheel();
         this.mouseDrag();

+ 1 - 1
src/views/project/components/view/table.vue

@@ -260,7 +260,7 @@ export default {
 </style>
 <style lang="scss" scoped>
 .patentName{
-  z-index: 99999;
+  // z-index: 99999;
   position: relative;
   // margin: 0 15px;
   .jiankong{