zhuliu 8 månader sedan
förälder
incheckning
5859b335c6

+ 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体,可为空

+ 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']

+ 2 - 177
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 = {
@@ -904,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++){
@@ -999,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);
 
@@ -1009,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();