13cc3f0093ca1b7d0c6bcd58e14d5b43afb7637b.svn-base 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <!-- <transition name="el-fade-in-linear"> -->
  3. <div id="draggableContainer" ref="draggableRef"
  4. :style="{
  5. top:initPosition.top + 'px',
  6. left:initPosition.left + 'px',
  7. width:initPosition.width + 'px',
  8. height:initPosition.height + 'px'
  9. }"
  10. >
  11. <div class="draggableTitleClass">
  12. <p style="width:100%;margin: 0px;font-size: 16px;" @mousedown="mousedownfun">{{title}}</p>
  13. <i @click="closeResult" class="draggableClose el-icon-close"></i>
  14. </div>
  15. <div style="display:flex;flex-direction;column;width:100%;background-color:rgba(255, 255, 255, 0.3);"
  16. :style="{'height':initPosition.height-31 + 'px'}">
  17. <div @mousedown="mousedown_left" class="leftClass"></div>
  18. <div class="slotClass">
  19. <slot></slot>
  20. </div>
  21. <div @mousedown="mousedown_right" class="rightClass"></div>
  22. </div>
  23. <div @mousedown="mousedown_bottom" class="bottomClass"></div>
  24. <img style="cursor:se-resize;position: inherit;width: 10px;height: 10px;bottom: 0px;right: 0px;"
  25. src="/src/assets/img/rightCorner.png" @mousedown="rightCornerFun" alt="">
  26. </div>
  27. <!-- </transition> -->
  28. </template>
  29. <script>
  30. export default {
  31. components:{},
  32. props:['title','initTop','initLeft','initWidth','initHeight'],
  33. data(){
  34. return{
  35. testHeight:'',
  36. titleName:null,
  37. initPosition:{
  38. top:100,
  39. left:100,
  40. width:100,
  41. height:100,
  42. }
  43. }
  44. },
  45. created :function() {
  46. if(this.initTop||this.initTop!=null){
  47. this.initPosition.top = this.initTop;
  48. }
  49. if(this.initLeft||this.initLeft!=null){
  50. this.initPosition.left = this.initLeft;
  51. }
  52. if(this.initWidth||this.initWidth!=null){
  53. this.initPosition.width = this.initWidth;
  54. }
  55. if(this.initHeight||this.initHeight!=null){
  56. this.initPosition.height = this.initHeight;
  57. }
  58. console.log(this.initPosition);
  59. },
  60. mounted:function(){
  61. this.titleName = this.title;
  62. this.init();
  63. },
  64. computed: {
  65. // initPosition:function(){
  66. // console.log('ccc');
  67. // this.$emit("positionChanged",{
  68. // 'position':this.initPosition
  69. // });
  70. // }
  71. },
  72. methods:{
  73. closeResult:function(){
  74. this.$emit("closeDraggable");
  75. },
  76. init:function(){
  77. this.testHeight = this.$refs['draggableRef'].offsetHeight;
  78. },
  79. mousedownfun:function(e){
  80. // var el = this.$refs['draggableRef'];
  81. var el = this.$refs['draggableRef'];
  82. var disx = e.pageX - el.offsetLeft;
  83. var disy = e.pageY - el.offsetTop;
  84. document.onmousemove = function (e){
  85. el.style.left = e.pageX - disx+'px';
  86. el.style.top = e.pageY - disy+'px';
  87. }
  88. document.onmouseup = function(){
  89. document.onmousemove = document.onmouseup = null;
  90. }
  91. },
  92. mousedown_bottom:function(e){
  93. var _self = this;
  94. // var el = this.$refs['draggableRef'];
  95. var el = _self.$refs['draggableRef'];
  96. var disy = e.pageY - el.offsetTop;
  97. document.onmousemove = function (e){
  98. var num = e.pageY - el.offsetTop - 100;
  99. // el.style.height = num +'px';
  100. _self.initPosition.height = num;
  101. console.log('initHeight'+ _self.initPosition.height);
  102. _self.$emit("positionChanged",{
  103. 'position':_self.initPosition
  104. });
  105. }
  106. document.onmouseup = function(){
  107. document.onmousemove = document.onmouseup = null;
  108. }
  109. },
  110. mousedown_left:function(e){
  111. var el = this.$refs['draggableRef'];
  112. var el = this.$refs['draggableRef'];
  113. var disx = e.pageX;
  114. var temp = el.offsetWidth;
  115. document.onmousemove = function (e){
  116. var num = disx - e.pageX + temp;
  117. el.style.left = e.pageX +'px';
  118. el.style.width = num +'px';
  119. }
  120. document.onmouseup = function(){
  121. document.onmousemove = document.onmouseup = null;
  122. }
  123. },
  124. mousedown_right:function(e){
  125. var el = this.$refs['draggableRef'];
  126. var el = this.$refs['draggableRef'];
  127. var disx = e.pageX;
  128. var temp = el.offsetWidth;
  129. document.onmousemove = function (e){
  130. var num = e.pageX - disx + temp;
  131. el.style.width = num +'px';
  132. }
  133. document.onmouseup = function(){
  134. document.onmousemove = document.onmouseup = null;
  135. }
  136. },
  137. rightCornerFun:function(e){
  138. var _self = this;
  139. var el = this.$refs['draggableRef'];
  140. var disx = e.pageX;
  141. var temp = el.offsetWidth;
  142. var disy = e.pageY - el.offsetTop;
  143. document.onmousemove = function (e){
  144. var num1 = e.pageX - disx + temp;
  145. el.style.width = num1 +'px';
  146. var num = e.pageY - el.offsetTop - 100;
  147. // el.style.height = num +'px';
  148. _self.initPosition.height = num;
  149. console.log('initHeight'+ _self.initPosition.height);
  150. _self.$emit("positionChanged",{
  151. 'position':_self.initPosition
  152. });
  153. }
  154. document.onmouseup = function(){
  155. document.onmousemove = document.onmouseup = null;
  156. }
  157. }
  158. }
  159. }
  160. </script>
  161. <style>
  162. #draggableContainer{
  163. position: absolute;
  164. display: flex;
  165. flex-direction: column;
  166. box-shadow: 0px 0px 3px 1px rgba(0,0,0,.3);
  167. border-radius: 7px 7px 0px 0px;
  168. z-index: 5;
  169. background-color: white;
  170. /* overflow-y: auto; */
  171. }
  172. .draggableTitleClass{
  173. display: flex;
  174. text-align: center;
  175. height: 31px;
  176. box-sizing: border-box;
  177. width: 100%;
  178. font-size: 13px;
  179. padding: 5px;
  180. /* border-bottom: 1px solid #ccc; */
  181. color: white;
  182. /* background-color: #0000ffb8; */
  183. background-color: #1862f7;
  184. background-image: url("../assets/img/rough-cloth-light.png");
  185. /* This is mostly intended for prototyping; please download the pattern and re-host for production environments. Thank you! */
  186. cursor: move;
  187. border-radius: 7px 7px 0px 0px;
  188. }
  189. .bottomClass{
  190. border-bottom: 2px solid rgb(78, 137, 243);
  191. cursor: n-resize;
  192. position: relative;
  193. }
  194. .leftClass{
  195. border-left: 2px solid rgb(78, 137, 243);
  196. cursor: w-resize;
  197. }
  198. .rightClass{
  199. border-right: 2px solid rgb(78, 137, 243);
  200. cursor: e-resize;
  201. }
  202. .slotClass{
  203. height: 100%;
  204. width:100%;
  205. overflow-y: auto;
  206. padding-bottom:2px;
  207. background-color: white;
  208. }
  209. .draggableClose{
  210. /* padding-top: 2px; */
  211. color: white;
  212. cursor: pointer;
  213. font-size: large;
  214. margin-right: 5px;
  215. }
  216. .draggableClose:hover{
  217. color:blue;
  218. }
  219. </style>