|
@@ -0,0 +1,111 @@
|
|
|
|
|
+@extends("layouts.app")
|
|
|
|
|
+@section("title","打印")
|
|
|
|
|
+
|
|
|
|
|
+@section("content")
|
|
|
|
|
+ <span id="nav2">
|
|
|
|
|
+ @component('maintenance.menu')@endcomponent
|
|
|
|
|
+ @component('maintenance.expressPrinting.menu')@endcomponent
|
|
|
|
|
+ @component('maintenance.expressPrinting.print.menu')@endcomponent
|
|
|
|
|
+ </span>
|
|
|
|
|
+ <div class="container" id="print">
|
|
|
|
|
+ <div class="position-relative border-1 row p-0 m-0 bg-white border" id="expressPrint" v-for="(item,i) in items" :style="getBgStyle(parts)">
|
|
|
|
|
+ <div class="position-relative" v-for="(part,index) in parts" >
|
|
|
|
|
+
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+@endsection
|
|
|
|
|
+
|
|
|
|
|
+@section("lastScript")
|
|
|
|
|
+ <script type="text/javascript" src="{{mix('js/utilities/barcode.js')}}"></script>
|
|
|
|
|
+ <script>
|
|
|
|
|
+ let vue = new Vue({
|
|
|
|
|
+ el:"#print",
|
|
|
|
|
+ data:{
|
|
|
|
|
+ template:{!! $template !!},
|
|
|
|
|
+ items:{!! $items !!},
|
|
|
|
|
+ parts:[],
|
|
|
|
|
+ index:0,
|
|
|
|
|
+ },
|
|
|
|
|
+ created() {
|
|
|
|
|
+ if(this.template) this.parts = JSON.parse(this.template.value);
|
|
|
|
|
+ },
|
|
|
|
|
+ mounted() {
|
|
|
|
|
+ this.printingTemplate(this.template,this.items)
|
|
|
|
|
+ },
|
|
|
|
|
+ methods:{
|
|
|
|
|
+ printingTemplate(template,items){
|
|
|
|
|
+ let _this = this;
|
|
|
|
|
+ $.each(items,function(i,item){
|
|
|
|
|
+ _this.paddingPrintDiv(template,item);
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ paddingPrintDiv(template,item){
|
|
|
|
|
+ let parts = JSON.parse(template.value);
|
|
|
|
|
+ let _this = this;
|
|
|
|
|
+ let div= $('<div class="position-relative border-1 row p-0 m-0 bg-white border"></div>');
|
|
|
|
|
+ $("#expressPrint").append(div);
|
|
|
|
|
+ $.each(parts,function(i,part){
|
|
|
|
|
+ if(part.type === 'bg'){
|
|
|
|
|
+ div.css({'width':item.width+'px','height':item.height+'px'});
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if(part.type === "StripeCode"){ // 一维码 【条形码】
|
|
|
|
|
+ let childDiv = $('<svg id="svg-'+(this.index++)+'"></svg>');
|
|
|
|
|
+ let css = _this.getSvgStyle(item);
|
|
|
|
|
+ childDiv.css(css);
|
|
|
|
|
+ div.append(childDiv);
|
|
|
|
|
+ setTimeout(function(){
|
|
|
|
|
+ // let text = _this.getContent(part,item);
|
|
|
|
|
+ window.setBarcode(part.text,"#svg-"+_this.index,2,50,true)
|
|
|
|
|
+ },100);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ let childDiv = $('<div class="position-absolute">'+_this.getContent(part,item)+'</div>');
|
|
|
|
|
+ childDiv.css(_this.getStyle(item));
|
|
|
|
|
+ div.append(childDiv);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ getBgStyle(parts){
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ getSvgStyle(item){
|
|
|
|
|
+ let style = JSON.parse(JSON.stringify(item));
|
|
|
|
|
+ return {
|
|
|
|
|
+ width:style.width+'px',
|
|
|
|
|
+ height:style.height+'px',
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+ getStyle(item){
|
|
|
|
|
+ let style = JSON.parse(JSON.stringify(item));
|
|
|
|
|
+ style.display = 'flex';
|
|
|
|
|
+ style['border-style'] = style.borderStyle;
|
|
|
|
|
+ style['border-width'] = style.borderWidth+'px';
|
|
|
|
|
+ style['font-size'] = style.fontSize+'px';
|
|
|
|
|
+ style['font-weight'] = style.fontWeight;
|
|
|
|
|
+ style['justify-content'] = style.justifyContent;
|
|
|
|
|
+ style['align-items'] = style.alignItems;
|
|
|
|
|
+ style.width+='px';
|
|
|
|
|
+ style.height+='px';
|
|
|
|
|
+ style.left+='px';
|
|
|
|
|
+ style.top+='px';
|
|
|
|
|
+ style['white-space'] = 'pre'; // 字体换行
|
|
|
|
|
+ return style;
|
|
|
|
|
+ },
|
|
|
|
|
+ getContent(part,item){ // 组件内容
|
|
|
|
|
+ if(part.text.indexOf("$")===-1)return part.text;
|
|
|
|
|
+ if(part.text.indexOf("+$")!==-1){
|
|
|
|
|
+ let arr = part.text.split("+$");
|
|
|
|
|
+ return arr[0]+item[ arr[1]];
|
|
|
|
|
+ }
|
|
|
|
|
+ if(part.text.indexOf("$")!==-1){
|
|
|
|
|
+ let arr = part.text.split("$");
|
|
|
|
|
+ return arr[0]+item[arr[1]];
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ </script>
|
|
|
|
|
+@endsection
|