SideMenu.vue 10.8 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" },
liushikai committed
45 46
        { inifrm: "2", ininam: "买方信用证", pntmiu: "" },
        { inifrm: "ditopn", ininam: "信用证开立", pntmiu: "2" },
zhengxiaokui committed
47
        { inifrm: "ditame", ininam: "信用证修改", pntmiu: "2" },
chenwen committed
48
        { inifrm: "ditcan", ininam: "信用证注销", pntmiu: "2" },
liushikai committed
49
        { inifrm: "infdid", ininam: "信用证交易查询", pntmiu: "2" },
liushikai committed
50 51 52
        { inifrm: "infbdd", ininam: "信用证单据查询", pntmiu: "2" },
        { inifrm: "bdtudp", ininam: "信用证承兑", pntmiu: "2" },
        { inifrm: "bdtdcr", ininam: "信用证不符点/拒付", pntmiu: "2" },
liushikai committed
53
		    { inifrm: "ditdck", ininam: "信用证到单", pntmiu: "2" },
liushikai committed
54
		    { inifrm: "bdtset", ininam: "信用证付款", pntmiu: "2" },
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" },
63 64
        { inifrm: "betacc", ininam: "出口信用证单据承兑", pntmiu: "3" },
        { inifrm: "betrcl", ininam: "出口信用证单据索汇", pntmiu: "3" },
liushikai committed
65
        { inifrm: "4", ininam: "进口信用证", pntmiu: "" },
66 67 68 69 70 71 72 73
        { 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" },
74 75
        { inifrm: "infbpd", ininam: "进口单据查询", pntmiu: "4" },
        { inifrm: "inftxm", ininam: "条式语句查询", pntmiu: "4" },
liushikai committed
76
        { inifrm: "5", ininam: "进口代收", pntmiu: "" },
wjj committed
77
        { inifrm: "bctdav", ininam: "进口代收到单通知", pntmiu: "5" },
xsh committed
78
        { inifrm: "bctame", ininam: "进口代收修改", pntmiu: "5" },
79
        { inifrm: "bctacc", ininam: "进口代收承兑", pntmiu: "5" },
wjj committed
80
        { inifrm: "bctrad", ininam: "进口代收二次收单", pntmiu: "5" },
chenwen committed
81 82
        { inifrm: "bctdor", ininam: "进口代收拒付", pntmiu: "5" },
        { inifrm: "bctset", ininam: "进口代收付款", pntmiu: "5" },
ccx committed
83
        { inifrm: "bctcan", ininam: "进口代收注销", pntmiu: "5" },
wjj committed
84
        { inifrm: "infbcd", ininam: "进口代收查询", pntmiu: "5" },
jxl committed
85
		    { inifrm: "6", ininam: "出口托收", pntmiu: "" },
jxl committed
86 87 88 89
        { inifrm: "botdav", ininam: "出口托收寄单", pntmiu: "6" },
        { inifrm: "botame", ininam: "出口托收修改", pntmiu: "6" },
        { inifrm: "botdcr", ininam: "出口托收拒付/不符点", pntmiu: "6" },
        { inifrm: "botset", ininam: "出口托收收汇", pntmiu: "6" },
xsh committed
90
        { inifrm: "botcan", ininam: "出口托收闭卷", pntmiu: "6" },
liushikai committed
91
        { inifrm: "7", ininam: "转让信用证", pntmiu: "" },
wjj committed
92 93
        { inifrm: "lttopn", ininam: "转让证开立", pntmiu: "7" },
        { inifrm: "lttame", ininam: "转让证修改", pntmiu: "7" },
94
        { inifrm: "lttcan", ininam: "转让证注销", pntmiu: "7" },
wjj committed
95 96 97
		    { inifrm: "bttsnd", ininam: "转让证单据寄单", pntmiu: "7" },
		    { inifrm: "bttdrv", ininam: "转让证修改单据金额", pntmiu: "7" },
		    { inifrm: "bttdcr", ininam: "转让证单据拒单", pntmiu: "7" },
liushikai committed
98 99
        { inifrm: "lttdav", ininam: "转让信用证单据第一受益人换单", pntmiu: "7" },
        { inifrm: "bttdck", ininam: "转让信用证通知到单", pntmiu: "7" },
liushikai committed
100
        { inifrm: "8", ininam: "打包托收", pntmiu: "" },
wjj committed
101 102 103
        { inifrm: "cltdav", ininam: "打包托收开立", pntmiu: "8" },
        { inifrm: "clttra", ininam: "打包托收催收", pntmiu: "8" },
        { inifrm: "cltset", ininam: "打包托收解包", pntmiu: "8" },
104 105 106
        { inifrm: "9",ininam: "光票托收", pntmiu: "" },
        { inifrm: "ccttra", ininam: "光票托收催收", pntmiu: "9" },
        { inifrm: "cctdcr", ininam: "光票托收退票", pntmiu: "9" },
liushikai committed
107
        { inifrm: "cctset", ininam: "光票托收收汇", pntmiu: "9" },
wangbinfei committed
108 109
        //{ inifrm: "cltdav", ininam: "光票托收开立", pntmiu: "10" },
        //{ inifrm: "clttra", ininam: "光票托收", pntmiu: "10" },
liushikai committed
110 111
        { inifrm: "10", ininam: "参数管理", pntmiu: "" },
        { inifrm: "infusr", ininam: "用户信息", pntmiu: "10" },
zhengxiaokui committed
112 113
      ],
      menus: [],
潘际乾 committed
114
      menusHeight: 0
zhengxiaokui committed
115 116 117 118 119
    };
  },
  computed: {
    activeMenu() {
      return this.$route.path;
120
    },
zhengxiaokui committed
121
  },
潘际乾 committed
122 123 124 125 126 127 128 129 130
  watch: {
    $route: function () {
      this.$nextTick(() => {
        const arr = []
        this.getOpenMenusIndex(this.menus, arr)
        this.openFlgArr = [...new Set([...this.openFlgArr, ...arr])]
      })
    }
  },
潘际乾 committed
131 132 133
  created() {
    this.menusHeight = 60 + 46 + 8;
  },
zhengxiaokui committed
134 135 136
  mounted() {
    const arr = [];
    this.generateMenuTree(arr);
137 138
    this.menus = arr;
    this.initOpenFlgIndex();
zhengxiaokui committed
139 140 141
  },
  methods: {
    generateMenuTree(list, item) {
142 143 144
      const cc = [],
        c = [];
      let n = 0;
zhengxiaokui committed
145 146 147 148 149 150 151
      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);
152
            const child = {
zhengxiaokui committed
153 154 155
              name: menuItem.ininam,
              path: menuItem.path,
              children,
156 157 158 159 160 161 162
            };
            if (children.length > 0) {
              child["index"] = child.path + "_" + n++;
              cc.push(child);
            } else {
              c.push(child);
            }
163
          }
zhengxiaokui committed
164 165 166 167 168
        } else {
          if (menuItem.pntmiu === item.inifrm) {
            const children = [];
            menuItem.path = item.path + "/" + menuItem.inifrm;
            this.generateMenuTree(children, menuItem);
169
            const child = {
zhengxiaokui committed
170 171 172 173
              name: menuItem.ininam,
              path: menuItem.path,
              icon: "el-icon-document",
              children,
174 175 176 177 178 179 180
            };
            if (children.length > 0) {
              child["index"] = child.path + "_" + n++;
              cc.push(child);
            } else {
              c.push(child);
            }
181 182
          }
        }
zhengxiaokui committed
183
      }
184
      list.push(...cc, ...c);
zhengxiaokui committed
185
    },
liushikai committed
186 187
    handleOpen(index, indexPath) {
      // console.log(index, indexPath);
188 189 190
      const arr = Object.assign([], this.openFlgArr);
      arr.push(index);
      this.openFlgArr = arr;
zhengxiaokui committed
191
    },
liushikai committed
192 193
    handleClose(index, indexPath) {
      // console.log(index, indexPath);
194 195
      const arr = Object.assign([], this.openFlgArr);
      this.openFlgArr = arr.filter((idx) => idx !== index);
zhengxiaokui committed
196 197 198 199 200
    },
    openMenu() {
      this.menuOpen = true;
      const aside = document.querySelector("aside");
      aside.className = aside.className.split(" ")[0];
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
      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
222 223 224 225 226
    },
    closeMenu() {
      this.menuOpen = false;
      const aside = document.querySelector("aside");
      aside.className = aside.className + " fold";
227
      this.openFlgArr = [];
zhengxiaokui committed
228
    },
zhengxiaokui committed
229 230
  },
};
fukai committed
231
</script>
潘际乾 committed
232
<style scoped>
zhengxiaokui committed
233 234 235 236 237
.eContainer-menu-search .el-button {
  border: none;
  font-size: 20px;
  padding: 12px 20px;
}
238

zhengxiaokui committed
239 240 241 242 243 244 245
.eContainer-menu-search .el-input {
  width: auto;
  position: absolute;
  right: 20px;
  top: 10px;
  left: 60px;
}
246

zhengxiaokui committed
247 248 249 250
.eContainer-scroller .el-scrollbar__wrap {
  overflow: auto;
  margin-right: 0px !important;
}
251

zhengxiaokui committed
252 253 254 255
.eContainer-menu-search {
  width: 100%;
  position: relative;
}
256

zhengxiaokui committed
257 258 259 260 261 262 263 264
.eContainer-menu-search .el-input,
.eContainer-menu-search .search-wrapper {
  width: auto;
  position: absolute;
  right: 20px;
  top: 10px;
  left: 60px;
}
265

zhengxiaokui committed
266 267 268
.eContainer-menu-search .el-input .el-input__inner {
  height: 30px;
}
269

zhengxiaokui committed
270 271 272
.eContainer-menu-search .el-icon-search {
  line-height: 30px;
}
273

zhengxiaokui committed
274 275 276
.eContainer-scroller {
  height: calc(100% - 44px);
}
277

zhengxiaokui committed
278 279 280
.eContainer-scroller .el-scrollbar__bar {
  display: none;
}
281

zhengxiaokui committed
282 283 284 285
.el-icon-s-fold {
  float: left;
  font-size: 20px;
}
286

zhengxiaokui committed
287 288 289 290
.el-icon-s-unfold {
  float: left;
  font-size: 20px;
}
291

zhengxiaokui committed
292 293 294
.el-menu {
  border-right: none;
}
295

zhengxiaokui committed
296 297 298 299 300
.eContainer-refresh {
  width: auto;
  overflow: auto;
  height: calc(100% - 44px);
}
301

zhengxiaokui committed
302 303 304 305
.el-button-refresh {
  width: 100%;
  height: 40px;
}
306 307 308
</style>

<style>
zhengxiaokui committed
309 310 311
.el-menu-vertical-demo.el-menu--collapse {
  width: 60px;
}
312

zhengxiaokui committed
313 314 315 316 317 318 319
.el-submenu__title,
.el-menu-item,
.el-submenu .el-menu-item {
  font-size: 12px;
  height: 35px;
  line-height: 35px;
}
320 321 322
.el-menu-vertical-demo [class^=el-icon-caret-] {
  color: #606266;
}
323
</style>