<template>
|
<div class="print-container">
|
<div class="margin-bottom-20">
|
<object id="LODOP" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width="800" height="600">
|
<param name="Caption" value="显示区" />
|
<param name="Border" value="0" />
|
<param name="Color" value="white" />
|
<embed id="LODOP_EM" type="application/x-print-lodop" width="1200" height="500" pluginspage="/upload/install_lodop32.exe" />
|
</object>
|
</div>
|
<el-button type="text" class="no-print" @click="deleteItem">删除选择项</el-button>
|
<el-button type="primary" class="no-print" @click="save">保存模板</el-button>
|
</div>
|
</template>
|
|
<script>
|
import VueBarcode from "@xkeshi/vue-barcode";
|
|
export default {
|
name: "PrintBarcode",
|
components: {
|
barcode: VueBarcode
|
},
|
data() {
|
return {
|
// 模板类型
|
printType: ""
|
};
|
},
|
computed: {},
|
created() {
|
this.printType = localStorage.getItem("printType");
|
this.tableData = JSON.parse(localStorage.getItem("tableData") || "[]");
|
},
|
mounted() {
|
window.setTimeout(() => {
|
this.initData();
|
}, 1000);
|
},
|
methods: {
|
initData() {
|
// 判断浏览器类型
|
var isIE = navigator.userAgent.indexOf("MSIE") >= 0 || navigator.userAgent.indexOf("Trident") >= 0;
|
var LODOP_OBJ = document.getElementById("LODOP");
|
var LODOP_EM = document.getElementById("LODOP_EM");
|
// LODOP对象
|
const LODOP = isIE ? LODOP_OBJ : LODOP_EM;
|
|
// 默认设置
|
const defaultDesign = `
|
LODOP.PRINT_INITA(0,0,"100.01mm","60.01mm","打印设计");
|
LODOP.ADD_PRINT_BARCODE(89,5,141,148,"QRCode","{物料二维码}");
|
LODOP.ADD_PRINT_BARCODE(15,11,354,66,"128B","{物料条码}");
|
LODOP.ADD_PRINT_TEXT(96,138,203,20,"名称:{物料名称}");
|
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
|
LODOP.ADD_PRINT_TEXT(130,141,216,25,"编号:{物料编号}");
|
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
|
LODOP.ADD_PRINT_TEXT(162,140,169,20,"规格:{物料规格}");
|
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
|
`;
|
const url = "/api/sys/print/getLodopTemplate";
|
var params = {
|
sendBillName: this.printType
|
};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
// eslint-disable-next-line
|
eval(res.data.designConent);
|
LODOP.SET_SHOW_MODE("DESIGN_IN_BROWSE", 1);
|
LODOP.PRINT_DESIGN();
|
} else {
|
// eslint-disable-next-line
|
eval(defaultDesign);
|
LODOP.SET_SHOW_MODE("DESIGN_IN_BROWSE", 1);
|
LODOP.PRINT_DESIGN();
|
}
|
},
|
true
|
);
|
},
|
// 保存模板
|
save() {
|
// 判断浏览器类型
|
var isIE = navigator.userAgent.indexOf("MSIE") >= 0 || navigator.userAgent.indexOf("Trident") >= 0;
|
var LODOP_OBJ = document.getElementById("LODOP");
|
var LODOP_EM = document.getElementById("LODOP_EM");
|
// LODOP对象
|
const LODOP = isIE ? LODOP_OBJ : LODOP_EM;
|
|
const designConent = LODOP.GET_VALUE("ProgramCodes", 0);
|
const url = "/api/sys/print/saveLodopTemplate";
|
const params = {
|
sendBillName: this.printType,
|
designConent: designConent
|
};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.$notify({
|
title: "提示",
|
type: "success",
|
message: res.msg,
|
position: "top-right"
|
});
|
},
|
true
|
);
|
},
|
// 删除选中项
|
deleteItem() {
|
// 判断浏览器类型
|
var isIE = navigator.userAgent.indexOf("MSIE") >= 0 || navigator.userAgent.indexOf("Trident") >= 0;
|
var LODOP_OBJ = document.getElementById("LODOP");
|
var LODOP_EM = document.getElementById("LODOP_EM");
|
// LODOP对象
|
const LODOP = isIE ? LODOP_OBJ : LODOP_EM;
|
|
LODOP.SET_PRINT_STYLEA("Selected", "Deleted", true);
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.print-container {
|
padding: 20px;
|
.print-page {
|
page-break-after: always;
|
margin-top: 20px;
|
}
|
}
|
|
@media print {
|
.canvas-container {
|
-moz-box-shadow: none;
|
-webkit-box-shadow: none;
|
box-shadow: none;
|
margin: 0px;
|
.canvas-content {
|
border: 0px dotted #000000;
|
}
|
}
|
.no-print {
|
display: none;
|
}
|
.page-next {
|
page-break-after: always;
|
}
|
}
|
</style>
|