Files
zhougf 5b1912ff07 计数:已操作的改个颜色
打印:两个二维码打到一个标签上,显示唯一码内容
货架入库:自动滚到最新数据,添加托盘信息
分解单据:不查找货架库库存
货架出库:添加导出excel
2024-04-29 16:21:44 +08:00

177 lines
7.2 KiB
Plaintext

<el-row id="print">
<el-row>
<el-col :span="12">
<el-input v-model="qrcode"
placeholder="请扫描二维码"
@@change="scanCode" ref="QrCode">
</el-input>
</el-col>
<el-col :span="8">
<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-row>
<div style="margin: 20px 0;"></div>
@* 富文本 *@
@* <el-input type="textarea"
:autosize="{ minRows: 4}"
readonly
v-model="gendCode">
</el-input> *@
<el-divider></el-divider>
<el-table :data="invTable" max-height="400" stripe border
style="width: 100%">
<el-table-column fixed="left"
label="操作"
width="120"
align="center">
<template slot-scope="scope">
<el-button @@click.native.prevent="deleteRow(scope.$index, invTable)"
type="text"
size="small">
移除
</el-button>
</template>
</el-table-column>
<el-table-column label="唯一码" width="220" align="center" prop="UniqueCode"></el-table-column>
<el-table-column label="批次" width="220" align="center" prop="Batch"></el-table-column>
</el-table>
<el-button style="float: right" type="primary" @@click="print">打印</el-button>
</el-row>
<script>
var app = new Vue({
el: "#print",
data() {
return {
invTable:[],
printData:[],
gendCode: '',
qrcode: '',
num: 1,
clear: false,
template: {"panels":[{"index":0,"height":25,"width":35,"paperHeader":43.5,"paperFooter":70.86614173228347,"printElements":[{"options":{"left":7.5,"top":0,"height":18,"width":86,"field":"code","testData":"A10209612024042800000001","fontFamily":"Microsoft YaHei"},"printElementType":{"type":"text"}},{"options":{"left":50,"top":20,"height":43,"width":48,"title":"123123","field":"batch","testData":"123123","textType":"qrcode"},"printElementType":{"type":"text"}},{"options":{"left":2,"top":20,"height":43,"width":48,"title":"123457","field":"qr","testData":"1231231","textType":"qrcode"},"printElementType":{"type":"text"}}],"paperNumberLeft":69,"paperNumberTop":48,"paperNumberDisabled":true}]}
}
},
methods: {
// 删除已绑定行
deleteRow(index, rows) {
rows.splice(index, 1);
},
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",
});
_this.qrcode = "";
}
if (_this.clear) {
_this.gendCode = "";
_this.invTable = [];
_this.printData = [];
}
},
error: function (json) {
_this.$message({
message: "扫描失败!",
type: "error",
duration: "10000",
});
},
});
},
genCode() {
var _this = this;
if (_this.qrcode == "") {
_this.$message({
message: "请扫描二维码后再操作!",
type: "warning",
duration: "500",
});
return;
}
if (_this.num == "") {
_this.$message({
message: "请输入数量后再操作!",
type: "warning",
duration: "500",
});
return;
}
// 调用后台方法,生成唯一码,(流水号)
$.ajax({
type: "post",
dataType: "json",
data: { code: _this.qrcode, num: _this.num },
url: "/configs/Print/GenCode",
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "生成失败!" + json.Msg,
type: "warning",
duration: "10000",
});
return;
}
else{
// console.log(json);
json.Data.forEach(function (item) {
// _this.gendCode += item.UniqueCode + '\n';
// _this.gendCode += item.Batch + '\n';
_this.invTable.push({
"UniqueCode": item.UniqueCode,
"Batch": item.Batch
});
// _this.printData.push({ uniqueCode: item.UniqueCode });
// _this.printData.push({ uniqueCode: item.Batch });
});
}
},
error: function (json) {
_this.$message({
message: "生成失败!",
type: "error",
duration: "10000",
});
},
});
_this.num = 1;
},
print() {
var _this = this;
_this.printData = [];
this.invTable.forEach(function (item) {
_this.printData.push({ qr: item.UniqueCode,code: item.UniqueCode,batch: item.Batch });
});
// _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>