|
|
@@ -8,9 +8,12 @@
|
|
|
@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 class="position-relative border-1 row p-0 m-0 bg-white border" v-for="(item,i) in items" :style="getBgStyle(template)">
|
|
|
+ <div class="position-absolute" v-for="(part,index) in parts" :style="getStyle(part)">
|
|
|
+ <svg v-if="isSvg(part)" :style="getSvgStyle(part)" :id="'svg'+i" class="StripeCode">
|
|
|
+ @{{ getContent(part,item) }}
|
|
|
+ </svg>
|
|
|
+ <span v-else>@{{ getContent(part,item) }}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -28,53 +31,41 @@
|
|
|
index:0,
|
|
|
},
|
|
|
created() {
|
|
|
- if(this.template) this.parts = JSON.parse(this.template.value);
|
|
|
+ this.parts = JSON.parse(this.template.value);
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.printingTemplate(this.template,this.items)
|
|
|
+ $.each(this.items,(index,item)=>{
|
|
|
+ window.setBarcode('123456',"#svg"+index,2,50,true);
|
|
|
+ $("#svg"+index).find("svg");
|
|
|
+ });
|
|
|
},
|
|
|
methods:{
|
|
|
+ isSvg(part){
|
|
|
+ return part.type==="StripeCode";
|
|
|
+ },
|
|
|
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(template){
|
|
|
+ if (this.parts === []) this.parts = JSON.parse(template.value);
|
|
|
+ let style = {};
|
|
|
+ this.parts.forEach((item)=>{
|
|
|
+ if(item.type==="bg"){
|
|
|
+ style = {
|
|
|
+ width:item.width+'px',
|
|
|
+ height:item.height+'px'
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- },
|
|
|
- getBgStyle(parts){
|
|
|
-
|
|
|
+ return style;
|
|
|
},
|
|
|
getSvgStyle(item){
|
|
|
- let style = JSON.parse(JSON.stringify(item));
|
|
|
return {
|
|
|
- width:style.width+'px',
|
|
|
- height:style.height+'px',
|
|
|
+ width:item.width+'px',
|
|
|
+ height:item.height+'px',
|
|
|
};
|
|
|
},
|
|
|
getStyle(item){
|
|
|
@@ -94,6 +85,8 @@
|
|
|
return style;
|
|
|
},
|
|
|
getContent(part,item){ // 组件内容
|
|
|
+ console.log(part.text);
|
|
|
+ return part.text;
|
|
|
if(part.text.indexOf("$")===-1)return part.text;
|
|
|
if(part.text.indexOf("+$")!==-1){
|
|
|
let arr = part.text.split("+$");
|
|
|
@@ -104,7 +97,6 @@
|
|
|
return arr[0]+item[arr[1]];
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
}
|
|
|
})
|
|
|
</script>
|