Drawer.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <a-drawer
  3. placement="left"
  4. id="sidebar-wrap"
  5. :closable="false"
  6. :visible="drawerVisible"
  7. :z-index="98"
  8. :width="width"
  9. :body-style="wrapStyle"
  10. @close="handleClose">
  11. <products-list @route-change="handleClose" :active-menu="activeMenu" :popover-align="{ offset: [5, 5] }" />
  12. </a-drawer>
  13. </template>
  14. <script>
  15. import get from 'lodash/get'
  16. import { mapGetters, mapState } from 'vuex'
  17. import ProductsList from '@/sections/ProductsList'
  18. export default {
  19. name: 'Sidebar',
  20. components: {
  21. ProductsList,
  22. },
  23. props: {
  24. activeMenu: Object,
  25. },
  26. data () {
  27. return {
  28. width: 200,
  29. }
  30. },
  31. computed: {
  32. ...mapGetters(['common']),
  33. ...mapState('common', {
  34. openCloudShell: state => state.openCloudShell,
  35. cloudShellHeight: state => state.cloudShellHeight,
  36. }),
  37. sidebar () {
  38. return this.common.sidebar
  39. },
  40. drawerVisible () {
  41. return get(this.common, 'sidebar.drawerVisible', false)
  42. },
  43. wrapStyle () {
  44. const style = { paddingTop: '60px', paddingLeft: 0, paddingRight: 0, paddingBottom: 0, height: '100%' }
  45. if (this.openCloudShell) {
  46. style.height = `calc(100% - ${this.cloudShellHeight}px)`
  47. }
  48. return style
  49. },
  50. },
  51. methods: {
  52. handleClose () {
  53. this.$store.dispatch('common/updateObject', {
  54. name: 'sidebar',
  55. data: {
  56. drawerVisible: false,
  57. },
  58. })
  59. },
  60. },
  61. }
  62. </script>