Zhang Li, BBF-411-2(Neusoft) 1 rok temu
rodzic
commit
d3911645c1

+ 61 - 0
src/api/knowledge/FormUtil.js

@@ -0,0 +1,61 @@
+import rxAjax from "@/assets/js/ajax";
+
+var FormUtil={};
+
+/**
+ * 客户端导出函数
+ * @param url     导出的URL
+ * @param params    传入的参数
+ */
+FormUtil.doExport=function (url,params){
+    return new Promise(function (resolve, reject) {
+        var config={responseType:"blob"};
+        rxAjax.postJson(url,params,config).then(res=>{
+            let data = res;
+            let fileReader = new FileReader();
+            fileReader.onload = function() {
+                const blob = new Blob([data], {type: 'application/vnd.ms-excel'});
+                // const filename = res.headers['content-disposition'];
+                const downloadElement = document.createElement('a');
+                const href = window.URL.createObjectURL(blob); //创建下载的链接
+                downloadElement.href = href;
+                // var name=decodeURI(filename.split('=')[1].replace(/\"/g, "" ));
+                // downloadElement.download = name;
+                document.body.appendChild(downloadElement);
+                downloadElement.click(); //点击下载
+                document.body.removeChild(downloadElement); //下载完成移除元素
+                window.URL.revokeObjectURL(href); //释放blob对
+                resolve()
+            };
+            fileReader.readAsText(data);
+        });
+    });
+}
+
+/**
+ * 客户端导出函数
+ * @param url     导出的URL
+ * @param params    传入的参数
+ */
+FormUtil.doExport2=function (url,params){
+    rxAjax.postJson(url,params,'blob').then(res=>{
+        let data = res.data;
+        let fileReader = new FileReader();
+        fileReader.onload = function() {
+            const blob = new Blob([data], {type: 'application/zip'});
+            const filename = res.headers['content-disposition'];
+            const downloadElement = document.createElement('a');
+            const href = window.URL.createObjectURL(blob); //创建下载的链接
+            downloadElement.href = href;
+            var name=decodeURI(filename.split('=')[1].replace(/\"/g, "" ));
+            downloadElement.download = name;
+            document.body.appendChild(downloadElement);
+            downloadElement.click(); //点击下载
+            document.body.removeChild(downloadElement); //下载完成移除元素
+            window.URL.revokeObjectURL(href); //释放blob对
+        };
+        fileReader.readAsText(data)
+    });
+}
+
+export default FormUtil;

+ 6 - 0
src/api/knowledge/statistics.js

@@ -1,8 +1,10 @@
 import rxAjax from '@/assets/js/ajax.js';
+import FormUtil from './FormUtil.js'
 // 栏目定义 api接口
 export const returnData = {};
 
 returnData.baseUrl= '/api-knowledge/analysis';
+
 // 组织访问量
 returnData.organizationVisits=function (parameter) {
   var url= returnData.baseUrl + '/organizationVisit'
@@ -191,6 +193,10 @@ returnData.personSearch=function (parameter) {
   })
 }
 
+returnData.downloadStatement=function (parameter) {
+  var url= returnData.baseUrl + '/download'
+  FormUtil.doExport(url,parameter);
+}
 
 //获取当前时间
 returnData.getNowDate=function(){

+ 0 - 3
src/views/modules/knowledge/statistics/album.vue

@@ -311,9 +311,6 @@ export default {
         this.tabStatus = flag
         this.gettotalUserVisits()
       }
-    },
-    downloadClick(arg) {
-      console.log(arg)
     }
   }
 }

+ 73 - 63
src/views/modules/knowledge/statistics/components/orgPeople.vue

@@ -6,7 +6,7 @@
                 <a-input class="set-input" v-model="serachValue" placeholder="请输入" />
             </a-form-item>
             <div style="display: flex;height:40px;align-items:flex-start;justify-content: center;margin-top: 4px;">
-                <a-button style="margin-right: 8px;" @click="handleResetClick">重置</a-button>
+                <a-button style="margin-right: 8px;" @click="handleResetClick(false)">重置</a-button>
                 <a-button type="primary" @click="handleSearchOrgClick">查询</a-button>
             </div>
         </a-form>
@@ -17,9 +17,19 @@
         </a-form> -->
         <div v-if="!isOnlyOrg" style="display: flex;align-items:center;justify-content: center;margin: 0 20px;"> 
             <div class="chooseOrg-style" style="width:80px;color:rgba(0, 0, 0, 0.85);">已选组织</div>
-            <div style="flex:1;display: flex;align-items:center;flex-wrap:wrap;max-height:58px;overflow-y:scroll;">
+            <div style="flex:1;display: flex;align-items:center;flex-wrap:wrap;max-height:53px;overflow-y:scroll;">
                 <template v-if="chooseTags.length">
-                    <div style="border:1px solid #e8e8e8;padding: 2px 3px;margin: 1px 2px;border-radius:2px;" v-for="(item,index) in chooseTags" :key="index">{{ item.name }}</div>
+                    <!-- <div style="border:1px solid #e8e8e8;padding: 2px 3px;margin: 1px 2px;border-radius:2px;" v-for="(item,index) in chooseTags" :key="index">{{ item.name }}</div> -->
+                    <!-- <a-tag style="margin-bottom: 2px;margin-top: 2px" 
+                            v-for="(item,index) in chooseTags" 
+                            :key="index" 
+                            closable 
+                            @close="handleTagClose(index,item.id)">{{ item.name }}
+                        </a-tag> -->
+                    <a-tag style="margin-bottom: 2px;margin-top: 2px" 
+                        v-for="(item,index) in chooseTags" 
+                        :key="index">{{ item.name }}
+                    </a-tag>
                 </template>
                 <template v-else>
                     <div>未选择组织</div>
@@ -33,7 +43,7 @@
                 <div style="width:100%;border:1px solid #e8e8e8;height:calc( 70vh - 150px );">
                     <div class="rightDetailtop" style="text-align: center;">组织名称</div>
                      <div  style="height:calc( 100% - 38.8px );overflow-y:auto;padding: 20px 0 0 20px;">
-                        <div v-for="(item,index) in orgDataTree" :key="index">
+                        <!-- <div v-for="(item,index) in orgDataTree" :key="index">
                             <rx-tree
                                 :treeData="item.orgData"
                                 :async="true"
@@ -46,7 +56,19 @@
                                 text-field="title"
                                 @check="(selKeys, e) => check(selKeys, e,index)"
                                 parent-field="groupId"></rx-tree>
-                        </div>
+                        </div> -->
+                        <rx-tree
+                            :treeData="orgData"
+                            :async="true"
+                            v-model="checkedKeys"
+                            :loadByParent="onLoadGroupTree"
+                            multiSelect
+                            :showTreeIcon="true"
+                            :expandOnLoad="0"
+                            id-field="key"
+                            text-field="title"
+                            @check="check"
+                            parent-field="groupId"></rx-tree>
                     </div>
                 </div>
             </template>
@@ -176,10 +198,10 @@
             },
             chooseTags: [],
             orgData: [],
-            orgDataTree: [{
-                checkedKeys: {checked:[]},
-                orgData: []
-            }],
+            // orgDataTree: [{
+            //     checkedKeys: {checked:[]},
+            //     orgData: []
+            // }],
             // 组织
             checkedTarget: {},
             // 组织架构(多选)
@@ -199,38 +221,37 @@
        }
     },
     methods: {
+        handleTagClose(index,id) {
+            this.chooseTags.splice(index,1)
+            if(this.checkedKeys.checked.some(item => item == id)) {
+                this.checkedKeys.checked.map((item,index) => {
+                    if (item.indexOf(id) > -1) {
+                        this.checkedKeys.checked.splice(index, 1);
+                    }
+                })
+            }
+
+        },
         // 多选节点
-        check(selKeys, e, index) {
+        check(selKeys, e) {
             // console.log(this.orgDataTree[index].checkedKeys.checked)
             if(e.checked) {
-                if(this.chooseTags.some(item => item.id == e.node.value)) {
-                    // console.log(selKeys)
-                    // console.log( this.orgDataTree[index].checkedKeys.checked)
-                    // this.orgDataTree[index].checkedKeys.checked.map((item,index) => {
-                    //     if(item.name == e.node.title) {
-                    //         this.orgDataTree[index].checkedKeys.checked.splice(index, 1);
-                    //     }
-                    // })
-                    // this.orgDataTree[index].checkedKeys.checked.remove(e.node.value)
-                    this.$message.error(`${e.node.title}已被选择`)
-                    return false
-                } else {
-                    this.orgDataTree[index].checkedKeys.checked = selKeys
-                    this.chooseTags.push({
-                        id: e.node.value,
-                        name: e.node.title
-                    })
-                }
+                this.checkedKeys.checked = selKeys
+                this.chooseTags.push({
+                    id: e.node.value,
+                    name: e.node.title
+                })
+                console.log(this.chooseTags)
             } else {
                 let id = e.node.value
-                this.orgDataTree[index].checkedKeys.checked = selKeys
+                this.checkedKeys.checked = selKeys
                 this.chooseTags.map((item,index) => {
                     if (item.id.indexOf(id) > -1) {
                         this.chooseTags.splice(index, 1);
                     }
                 })
             }
-
+            // console.log(selKeys, e)
             // this.chooseTags.push(e.checkedNodes.map(item => {
             //     return {
             //         id: item.key,
@@ -247,7 +268,7 @@
         // 组织名称搜索
         handleSearchOrgClick() {
             if(this.serachValue==''){
-                this.handleResetClick()
+                this.handleResetClick(true)
             }else{
                 let getData={
                     "sortOrder": "asc",
@@ -276,15 +297,13 @@
                         for (let i = 0; i < data.length; i++) {
                             var rs = data[i];
                             var _isLeaf = rs.childAmount == 0 ? true : false;
-                            temp.push({title: rs.name, groupId: rs.groupId, key: rs.key, isLeaf: _isLeaf})
+                            temp.push({title: `${rs.name}-${rs.key}`, groupId: rs.groupId, key: rs.key, isLeaf: _isLeaf})
                         }
-
-                        console.log(this.orgDataTree)
-                        // this.orgData = [...temp];
-                        this.orgDataTree.push({
-                            checkedKeys: {checked:[]},
-                            orgData: [...temp]
-                        })
+                        this.orgData = [...temp]
+                        // this.orgDataTree.push({
+                        //     checkedKeys: {checked:[]},
+                        //     orgData: [...temp]
+                        // })
                     }
                     this.queryParam.params.groupId = ''
                     this.userData = []
@@ -293,15 +312,15 @@
             //清除下拉的数据
             // this.$refs.orgTable.expandedRowKeys=[];
         },
-        handleResetClick() {
+        handleResetClick(arg = false) {
             this.serachValue = ''
             this.getTreeData()
             if(!this.isOnlyOrg) {
-                this.chooseTags = []
-                this.orgDataTree = [{
-                    checkedKeys: {checked:[]},
-                    orgData: []
-                }]
+                this.orgData = []
+                if(!arg) {
+                    this.chooseTags = []
+                    this.checkedKeys.checked = []
+                }
             } else {
                 this.userData = []
                 this.queryParam.pageNo = 1
@@ -323,15 +342,9 @@
                     for (let i = 0; i < data.length; i++) {
                         var rs = data[i];
                         var _isLeaf = rs.childAmount == 0 ? true : false;
-                        temp.push({title: rs.name, groupId: rs.groupId, key: rs.key, isLeaf: _isLeaf})
+                        temp.push({title: `${rs.name}-${rs.key}`, groupId: rs.groupId, key: rs.key, isLeaf: _isLeaf})
                     }
-                    // this.orgData = [...temp]
-                    this.orgDataTree[0].orgData =  [...temp]
-                    // this.orgDataTree.push({
-                    //     checkedKeys: {checked:[]},
-                    //     orgData: [...temp]
-                    // })
-                    console.log( this.orgDataTree)
+                    this.orgData = [...temp]
                 }
             })
             //清除下拉的数据
@@ -468,8 +481,7 @@
             })
         },
         //加载左树下的子节点
-        onLoadGroupTree(treeNode,index) {
-            console.log(treeNode,index)
+        onLoadGroupTree(treeNode) {
             if (treeNode.dataRef.children) {
                 return;
             }
@@ -479,15 +491,13 @@
                 for (let i = 0; i < data.length; i++) {
                     var rs = data[i]
                     var _isLeaf = rs.childAmount == 0 ? true : false;
-                    treeData.push({title: rs.name, groupId: rs.groupId, key: rs.key,isLeaf: _isLeaf})
+                    // treeData.push({title: rs.name, groupId: rs.groupId, key: rs.key,isLeaf: _isLeaf})
+                    treeData.push({title:`${rs.name}-${rs.key}`, groupId: rs.groupId, key: rs.key,isLeaf: _isLeaf})
                 }
-                // var orgData = this.getGroupTree(this.orgData, treeNode.dataRef.groupId, treeData);
-
-                // this.orgData = [...orgData];
-                var orgData = this.getGroupTree(this.orgDataTree[index].orgData, treeNode.dataRef.groupId, treeData);
-                this.orgDataTree[index].orgData =  [...orgData];
-                // console.info("onLoadGroupTree")
-                // console.info(this.orgData)
+                var orgData = this.getGroupTree(this.orgData, treeNode.dataRef.groupId, treeData);
+                this.orgData = [...orgData];
+                // var orgData = this.getGroupTree(this.orgDataTree[index].orgData, treeNode.dataRef.groupId, treeData);
+                // this.orgDataTree[index].orgData =  [...orgData];
             })
         },
         getGroupTree(orgData, groupId, treeData) {

+ 1 - 3
src/views/modules/knowledge/statistics/map.vue

@@ -180,6 +180,7 @@ export default {
       barDataNew:[],
       barXData:[],
       type:'month',
+      name: 4,
       timeData:'',
       statistics,
       tabStatus: true,
@@ -296,9 +297,6 @@ export default {
         this.tabStatus = flag
         this.gettotalUserVisits()
       }
-    },
-    downloadClick(arg) {
-      console.log(arg)
     }
   }
 }

+ 23 - 0
src/views/modules/knowledge/statistics/sMixin/statisticsMixin.js

@@ -180,6 +180,29 @@ export default (titlePromise) => {
           this.orgForm = Object.assign({},this.$options.data().orgForm)
           this.getUserStatistics('',2)
         }
+      },
+      downloadClick(arg) {
+        let info
+        if(arg == 1) {
+          info = {
+            createTime: this.staffTime[0],
+            endTime: this.staffTime[1],
+            personId: this.staffForm.personId ? this.staffForm.personId : []
+          }
+        } else {
+          info = {
+            ...this.orgForm,
+            createTime: this.orgTime[0],
+            endTime: this.orgTime[1],
+          }
+        }
+        let data = {
+          type: this.type,
+          name: this.name,
+          downType: parseInt(arg),
+          ...info
+        }
+        statistics.downloadStatement(data)
       }
     }
   }

+ 0 - 3
src/views/modules/knowledge/statistics/search.vue

@@ -253,9 +253,6 @@ export default {
     },
     setbarDataNum(data){
       this.barDataNum=data
-    },
-    downloadClick(arg) {
-      console.log(arg)
     }
   }
 }

+ 0 - 3
src/views/modules/knowledge/statistics/synthesize.vue

@@ -300,9 +300,6 @@ export default {
       statistics.moduleUserUniqueVisits({module: 'total',type:this.type}).then(res => {
         this.dataNum = res.data
       })
-    },
-    downloadClick(arg) {
-      console.log(arg)
     }
   }
 }

+ 0 - 3
src/views/modules/knowledge/statistics/warehouse.vue

@@ -298,9 +298,6 @@ export default {
         this.barXData=barXData,
         this.barData=barData
       })
-    },
-    downloadClick(arg) {
-      console.log(arg)
     }
   }
 }