Przeglądaj źródła

bug修复+改造机构树

林倩 4 lat temu
rodzic
commit
a9a35341dc

+ 6 - 1
src/api/common.js

@@ -65,7 +65,12 @@ export function appTree(data) {
  * 根据名称name 分页pageNum pageSize
  */
 export function treeMatch(data) {
-    return axios.post(`orgsvr/v2/org/tree/match`, data, { loading: true });
+    // return axios.post(`orgsvr/v2/org/tree/match`, data);
+   return request({
+        url: "orgsvr/v2/org/tree/match",
+        method: "POST",
+        data
+    })
 }
 
 /**

+ 2 - 0
src/api/data-auth.js

@@ -125,6 +125,7 @@ export function getDataDetailList() {
 export function getSelectList(params) {
     return request({
         url: `${baseUrl}/getDataResourceTree`,
+        method: "GET",
         params: {
             typeCode: params
         }
@@ -135,6 +136,7 @@ export function getSelectList(params) {
 export function userDataTreeByIdcard(authType, idcard) {
     return request({
         url: `${baseUrl}/userDataTreeByIdcard`,
+        method: "GET",
         params: {
             authType,
             idcard

+ 21 - 7
src/components/data-auth/set-auth.vue

@@ -9,18 +9,22 @@
             <el-tabs v-model="activeName" @tab-click="handleClick">
                 <el-tab-pane label="表授权" name="TABLE">
                     <table-column-auth
+                        :key="tableKey"
                         :subId="subId"
                         :subType="subType"
                         :saveApi="saveApi"
                         tab="TABLE"
+                        @submitReset="submitReset"
                     ></table-column-auth>
                 </el-tab-pane>
-                <el-tab-pane label="列授权" name="COLUMN"> 
-                     <table-column-auth
+                <el-tab-pane label="列授权" name="COLUMN">
+                    <table-column-auth
+                        :key="columnKey"
                         :subId="subId"
                         :subType="subType"
                         :saveApi="saveApi"
                         tab="COLUMN"
+                        @submitReset="submitReset"
                     ></table-column-auth>
                 </el-tab-pane>
             </el-tabs>
@@ -44,13 +48,14 @@ export default {
         saveApi: String
     },
     components: {
-        tableColumnAuth,
-        
+        tableColumnAuth
     },
     data() {
         return {
             // 激活的tab
-            activeName: "TABLE"
+            activeName: "TABLE",
+            tableKey: 0,
+            columnKey: 0
         };
     },
     computed: {},
@@ -59,8 +64,17 @@ export default {
          * @description: 切换tab
          * @param {*} tab
          */
-        handleClick(tab) {
-           
+        handleClick(tab) {},
+        /**
+         * @description: 重置
+         * @param {*} tab
+         */
+        submitReset(tab) {
+            if (tab == "TABLE") {
+                this.tableKey++;
+            } else {
+                this.columnKey++;
+            }
         }
     },
     created() {

+ 2 - 3
src/components/data-auth/table-column-auth.vue

@@ -4,7 +4,7 @@
 @Date: 2021-04-19 15:46 
 -->
 <template>
-    <div :key="key">
+    <div>
         <div v-if="subId">
             <div style="height: calc(100vh - 22rem)">
                 <dg-scrollbar>
@@ -51,7 +51,6 @@ export default {
             authData: [],
             showCheckListBtn: false,
             saveAuthVoList: {},
-            key: 0
         };
     },
     computed: {},
@@ -82,7 +81,7 @@ export default {
          * @description: 重置授权
          */
         handleReset() {
-            this.key++;
+            this.$emit("submitReset", this.tab)
         },
         /**
          * @description: 保存授权

+ 1 - 1
src/main.js

@@ -45,7 +45,7 @@ if (!process.env.IS_BASE_PACKAGE) {
     utils = require("@/utils").default;
 } else {
     // 引入路由权限控制
-    if(process.env.NEED_LOGIN) {
+    if(process.env.NEED_LOGIN == "true") {
        require("@/router/dcuc_permission.js");      
     }else {
         require("@/router/lxr_permission.js");  

+ 2 - 1
src/pages/common/search-tree/index.vue

@@ -107,7 +107,8 @@ export default {
             const { searchForm } = this;
 
             commonApi.treeMatch(searchForm).then(res => {
-                that.searchResultList = [...that.searchResultList, ...res];
+                const { content } = res.data;
+                that.searchResultList = [...that.searchResultList, ...content];
                 that.isclickSearch = true;
                 if (that.searchResultList.length > 0) {
                     that.isShowSearchResult = true;

+ 58 - 36
src/pages/common/tree/index.vue

@@ -1,8 +1,8 @@
 <template>
-    <div :class="{ 'u-tree_pop': title }">
+    <div class="u-tree_pop">
         <h4 v-if="title" class="dg-words-title-second">{{ title }}</h4>
         <slot></slot>
-        <div v-if="search" class="u-tree__seach">
+        <div v-if="search" class="u-tree__search">
             <!--<el-input placeholder="关键字搜索" suffix-icon="el-icon-search" v-model="filterText" />-->
             <el-input
                 placeholder="关键字搜索"
@@ -12,13 +12,11 @@
                 size="mini"
                 @keyup.enter.native="handleSearch"
             ></el-input>
-            <dg-button type="primary" @click="handleSearch" icon="el-icon-search">查询</dg-button>
-        </div>
-        <div v-if="search && searchResultList.length == 0 && isclickSearch" class="no-search-data">
-            没有数据或权限不足
+            <dg-button type="primary" @click="handleSearch" icon="el-icon-search" class="u-tree__search-btn" size="mini">查询</dg-button>
         </div>
+        <div v-if="searchResultList.length == 0 && isclickSearch && !loading" class="no-search-data">查无数据</div>
         <div class="u-tree__bar" :style="{ height: treeHeight }">
-            <dg-scrollbar v-show="!isShowSearchResult">
+            <dg-scrollbar v-show="!isclickSearch" :key="key">
                 <dg-tree
                     ref="tree"
                     node-key="id"
@@ -30,7 +28,7 @@
                     v-bind="$attrs"
                     v-on="$listeners"
                     :expand-on-click-node="true"
-                    :style="{'padding-right': paddingRight}"
+                    :style="{ 'padding-right': paddingRight }"
                 >
                     <div slot-scope="{ node, data }" class="u-tree-label">
                         <p @dblclick="handlerNodeDoubleClick(data)" @click="handleNodeClick(data)">
@@ -41,9 +39,9 @@
                     </div>
                 </dg-tree>
             </dg-scrollbar>
-            <dg-scrollbar v-show="isShowSearchResult" load-distance @scroll-bottom="handleScrollToBottomLoading">
-                <ul class="search-result">
-                    <li v-for="(item, index) in searchResultList" :key="index" @click="doClickSearchItem(item)">
+            <dg-scrollbar load-distance @scroll-bottom="handleScrollToBottomLoading" v-loading="loading">
+                <ul class="search-result" v-show="searchResultList.length > 0">
+                    <li :class="{'is-active': item.selected}" v-for="(item, index) in searchResultList" :key="index" @click="doClickSearchItem(item,index)">
                         {{ item.fullName }}
                     </li>
                 </ul>
@@ -110,7 +108,7 @@ export default {
                     name: "",
                     mtType: "app",
                     pageNum: 1,
-                    pageSize: 20
+                    pageSize: 50
                 };
             }
         },
@@ -131,7 +129,7 @@ export default {
         },
         paddingRight: {
             type: String,
-            default: '0px'
+            default: "0px"
         },
         lazy: {
             type: Boolean,
@@ -166,44 +164,58 @@ export default {
             timer: null,
             isShowSearchResult: false,
             searchResultList: [],
-            isclickSearch: false
+            isclickSearch: false,
+            key: 0,
+            loading: false
         };
     },
     methods: {
         // 滚动条触底加载数据
         handleScrollToBottomLoading() {
-            let self = this;
-            console.log("scroll bottom");
+            if (this.isLast) {
+                return;
+            }
+            this.loading = true;
             setTimeout(function () {
-                self.searchForm.pageNum++;
-                self.treeMatch();
+                this.searchForm.pageNum++;
+                this.treeMatch();
             }, 500);
         },
         // 加载数据
         treeMatch() {
-            const that = this;
             const { searchForm } = this;
-
             commonApi.treeMatch(searchForm).then((res) => {
-                if (res) {
-                    that.searchResultList = [...that.searchResultList, ...res];
-                }
-                that.isclickSearch = true;
-                if (that.searchResultList.length > 0) {
-                    that.isShowSearchResult = true;
+                let { content, totalElements } = res.data;
+                for (let i = 0; i < content.length; i++) {
+                    content[i].selected = false;                    
                 }
+                this.searchResultList = [...this.searchResultList, ...content];
+                this.isLast = this.searchResultList.length == totalElements;
+                this.loading = false;
             });
         },
         handleSearch() {
-            this.$set(this.searchForm, "pageNum", 1);
-            this.$set(this, "searchResultList", []);
-
-            this.treeMatch();
+            if (this.searchForm.name) {
+                this.loading = true;
+                this.isclickSearch = true;
+                this.$set(this.searchForm, "pageNum", 1);
+                this.$set(this, "searchResultList", []);
+                this.treeMatch();
+            } else {
+                this.searchResultList = [];
+                this.isclickSearch = false;
+                this.key++;
+            }
         },
-        doClickSearchItem(item) {
-            this.isShowSearchResult = false;
-            this.searchForm.name = item.fullName;
+        doClickSearchItem(item, index) {
+            // 清空选中效果
+            for (let i = 0; i < this.searchResultList.length; i++) {
+                this.searchResultList[i].selected = false;               
+            }
+            // 设置选中效果
+            this.searchResultList[index].selected = true;
             this.$emit("doClickSearchItem", item);
+            this.$emit("handleGetNode", { ...item, code: item.id });
         },
         handlerNodeDoubleClick(data) {
             const that = this;
@@ -276,7 +288,7 @@ export default {
                         if (that.ifCheckedFirstNode) {
                             that.setCurrentKey(that.rootNode);
                         }
-                        that.$emit("submitRootNode", { id: that.rootNode, name: res[0].name, code: res[0].code});
+                        that.$emit("submitRootNode", { id: that.rootNode, name: res[0].name, code: res[0].code });
                     }
                 })
                 .catch(() => resolve([]));
@@ -312,13 +324,20 @@ export default {
         margin-left: 7px;
     }
 
-    .u-tree__seach {
+    .u-tree__search {
         margin: 8px;
+        display: flex;
+        align-items: center;
+        &-btn {
+            margin-left: 5px;
+        }
     }
 }
 
 .no-search-data {
-    color: #ff684d;
+    text-align: center;
+    color: rgba(0, 0, 0, 0.45);
+    margin-top: 40px;
 }
 .search-result {
     li {
@@ -331,6 +350,9 @@ export default {
     li:hover {
         background-color: rgba(24, 144, 255, 0.12);
     }
+    .is-active {
+        background-color: rgba(24, 144, 255, 0.12);
+    }
 }
 .u-tree-label {
     width: 85%;

+ 4 - 4
src/pages/data-auth-module/data-permission-manage/data-auth-manage/org-auth.vue

@@ -9,7 +9,7 @@
             <!-- 机构列表 -->
             <dg-col :span="5" class="property-wapper__left">
                 <dg-card header="机构列表" class="org-card box-card">
-                    <propety-tree
+                    <org-tree
                         ref="tree"
                         class="u-pm__left"
                         treeHeight="calc(100vh - 19rem)"
@@ -17,7 +17,7 @@
                         paddingRight="15px"
                         @handleGetNode="handleGetNode"
                         @submitRootNode="handleGetNode"
-                    ></propety-tree>
+                    ></org-tree>
                 </dg-card>
             </dg-col>
             <!-- 权限设置 -->
@@ -29,11 +29,11 @@
 </template>
 
 <script>
-import propetyTree from "@/pages/common/tree";
+import orgTree from "@/pages/common/tree";
 import setAuth from "@/components/data-auth/set-auth";
 export default {
     components: {
-        propetyTree,
+        orgTree,
         setAuth
     },
     data() {