SideMenu.vue 12.7 KB
Newer Older
1
<template id="SideMenu">
zhengxiaokui committed
2
  <c-row>
3
    <div class="eContainer-menu-search">
4
      <el-button
zhengxiaokui committed
5 6 7
        icon="el-icon-s-fold"
        v-if="menuOpen"
        @click="closeMenu"
8 9
      ></el-button>
      <el-button icon="el-icon-s-unfold" v-else @click="openMenu"></el-button>
10
      <c-search-input v-show="menuOpen"></c-search-input>
11
    </div>
潘际乾 committed
12
    <c-content :height="menusHeight">
zhengxiaokui committed
13 14 15 16 17 18 19 20
      <el-menu
        :default-active="activeMenu"
        class="el-menu-vertical-demo"
        v-bind:router="true"
        @open="handleOpen"
        @close="handleClose"
        :collapse="!menuOpen"
      >
liushikai committed
21
        <SubMenu :subMenuList="menus" :openFlgArr="openFlgArr"></SubMenu>
zhengxiaokui committed
22
      </el-menu>
23
    </c-content>
zhengxiaokui committed
24
  </c-row>
fukai committed
25 26
</template>
<script>
zhengxiaokui committed
27 28
import Button from "../../components/Button.vue";
import SubMenu from "~/components/SubMenu.vue";
29

zhengxiaokui committed
30 31
export default {
  components: { Button, SubMenu },
32
  data: function () {
zhengxiaokui committed
33
    return {
liushikai committed
34
      openFlgArr: [],
zhengxiaokui committed
35 36
      menuOpen: true,
      menuList: [
wangguangchao committed
37 38 39 40
        // { inifrm: "0", ininam: "公共夹", pntmiu: "" },
        // { inifrm: "sptsel", ininam: "待办任务", pntmiu: "0" },
        // { inifrm: "trnrel", ininam: "复核任务", pntmiu: "0" },
        // { inifrm: "diasel", ininam: "备忘录选择交易", pntmiu: "0" },
liushikai committed
41
        { inifrm: "1", ininam: "汇款业务", pntmiu: "" },
zhengxiaokui committed
42 43 44
        { inifrm: "infcpd", ininam: "汇款查询", pntmiu: "1" },
        { inifrm: "cptopn", ininam: "汇出汇款", pntmiu: "1" },
        { inifrm: "cptadv", ininam: "汇入汇款", pntmiu: "1" },
45

liushikai committed
46
        { inifrm: "2", ininam: "买方信用证", pntmiu: "" },
47 48 49
        // { inifrm: "ditopn", ininam: "信用证开立", pntmiu: "2" },
        // { inifrm: "ditame", ininam: "信用证修改", pntmiu: "2" },
        // { inifrm: "ditcan", ininam: "信用证注销", pntmiu: "2" },
潘际乾 committed
50 51
        { inifrm: "infdid", ininam: "买方信用证交易查询", pntmiu: "2" },
        { inifrm: "infbdd", ininam: "买方信用证单据查询", pntmiu: "2" },
zhoubaojian committed
52
        //{ inifrm: "bdtset", ininam: "买方信用证收款", pntmiu: "2" },
潘际乾 committed
53
        { inifrm: "22", ininam: "卖方信用证", pntmiu: "" },
54 55 56 57
        { inifrm: "infdet", ininam: "卖方信用证交易查询", pntmiu: "22" },
        { inifrm: "infbfd", ininam: "卖方信用证单据查询", pntmiu: "22" },
        //{ inifrm: "bftsnd", ininam: "卖方信用证寄单", pntmiu: "2" },
        //{ inifrm: "bftset", ininam: "卖方信用证收款", pntmiu: "2" },
58 59
        // { inifrm: "bdtudp", ininam: "信用证承兑", pntmiu: "2" },
        // { inifrm: "bdtdcr", ininam: "信用证不符点/拒付", pntmiu: "2" },
60 61
        // { inifrm: "ditdck", ininam: "信用证到单", pntmiu: "2" },
        // { inifrm: "bdtset", ininam: "信用证付款", pntmiu: "2" },
liushikai committed
62
        { inifrm: "3", ininam: "出口信用证", pntmiu: "" },
zhengxiaokui committed
63
        { inifrm: "letsel", ininam: "出口信用证查询", pntmiu: "3" },
zhengxiaokui committed
64
        { inifrm: "letopn", ininam: "出口信用证通知", pntmiu: "3" },
hpj committed
65
        { inifrm: "letnot", ininam: "出口信用证预通知", pntmiu: "3" },
zhengxiaokui committed
66 67
        { inifrm: "letame", ininam: "出口信用证修改", pntmiu: "3" },
        { inifrm: "letrsv", ininam: "出口信用证补通知", pntmiu: "3" },
68
        { inifrm: "infled", ininam: "出口信用证查询infled", pntmiu: "3" },
杜大兵 committed
69
        { inifrm: "bptcan", ininam: "出口融资注销", pntmiu: "3" },
cyy committed
70 71
        { inifrm: "infbed", ininam: "出口信用证单据查询", pntmiu: "3" },
        { inifrm: "letcan", ininam: "出口信用证注销", pntmiu: "3" },
72 73
        { inifrm: "betacc", ininam: "出口信用证单据承兑", pntmiu: "3" },
        { inifrm: "betrcl", ininam: "出口信用证单据索汇", pntmiu: "3" },
jinqian committed
74 75
        { inifrm: "betdcr", ininam: "出口信用证不符点/拒付", pntmiu: "3" },
        { inifrm: "betdrv", ininam: "出口信用证单据修改", pntmiu: "3" },
hpj committed
76
        { inifrm: "infbpd", ininam: "出口押汇查询", pntmiu: "3" },
liushikai committed
77
        { inifrm: "4", ininam: "进口信用证", pntmiu: "" },
78 79 80 81 82 83 84 85
        { inifrm: "inflid", ininam: "进口信用证查询", pntmiu: "4" },
        { inifrm: "litopn", ininam: "进口信用证开立", pntmiu: "4" },
        { inifrm: "litdav", ininam: "进口信用证通知到单", pntmiu: "4" },
        { inifrm: "litdck", ininam: "进口信用证到单", pntmiu: "4" },
        { inifrm: "brtlat", ininam: "进口信用证单据偿还垫款", pntmiu: "4" },
        { inifrm: "litcan", ininam: "进口信用证注销", pntmiu: "4" },
        { inifrm: "inftrd", ininam: "进口押汇查询", pntmiu: "4" },
        { inifrm: "trtame", ininam: "进口融资修改", pntmiu: "4" },
86
        { inifrm: "inftxm", ininam: "条式语句查询", pntmiu: "4" },
liushikai committed
87
        { inifrm: "5", ininam: "进口代收", pntmiu: "" },
wjj committed
88
        { inifrm: "bctdav", ininam: "进口代收到单通知", pntmiu: "5" },
xsh committed
89
        { inifrm: "bctame", ininam: "进口代收修改", pntmiu: "5" },
90
        { inifrm: "bctacc", ininam: "进口代收承兑", pntmiu: "5" },
wjj committed
91
        { inifrm: "bctrad", ininam: "进口代收二次收单", pntmiu: "5" },
chenwen committed
92 93
        { inifrm: "bctdor", ininam: "进口代收拒付", pntmiu: "5" },
        { inifrm: "bctset", ininam: "进口代收付款", pntmiu: "5" },
ccx committed
94
        { inifrm: "bctcan", ininam: "进口代收注销", pntmiu: "5" },
wjj committed
95
        { inifrm: "infbcd", ininam: "进口代收查询", pntmiu: "5" },
96
        { inifrm: "6", ininam: "出口托收", pntmiu: "" },
jxl committed
97 98 99 100
        { inifrm: "botdav", ininam: "出口托收寄单", pntmiu: "6" },
        { inifrm: "botame", ininam: "出口托收修改", pntmiu: "6" },
        { inifrm: "botdcr", ininam: "出口托收拒付/不符点", pntmiu: "6" },
        { inifrm: "botset", ininam: "出口托收收汇", pntmiu: "6" },
xsh committed
101
        { inifrm: "botcan", ininam: "出口托收闭卷", pntmiu: "6" },
liushikai committed
102
        { inifrm: "7", ininam: "转让信用证", pntmiu: "" },
wjj committed
103 104
        { inifrm: "lttopn", ininam: "转让证开立", pntmiu: "7" },
        { inifrm: "lttame", ininam: "转让证修改", pntmiu: "7" },
105
        { inifrm: "lttcan", ininam: "转让证注销", pntmiu: "7" },
106 107 108 109 110 111 112 113
        { inifrm: "bttsnd", ininam: "转让证单据寄单", pntmiu: "7" },
        { inifrm: "bttdrv", ininam: "转让证修改单据金额", pntmiu: "7" },
        { inifrm: "bttdcr", ininam: "转让证单据拒单", pntmiu: "7" },
        {
          inifrm: "lttdav",
          ininam: "转让信用证单据第一受益人换单",
          pntmiu: "7",
        },
liushikai committed
114
        { inifrm: "bttdck", ininam: "转让信用证通知到单", pntmiu: "7" },
liushikai committed
115
        { inifrm: "8", ininam: "打包托收", pntmiu: "" },
wjj committed
116 117 118
        { inifrm: "cltdav", ininam: "打包托收开立", pntmiu: "8" },
        { inifrm: "clttra", ininam: "打包托收催收", pntmiu: "8" },
        { inifrm: "cltset", ininam: "打包托收解包", pntmiu: "8" },
119
        { inifrm: "9", ininam: "光票托收", pntmiu: "" },
120 121
        { inifrm: "ccttra", ininam: "光票托收催收", pntmiu: "9" },
        { inifrm: "cctdcr", ininam: "光票托收退票", pntmiu: "9" },
liushikai committed
122
        { inifrm: "cctset", ininam: "光票托收收汇", pntmiu: "9" },
wangbinfei committed
123 124
        //{ inifrm: "cltdav", ininam: "光票托收开立", pntmiu: "10" },
        //{ inifrm: "clttra", ininam: "光票托收", pntmiu: "10" },
liushikai committed
125 126
        { inifrm: "10", ininam: "参数管理", pntmiu: "" },
        { inifrm: "infusr", ininam: "用户信息", pntmiu: "10" },
127 128 129 130 131 132
        { inifrm: "11", ininam: "卖方信用证", pntmiu: "" },
        { inifrm: "detopn", ininam: "卖方信用证开立", pntmiu: "11" },
        { inifrm: "detame", ininam: "卖方信用证修改", pntmiu: "11" },
        { inifrm: "detsel", ininam: "卖方信用证查询", pntmiu: "11" },

        { inifrm: "12", ininam: "智能审单", pntmiu: "" },
133
        { inifrm: "examRule", ininam: "智能审单规则配置", pntmiu: "12" },
134
        //进口保函
135 136 137 138 139
        { inifrm: "13", ininam: "进口保函", pntmiu: "" },
        { inifrm: "gitsel", ininam: "进口保函查询", pntmiu: "13" },
        { inifrm: "gitset", ininam: "进口保函赔付", pntmiu: "13" },
        { inifrm: "gitcrq", ininam: "进口保函索赔登记", pntmiu: "13" },
        { inifrm: "14", ininam: "服务管理", pntmiu: "" },
吴佳 committed
140
        { inifrm: "switsk", ininam: "Switsk", pntmiu: "14" },
liuxin committed
141
        { inifrm: "mgrtsk", ininam: "Mgrtsk", pntmiu: "14" },
吴佳 committed
142
        { inifrm: "sptrel", ininam: "sptrel", pntmiu: "14" },
zhengxiaokui committed
143 144
      ],
      menus: [],
145
      menusHeight: 0,
zhengxiaokui committed
146 147 148 149 150
    };
  },
  computed: {
    activeMenu() {
      return this.$route.path;
151
    },
zhengxiaokui committed
152
  },
潘际乾 committed
153 154 155
  watch: {
    $route: function () {
      this.$nextTick(() => {
156 157 158 159 160
        const arr = [];
        this.getOpenMenusIndex(this.menus, arr);
        this.openFlgArr = [...new Set([...this.openFlgArr, ...arr])];
      });
    },
潘际乾 committed
161
  },
潘际乾 committed
162 163 164
  created() {
    this.menusHeight = 60 + 46 + 8;
  },
zhengxiaokui committed
165 166 167
  mounted() {
    const arr = [];
    this.generateMenuTree(arr);
168
    this.menus = arr;
169
    this.$store.commit("UserContext/setMenu", arr);
170
    this.initOpenFlgIndex();
zhengxiaokui committed
171 172 173
  },
  methods: {
    generateMenuTree(list, item) {
174 175 176
      const cc = [],
        c = [];
      let n = 0;
zhengxiaokui committed
177 178 179 180 181 182 183
      for (let i = 0; i < this.menuList.length; i++) {
        const menuItem = this.menuList[i];
        if (!item) {
          if (menuItem.pntmiu === undefined || menuItem.pntmiu === "") {
            const children = [];
            menuItem.path = "/business";
            this.generateMenuTree(children, menuItem);
184
            const child = {
zhengxiaokui committed
185 186 187
              name: menuItem.ininam,
              path: menuItem.path,
              children,
188 189 190 191 192 193 194
            };
            if (children.length > 0) {
              child["index"] = child.path + "_" + n++;
              cc.push(child);
            } else {
              c.push(child);
            }
195
          }
zhengxiaokui committed
196 197 198 199 200
        } else {
          if (menuItem.pntmiu === item.inifrm) {
            const children = [];
            menuItem.path = item.path + "/" + menuItem.inifrm;
            this.generateMenuTree(children, menuItem);
201
            const child = {
zhengxiaokui committed
202 203 204 205
              name: menuItem.ininam,
              path: menuItem.path,
              icon: "el-icon-document",
              children,
206 207 208 209 210 211 212
            };
            if (children.length > 0) {
              child["index"] = child.path + "_" + n++;
              cc.push(child);
            } else {
              c.push(child);
            }
213 214
          }
        }
zhengxiaokui committed
215
      }
216
      list.push(...cc, ...c);
zhengxiaokui committed
217
    },
liushikai committed
218 219
    handleOpen(index, indexPath) {
      // console.log(index, indexPath);
220 221 222
      const arr = Object.assign([], this.openFlgArr);
      arr.push(index);
      this.openFlgArr = arr;
zhengxiaokui committed
223
    },
liushikai committed
224 225
    handleClose(index, indexPath) {
      // console.log(index, indexPath);
226 227
      const arr = Object.assign([], this.openFlgArr);
      this.openFlgArr = arr.filter((idx) => idx !== index);
zhengxiaokui committed
228 229 230 231 232
    },
    openMenu() {
      this.menuOpen = true;
      const aside = document.querySelector("aside");
      aside.className = aside.className.split(" ")[0];
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
      this.initOpenFlgIndex();
    },
    initOpenFlgIndex() {
      const r = [];
      this.getOpenMenusIndex(this.menus, r);
      this.openFlgArr = r;
    },
    getOpenMenusIndex(menus, arr) {
      for (let i = 0; i < menus.length; i++) {
        const menu = menus[i];
        if (menu.path === this.activeMenu) {
          return true;
        }
        if (menu.children.length > 0) {
          if (this.getOpenMenusIndex(menu.children, arr)) {
            arr.push(menu.index);
            return true;
          }
        }
      }
      return false;
zhengxiaokui committed
254 255 256 257 258
    },
    closeMenu() {
      this.menuOpen = false;
      const aside = document.querySelector("aside");
      aside.className = aside.className + " fold";
259
      this.openFlgArr = [];
zhengxiaokui committed
260
    },
zhengxiaokui committed
261 262
  },
};
fukai committed
263
</script>
潘际乾 committed
264
<style scoped>
zhengxiaokui committed
265 266 267 268 269
.eContainer-menu-search .el-button {
  border: none;
  font-size: 20px;
  padding: 12px 20px;
}
270

zhengxiaokui committed
271 272 273 274 275 276 277
.eContainer-menu-search .el-input {
  width: auto;
  position: absolute;
  right: 20px;
  top: 10px;
  left: 60px;
}
278

zhengxiaokui committed
279 280 281 282
.eContainer-scroller .el-scrollbar__wrap {
  overflow: auto;
  margin-right: 0px !important;
}
283

zhengxiaokui committed
284 285 286 287
.eContainer-menu-search {
  width: 100%;
  position: relative;
}
288

zhengxiaokui committed
289 290 291 292 293 294 295 296
.eContainer-menu-search .el-input,
.eContainer-menu-search .search-wrapper {
  width: auto;
  position: absolute;
  right: 20px;
  top: 10px;
  left: 60px;
}
297

zhengxiaokui committed
298 299 300
.eContainer-menu-search .el-input .el-input__inner {
  height: 30px;
}
301

zhengxiaokui committed
302 303 304
.eContainer-menu-search .el-icon-search {
  line-height: 30px;
}
305

zhengxiaokui committed
306 307 308
.eContainer-scroller {
  height: calc(100% - 44px);
}
309

zhengxiaokui committed
310 311 312
.eContainer-scroller .el-scrollbar__bar {
  display: none;
}
313

zhengxiaokui committed
314 315 316 317
.el-icon-s-fold {
  float: left;
  font-size: 20px;
}
318

zhengxiaokui committed
319 320 321 322
.el-icon-s-unfold {
  float: left;
  font-size: 20px;
}
323

zhengxiaokui committed
324 325 326
.el-menu {
  border-right: none;
}
327

zhengxiaokui committed
328 329 330 331 332
.eContainer-refresh {
  width: auto;
  overflow: auto;
  height: calc(100% - 44px);
}
333

zhengxiaokui committed
334 335 336 337
.el-button-refresh {
  width: 100%;
  height: 40px;
}
338 339 340
</style>

<style>
zhengxiaokui committed
341 342 343
.el-menu-vertical-demo.el-menu--collapse {
  width: 60px;
}
344

zhengxiaokui committed
345 346 347 348 349 350 351
.el-submenu__title,
.el-menu-item,
.el-submenu .el-menu-item {
  font-size: 12px;
  height: 35px;
  line-height: 35px;
}
352
.el-menu-vertical-demo [class^="el-icon-caret-"] {
353 354
  color: #606266;
}
355
</style>