324 lines
12 KiB
Plaintext
324 lines
12 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-select v-model="lot" :popper-append-to-body="false" placeholder="型号"
|
||
filterable
|
||
allow-create
|
||
default-first-option>
|
||
<el-option v-for="item in lotList"
|
||
:key="item.value"
|
||
:label="item.label"
|
||
:value="item.value">
|
||
</el-option>
|
||
</el-select>
|
||
</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柱片'
|
||
}
|
||
],lotList:[],
|
||
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": 93,
|
||
"top": 39,
|
||
"height": 87,
|
||
"width": 120,
|
||
"field": "qrcode",
|
||
"testData": "12312312312",
|
||
"textType": "qrcode"
|
||
},
|
||
"printElementType": {
|
||
"type": "text"
|
||
}
|
||
}, {
|
||
"options": {
|
||
"left": 15,
|
||
"top": 46.5,
|
||
"height": 28.5,
|
||
"width": 72,
|
||
"field": "px",
|
||
"testData": "123123",
|
||
"textAlign": "center",
|
||
"textContentVerticalAlign": "middle",
|
||
"fontFamily": "Microsoft YaHei",
|
||
"fontSize": 8,
|
||
"fontWeight": "bold"
|
||
},
|
||
"printElementType": {
|
||
"type": "text"
|
||
}
|
||
}, {
|
||
"options": {
|
||
"left": 13.5,
|
||
"top": 9,
|
||
"height": 24,
|
||
"width": 198,
|
||
"field": "lot",
|
||
"testData": "1231231",
|
||
"textAlign": "center",
|
||
"textContentVerticalAlign": "middle",
|
||
"fontFamily": "Microsoft YaHei",
|
||
"fontSize": 8,
|
||
"fontWeight": "bold"
|
||
},
|
||
"printElementType": {
|
||
"type": "text"
|
||
}
|
||
}],
|
||
"paperNumberLeft": 196.5,
|
||
"paperNumberTop": 118.5,
|
||
"paperNumberDisabled": true
|
||
}]
|
||
}
|
||
}
|
||
},
|
||
mounted: function() {
|
||
var t = window.localStorage.getItem("lot");
|
||
if (t == undefined) {
|
||
window.localStorage.setItem("lot", JSON.stringify(this.lotList));
|
||
}
|
||
this.lotList = JSON.parse(window.localStorage.getItem("lot"));
|
||
},
|
||
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.lotList.push({
|
||
value: _this.lot,
|
||
label: _this.lot
|
||
});
|
||
|
||
var ttt = []
|
||
if (this.lotList.length > 20) {
|
||
ttt = this.lotList.slice(2);
|
||
} else {
|
||
ttt = this.lotList;
|
||
}
|
||
var tt = Array.from(new Set(ttt.map(JSON.stringify))).map(JSON.parse);
|
||
window.localStorage.setItem("lot", JSON.stringify(tt));
|
||
this.lotList = JSON.parse(window.localStorage.getItem("lot"));
|
||
|
||
|
||
_this.gendCode = _this.lot + '--' + _this.px;
|
||
var pxName = "";
|
||
_this.pxList.forEach(function (item) {
|
||
if (item.value == _this.px)
|
||
pxName = item.label;
|
||
})
|
||
|
||
// 设置参数方式
|
||
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.printData = [];
|
||
_this.pxList.forEach(function (item) {
|
||
if (item.value == _this.px)
|
||
pxName = item.label;
|
||
})
|
||
var n = _this.num;
|
||
while (n > 0) {
|
||
_this.printData.push({
|
||
px: pxName,
|
||
lot: _this.lot,
|
||
qrcode: _this.lot + '--' + _this.px
|
||
});
|
||
n--;
|
||
}
|
||
|
||
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>
|