GlobalNavFooter.vue 9.9 KB

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