create.blade.php 8.3 KB

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