surprise
2024-03-05 1ce1b525e7470ebaaeb0d5cd1e59bd905c1a7114
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<template>
  <div class="contentBox">
 
    <div
      class="box"
      ref="box"
    >
      <div class="left box_div">
        <el-menu
          :default-active="activeIndex"
          background-color="transparent"
          @select="handleselect"
        >
          <customElMenu :menuData="menuList"></customElMenu>
        </el-menu>
      </div>
      <div
        class="resize"
        title="收缩侧边栏"
      >
        ⋮
      </div>
      <div class="mid box_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>
        <template-manage v-if="setMenuFlag == 'templateManage'"></template-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>
   
        <data-statistics v-if="setMenuFlag == 'dataStatistics'"></data-statistics> -->
      </div>
    </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 templateManage from '@/views/userManage/templateManage.vue'//模板管理
import { selectMenuRecursive, queryMenuTree, getPerms, sign_insertOpLog } from '../../api/api';
import customElMenu from '../../components/customElMenu.vue';
import dataStatistics from '@/views/datamanage/dataStatistics.vue'; //数据统计
 
export default {
  components: {
    menuSettings,
    userManagement,
    orgManage,
    resourceManage,
    roleManage,
    authorityManage,
    userRoleAuthorization,
    menuRoleAuthorization,
    roleMenuAuthorization,
    roleResAuthorization,
    logLog,
    operationLog,
    eventlogManage,
    tokentool,
    blackwhiteList,
    databaseMonitoring,
    systemMonitoring,
    parameterConfiguration,
    customElMenu,
    downlog,
    templateManage,
    dataStatistics
  },
  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',
      m1: null,
      menuId: null,
    };
  },
  created() { },
  mounted() {
    this.getTreeData();
    //左右拖動
    this.dragControllerDiv();
  },
  methods: {
    //左右拖動
    dragControllerDiv: function () {
      var resize = document.getElementsByClassName('resize');
      var left = document.getElementsByClassName('left');
      var mid = document.getElementsByClassName('mid');
      var box = document.getElementsByClassName('box');
      for (let i = 0; i < resize.length; i++) {
        // 鼠标按下事件
        resize[i].onmousedown = function (e) {
          //颜色改变提醒
          resize[i].style.background = '#818181';
          var startX = e.clientX;
          resize[i].left = resize[i].offsetLeft;
          // 鼠标拖动事件
          document.onmousemove = function (e) {
            var endX = e.clientX;
            var moveLen = resize[i].left + (endX - startX); // (endx-startx)=移动的距离。resize[i].left+移动的距离=左边区域最后的宽度
            var maxT = box[i].clientWidth - resize[i].offsetWidth; // 容器宽度 - 左边区域的宽度 = 右边区域的宽度
 
            if (moveLen < 205) moveLen = 205; // 左边区域的最小宽度为32px
            if (moveLen > maxT - 300) moveLen = maxT - 300; //右边区域最小宽度为150px
 
            resize[i].style.left = moveLen; // 设置左侧区域的宽度
 
            for (let j = 0; j < left.length; j++) {
              left[j].style.width = moveLen + 'px';
              mid[j].style.width = (box[i].clientWidth - moveLen - 10) + 'px';
            }
          };
          // 鼠标松开事件
          document.onmouseup = function (evt) {
            //颜色恢复
            resize[i].style.background = '#d6d6d6';
            document.onmousemove = null;
            document.onmouseup = null;
            resize[i].releaseCapture && resize[i].releaseCapture(); //当你不在需要继续获得鼠标消息就要应该调用ReleaseCapture()释放掉
          };
          resize[i].setCapture && resize[i].setCapture(); //该函数在属于当前线程的指定窗口里设置鼠标捕获
          return false;
        };
      }
    },
 
    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.m1 = store.cnName;
      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 == '/systemController';
      });
      debugger
      this.menuId = menuLists[0].id;
      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;
          })
            .filter(value => {
              return value.isShow == 1;
            });
          this.menuList = this.treeData(menuList);
          this.getCookies();
          const hanleselectmochaitmo = sessionStorage.getItem('hanleselectmochaitmo')
          if (hanleselectmochaitmo) {
            this.$nextTick(function () {
              this.handleselecttwo(JSON.parse(hanleselectmochaitmo).url, JSON.parse(hanleselectmochaitmo))
              this.setViewController(JSON.parse(hanleselectmochaitmo))
            })
          }
          //
        } else {
          alert('暂无菜单栏数据');
        }
      } else {
        console.log('接口报错');
      }
 
      // this.treeList = this.treeData(data.result);
    },
    async signInsertOpLog(m1, m2) {
      var obj = {
        m1: m1,
        m2: m2,
      }
      // const data = await sign_insertOpLog(obj);
 
 
    },
    setViewController(res) {
      if (res == null) {
        return;
      }
 
      if (res.children != null) {
 
 
        this.setViewController(res.children[0]);
      } else {
 
        this.$store.state.currentPerms = res.perms;
        this.signInsertOpLog(this.m1, res.cnName)
        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 == this.menuId; // 返回一级菜单
        });
      } else {
        alert('暂无菜单栏数据');
      }
    },
 
    handleselect(index, indexPath, e) {
      this.getTimeCookies();
 
      this.signInsertOpLog(this.m1, e.$attrs.perms.cnName)
      const a = JSON.stringify(e.$attrs.perms)
      sessionStorage.setItem('hanleselectmochaitmo', a)
 
      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;
 
    },
    handleselecttwo(index, e) {
      this.getTimeCookies();
 
      const a = JSON.stringify(e)
      sessionStorage.setItem('hanleselectmochaitmo', a)
 
      var data = e;
      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>