create.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. @extends('layouts.app')
  2. @section('title')组件创建@endsection
  3. @section('content')
  4. <span class="nav">
  5. @component('maintenance.menu')@endcomponent
  6. @component('maintenance.expressPrinting.menu')@endcomponent
  7. @component('maintenance.expressPrinting.part.menu')@endcomponent
  8. </span>
  9. <div class="container-fluid d-none" id="create-print-part">
  10. <div class="row">
  11. <div class="col-3">
  12. <div class="card">
  13. <div class="card-header">
  14. 基础设置
  15. </div>
  16. <div class="card-body">
  17. <div class="form-group">
  18. <label for="template-width">宽</label>
  19. <input type="number" id="template-width" v-model="template.width" class="form form-control">
  20. </div>
  21. <div class="form-group">
  22. <label for=template-height>高</label>
  23. <input type="number" id="template-height" v-model="template.height" class="form form-control">
  24. </div>
  25. <div class="form-group">
  26. <label for="template-border-type">边框类型</label>
  27. <select class="form-control" id="template-border-type" v-model="template.borderStyle">
  28. <option v-for="style in borderStyles" :value="style.value">@{{ style.name }}</option>
  29. </select>
  30. </div>
  31. <div class="form-group">
  32. <label for="template-border-weight">边框大小</label>
  33. <input type="number" id="template-border-weight" v-model="template.borderWidth" class="form form-control">
  34. </div>
  35. </div>
  36. <div class="card-footer">
  37. <button type="button" class="btn btn-success" @click="show">保存当前模板</button>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="col-6 justify-content-center align-items-center flex-fill" >
  42. {{-- 模板展示--}}
  43. <div v-if="template.type==='text'" :style="getStyle()">
  44. <span >@{{ template.text }}</span>
  45. </div>
  46. {{-- 二维码展示 --}}
  47. <svg v-show="template.type!=='text'" :style="{width:template.width,height:template.height}" id="barcodeDiv1">
  48. </svg>
  49. </div>
  50. <div class="col-3">
  51. {{-- 属性 --}}
  52. <div class="card">
  53. <div class="card-header">
  54. 设置
  55. </div>
  56. <div class="card-body">
  57. <div class="form-group">
  58. <label for="template-type">组件类型</label>
  59. <select class="form-control" v-model="template.type" @change="setContent">
  60. <option v-for="type in types" :value="type.value">@{{ type.name }}</option>
  61. </select>
  62. </div>
  63. <div class="form-group">
  64. <label for="template-text">内容</label>
  65. <textarea id="template-text" class="form-text form-control" cols="5" rows="5" v-model="template.text"></textarea>
  66. </div>
  67. <div class="form-group">
  68. <label for="template-text-align">文本对齐方式</label>
  69. <select name="" id="template-text-align" v-model="template.justifyContent" class="form form-control">
  70. <option v-for="justifyContent in justifyContents" :value="justifyContent.value">@{{ justifyContent.name }}</option>
  71. </select>
  72. </div>
  73. <div class="form-group">
  74. <label for="template-text-align">文本垂直对齐</label>
  75. <select name="" id="template-text-align" v-model="template.alignItems" class="form form-control">
  76. <option v-for="alignItem in alignItems" :value="alignItem.value">@{{ alignItem.name }}</option>
  77. </select>
  78. </div>
  79. <div class="form-group">
  80. <label for="template-font-size">字体大小</label>
  81. <input type="text" id="template-font-size" v-model="template.fontSize" class="form form-control">
  82. </div>
  83. <div class="form-group">
  84. <label for="template-font-weight">字体宽</label>
  85. <select id="template-font-weight" v-model="template.fontWeight" class="form-control">
  86. <option v-for="fontWeight in fontWeights" :value="fontWeight.value" >@{{ fontWeight.name }}</option>
  87. </select>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. <div class="modal fade" id="saveModal" tabindex="-1" aria-hidden="true">
  94. <div class="modal-dialog">
  95. <div class="modal-content">
  96. <div class="modal-header">
  97. <h5 class="modal-title" id="saveModalLabel">保存组件</h5>
  98. <button type="button" class="close" data-dismiss="modal" aria-label="Close" >
  99. <span aria-hidden="true">&times;</span>
  100. </button>
  101. </div>
  102. <div class="modal-body">
  103. <form>
  104. <div class="form-group">
  105. <label for="recipient-name" class="col-form-label">组件名称</label>
  106. <input type="text" id="recipient-name" class="form-control" v-model="printPart.name">
  107. </div>
  108. </form>
  109. </div>
  110. <div class="modal-footer">
  111. <button type="button" class="btn btn-secondary" data-dismiss="modal" >关闭</button>
  112. <button type="button" class="btn btn-success" @click="create">保存</button>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. @endsection
  119. @section('lastScript')
  120. <script type="text/javascript" src="{{mix('js/utilities/barcode.js')}}"></script>
  121. <script>
  122. let vue = new Vue({
  123. el:"#create-print-part",
  124. data:{
  125. printPart:{name:'',value:''},
  126. template:{
  127. type:'text',
  128. width:200,
  129. height:100,
  130. borderStyle:'solid',
  131. borderWidth:1,
  132. fontSize:12,
  133. text:'',
  134. fontWeight:'normal', //normal lighter bold
  135. justifyContent:'', //文字水平对齐方式
  136. alignItems:'center', //文字垂直对齐
  137. },
  138. types:[
  139. {name:"文本框",value:"text"},
  140. {name:"条纹码",value:"StripeCode"},
  141. ],
  142. fontWeights:[
  143. {name:"正常",value:"normal"},
  144. {name:"细体",value:"lighter"},
  145. {name:"粗体",value:"bold"},
  146. ],
  147. justifyContents:[
  148. {name:"左对齐",value:""},
  149. {name:"居中",value:"center"},
  150. {name:"右对齐",value:"flex-end"},
  151. ],
  152. alignItems:[
  153. {name:"顶部",value:""},
  154. {name:"居中",value:"center"},
  155. {name:"底部",value:"flex-end"},
  156. ],
  157. borderStyles:[
  158. {name:"默认边框",value:"solid"},
  159. {name:"无边框",value:"none"},
  160. {name:"虚线边框",value:"dashed"},
  161. ]
  162. },
  163. mounted() {
  164. $("#create-print-part").removeClass('d-none');
  165. },
  166. methods:{
  167. show(){
  168. $('#saveModal').modal('show');
  169. },
  170. getStyle(){
  171. return {
  172. 'display':'flex',
  173. 'width':this.template.width+'px',
  174. 'height':this.template.height+'px',
  175. 'border-style':this.template.borderStyle,
  176. 'border-width':this.template.borderWidth+'px',
  177. 'font-size':this.template.fontSize+'px',
  178. 'font-weight':this.template.fontWeight,
  179. 'justify-content':this.template.justifyContent,
  180. 'align-items':this.template.alignItems,
  181. };
  182. },
  183. create(){
  184. tempTip.setDuration(3000);
  185. tempTip.setIndex(2000);
  186. let value = JSON.stringify(this.template);
  187. let data = {name:this.printPart.name,value:value};
  188. window.axios.post('{{url('apiLocal/maintenance/expressPrinting/part/create')}}',data).then(res=>{
  189. if(res.data.success){
  190. tempTip.showSuccess(res.data.data);
  191. $('#saveModal').modal('hide');
  192. return;
  193. }
  194. tempTip.show(res.data.message);
  195. }).catch(err=>{
  196. tempTip.show('网络异常:'+err);
  197. });
  198. },
  199. setContent(){
  200. if(this.template.type === "text")return;
  201. this.template.borderStyle = 'none';
  202. let div = $("#barcodeDiv1");
  203. window.setBarcode("0123456789","#barcodeDiv1",2,50,true)
  204. this.template.width = div.width();
  205. this.template.height = div.height();
  206. }
  207. }
  208. });
  209. </script>
  210. @endsection