index.blade.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. @extends('layouts.app')
  2. @section('title')模板@endsection
  3. @section('content')
  4. <span id="nav2">
  5. @component('maintenance.menu')@endcomponent
  6. @component('maintenance.expressPrinting.menu')@endcomponent
  7. </span>
  8. <div class="container-fluid d-none row m-1" id="print-template">
  9. <div class="col-lg-2 col-sm-3 p-0" id="part_panel">
  10. {{-- 组件选择面板 --}}
  11. @include('maintenance.expressPrinting.template._select')
  12. </div>
  13. <div class="col-lg-8 col-sm-6 p-0" id="production_panel">
  14. {{-- 模板制作面板 --}}
  15. @include('maintenance.expressPrinting.template._produce')
  16. </div>
  17. <div class="col-lg-2 col-sm-3 p-0" id="compile_panel">
  18. {{-- 模板编辑页面 --}}
  19. @include('maintenance.expressPrinting.template._compile')
  20. </div>
  21. </div>
  22. @endsection
  23. @section('lastScript')
  24. <script>
  25. let vue = new Vue({
  26. el:"#print-template",
  27. data:{
  28. printParts:{!! $printParts !!},
  29. filterPrintParts:[],
  30. producePanel:{}, // 背景版
  31. selectProducePanel:false, // 是否选中背景版
  32. productionParts:{
  33. printParts:[], // 组件s
  34. editPart: null, // 编辑中的组件
  35. editIndex:{}, // 编辑中组件的下标
  36. addPart:{}, // 添加模板
  37. },
  38. partIsSelected:false, // 表示模块被选中
  39. selectPrintPart:{}, // 选中模块
  40. selectPrintPartPoint:{x:'',y:''}, // 选中模块时模块 point
  41. mousePointStart:{x:'',y:''}, // 开始拖动时的 point
  42. mousePointEnd:{x:'',y:''}, // 结束拖动时的 point
  43. selectPrintPartOffset:{left:'',top:''}, // 选中时的left 和 top
  44. z_index:10,
  45. },
  46. mounted(){
  47. this.initProductionParts();
  48. $('.navbar,.nav1,.nav2').hide();
  49. $('.nav3').on('mouseenter', function () {
  50. $('.navbar,.nav1,.nav2').show();
  51. });
  52. $('.body').on('mouseenter', function () {
  53. $('.navbar,.nav1,.nav2').hide();
  54. });
  55. $("#print-template").removeClass('d-none');
  56. },
  57. methods:{
  58. _addPartToProductionPanel(printPart){
  59. let _clone = JSON.parse(JSON.stringify(printPart));
  60. let print_part_style = JSON.parse(printPart.value);
  61. let item = {
  62. index:this.productionParts.printParts.length,
  63. printPart:_clone,
  64. left:'10',
  65. top:'20',
  66. width:print_part_style.width,
  67. height:print_part_style.height,
  68. text:print_part_style.text,
  69. z_index:this.z_index++,
  70. style:print_part_style
  71. };
  72. this.productionParts.printParts.push(item);
  73. },
  74. _alignContentToProductionPanel(){
  75. this.productionParts.printParts.splice(this.productionParts.editIndex,1);
  76. this.$forceUpdate();
  77. },
  78. _searchPrintPart(event){
  79. let value = $(event.target).val();
  80. this.filterPrintParts = this.printParts.filter(function(printPart){
  81. return printPart.name.includes(value);
  82. });
  83. if(value===null || value=== '') this.filterPrintParts = JSON.parse(JSON.stringify(this.printParts));
  84. },
  85. showSaveModal(){
  86. $('#saveModal').modal('show');
  87. },
  88. _savePrintTemplate(){
  89. tempTip.setDuration(3000);
  90. tempTip.setIndex(1999);
  91. window.axios.post("{{url('print/template/store')}}",this.productionParts.addPart).then(res=>{
  92. if(res.data.success){
  93. tempTip.showSuccess('保存成功!');
  94. return ;
  95. }
  96. tempTip.show(res.data.message);
  97. }).catch(err=>{
  98. tempTip.show(err);
  99. });
  100. },
  101. initProductionParts(){
  102. this.productionParts = {printParts:[], editPart:null, addPart:{}};
  103. this.filterPrintParts=JSON.parse(JSON.stringify(this.printParts));
  104. let height = (window.innerHeight-120)+'px';
  105. $("#production_panel,#part_panel,#compile_panel,#select-panel").css({height:height});
  106. let produce_panel = $("#produce-panel");
  107. produce_panel.css({height:height});
  108. let production_panel = $("#production_panel");
  109. this.producePanel = {
  110. width:parseInt(production_panel.width()),
  111. height:parseInt(production_panel.css('height')),
  112. };
  113. },
  114. getPrintPartStyle(item){
  115. let style = item.style;
  116. style = {
  117. 'display':'flex',
  118. 'width':style.width+'px',
  119. 'height':style.height+'px',
  120. 'border-style':'solid',
  121. 'border-width':style.border+'px',
  122. 'font-size':style.font_size+'px',
  123. 'font-weight':style.font_weight,
  124. 'justify-content':style.justify_content,
  125. 'align-items':style.align_items,
  126. };
  127. return style;
  128. },
  129. getPrintPartDivStyle(item){
  130. let div_style = {
  131. 'left':item.left+'px',
  132. 'top':item.top+'px',
  133. 'width':item.width+'px',
  134. 'height':item.height+'px'
  135. };
  136. console.log(div_style);
  137. return div_style;
  138. },
  139. _dragstart(item,$event){
  140. {{--开始拖动元素时触发--}}
  141. this.selectPrintPartPoint = {x:parseInt(item.left),y:parseInt(item.top)};
  142. this.mousePointStart = {x:$event.offsetX, y:$event.offsetY};
  143. },
  144. _dragend(item,$event){
  145. {{--结束拖动元素时触发--}}
  146. this.mousePointEnd = {x:$event.offsetX, y:$event.offsetY};
  147. let left = item.left - (this.mousePointStart.x - this.mousePointEnd.x);
  148. let top = item.top - (this.mousePointStart.y - this.mousePointEnd.y);
  149. item.left = left >0 ? left:0;
  150. item.top = top > 0 ? top:0;
  151. },
  152. editProducePanel(){
  153. this.selectProducePanel =!this.selectProducePanel;
  154. },
  155. }
  156. });
  157. </script>
  158. @endsection