index.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <a-drawer
  3. destroyOnClose
  4. placement="right"
  5. wrapClassName="base-drawer-wrap"
  6. :width="700"
  7. :closable="false"
  8. :visible="visible"
  9. @close="handleCancel">
  10. <template v-slot:title><div class="base-drawer-title">{{ title }}</div></template>
  11. <div class="d-flex flex-column h-100">
  12. <div class="base-drawer-body flex-fill position-relative">
  13. <div class="base-drawer-content h-100 w-100 overflow-auto flex-fill position-absolute"><slot /></div>
  14. </div>
  15. <div class="base-drawer-footer flex-grow-0 flex-shrink-0">
  16. <a-button type="primary" @click="handleConfirm">{{ $t('common.ok') }}</a-button>
  17. <a-button class="ml-2" @click="handleCancel">{{ $t('common.cancel') }}</a-button>
  18. </div>
  19. </div>
  20. </a-drawer>
  21. </template>
  22. <script>
  23. export default {
  24. name: 'BaseDrawer',
  25. props: {
  26. title: String,
  27. visible: Boolean,
  28. },
  29. methods: {
  30. handleConfirm () {
  31. this.$emit('ok')
  32. },
  33. handleCancel () {
  34. this.$emit('update:visible', false)
  35. this.$emit('cancel')
  36. },
  37. },
  38. }
  39. </script>
  40. <style lang="less">
  41. .base-drawer-wrap {
  42. .ant-drawer-wrapper-body {
  43. overflow: hidden;
  44. display: flex;
  45. flex-direction: column;
  46. .ant-drawer-body {
  47. padding: 0;
  48. flex: 1;
  49. }
  50. .ant-drawer-header {
  51. flex-shrink: 0;
  52. flex-grow: 0;
  53. }
  54. }
  55. }
  56. .base-drawer-title {
  57. font-size: 14px;
  58. font-weight: normal;
  59. }
  60. .base-drawer-footer {
  61. border-top: 1px solid #eee;
  62. padding: 15px;
  63. }
  64. .base-drawer-content {
  65. padding: 15px;
  66. left: 0;
  67. top: 0;
  68. }
  69. </style>