159 lines
7.8 KiB
Plaintext
159 lines
7.8 KiB
Plaintext
@model HHWMS.Web.ReceiptDetail2VM
|
|
@inject IStringLocalizer<Program> Localizer;
|
|
|
|
<el-row id="PrintDetail">
|
|
<el-form :inline="true">
|
|
|
|
<el-form-item>
|
|
<el-input v-model.number="num" placeholder="拆分数量" @@keyup.enter.native="chai()"></el-input>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-input v-model="qty" placeholder="重量" @@keyup.enter.native="splitQty()"></el-input>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button type="primary" @@click="print">打印</el-button>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button type="primary" @@click="chaiBill">拆分</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
|
|
<el-table :data="tableData"
|
|
height="600" stripe border
|
|
style="width: 100%"
|
|
ref="tableData"
|
|
v-loading="loading">
|
|
<el-table-column type="index"
|
|
width="50">
|
|
</el-table-column>
|
|
<el-table-column label="ID" width="150" align="center" prop="Id" v-if="false"></el-table-column>
|
|
<el-table-column label="卷号" width="150" align="center" prop="MaterialCode"></el-table-column>
|
|
<el-table-column label="物料名称" width="150" align="center" prop="MaterialName"></el-table-column>
|
|
<el-table-column label="规格" width="150" align="center" prop="Lot"></el-table-column>
|
|
<el-table-column label="批次" width="150" align="center" prop="Batch"></el-table-column>
|
|
<el-table-column label="数量" width="150" align="center" prop="Qty"></el-table-column>
|
|
|
|
</el-table>
|
|
</el-row>
|
|
|
|
<script>
|
|
var str = "";
|
|
@{
|
|
<text>str = @Model.Entity.ID</text>
|
|
}
|
|
|
|
var app = new Vue({
|
|
el: "#PrintDetail",
|
|
data() {
|
|
return {
|
|
num:'',
|
|
qty:'',
|
|
loading: false,
|
|
tableData: [],
|
|
sumQty:0
|
|
};
|
|
},
|
|
mounted: function () {
|
|
this.search();
|
|
},
|
|
methods: {
|
|
search() {
|
|
var _this = this;
|
|
_this.loading = true;
|
|
$.ajax({
|
|
type: "post",
|
|
dataType: "json",
|
|
data: {
|
|
id: str
|
|
},
|
|
url: "/xwms/ReceiptDetail2/SearchDetail",
|
|
success: function (json) {
|
|
_this.tableData = json.Data;
|
|
_this.tableData[0].Qty = parseFloat(_this.tableData[0].Qty);
|
|
_this.sumQty = json.Data[0].Qty;
|
|
_this.loading = false;
|
|
},
|
|
error: function (json) {
|
|
_this.$message.error("加载失败");
|
|
_this.loading = false;
|
|
}
|
|
});
|
|
},
|
|
splitQty() {
|
|
var _this = this;
|
|
if (this.qty != "") {
|
|
var list = this.qty.split(" ");
|
|
// var sum = 0;
|
|
// list.forEach(function(val){
|
|
// sum += parseFloat(val);
|
|
// })
|
|
// if (sum != this.sumQty) {
|
|
// layer.alert("总数不一致!!", { icon: 5, shadeClose: true, title: "错误信息" });
|
|
// }
|
|
if (list.length == this.tableData.length) {
|
|
var nn = list.length - 1;
|
|
while (nn >= 0) {
|
|
_this.tableData[nn].Qty = list[nn];
|
|
nn--;
|
|
}
|
|
} else {
|
|
layer.alert("数量与表行不一致!!", { icon: 5, shadeClose: true, title: "错误信息" });
|
|
}
|
|
}
|
|
},
|
|
chai() {
|
|
if (this.num > 1) {
|
|
this.tableData[0].Qty = this.sumQty / this.num;
|
|
while (this.num > 1) {
|
|
this.tableData.push(JSON.parse(JSON.stringify(this.tableData[0])));
|
|
this.num--;
|
|
}
|
|
}
|
|
},
|
|
chaiBill() {
|
|
var _this = this;
|
|
$.ajax({
|
|
type: "post",
|
|
dataType: "json",
|
|
data: {
|
|
data: _this.tableData
|
|
},
|
|
url: "/xwms/ReceiptDetail2/ChaiDetail",
|
|
success: function (json) {
|
|
if (json.Code == 200) {
|
|
layer.msg("拆分数据成功");
|
|
} else {
|
|
layer.alert(json.Msg, { icon: 5, shadeClose: true, title: "错误信息" });
|
|
}
|
|
},
|
|
error: function (json) {
|
|
layer.alert("失败", { icon: 5, shadeClose: true, title: "错误信息" });
|
|
}
|
|
});
|
|
}
|
|
},
|
|
});
|
|
let template = { "panels": [{ "index": 0, "height": 50, "width": 80, "paperHeader": 43.5, "paperFooter": 141.73228346456693, "printElements": [{ "options": { "left": 3, "top": 3, "height": 40, "width": 220, "field": "lot", "textAlign": "center", "textContentVerticalAlign": "middle", "fontFamily": "Microsoft YaHei", "fontSize": 8, "fontWeight": "bold" }, "printElementType": { "type": "text" } }, { "options": { "left": 3, "top": 3, "height": 130, "width": 220, "borderWidth": "1.5", "borderStyle": "solid" }, "printElementType": { "type": "rect" } }, { "options": { "left": 3, "top": 42, "height": 9, "width": 219 }, "printElementType": { "type": "hline" } }, { "options": { "left": 135, "top": 42, "height": 90, "width": 9 }, "printElementType": { "type": "vline" } }, { "options": { "left": 3, "top": 43.5, "height": 28.5, "width": 132, "field": "code", "testData": "1324123412341234123", "textAlign": "center", "textContentVerticalAlign": "middle", "fontFamily": "Microsoft YaHei", "fontSize": 12, "fontWeight": "bold" }, "printElementType": { "type": "text" } }, { "options": { "left": 138, "top": 46.5, "height": 79.5, "width": 81, "textType": "qrcode", "field": "qrcode", "testData": "1234123413234132" }, "printElementType": { "type": "text" } }, { "options": { "left": 3, "top": 72, "height": 30, "width": 132, "field": "qty", "testData": "5555", "textAlign": "center", "textContentVerticalAlign": "middle", "fontFamily": "Microsoft YaHei", "fontSize": 12, "fontWeight": "bold" }, "printElementType": { "type": "text" } }, { "options": { "left": 3, "top": 72, "height": 9, "width": 132 }, "printElementType": { "type": "hline" } }, { "options": { "left": 3, "top": 102, "height": 9, "width": 132 }, "printElementType": { "type": "hline" } }, { "options": { "left": 4.5, "top": 102, "height": 28.5, "width": 132, "field": "batch", "testData": "HYB2202030003", "textAlign": "center", "textContentVerticalAlign": "middle", "fontFamily": "Microsoft YaHei", "fontSize": 12, "fontWeight": "bold" }, "printElementType": { "type": "text" } }], "paperNumberLeft": 196.5, "paperNumberTop": 118.5, "paperNumberDisabled": true }] };
|
|
|
|
let printData = [];
|
|
|
|
function print() {
|
|
app.tableData.forEach(function (value, index, arr) {
|
|
printData.push({
|
|
lot: value.MaterialName + '|' + value.Lot,
|
|
code: value.MaterialCode,
|
|
batch: value.Batch,
|
|
qty: value.Qty,
|
|
qrcode: 'MT.' + value.MaterialCode + '@@@@LT.' + value.Batch + '@@@@QT.' + value.Qty
|
|
})
|
|
});
|
|
|
|
hiprint.init();
|
|
var hiprintTemplate = new hiprint.PrintTemplate({
|
|
template: template
|
|
});
|
|
hiprintTemplate.print(printData);
|
|
printData = [];
|
|
}
|
|
</script>
|