zhaoke před 1 rokem
rodič
revize
98679baf04

+ 8 - 4
src/components/publicPageTree/index.vue

@@ -40,9 +40,10 @@ export default {
         children: 'children',
         label: 'pagename'
       },
-      defaultKeys: [],
+      defaultKeys: [-1],
       nodeKey: 'pageconfigurationid',
-      msgCaps: []
+      msgCaps: [],
+      dataKey: 'pagename'
     }
   },
   watch: {
@@ -61,7 +62,10 @@ export default {
       handler (row) {
         const { nodeKey, nodeValue } = row
         if (nodeKey) this.nodeKey = nodeKey
-        if (nodeValue) this.defaultProps.label = nodeValue
+        if (nodeValue) {
+          this.defaultProps.label = nodeValue
+          this.dataKey = nodeValue
+        }
       },
       deep: true,
       immediate: true
@@ -88,7 +92,7 @@ export default {
     },
     filterNode (value, data) {
       if (!value) return true;
-      return data.pagename.indexOf(value) !== -1;
+      return data[this.dataKey].indexOf(value) !== -1;
     },
     pageInit (arr) {
       if (typeof arr == 'object') {

+ 61 - 4
src/views/permissionPage/components/permissionList.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="permissionList">
+  <div v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)" class="permissionList">
     <div class="permissionList_tree">
       <div class="permissionList_tree_head flex">
         <div class="permissionList_tree_head_list">名称</div>
@@ -9,7 +9,7 @@
       </div>
       <div class="permissionList_tree_body">
         <el-scrollbar style="height: 100%" :horizontal="false">
-          <el-tree :data="data" show-checkbox node-key="tid" default-expand-all :expand-on-click-node="false">
+          <el-tree ref="tree" :data="data" show-checkbox node-key="tid" default-expand-all :expand-on-click-node="false">
             <template slot-scope="{node,data}">
               <div class="custom-tree-node flex">
                 <div class="custom-tree-node-list">{{data.pagename}}</div>
@@ -40,13 +40,24 @@ import PublicPageDialog from '@/components/PublicPageDialog'
 import AdvancedQuery from '@/components/AdvancedQuery'
 import { mapGetters } from 'vuex'
 import { listToTree } from '@/utils/validate'
-
+import { Query } from "@/api/webApi"
 export default {
   name: 'Permissionlist',
+  props: {
+    listMap: {
+      type: Object,
+      default: () => new Object()
+    },
+    treeMap: {
+      type: Object,
+      default: () => new Object()
+    },
+  },
   components: { PublicPageDialog, AdvancedQuery },
   data () {
     return {
       advancedDrawer: false,
+      loading: false,
       data: [],
       defaultProps: {
         children: 'children',
@@ -54,9 +65,35 @@ export default {
       },
       defaultKeys: [],
       nodeKey: 'pageconfigurationid',
-      adDep: 1
+      adDep: 1,
+      dataKey: 'pagename'
     }
   },
+  watch: {
+    listMap: {
+      handler (row) {
+        if (Object.keys(row).length) {
+          const queryItem = {}
+          queryItem[this.nodeKey] = row[this.nodeKey]
+          this.queryTreeData(6, queryItem, '用户组')
+        }
+      },
+      deep: true,
+      immediate: true
+    },
+    treeMap: {
+      handler (row) {
+        const { nodeKey, nodeValue } = row
+        if (nodeKey) this.nodeKey = nodeKey
+        if (nodeValue) {
+          // this.defaultProps.label = nodeValue
+          this.dataKey = nodeValue
+        }
+      },
+      deep: true,
+      immediate: true
+    },
+  },
   computed: {
     ...mapGetters(['authArrs'])
   },
@@ -86,6 +123,26 @@ export default {
       this.$store.dispatch('auth/changeAuthMsg', ndata.children)
       this.advancedDrawer = true
     },
+    async queryTreeData (serviceid, defaultfilter, pagename) {
+      this.loading = true;
+      const datacontent = { filter: defaultfilter }
+      try {
+        const { code, returnData } = await Query({
+          serviceid,
+          datacontent,
+          event: '0'
+        });
+        if (code == 0) {
+          console.log(returnData)
+          this.$refs.tree.setCheckedKeys([1])
+        } else {
+          this.$message.error(`获取${pagename}数据失败`);
+        }
+      } catch (error) {
+        this.$message.error(`获取${pagename}数据失败`);
+      }
+      this.loading = false;
+    }
   }
 }
 </script>

+ 48 - 2
src/views/permissionPage/index.vue

@@ -3,10 +3,10 @@
     <PublicPageHeader class="permissionPage_head" page-title="界面配置管理" />
     <div class="permissionPage_content flex">
       <div class="permissionPage_content_left">
-        <PublicPageTree />
+        <PublicPageTree :tree-data="treeData" :dep-math="depMath" :tree-map="treeNodeMap" @treeNodeClick="treeNodeClick" />
       </div>
       <div class="permissionPage_content_right">
-        <PublicPageTable />
+        <PublicPageTable :list-map="listMap" :tree-map="treeNodeMap" />
       </div>
     </div>
   </div>
@@ -16,9 +16,55 @@
 import PublicPageHeader from '@/components/PublicPageHeader'
 import PublicPageTable from './components/permissionList.vue'
 import PublicPageTree from '@/components/publicPageTree'
+import { mapGetters } from 'vuex'
 export default {
   name: 'Permissionpage',
   components: { PublicPageHeader, PublicPageTable, PublicPageTree, },
+  data () {
+    return {
+      treeData: [], //tree数据
+      treeParameters: {}, //tree传递参数
+      treeNodeMap: {}, //tree传递map
+      depMath: 0,
+      listMap: {}
+    }
+  },
+  computed: {
+    ...mapGetters(['authArrs']),
+  },
+  mounted () {
+    this.pageInit()
+  },
+  methods: {
+    //页面初始化
+    pageInit () {
+      //获取页面查询参数
+      const { query } = this.$route
+      this.pageQuery = query
+      //获取页面配置
+      const { pagecode, qid, auth_id } = this.$route.meta
+      //获取页面权限类型组件  pagetype 1模块  2页面  3按钮 4表格 5树形  6弹窗
+      const pageAuths = this.authArrs
+      if (!pageAuths.length) return
+      //获取当前页面权限类型
+      const pageAuthArrs = pageAuths.filter(item => item['superiorid'] == auth_id)
+      if (!pageAuthArrs.length) return
+      //获取tree权限
+      const pageAuthtrees = pageAuthArrs.filter(item => item.pagetype == 'tree')
+      if (pageAuthtrees?.length) this.getPageTreeSetting(pageAuthtrees)
+    },
+    //根据页面tree设置数据
+    getPageTreeSetting (pageAuthtrees) {
+      const { passparameters, dropdownlistid, dropdownlistlabel } = pageAuthtrees[0]
+      this.treeNodeMap = { nodeKey: dropdownlistid, nodeValue: dropdownlistlabel }
+      this.treeParameters = passparameters
+      this.treeData = pageAuthtrees
+    },
+    //获取tree点击
+    treeNodeClick (data) {
+      this.listMap = data
+    },
+  }
 }
 </script>