drag-window.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <VueDragResize
  3. ref="ref_drag"
  4. :isActive="false"
  5. :z="state.zIndex"
  6. :layout="layout"
  7. :isResizable="isResizable"
  8. :parentLimitation="true"
  9. @resizing="resize"
  10. @dragging="resize"
  11. @mousedown="setZ"
  12. >
  13. <div class="drag-window">
  14. <div class="head">
  15. <div class="head-bg">
  16. <img class="img-bg" src="@/assets/images/web/title-bg.png"/>
  17. <div class="color-bg"/>
  18. </div>
  19. <div class="head-content">
  20. <div class="title">
  21. {{title}}
  22. <slot name="title"/>
  23. </div>
  24. <div class="buttons">
  25. <slot name="buttons"/>
  26. <SvgIcon v-if="expend !== false" class="expend-button __hover" :class="{active: state.notExpend}" @click="state.notExpend = !state.notExpend" name="arrow_4" color="#ffffff" size="18"/>
  27. <SvgIcon v-if="close !== false" class="__hover" @click="$emit('onClose')" name="close_3" color="#ffffff" size="16"/>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="content" :class="{'not-expend': expend !== false && state.notExpend}">
  32. <slot/>
  33. </div>
  34. </div>
  35. </VueDragResize>
  36. </template>
  37. <script setup lang="ts">
  38. import {computed, getCurrentInstance, nextTick, reactive} from "vue";
  39. import VueDragResize from '@/components/vue-drag-resize/index.vue'
  40. import {useAppStore} from "@/stores";
  41. const {proxy} = getCurrentInstance()
  42. const emit = defineEmits(['update:layout'])
  43. const appStore = useAppStore()
  44. const props = defineProps({
  45. title: {default: ''},
  46. layout: {required: false},
  47. isResizable: {default: false},
  48. close: {default: false},
  49. expend: {default: false},
  50. })
  51. const state: any = reactive({
  52. zIndex: appStore.getZIndex(),
  53. notExpend: false
  54. })
  55. const resize = (layout) => {
  56. nextTick(() => {
  57. let c = layout
  58. if (props.expend !== false) {
  59. c = Object.assign(c, {
  60. height: 'auto'
  61. })
  62. }
  63. emit('update:layout', c)
  64. })
  65. }
  66. const setZ = () => {
  67. state.zIndex = appStore.getZIndex()
  68. }
  69. defineExpose({
  70. setZ,
  71. })
  72. </script>
  73. <style scoped lang="scss">
  74. .drag-window {
  75. display: flex;
  76. flex-direction: column;
  77. .head {
  78. position: relative;
  79. width: 100%;
  80. height: 58px;
  81. display: flex;
  82. .head-bg {
  83. width: 100%;
  84. position: relative;
  85. z-index: 1;
  86. opacity: 0.8;
  87. overflow: hidden;
  88. border-radius: 16px 16px 0 0;
  89. .img-bg {
  90. user-select: none;
  91. width: 372px;
  92. height: 100%;
  93. position: absolute;
  94. top: 0;
  95. left: 0;
  96. z-index: 2;
  97. }
  98. .color-bg {
  99. width: calc(100% - 20px);
  100. height: 100%;
  101. background-color: rgba(88, 148, 235, 1);
  102. position: absolute;
  103. top: 0;
  104. right: 0;
  105. z-index: 1;
  106. }
  107. }
  108. .head-content {
  109. width: 100%;
  110. height: 100%;
  111. position: absolute;
  112. z-index: 2;
  113. display: flex;
  114. align-items: center;
  115. .title {
  116. margin-left: 24px;
  117. font-weight: 400;
  118. font-size: 20px;
  119. color: #FFFFFF;
  120. display: flex;
  121. line-height: 1;
  122. align-items: center;
  123. }
  124. .buttons {
  125. margin-left: auto;
  126. margin-right: 24px;
  127. display: flex;
  128. align-items: center;
  129. .expend-button {
  130. margin-right: 8px;
  131. transition: all .2s;
  132. &.active {
  133. transform: rotate(180deg) !important;
  134. }
  135. }
  136. }
  137. }
  138. }
  139. .content {
  140. width: 100%;
  141. height: calc(100% - 40px);
  142. background-color: rgba(0, 52, 159, 0.85);
  143. overflow: hidden;
  144. transition: height .2s;
  145. border-radius: 0 0 16px 16px;
  146. &.not-expend {
  147. height: 0;
  148. }
  149. }
  150. }
  151. </style>