171 lines
6.6 KiB
Plaintext
171 lines
6.6 KiB
Plaintext
<el-row id="print">
|
|
<el-row>
|
|
<el-col :span="16">
|
|
<el-input v-model="qrcode"
|
|
placeholder="请扫描二维码"
|
|
@@change="scanCode" ref="QrCode">
|
|
</el-input>
|
|
</el-col>
|
|
<el-col :span="8">
|
|
<el-button type="primary" @@click="genCode">生成</el-button>
|
|
</el-col>
|
|
</el-row>
|
|
<div style="margin: 20px 0;"></div>
|
|
@* 富文本 *@
|
|
<el-input type="textarea"
|
|
:autosize="{ minRows: 4}"
|
|
readonly
|
|
v-model="gendCode">
|
|
</el-input>
|
|
<el-button style="float: right" type="primary" @@click="print">打印</el-button>
|
|
</el-row>
|
|
|
|
<script>
|
|
var app = new Vue({
|
|
el: "#print",
|
|
data() {
|
|
return {
|
|
printData:[],
|
|
gendCode: '',
|
|
qrcode: '',
|
|
template: {
|
|
"panels": [
|
|
{
|
|
"index": 0,
|
|
"height": 20,
|
|
"width": 30,
|
|
"paperHeader": 43.5,
|
|
"paperFooter": 56.69,
|
|
"printElements": [
|
|
{
|
|
"options": {
|
|
"left": 0,
|
|
"top": 2,
|
|
"height": 52,
|
|
"width": 81,
|
|
"title": "",
|
|
"field": "uniqueCode",
|
|
"testData": "",
|
|
"textType": "qrcode",
|
|
"barcodeMode": "CODE39"
|
|
},
|
|
"printElementType": {
|
|
"type": "text"
|
|
}
|
|
}
|
|
],
|
|
"paperNumberLeft": 55.5,
|
|
"paperNumberTop": 34.5,
|
|
"paperNumberDisabled": true
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
scanCode() {
|
|
var _this = this;
|
|
// 调用后台方法,判断是否在物料表内
|
|
$.ajax({
|
|
type: "post",
|
|
dataType: "json",
|
|
data: { code: _this.qrcode },
|
|
url: "/configs/Print/ScanCode",
|
|
success: function (json) {
|
|
console.log(json);
|
|
if (json.Code != 200) {
|
|
_this.$message({
|
|
message: "扫描失败!" + json.Msg,
|
|
type: "warning",
|
|
duration: "10000",
|
|
});
|
|
}
|
|
else{
|
|
$.ajax({
|
|
type: "post",
|
|
dataType: "json",
|
|
data: { code: _this.qrcode },
|
|
url: "/configs/Print/GenCode",
|
|
success: function (json) {
|
|
if (json.Code != 200) {
|
|
_this.$message({
|
|
message: "生成失败!" + json.Msg,
|
|
type: "warning",
|
|
duration: "10000",
|
|
});
|
|
return;
|
|
}
|
|
else {
|
|
_this.gendCode += json.Data + '\n';
|
|
_this.printData.push({ uniqueCode: json.Data });
|
|
//清空
|
|
_this.qrcode = '';
|
|
}
|
|
},
|
|
error: function (json) {
|
|
_this.$message({
|
|
message: "生成失败!",
|
|
type: "error",
|
|
duration: "10000",
|
|
});
|
|
},
|
|
});
|
|
|
|
}
|
|
},
|
|
error: function (json) {
|
|
_this.$message({
|
|
message: "扫描失败!",
|
|
type: "error",
|
|
duration: "10000",
|
|
});
|
|
},
|
|
});
|
|
},
|
|
genCode() {
|
|
var _this = this;
|
|
// 调用后台方法,生成唯一码,(流水号)
|
|
$.ajax({
|
|
type: "post",
|
|
dataType: "json",
|
|
data: { code: _this.qrcode },
|
|
url: "/configs/Print/GenCode",
|
|
success: function (json) {
|
|
if (json.Code != 200) {
|
|
_this.$message({
|
|
message: "生成失败!" + json.Msg,
|
|
type: "warning",
|
|
duration: "10000",
|
|
});
|
|
return;
|
|
}
|
|
else{
|
|
_this.gendCode += json.Data + '\n';
|
|
_this.printData.push({ uniqueCode: json.Data });
|
|
}
|
|
},
|
|
error: function (json) {
|
|
_this.$message({
|
|
message: "生成失败!",
|
|
type: "error",
|
|
duration: "10000",
|
|
});
|
|
},
|
|
});
|
|
//清空
|
|
_this.qrcode = '';
|
|
},
|
|
print() {
|
|
var _this = this;
|
|
_this.gendCode = "";
|
|
hiprint.init();
|
|
var hiprintTemplate = new hiprint.PrintTemplate({
|
|
template: this.template
|
|
})
|
|
hiprintTemplate.print(this.printData);
|
|
_this.printData = [];
|
|
}
|
|
}
|
|
});
|
|
</script>
|