GlobalNavFooter.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. /* eslint-disable camelcase */
  2. <template>
  3. <div id="navFooter">
  4. <!-- 底部快捷菜单 -->
  5. <a-row>
  6. <!-- 左 小箭头 -->
  7. <a-col :span="1" @click="handleChange" style="background:rgba(24, 144, 255,.9);">
  8. <a class="arrowBtn">
  9. <a-icon v-if="isShow" type="arrow-left" />
  10. <a-divider type="vertical" style="width:3px;height:20px;marginBottom:6px;borderRadius:4px;" />
  11. <a-icon v-if="!isShow" type="arrow-right" />
  12. </a>
  13. </a-col>
  14. <!-- 右 菜单 -->
  15. <a-col :span="23">
  16. <transition-group name="animation">
  17. <div class="shortcut" v-if="isShow" :key="1">
  18. <a-row style="textAlign:;background:rgba(24, 144, 255,.9); ">
  19. <!-- 设置快捷 -->
  20. <a-col :span="16">
  21. <a href="#" @click="showDrawer" class="setBtn" style="float:left;marginRight:6px;">设置快捷</a>
  22. <!-- 菜单 -->
  23. <div class="nav" v-for="item in selectList" :key="item.id">
  24. <a href="#" @click="menuPuth(item)">{{ item.name }}</a>
  25. </div>
  26. </a-col>
  27. <!-- 公司名称 -->
  28. <a-col :span="8" style="textAlign:right;">
  29. <span style="color:#ccc;">上海萃颠信息科技有限公司出品</span>
  30. </a-col>
  31. </a-row>
  32. </div>
  33. </transition-group>
  34. </a-col>
  35. </a-row>
  36. <!-- 抽屉 设置快捷 -->
  37. <a-drawer
  38. title="设置快捷菜单"
  39. width="520"
  40. :placement="placement"
  41. :closable="false"
  42. :visible="visible"
  43. :bodyStyle="{ padding: '12px', marginBottom: '90px', background: '#90caf9' }"
  44. >
  45. <!-- 固定屏幕 部分-->
  46. <div
  47. :style="{
  48. position: 'absolute',
  49. left: 0,
  50. top: '0',
  51. width: '100%',
  52. textAlign: 'left',
  53. zIndex: 6,
  54. height: '124px'
  55. }"
  56. >
  57. <!-- 已选 -->
  58. <a-row>
  59. <a-col :span="24">
  60. <a-card title="已选功能" :bordered="false" class="selectTag">
  61. <div v-if="selectList.length > 0" class="selected">
  62. <a-tag
  63. :key="item.id"
  64. v-for="item in selectList"
  65. :closable="true"
  66. @close="() => handleClose(item)"
  67. class="selectedItem"
  68. >
  69. <span style="width: 8em">
  70. {{ item.name }}
  71. </span>
  72. </a-tag>
  73. </div>
  74. <!-- 无快捷 -->
  75. <span v-if="selectList.length == 0" style="color:#6a040f;marginLeft:12px;">
  76. 请点击选择快捷菜单
  77. </span>
  78. </a-card>
  79. </a-col>
  80. </a-row>
  81. <!-- 搜索栏 -->
  82. <div class="second">
  83. <a-row style="textAlign:right;">
  84. <a-col :span="3">
  85. <span style="fontSize:14px;fontWeight:700;">功能菜单</span>
  86. </a-col>
  87. <a-col :span="20">
  88. <a-input-search
  89. placeholder="请输入菜单名称"
  90. style="width: 180px"
  91. v-model="searchName"
  92. @search="searchMenu"
  93. />
  94. </a-col>
  95. </a-row>
  96. </div>
  97. </div>
  98. <!-- 所有菜单-->
  99. <a-row>
  100. <a-col a-col :span="24">
  101. <a-card title="" :bordered="false" class="searchLine">
  102. <!-- 一级菜单 -->
  103. <a-row v-for="menu in menuALL" :key="menu.name">
  104. <a-col :span="4">
  105. <span>{{ menu.name }}:</span>
  106. </a-col>
  107. <!-- 二级菜单 -->
  108. <a-col :span="20" class="LevelTwoMenu">
  109. <div v-for="item in menu.childList" :key="item.id" class="twoMenuItem">
  110. <a
  111. href="#"
  112. style="width: 8em"
  113. @click.stop="selectItem(item)"
  114. :class="{ active: getActive(item.sysPermissionId) }"
  115. >
  116. {{ item.name }}
  117. </a>
  118. </div>
  119. </a-col>
  120. <a-divider :dashed="true" />
  121. </a-row>
  122. </a-card>
  123. </a-col>
  124. </a-row>
  125. <!-- 抽屉底部按钮 -->
  126. <div
  127. :style="{
  128. position: 'absolute',
  129. right: 0,
  130. bottom: '40px',
  131. width: '100%',
  132. padding: '10px 16px',
  133. background: '#fff',
  134. textAlign: 'right',
  135. zIndex: 1,
  136. background: '#90caf9'
  137. }"
  138. >
  139. <a-popconfirm title="确定取消设置吗?" ok-text="是" cancel-text="否" @confirm="openTips">
  140. <a-button :style="{ marginRight: '8px' }">取消</a-button>
  141. </a-popconfirm>
  142. <a-button type="primary" @click="drawerSave">保存</a-button>
  143. </div>
  144. </a-drawer>
  145. </div>
  146. </template>
  147. <script>
  148. import Vue from 'vue'
  149. import { ACCESS_TOKEN } from '@/store/mutation-types'
  150. import { getUserPermissionByTokenBottom, getListByCreateBy, addBatch } from '@api/api.js'
  151. export default {
  152. name: 'GlobalNavFooter',
  153. data () {
  154. return {
  155. isShow: true, // 默认显示快捷导航
  156. visible: false, // 抽屉默认关闭
  157. placement: 'left', // 抽屉方向布局
  158. selectList: [], // 已选功能
  159. menuALL: {}, // 所有菜单
  160. bottomMenuList: [], // 后台接收快捷菜单
  161. searchName: '' // 搜索的菜单名称
  162. }
  163. },
  164. created () {
  165. this.getFooterNav() // 获取快捷导航
  166. },
  167. methods: {
  168. // 搜索菜单
  169. searchMenu () {
  170. this.getMenuList()
  171. },
  172. // 所有菜单
  173. getMenuList () {
  174. this.$nextTick(() => {
  175. let token = Vue.ls.get(ACCESS_TOKEN)
  176. let params = { token: token, name: this.searchName }
  177. console.log('params---->', params.name)
  178. getUserPermissionByTokenBottom(params).then(res => {
  179. console.log('所有菜单res---->', res)
  180. if (res.success) {
  181. this.menuALL = res.result.menu
  182. }
  183. })
  184. })
  185. },
  186. // 设置快捷
  187. showDrawer () {
  188. // 每次打开抽屉时,重新渲染所有菜单
  189. this.getMenuList()
  190. this.visible = true
  191. },
  192. // 底部菜单跳转
  193. menuPuth (item) {
  194. console.log('点击快捷菜单', item)
  195. this.visible = false
  196. this.$router.push(item.path)
  197. },
  198. // 判断是否勾选(参数是菜单 ID)
  199. getActive (sysPermissionId) {
  200. let isActive = false // 默认未点击
  201. this.selectList.forEach(element => {
  202. if (sysPermissionId === element.sysPermissionId) {
  203. isActive = true // 点击变色
  204. }
  205. })
  206. // console.log(isActive)
  207. return isActive // 返回active状态
  208. },
  209. // 点击勾选
  210. selectItem (item) {
  211. // console.log('【点击的菜单】', item.name)
  212. let isSelect = false // 默认未勾选
  213. this.selectList.forEach((element, index) => {
  214. // 判断是否重复点击
  215. if (item.sysPermissionId === element.sysPermissionId) {
  216. isSelect = true // 勾选
  217. this.selectList.splice(index, 1)
  218. }
  219. })
  220. // 长度控制
  221. if (this.selectList.length >= 8) {
  222. this.$message.warning('最多可选8个快捷菜单')
  223. return
  224. }
  225. // 未勾选
  226. if (!isSelect) {
  227. this.selectList.push(item)
  228. }
  229. },
  230. // 获取快捷菜单
  231. async getFooterNav () {
  232. await getListByCreateBy().then(res => {
  233. if (res.success) {
  234. console.log('底部快捷菜单', res)
  235. this.selectList = res.result
  236. }
  237. })
  238. },
  239. // 保存 快捷菜单
  240. async drawerSave () {
  241. await addBatch({ bottomMenuList: this.selectList }).then(res => {
  242. if (res.success) {
  243. // 无需其他操作
  244. this.$message.success('快捷菜单保存成功')
  245. this.visible = false
  246. }
  247. })
  248. },
  249. // 头部叉叉
  250. handleClose (item) {
  251. console.log('点击的叉叉', item)
  252. this.selectList.forEach((e, index) => {
  253. if (e.id == item.id) {
  254. this.selectList.splice(index, 1)
  255. }
  256. console.log(' 删后this.selectList', this.selectList)
  257. })
  258. },
  259. // 抽屉取消
  260. openTips () {
  261. console.log('点击抽屉取消')
  262. this.visible = false
  263. },
  264. // 底部导航 显示隐藏
  265. handleChange () {
  266. // console.log(this.isShow)
  267. if (!this.isShow) {
  268. this.visible = false
  269. this.isShow = true
  270. } else {
  271. this.isShow = false
  272. }
  273. }
  274. }
  275. }
  276. </script>
  277. <style lang="less" scoped>
  278. @import '~@assets/less/common.less';
  279. // 抽屉样式(独立文件)
  280. @import '~@assets/less/drawer.less';
  281. // 整个底部导航
  282. #navFooter {
  283. width: 100%;
  284. position: fixed;
  285. bottom: 0;
  286. left: 0;
  287. height: 40px;
  288. line-height: 40px;
  289. z-index: 99999;
  290. // 箭头
  291. .arrowBtn {
  292. background: transparent;
  293. font-size: 26px;
  294. color: white;
  295. }
  296. // 可消失行
  297. .shortcut {
  298. //设置快捷(文字)
  299. .setBtn {
  300. font-size: 12px;
  301. font-weight: 700;
  302. color: white;
  303. }
  304. // 快捷菜单
  305. .nav {
  306. float: left;
  307. a {
  308. margin: 0 6px;
  309. font-size: 12px;
  310. color: white;
  311. font-weight: 700;
  312. overflow: hidden;
  313. white-space: nowrap;
  314. text-overflow: ellipsis;
  315. }
  316. }
  317. a.setBtn:hover,
  318. a:hover {
  319. color: orange;
  320. font-weight: 400;
  321. }
  322. }
  323. // 动画效果
  324. .animation-enter,
  325. .animation-leave-to {
  326. opacity: 0;
  327. transform: translateX(-20px);
  328. }
  329. .animation-enter-to,
  330. .animation-leave {
  331. opacity: 1;
  332. }
  333. .animation-enter-active,
  334. .animation-leave-active {
  335. transition: all 0.5s;
  336. }
  337. }
  338. </style>