管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-01-16 21ddc9ec1b1b76d2ce20e512328e65acaf1af2bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<template>
  <div class="mochaitmo_Box">
    <div class="left_tree">
      <el-card class="el-card-define">
        <div class="card_tree">
          <el-menu
            active-text-color="#ffd04b"
            class="el-menu-vertical-demo"
            :default-active="activeIndex"
            background-color="transparent"
            text-color="#fff"
            @select="handleselect"
          >
            <customElMenu :menuData="menuList"></customElMenu>
          </el-menu>
        </div>
      </el-card>
    </div>
    <div class="right_page">
      <el-card class="el-card-define">
       <div>
          <menu-settings v-if="setMenuFlag == 'menuSettings'"></menu-settings>
          <user-management v-if="setMenuFlag == 'userInfoManage'"></user-management>
          <org-manage v-if="setMenuFlag == 'orgManage'"></org-manage>
          <resource-manage v-if="setMenuFlag == 'resourceManage'"></resource-manage>
          <role-manage v-if="setMenuFlag == 'roleManage'"></role-manage>
          <authority-manage v-if="setMenuFlag == 'authorityManage'"></authority-manage>
          <user-role-authorization v-if="setMenuFlag == 'userRoleAuthorization'"></user-role-authorization>
          <menu-role-authorization v-if="setMenuFlag == 'menuRoleAuthorization'"></menu-role-authorization>
          <role-menu-authorization v-if="setMenuFlag == 'roleMenuAuthorization'">
          </role-menu-authorization>
          <role-res-authorization v-if="setMenuFlag == 'roleResAuthorization'"></role-res-authorization>
          <log-log v-if="setMenuFlag == 'logLog'"> </log-log>
          <operation-log v-if="setMenuFlag == 'operationLog'"></operation-log>
          <eventlog-manage v-if="setMenuFlag == 'eventlogManage'"></eventlog-manage>
          <tokentool v-if="setMenuFlag == 'tokentool'"></tokentool>
          <blackwhite-list v-if="setMenuFlag == 'blackwhiteList'"></blackwhite-list>
          <database-monitoring v-if="setMenuFlag == 'dataIfream'"></database-monitoring>
          <system-monitoring v-if="setMenuFlag == 'systemMonitoring'"></system-monitoring>
          <parameter-configuration v-if="setMenuFlag == 'parameterConfiguration'"></parameter-configuration>
          <downlog v-if="setMenuFlag == 'downlog'"></downlog>
        </div>
      </el-card>
    </div>
  </div>
</template>
 
<script>
import menuSettings from '@/views/maintenance/menuSettings.vue'; //菜单管理
import userManagement from '@/views/maintenance/userManagement.vue'; //用户管理
import orgManage from '@/views/userManage/orgManage.vue'; //单位管理
import resourceManage from '@/views/userManage/resourceManage.vue'; //资源管理
import roleManage from '@/views/userManage/roleManage.vue'; //角色管理
import authorityManage from '@/views/userManage/authorityManage.vue'; //权限管理
import userRoleAuthorization from '@/views/AuthorizationManagement/userRoleAuthorization.vue'; //用户角色授权
import menuRoleAuthorization from '@/views/AuthorizationManagement/menuRoleAuthorization.vue'; //菜单权限授权
import roleMenuAuthorization from '@/views/AuthorizationManagement/roleMenuAuthorization.vue'; //角色菜单授权
import roleResAuthorization from '@/views/AuthorizationManagement/roleResAuthorization.vue'; //角色资源授权
import logLog from '@/views/maintenance/logLog.vue'; //登录日志
import operationLog from '@/views/maintenance/operationLog.vue'; //操作日志
import eventlogManage from '@/views/maintenance/eventlogManage.vue'; //资源日志
import tokentool from '@/views/maintenance/tokentool.vue'; //令牌管理
import blackwhiteList from '@/views/maintenance/blackwhiteList.vue'; //黑白名单
import databaseMonitoring from '@/views/maintenance/databaseMonitoring.vue'; //数据库监控
import systemMonitoring from '@/views/maintenance/systemMonitoring.vue'; //系统监控
import parameterConfiguration from '@/views/maintenance/parameterConfiguration.vue'; //系统配置
import downlog  from '@/views/maintenance/downlog.vue'; //下载日志
import { selectMenuRecursive, queryMenuTree, getPerms } from '../../api/api';
import customElMenu from '../../components/customElMenu.vue';
export default {
  components: {
  menuSettings,
    userManagement,
    orgManage,
    resourceManage,
    roleManage,
    authorityManage,
    userRoleAuthorization,
    menuRoleAuthorization,
    roleMenuAuthorization,
    roleResAuthorization,
    logLog,
    operationLog,
    eventlogManage,
    tokentool,
    blackwhiteList,
    databaseMonitoring,
    systemMonitoring,
    parameterConfiguration,
    customElMenu,
    downlog
  },
  data() {
    return {
     setMenuFlag: '   ',
      activeIndex: ' ',
      oriData: [], //原始树数据
      dirData: [], //el树数据
      newData: [], //拖动后数据
      lang: 'zh',
 
      menuList: [],
      editTitle: '',
      showPopover: false,
      showEditInfoWrapper: false,
      showEdit: false,
      editMenu: false,
      editCatalogue: false,
      editUnit: false,
      itemdetail: {},
      formLabelWidth: '70px',
    };
  },
  created() { },
  mounted() {
  this.getTreeData();
  },
  methods: {
     async getCookies() {
      var boolean = this.getTimeCookies();
      if (boolean != true) {
        this.$router.push('/login');
        return;
      }
      if (this.$store.state.permsEntity.length == 0) {
        const data = await getPerms();
        this.$store.state.permsEntity = data.result;
      }
      var store = this.menuList[0];
      this.setViewController(store);
    },
    getTimeCookies() {
      var time1 = new Date(JSON.parse(localStorage.getItem('LFToken')).time);
      var time2 = new Date();
      if (time2 > time1) {
        return false;
      } else {
        return true;
      }
    },
    //获取树
    async getTreeData() {
      const data = await queryMenuTree();
 
      let menuLists = data.result.filter((value) => {
        return value.url == '/mochaitmo';
      });
      
      const res = await selectMenuRecursive({ id: menuLists[0].id});
         
      if (res.code == 200) {
        if (res.result.length != 0) {
          let menuList = res.result.filter((value) => {
            return value.type == 1;
          });
          this.menuList = this.treeData(menuList);
          this.getCookies();
          //
        } else {
          alert('暂无菜单栏数据');
        }
      } else {
        console.log('接口报错');
      }
 
      // this.treeList = this.treeData(data.result);
    },
    setViewController(res) {
      if (res == null) {
        return;
      }
      if (res.children != null) {
        this.setViewController(res.children[0]);
      } else {
        this.$store.state.currentPerms = res.perms;
        this.setMenuFlag = res.url;
        this.activeIndex = res.url;
      }
    },
    treeData(source) {
      let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
      // console.log(cloneData);
      if (cloneData.length != 0) {
        return cloneData.filter((father) => {
          // 循环所有项
          let branchArr = cloneData.filter((child) => father.id == child.pid); // 对比ID,分别上下级菜单,并返回数据
          branchArr.length > 0 ? (father.children = branchArr) : ''; // 给父级添加一个children属性,并赋值
          // 属于同一对象问题,例如:令 a=b、c=1 ,然后再令 b.c=c , 那么 a.c=b.c=c=1 ;同理,后续令 c.d=2 ,那么 a.c.d 也是=2;
          // 由此循环多次后,就能形成相应的树形数据结构
          return father.pid == 1; // 返回一级菜单
        });
      } else {
        alert('暂无菜单栏数据');
      }
    },
 
    handleselect(index, indexPath, e) {
      this.getTimeCookies();
      var data = e.$attrs.perms;
      this.$store.state.currentPerms = data.perms;
      var index = data.url;
      if (index != null) {
        if (index.indexOf('http') != -1) {
          this.$store.commit('getIframe', data.url);
          index = 'dataIfream';
        }
      }
      this.setMenuFlag = index;
 
    },
  },
};
</script>
 
<style lang="less" scoped>
.mochaitmo_Box {
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  margin: 0;
  padding: 10px;
  overflow-y: hidden;
  .left_tree {
    width: 270px;
    height: 100%;
    position: relative;
    float: left;
    border-radius: 5px;
  }
  .el-card-define {
    height: 100%;
    background: #303030;
    border: 1px solid gray;
    padding: 1px !important;
  }
  .el-tree {
    background-color: transparent;
  }
  .card_tree {
    height: 100%;
    overflow-y: auto;
  }
  .el-card__body,
  .el-main {
    padding: 0px !important;
    height: 100%;
  }
  .right_page {
    width: calc(100% - 280px);
    height: 100%;
    background: #303030;
    position: relative;
    float: right;
  }
  /deep/.el-menu {
    border: transparent !important;
  }
  /deep/.el-submenu__title:hover {
    background: rgba(255, 255, 255, 0.3) !important;
  }
  /deep/ .el-submenu .el-menu-item:hover {
    background: rgba(255, 255, 255, 0.3) !important;
  }
  /deep/.el-textarea__inner {
    background: transparent;
    border-color: #fff !important;
    color: white;
  }
  /deep/.el-textarea .el-input__count {
    background: transparent;
    color: #fff !important;
  }
  /deep/ .el-card__body {
    padding: 0px !important;
    height: 100%;
  }
}
</style>