224 lines
8.5 KiB
Plaintext
224 lines
8.5 KiB
Plaintext
<el-row id="print">
|
||
<el-row>
|
||
<el-col :span="4">
|
||
<el-select v-model="px" :popper-append-to-body="false" placeholder="片型">
|
||
<el-option v-for="item in pxList"
|
||
:key="item.value"
|
||
:label="item.label"
|
||
:value="item.value">
|
||
</el-option>
|
||
</el-select>
|
||
</el-col>
|
||
<el-col :span="4">
|
||
<el-input v-model="lot"
|
||
placeholder="型号">
|
||
</el-input>
|
||
</el-col>
|
||
<el-col :span="4">
|
||
<el-input v-model.number="num"
|
||
placeholder="数量">
|
||
</el-input>
|
||
</el-col>
|
||
<el-col :span="4">
|
||
<el-button type="primary" @@click="genCode">生成</el-button>
|
||
</el-col>
|
||
<el-col :span="4">
|
||
<el-button type="primary" @@click="create">创建入库单</el-button>
|
||
</el-col>
|
||
</el-row>
|
||
<div style="margin: 20px 0;"></div>
|
||
|
||
<div id="qrcode" style="
|
||
height: 10%;
|
||
"></div>
|
||
<el-button style="float: right" type="primary" @@click="print">打印</el-button>
|
||
</el-row>
|
||
|
||
<script>
|
||
var app = new Vue({
|
||
el: "#print",
|
||
data() {
|
||
return {
|
||
pxList:[
|
||
{
|
||
value: '1',
|
||
label: '上轭片'
|
||
}, {
|
||
value: '2',
|
||
label: '下轭片'
|
||
}, {
|
||
value: '3',
|
||
label: 'A柱片'
|
||
}, {
|
||
value: '4',
|
||
label: 'B柱片'
|
||
}, {
|
||
value: '5',
|
||
label: 'C柱片'
|
||
}
|
||
],
|
||
printData:[],
|
||
gendCode: '',
|
||
px: '',
|
||
lot:'',
|
||
num: 1,
|
||
clear: false,
|
||
template: { "panels": [{ "index": 0, "height": 50, "width": 80, "paperHeader": 43.5, "paperFooter": 141.73228346456693, "printElements": [{ "options": { "left": 96, "top": 19.5, "height": 87, "width": 120, "field": "qrcode", "testData": "12312312312", "textType": "qrcode" }, "printElementType": { "type": "text" } }, { "options": { "left": 16.5, "top": 24, "height": 25.5, "width": 69, "field": "px", "testData": "123123", "textAlign": "center", "textContentVerticalAlign": "middle" }, "printElementType": { "type": "text" } }, { "options": { "left": 16.5, "top": 67.5, "height": 24, "width": 67.5, "field": "lot", "testData": "1231231", "textAlign": "center", "textContentVerticalAlign": "middle" }, "printElementType": { "type": "text" } }], "paperNumberLeft": 196.5, "paperNumberTop": 118.5, "paperNumberDisabled": true }] }
|
||
}
|
||
},
|
||
methods: {
|
||
create() {
|
||
var _this = this;
|
||
if (_this.px == "") {
|
||
_this.$message({
|
||
message: "请选择片型!",
|
||
type: "warning",
|
||
duration: "500",
|
||
});
|
||
return;
|
||
}
|
||
if (_this.lot == "") {
|
||
_this.$message({
|
||
message: "请输入型号!",
|
||
type: "warning",
|
||
duration: "500",
|
||
});
|
||
return;
|
||
}
|
||
if (_this.num <= 0) {
|
||
_this.$message({
|
||
message: "数量要大于0!",
|
||
type: "warning",
|
||
duration: "500",
|
||
});
|
||
return;
|
||
}
|
||
var pxName = "";
|
||
_this.pxList.forEach(function (item) {
|
||
if (item.value == _this.px)
|
||
pxName = item.label;
|
||
})
|
||
// 调用后台方法,判断是否在物料表内
|
||
$.ajax({
|
||
type: "post",
|
||
dataType: "json",
|
||
data: { px: _this.px, pxName: pxName, lot: _this.lot, num: _this.num },
|
||
url: "/xwms/ReceiptHeader2/CreateDetail3",
|
||
success: function (json) {
|
||
if (json.Code != 200) {
|
||
_this.$message({
|
||
message: "创建失败!" + json.Msg,
|
||
type: "warning",
|
||
duration: "10000",
|
||
});
|
||
return;
|
||
} else {
|
||
_this.$message({
|
||
message: "创建成功!"
|
||
});
|
||
_this.gendCode = "";
|
||
_this.printData = [];
|
||
}
|
||
},
|
||
error: function (json) {
|
||
_this.$message({
|
||
message: "创建失败!",
|
||
type: "error",
|
||
duration: "10000",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
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",
|
||
});
|
||
}
|
||
if (_this.clear) {
|
||
_this.gendCode = "";
|
||
_this.printData = [];
|
||
}
|
||
},
|
||
error: function (json) {
|
||
_this.$message({
|
||
message: "扫描失败!",
|
||
type: "error",
|
||
duration: "10000",
|
||
});
|
||
},
|
||
});
|
||
},
|
||
genCode() {
|
||
var _this = this;
|
||
if (_this.px == "") {
|
||
_this.$message({
|
||
message: "请选择片型!",
|
||
type: "warning",
|
||
duration: "500",
|
||
});
|
||
return;
|
||
}
|
||
if (_this.lot == "") {
|
||
_this.$message({
|
||
message: "请输入型号!",
|
||
type: "warning",
|
||
duration: "500",
|
||
});
|
||
return;
|
||
}
|
||
_this.gendCode = _this.lot + '--' + _this.px;
|
||
var pxName = "";
|
||
_this.pxList.forEach(function (item) {
|
||
if (item.value == _this.px)
|
||
pxName = item.label;
|
||
})
|
||
_this.printData.push({
|
||
px: pxName,
|
||
lot: _this.lot,
|
||
qrcode: _this.gendCode
|
||
});
|
||
// 设置参数方式
|
||
var qrcode = new QRCode(document.getElementById('qrcode'), {
|
||
text: _this.gendCode,
|
||
width: 256,
|
||
height: 256,
|
||
colorDark: '#000000',
|
||
colorLight: '#ffffff',
|
||
correctLevel: QRCode.CorrectLevel.H
|
||
});
|
||
|
||
// 使用 API
|
||
qrcode.clear();
|
||
qrcode.makeCode(_this.gendCode);
|
||
},
|
||
print() {
|
||
var _this = this;
|
||
// _this.gendCode = "";
|
||
hiprint.init();
|
||
var hiprintTemplate = new hiprint.PrintTemplate({
|
||
template: this.template
|
||
})
|
||
hiprintTemplate.print(this.printData);
|
||
// _this.printData = [];
|
||
_this.clear = true;
|
||
//清空
|
||
_this.qrcode = '';
|
||
_this.num = 1;
|
||
}
|
||
}
|
||
});
|
||
|
||
</script>
|