Files
WMS/HHWMS.Web/Areas/Configs/Views/Print/Index.cshtml
T
2023-09-05 21:27:13 +08:00

135 lines
4.9 KiB
Plaintext

<el-row id="print">
<el-row>
<el-col :span="16">
<el-input v-model="qrcode"
placeholder="请扫描二维码"
@@change="scanCode">
</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": 15,
"top": 5,
"height": 44,
"width": 54,
"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) {
if (json.Code != 200) {
_this.$message({
message: "扫描失败!" + json.Msg,
type: "warning",
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() {
hiprint.init();
var hiprintTemplate = new hiprint.PrintTemplate({
template: this.template
})
hiprintTemplate.print(this.printData);
}
}
});
</script>