SideMenu.vue 8.99 KB
Newer Older
1
<template id="SideMenu">
zhengxiaokui committed
2
  <c-row>
3
    <div class="eContainer-menu-search">
zhengxiaokui committed
4 5 6 7 8
      <c-button
        icon="el-icon-s-fold"
        v-if="menuOpen"
        @click="closeMenu"
      ></c-button>
9
      <c-button icon="el-icon-s-unfold" v-else @click="openMenu"></c-button>
10
      <c-search-input v-show="menuOpen"></c-search-input>
11 12
    </div>
    <c-content :height="250">
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: [],
35
      openFlgArrCopy: [],
zhengxiaokui committed
36 37
      menuOpen: true,
      menuList: [
wangguangchao committed
38 39 40 41
        // { inifrm: "0", ininam: "公共夹", pntmiu: "" },
        // { inifrm: "sptsel", ininam: "待办任务", pntmiu: "0" },
        // { inifrm: "trnrel", ininam: "复核任务", pntmiu: "0" },
        // { inifrm: "diasel", ininam: "备忘录选择交易", pntmiu: "0" },
42
        { inifrm: "1", ininam: "汇款", pntmiu: "" },
zhengxiaokui committed
43 44 45
        { inifrm: "infcpd", ininam: "汇款查询", pntmiu: "1" },
        { inifrm: "cptopn", ininam: "汇出汇款", pntmiu: "1" },
        { inifrm: "cptadv", ininam: "汇入汇款", pntmiu: "1" },
liushikai committed
46 47
        { inifrm: "2", ininam: "买方信用证", pntmiu: "" },
        { inifrm: "ditopn", ininam: "信用证开立", pntmiu: "2" },
zhengxiaokui committed
48
        { inifrm: "ditame", ininam: "信用证修改", pntmiu: "2" },
chenwen committed
49
        { inifrm: "ditcan", ininam: "信用证注销", pntmiu: "2" },
50
        { inifrm: "infdid", ininam: "信用证查询", pntmiu: "2" },
liushikai committed
51 52 53
        { inifrm: "infbdd", ininam: "信用证单据查询", pntmiu: "2" },
        { inifrm: "bdtudp", ininam: "信用证承兑", pntmiu: "2" },
        { inifrm: "bdtdcr", ininam: "信用证不符点/拒付", pntmiu: "2" },
liushikai committed
54
        { inifrm: "3", ininam: "出口信用证", pntmiu: "" },
liushikai committed
55
        //{ inifrm: "3", ininam: "出口信用证", pntmiu: "" },
zhengxiaokui committed
56
        { inifrm: "letsel", ininam: "出口信用证查询", pntmiu: "3" },
zhengxiaokui committed
57 58 59
        { inifrm: "letopn", ininam: "出口信用证通知", pntmiu: "3" },
        { inifrm: "letame", ininam: "出口信用证修改", pntmiu: "3" },
        { inifrm: "letrsv", ininam: "出口信用证补通知", pntmiu: "3" },
60
        { inifrm: "infled", ininam: "出口信用证查询infled", pntmiu: "3" },
cyy committed
61 62
        { inifrm: "infbed", ininam: "出口信用证单据查询", pntmiu: "3" },
        { inifrm: "letcan", ininam: "出口信用证注销", pntmiu: "3" },
liushikai committed
63
        { inifrm: "4", ininam: "进口信用证", pntmiu: "" },
64 65 66 67 68 69 70 71
        { 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" },
72 73
        { inifrm: "infbpd", ininam: "进口单据查询", pntmiu: "4" },
        { inifrm: "inftxm", ininam: "条式语句查询", pntmiu: "4" },
liushikai committed
74
        { inifrm: "5", ininam: "进口代收", pntmiu: "" },
75
        { inifrm: "bctdav", ininam: "进口代收", pntmiu: "5" },
xsh committed
76
        { inifrm: "bctame", ininam: "进口代收修改", pntmiu: "5" },
77
        { inifrm: "bctacc", ininam: "进口代收承兑", pntmiu: "5" },
chenwen committed
78 79
        { inifrm: "bctdor", ininam: "进口代收拒付", pntmiu: "5" },
        { inifrm: "bctset", ininam: "进口代收付款", pntmiu: "5" },
ccx committed
80
        { inifrm: "bctcan", ininam: "进口代收注销", pntmiu: "5" },
jxl committed
81
		    { inifrm: "6", ininam: "出口托收", pntmiu: "" },
jxl committed
82 83 84 85
        { inifrm: "botdav", ininam: "出口托收寄单", pntmiu: "6" },
        { inifrm: "botame", ininam: "出口托收修改", pntmiu: "6" },
        { inifrm: "botdcr", ininam: "出口托收拒付/不符点", pntmiu: "6" },
        { inifrm: "botset", ininam: "出口托收收汇", pntmiu: "6" },
xsh committed
86
        { inifrm: "botcan", ininam: "出口托收闭卷", pntmiu: "6" },
87
        { inifrm: "7", ininam: "静态参数管理", pntmiu: "" },
jxl committed
88
        { inifrm: "infusr", ininam: "用户信息", pntmiu: "7" },
89
        { inifrm: "8", ininam: "转让证", pntmiu: "" },
jxl committed
90 91 92
        { inifrm: "lttopn", ininam: "转让证开立", pntmiu: "8" },
        { inifrm: "lttame", ininam: "转让证修改", pntmiu: "8" },
        { inifrm: "lttcan", ininam: "转让证注销", pntmiu: "8" },
zhengxiaokui committed
93 94 95 96 97 98 99
      ],
      menus: [],
    };
  },
  computed: {
    activeMenu() {
      return this.$route.path;
100
    },
zhengxiaokui committed
101 102 103 104
  },
  mounted() {
    const arr = [];
    this.generateMenuTree(arr);
105 106
    this.menus = arr;
    this.initOpenFlgIndex();
zhengxiaokui committed
107 108 109
  },
  methods: {
    generateMenuTree(list, item) {
110 111 112
      const cc = [],
        c = [];
      let n = 0;
zhengxiaokui committed
113 114 115 116 117 118 119
      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);
120
            const child = {
zhengxiaokui committed
121 122 123
              name: menuItem.ininam,
              path: menuItem.path,
              children,
124 125 126 127 128 129 130
            };
            if (children.length > 0) {
              child["index"] = child.path + "_" + n++;
              cc.push(child);
            } else {
              c.push(child);
            }
131
          }
zhengxiaokui committed
132 133 134 135 136
        } else {
          if (menuItem.pntmiu === item.inifrm) {
            const children = [];
            menuItem.path = item.path + "/" + menuItem.inifrm;
            this.generateMenuTree(children, menuItem);
137
            const child = {
zhengxiaokui committed
138 139 140 141
              name: menuItem.ininam,
              path: menuItem.path,
              icon: "el-icon-document",
              children,
142 143 144 145 146 147 148
            };
            if (children.length > 0) {
              child["index"] = child.path + "_" + n++;
              cc.push(child);
            } else {
              c.push(child);
            }
149 150
          }
        }
zhengxiaokui committed
151
      }
152
      list.push(...cc, ...c);
zhengxiaokui committed
153
    },
liushikai committed
154 155
    handleOpen(index, indexPath) {
      // console.log(index, indexPath);
156 157 158
      const arr = Object.assign([], this.openFlgArr);
      arr.push(index);
      this.openFlgArr = arr;
zhengxiaokui committed
159
    },
liushikai committed
160 161
    handleClose(index, indexPath) {
      // console.log(index, indexPath);
162 163
      const arr = Object.assign([], this.openFlgArr);
      this.openFlgArr = arr.filter((idx) => idx !== index);
zhengxiaokui committed
164 165 166 167 168
    },
    openMenu() {
      this.menuOpen = true;
      const aside = document.querySelector("aside");
      aside.className = aside.className.split(" ")[0];
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
      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
190 191 192 193 194
    },
    closeMenu() {
      this.menuOpen = false;
      const aside = document.querySelector("aside");
      aside.className = aside.className + " fold";
195
      this.openFlgArr = [];
zhengxiaokui committed
196
    },
zhengxiaokui committed
197 198
  },
};
fukai committed
199
</script>
潘际乾 committed
200
<style scoped>
zhengxiaokui committed
201 202 203 204 205
.eContainer-menu-search .el-button {
  border: none;
  font-size: 20px;
  padding: 12px 20px;
}
206

zhengxiaokui committed
207 208 209 210 211 212 213
.eContainer-menu-search .el-input {
  width: auto;
  position: absolute;
  right: 20px;
  top: 10px;
  left: 60px;
}
214

zhengxiaokui committed
215 216 217 218
.eContainer-scroller .el-scrollbar__wrap {
  overflow: auto;
  margin-right: 0px !important;
}
219

zhengxiaokui committed
220 221 222 223
.eContainer-menu-search {
  width: 100%;
  position: relative;
}
224

zhengxiaokui committed
225 226 227 228 229 230 231 232
.eContainer-menu-search .el-input,
.eContainer-menu-search .search-wrapper {
  width: auto;
  position: absolute;
  right: 20px;
  top: 10px;
  left: 60px;
}
233

zhengxiaokui committed
234 235 236
.eContainer-menu-search .el-input .el-input__inner {
  height: 30px;
}
237

zhengxiaokui committed
238 239 240
.eContainer-menu-search .el-icon-search {
  line-height: 30px;
}
241

zhengxiaokui committed
242 243 244
.eContainer-scroller {
  height: calc(100% - 44px);
}
245

zhengxiaokui committed
246 247 248
.eContainer-scroller .el-scrollbar__bar {
  display: none;
}
249

zhengxiaokui committed
250 251 252 253
.el-icon-s-fold {
  float: left;
  font-size: 20px;
}
254

zhengxiaokui committed
255 256 257 258
.el-icon-s-unfold {
  float: left;
  font-size: 20px;
}
259

zhengxiaokui committed
260 261 262
.el-menu {
  border-right: none;
}
263

zhengxiaokui committed
264 265 266 267 268
.eContainer-refresh {
  width: auto;
  overflow: auto;
  height: calc(100% - 44px);
}
269

zhengxiaokui committed
270 271 272 273
.el-button-refresh {
  width: 100%;
  height: 40px;
}
274 275 276
</style>

<style>
zhengxiaokui committed
277 278 279
.el-menu-vertical-demo.el-menu--collapse {
  width: 60px;
}
280

zhengxiaokui committed
281 282 283 284 285 286 287
.el-submenu__title,
.el-menu-item,
.el-submenu .el-menu-item {
  font-size: 12px;
  height: 35px;
  line-height: 35px;
}
288
</style>