GlobalNavFooter.vue 10 KB

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