GlobalNavFooter.vue 10 KB

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