<template>
|
<div class="scan-container">
|
<el-card class="scan-card no-print">
|
<div slot="header" class="clearfix">
|
<span>出库单打包校验</span>
|
</div>
|
<el-form ref="form" :model="formData" label-width="120px" class="scan-form">
|
<el-form-item label="快递号/出库单号">
|
<el-input ref="batchCode" v-model="formData.batchCode" autofocus class="input-300" @keyup.native.enter.stop="getData"></el-input>
|
<span class="sub-item">
|
<span class="sub-label">物料校验:</span>
|
<el-switch v-model="formData.isValidateProductCode" @change="onIsValidateProductCodeChange"></el-switch>
|
</span>
|
<span class="sub-item">
|
<span class="sub-label">开启装箱:</span>
|
<el-switch v-model="formData.isOpenCase" @change="onIsOpenCase"></el-switch>
|
</span>
|
</el-form-item>
|
<el-form-item v-if="formData.isOpenCase" label="箱号">
|
<el-input v-model="formData.caseNumber" class="input-300" @keyup.native.enter.stop="onKeyupCaseNumber"></el-input>
|
<el-radio-group v-model="formData.caseMode" @change="onCaseMode">
|
<el-radio :label="1">一品一箱</el-radio>
|
<el-radio :label="2">多品一箱</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
<el-form-item label="物料条码">
|
<el-input ref="productModel" v-model="formData.productModel" :disabled="!formData.isValidateProductCode" class="input-300" @keyup.native.enter.stop="checkPackingBarcode"></el-input>
|
</el-form-item>
|
<el-form-item label="包材条码">
|
<el-input ref="txtwrapperBarcode" v-model="formData.wrapperBarcode" class="w-300"></el-input>
|
</el-form-item>
|
<el-form-item label="扫描数量">
|
<el-input-number ref="scanQty" v-model="formData.scanQty" :min="0" :disabled="!formData.isValidateProductCode" controls-position="right" class="input-120" @change="changeScanQty"></el-input-number>
|
<span class="sub-item">
|
<span class="sub-label">称重:</span>
|
<el-input-number v-model="formData.weight" :min="0" controls-position="right" class="input-105"></el-input-number>
|
</span>
|
</el-form-item>
|
<el-form-item v-if="formData.isOpenCase" label="选择打印机">
|
<el-select v-model="formData.printerName" placeholder="请选择打印机" class="w-300" @change="changePrint">
|
<el-option v-for="(item, index) in printList" :key="index" :label="item" :value="item"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item>
|
<el-button v-if="formData.isOpenCase" @click="changeBox">换箱</el-button>
|
<el-button type="success" @click="openPackage">复核提交</el-button>
|
<el-button @click="onReset">重置</el-button>
|
<el-checkbox v-if="config.outer_printBill" v-model="formData.isOuter_PrintBill">打印面单</el-checkbox>
|
<el-checkbox v-if="formData.isOpenCase" v-model="formData.isOuter_Packinglist" @change="outerPacking">打印装箱清单</el-checkbox>
|
</el-form-item>
|
</el-form>
|
</el-card>
|
<el-card class="scan-card body-no-padding no-print">
|
<div slot="header" class="clearfix">
|
<span class="padding-top-10">扫描结果</span>
|
<el-button type="text" class="floatRight" @click="setting.visible=true">字段设置</el-button>
|
</div>
|
<el-table ref="scan-table" :data="tableData" :row-class-name="rowClass" stripe style="width: 100%" class="scan-table" @row-dblclick="setCurrent">
|
<template v-for="(item, index) in setting.fields">
|
<template v-if="['unFinishedQuantity','finishedQuantity'].indexOf(item.prop)>=0">
|
<el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
|
<template slot-scope="scope">
|
<template v-if="!formData.isValidateProductCode">
|
<el-input-number v-model="scope.row[item.prop]" :min="0" :max="scope.row['quantityOrder']" size="mini" class="w-100pc" controls-position="right" @change="rowChangeQty(item.prop, scope.row)"></el-input-number>
|
</template>
|
<template v-else>
|
{{ scope.row[item.prop] }}
|
</template>
|
</template>
|
</el-table-column>
|
</template>
|
<template v-else-if="'positionName,scanWeight'.indexOf(item.prop)>=0">
|
<el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
|
<template slot-scope="scope">
|
<template>
|
<el-input v-model="scope.row[item.prop]" size="mini" class="w-100pc"></el-input>
|
</template>
|
</template>
|
</el-table-column>
|
</template>
|
<template v-else-if="'produceDate,limitDate'.indexOf(item.prop)>=0">
|
<el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
|
<template slot-scope="scope">
|
<template>
|
<el-date-picker v-model="scope.row[item.prop]" size="mini" type="date" placeholder="选择日期" class="w-110" value-format="yyyy-MM-dd">
|
</el-date-picker>
|
</template>
|
</template>
|
</el-table-column>
|
</template>
|
<template v-else-if="'caseNumber'.indexOf(item.prop)>=0">
|
<el-table-column v-if="item.visible&&formData.isOpenCase" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
|
</el-table-column>
|
</template>
|
<template v-else>
|
<el-table-column v-if="item.visible" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
|
</el-table-column>
|
</template>
|
</template>
|
</el-table>
|
</el-card>
|
|
<scan-setting-dialog ref="setting-dialog" :visible.sync="setting.visible" :fields="setting.fields" :name="setting.name">
|
</scan-setting-dialog>
|
<!-- 显示打印模板 -->
|
<print v-if="formData.isOuter_PrintBill" ref="printRef" :ids="''+formData.order_Id" type="express"></print>
|
<!-- 显示打印装箱清单模板 -->
|
<div id="mount-print"></div>
|
|
<!--复核提交-->
|
<el-dialog :visible.sync="isOpenPackage" title="复核提交" width="500px">
|
<el-form :label-width="formLabelWidth">
|
<el-form-item label="合计件数" style="width:320px;">
|
<el-input v-model="totalPackage" type="text"></el-input>
|
</el-form-item>
|
<el-form-item label="合计体积" style="width:320px;">
|
<el-input v-model="totalVolume" type="text"></el-input>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="isOpenPackage=false">取 消</el-button>
|
<el-button type="primary" @click="partialSave()">确 定</el-button>
|
</div>
|
</el-dialog>
|
|
<!--声音文件-->
|
<audio ref="sound_error" controls="controls" style="display:none;">
|
<source src="@/assets/sounds/error2.mp3" type="audio/mpeg" />
|
</audio>
|
<audio ref="sound_correct" controls="controls" style="display:none;">
|
<source src="@/assets/sounds/feixin.mp3" type="audio/mpeg" />
|
</audio>
|
<audio controls="controls" style="display:none;">
|
<source ref="sound_scan" src="@/assets/sounds/saomiao.wav" type="audio/mpeg" />
|
</audio>
|
</div>
|
</template>
|
|
<script>
|
import { getLodop } from "@/utils/LodopFuncs";
|
import Vue from "vue";
|
import print from "@/views/sys/print/base2";
|
import PrintPacking from "@/views/sys/print/base3";
|
import YrtScanMixins from "@/components/common/yrtScanMixins.vue";
|
import PrintCase from "@/views/sys/print/base-fenjianji";
|
import ScanSettingDialog from "@/components/common/components/scanSettingDialog.vue";
|
|
export default {
|
name: "outbound-scan-out",
|
components: {
|
ScanSettingDialog,
|
print,
|
PrintPacking,
|
PrintCase
|
},
|
mixins: [YrtScanMixins],
|
data() {
|
return {
|
// 配置参数
|
config: {
|
// 自动生成上架单
|
in_generateShelve: true,
|
// 是否启用装箱操作
|
in_caseNumber: false,
|
// 支持一品多码
|
sku_productToMultiBarcode: true,
|
// 打印面单
|
outer_printBill: true,
|
// 打印装箱清单
|
outer_Packinglist: true,
|
// 称重阈值
|
outer_weightWhreshold: 0,
|
// 是否体积,件数
|
outer_openPackage: false
|
},
|
formData: {
|
order_Id: 0,
|
orderCode: null,
|
batchCode: null,
|
caseNumber: null,
|
productModel: null, // 包装条码
|
scanQty: 0, // 扫描数量
|
weight: 0, // 称重
|
isValidateProductCode: false, // 是否校验物料
|
isOpenCase: false, // 开启装箱
|
// 装箱方式:0:常规扫描,1:一品一箱,2:多品一箱
|
caseMode: 2,
|
// 打印面单
|
isOuter_PrintBill: false,
|
// 打印装箱清单
|
isOuter_Packinglist: false,
|
wrapperBarcode: ""
|
},
|
// 订单信息
|
orderInfo: null,
|
// 扫描数据
|
tableData: [],
|
// 当前正在扫描的数据
|
currentRow: {},
|
// 已经找到的数据
|
existRows: [],
|
// 一次扫描的数量
|
scanCount: 1,
|
// 装箱打印模板
|
printCaseVueData: {},
|
// 打印机设备列表
|
printList: [],
|
// // 当前正在扫描的数据
|
// currentRow: {},
|
// 扫描列设置对话框参数
|
setting: {
|
visible: false,
|
name: "outbound-scan-out",
|
fields: [
|
{
|
prop: "productModel",
|
label: "条形码",
|
visible: true,
|
width: 130,
|
order: 1
|
},
|
{
|
prop: "quantityOrder",
|
label: "物料数量",
|
visible: true,
|
width: 90,
|
order: 2
|
},
|
{
|
prop: "quantityOuter",
|
label: "已出库数量",
|
visible: true,
|
width: 90,
|
order: 3
|
},
|
{
|
prop: "finishedQuantity",
|
label: "当前扫描数量",
|
visible: true,
|
width: 120,
|
order: 4
|
},
|
{
|
prop: "unFinishedQuantity",
|
label: "未扫描数量",
|
visible: true,
|
width: 130,
|
order: 5
|
},
|
{
|
prop: "productCode",
|
label: "物料编号",
|
visible: true,
|
width: 130,
|
order: 6
|
},
|
{
|
prop: "salePrice",
|
label: "单价",
|
visible: true,
|
width: 90,
|
order: 6
|
},
|
{
|
prop: "caseNumber",
|
label: "箱号",
|
visible: true,
|
width: 90,
|
order: 7
|
},
|
{
|
prop: "productSpec",
|
label: "物料规格",
|
visible: true,
|
width: 130,
|
order: 8
|
},
|
{
|
prop: "weight",
|
label: "单位毛重",
|
visible: false,
|
width: 90,
|
order: 9
|
},
|
{
|
prop: "totalWeight",
|
label: "合计重量",
|
visible: false,
|
width: 80,
|
order: 10
|
},
|
{
|
prop: "scanWeight",
|
label: "已扫重量",
|
visible: false,
|
width: 80,
|
order: 11
|
},
|
{
|
prop: "productName",
|
label: "物料名称",
|
visible: true,
|
width: null,
|
order: 12
|
}
|
]
|
},
|
// 弹出框
|
isOpenPackage: false,
|
formLabelWidth: "120px",
|
totalPackage: null, // 合计件数
|
totalVolume: null // 合计体积
|
};
|
},
|
activated() {
|
// 校验条码
|
const isValidateProductCode = localStorage["out_isValidateProductCode"];
|
if (isValidateProductCode) {
|
this.formData.isValidateProductCode = isValidateProductCode === "true";
|
}
|
// 开启装箱
|
const isOpenCase = localStorage["out_isOpenCase"];
|
if (isOpenCase) {
|
this.formData.isOpenCase = isOpenCase === "true";
|
const caseMode = localStorage["out_caseMode"] || "0";
|
this.formData.caseMode = parseInt(caseMode);
|
}
|
// 勾选打印装箱
|
const isOuter_Packinglist = localStorage["isOuter_Packinglist"];
|
if (isOuter_Packinglist) {
|
this.formData.isOuter_Packinglist = isOuter_Packinglist === "true";
|
}
|
},
|
|
mounted() {
|
// 获取配置参数
|
this.getConfig();
|
// 获得打印模板
|
this.getPrintTemplate();
|
// 获取打印机
|
this.getPrintList();
|
// 字段设置
|
const setting = localStorage[this.setting.name + "-setting"];
|
if (setting) {
|
this.setting.fields = JSON.parse(setting);
|
}
|
},
|
methods: {
|
// 是否校验物料切换
|
onIsValidateProductCodeChange() {
|
localStorage["out_isValidateProductCode"] = this.formData.isValidateProductCode;
|
|
this.tableData = this.tableData.map(row => {
|
let unFinishedQuantity = Math.Round(row.quantityOrder - row.quantityOuter, 4);
|
row.scanWeight = 0;
|
let finishedQuantity = 0;
|
if (!this.formData.isValidateProductCode) {
|
unFinishedQuantity = 0;
|
finishedQuantity = Math.Round(row.quantityOrder - row.quantityOuter, 4);
|
row.scanWeight = row.totalWeight;
|
}
|
row.unFinishedQuantity = unFinishedQuantity;
|
row.finishedQuantity = finishedQuantity;
|
row.sortIndex = 0;
|
return row;
|
});
|
},
|
// 是否开启装箱
|
onIsOpenCase() {
|
localStorage["out_isOpenCase"] = this.formData.isOpenCase;
|
if (this.formData.isOpenCase) {
|
const caseMode = localStorage["out_caseMode"] || "0";
|
this.formData.caseMode = parseInt(caseMode);
|
} else {
|
this.formData.caseMode = 0;
|
}
|
},
|
// 切换装箱模式
|
onCaseMode() {
|
localStorage["out_caseMode"] = this.formData.caseMode;
|
},
|
// 箱号回车
|
onKeyupCaseNumber() {
|
this.focus("productModel");
|
},
|
// 获得配置参数
|
getConfig() {
|
var keys = Object.keys(this.config).join(",");
|
var url = "/api/sys/param/getConfig";
|
var params = {
|
openNodeApi: true,
|
keys: keys
|
};
|
var callback = res => {
|
this.common.showMsg(res);
|
this.valueList = res.data;
|
// 获得参数值列表,将数字转换为对象
|
res.data.forEach(item => {
|
var value02 = item.value02; // 字段名称
|
var value03 = item.value03;
|
|
if (this.common.isNumber(item.value03)) {
|
value03 = parseInt(item.value03);
|
}
|
// 称重阈值不需要转为boolean
|
if (value02 !== "outer_weightWhreshold") {
|
this.$set(this.config, item.value02, !!value03);
|
}
|
});
|
};
|
var target = this.$refs["settings"];
|
this.common.ajax(url, params, callback, target);
|
},
|
// 获取扫描数据
|
getData() {
|
var batchCode = this.formData.batchCode;
|
if (!batchCode) {
|
this.$message.error("快递单号不能为空!");
|
return;
|
}
|
batchCode = batchCode.trim();
|
this.formData.batchCode = batchCode;
|
|
var url = "/api/outbound/outScan/getData";
|
var params = {
|
openNodeApi: true,
|
expressCode: batchCode,
|
batchCode: batchCode
|
};
|
var callBack = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.orderInfo = res.data2;
|
this.tableData = res.data.map(row => {
|
let unFinishedQuantity = Math.Round(row.quantityOrder - row.quantityOuter, 4);
|
let finishedQuantity = 0;
|
let scanWeight = 0;
|
if (!this.formData.isValidateProductCode) {
|
unFinishedQuantity = 0;
|
finishedQuantity = Math.Round(row.quantityOrder - row.quantityOuter, 4);
|
scanWeight = row.totalWeight;
|
}
|
row.unFinishedQuantity = unFinishedQuantity;
|
row.finishedQuantity = finishedQuantity;
|
row.scanWeight = scanWeight;
|
row.sortIndex = 0;
|
return row;
|
});
|
if (this.config.outer_printBill === true) {
|
this.formData.order_Id = this.tableData[0].order_Id;
|
}
|
this.formData.caseNumber = res.dynamic;
|
// 条码框获得焦点
|
if (this.formData.isValidateProductCode) {
|
this.$refs.productModel.focus();
|
this.$refs.productModel.select();
|
} else {
|
this.$refs.txtwrapperBarcode.focus();
|
this.$refs.txtwrapperBarcode.select();
|
}
|
} else {
|
this.onReset();
|
}
|
};
|
this.common.ajax(url, params, callBack, true);
|
},
|
// 判断扫描包装条码
|
checkPackingBarcode() {
|
var code = this.formData.productModel;
|
if (!code) {
|
this.focus("productModel");
|
this.$message.error("物料条码不能为空!");
|
return;
|
}
|
if (this.formData.isOpenCase && this.formData.caseMode <= 0) {
|
this.focus("productModel");
|
this.$message.error("请选择装箱方式!");
|
return;
|
}
|
|
// 装箱操作
|
if (this.formData.isOpenCase) {
|
if (this.formData.caseMode === 1) {
|
// 一品一箱
|
this.addRow_1();
|
} else if (this.formData.caseMode === 2) {
|
// 多品一箱
|
this.addRow_2();
|
}
|
} else {
|
// 常规扫描
|
this.checkPackingProductModel(this.tableData);
|
}
|
this.focus("productModel");
|
if (this.currentRow) {
|
this.formData.scanQty = this.currentRow.finishedQuantity;
|
}
|
},
|
// 设置扫描数量
|
setScanCount(barcode, count, isAdd) {
|
if (!count || count < 0) {
|
this.$message({
|
showClose: true,
|
message: '"数量不正确',
|
type: "warning"
|
});
|
return;
|
}
|
if (!barcode) {
|
this.$message({
|
showClose: true,
|
message: '"条码不能为空',
|
type: "warning"
|
});
|
return;
|
}
|
},
|
// 行样式
|
rowClass({ row, rowIndex }) {
|
if (this.currentRow === row) {
|
return "row-active";
|
}
|
},
|
// 扫描数量手工改变
|
changeScanQty() {
|
if (this.currentRow) {
|
let finishedQuantity = 0; // 当前物料所有分箱的出库数量求和
|
this.tableData
|
.filter(item => {
|
return item.orderList_Id === this.currentRow.orderList_Id;
|
})
|
.forEach(item => {
|
finishedQuantity += item.finishedQuantity;
|
});
|
|
// 不包含当前行完成数量
|
finishedQuantity -= this.currentRow.finishedQuantity;
|
const unFinishedQuantity = Math.Round(this.currentRow.quantityOrder - this.currentRow.quantityOuter - finishedQuantity, 4);
|
if (this.formData.scanQty <= unFinishedQuantity) {
|
this.currentRow.unFinishedQuantity = Math.Round(unFinishedQuantity - this.formData.scanQty, 4);
|
this.currentRow.finishedQuantity = this.formData.scanQty;
|
this.currentRow.scanWeight = Math.Round(this.currentRow.weight * this.currentRow.finishedQuantity, 2);
|
} else {
|
this.$message({
|
showClose: true,
|
message: "没有足够的数量!",
|
type: "warning"
|
});
|
}
|
}
|
},
|
// 校验是否显示弹出框
|
openPackage() {
|
if (this.config.outer_openPackage) {
|
this.isOpenPackage = true;
|
} else {
|
this.partialSave();
|
}
|
},
|
// 复核提交,封箱(部分打包),然后计算已打包数量,设置 新快递单号为 “可用”
|
partialSave() {
|
if (this.config.outer_openPackage) {
|
if (!this.totalPackage || !this.totalVolume) {
|
this.$message({
|
message: "合计件数、合计体积不能为空!",
|
type: "warning"
|
});
|
return false;
|
}
|
}
|
var expressCode = this.formData.batchCode; // 快递单号
|
var wrapperBarcode = this.formData.wrapperBarcode; // 包材条码
|
var newExpressCode = ""; // 新快递单号
|
var weight = this.formData.weight; // 重量
|
if (!expressCode) {
|
this.$message({
|
showClose: true,
|
message: "快递单号不能为空!",
|
type: "warning"
|
});
|
return;
|
}
|
var dataArray = this.tableData
|
.filter(item => {
|
return item.finishedQuantity > 0;
|
})
|
.map(rowData => {
|
return {
|
caseNumber: rowData.caseNumber,
|
order_Id: rowData.order_Id,
|
orderCode: rowData.orderCode,
|
orderList_Id: rowData.orderList_Id,
|
scanCount: rowData.finishedQuantity,
|
totalWeight: rowData.scanWeight,
|
weight: rowData.weight
|
};
|
});
|
if (!dataArray.length) {
|
this.$message({
|
showClose: true,
|
message: "请先扫描条码!",
|
type: "error"
|
});
|
return;
|
}
|
// 明细理论求和值
|
let theoryweight = 0;
|
// 明细实际求和值
|
let scanWeight = 0;
|
// 得到设置的阈值,阈值大于0进行校验
|
const outer_weightWhreshold = this.config.outer_weightWhreshold;
|
// 对明细已扫描数量求和算出理论值
|
dataArray.forEach(item => {
|
theoryweight += item.scanCount * item.weight;
|
});
|
// 直接扫描重量
|
dataArray.forEach(item => {
|
scanWeight += Math.Round(item.totalWeight, 2);
|
});
|
const absWeight = Math.abs(theoryweight - scanWeight);
|
if (outer_weightWhreshold > 0 && absWeight > outer_weightWhreshold) {
|
this.$message.error("物料实际重量与物料理论重量差值超过设定阈值" + outer_weightWhreshold + ",不允许出库");
|
return;
|
}
|
const url = "/api/outbound/outScan/orderPartialSaveScan";
|
const params = {
|
openNodeApi: true,
|
expressCode: expressCode,
|
wrapperBarcode: wrapperBarcode,
|
newExpressCode: newExpressCode,
|
data: dataArray,
|
weight: weight,
|
totalPackage: this.totalPackage,
|
totalVolume: this.totalVolume
|
};
|
const callBack = res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.onReset();
|
// 自动打印,系统配置中心开启,且勾选打印复选框
|
if (this.config.outer_printBill === true && this.formData.isOuter_PrintBill) {
|
this.$refs.printRef.lodopPrint();
|
}
|
}
|
};
|
this.common.ajax(url, params, callBack, true);
|
},
|
// 重置
|
onReset() {
|
const isValidateProductCode = localStorage["out_isValidateProductCode"];
|
|
this.formData = {
|
order_Id: 0,
|
orderCode: null,
|
batchCode: null,
|
caseNumber: null,
|
productModel: null, // 包装条码
|
scanQty: 0, // 扫描数量
|
weight: 0, // 称重
|
isValidateProductCode: isValidateProductCode === "true", // 是否校验物料
|
isOuter_PrintBill: false,
|
isOuter_Packinglist: false,
|
wrapperBarcode: ""
|
};
|
// 扫描数据
|
this.tableData = [];
|
// 当前正在扫描的数据
|
this.currentRow = {};
|
// 已经找到的数据
|
this.existRows = [];
|
// 一次扫描的数量
|
this.scanCount = 1;
|
// 配置参数
|
this.config = {
|
// 自动生成上架单
|
in_generateShelve: true,
|
// 是否启用装箱操作
|
in_caseNumber: false,
|
// 支持一品多码
|
sku_productToMultiBarcode: true,
|
// 打印面单
|
outer_printBill: true,
|
// 打印装箱清单
|
outer_Packinglist: true,
|
// 称重阈值
|
outer_weightWhreshold: 0,
|
// 是否体积,件数
|
outer_openPackage: 0
|
};
|
// 弹出框
|
this.isOpenPackage = false;
|
this.formLabelWidth = "120px";
|
this.totalPackage = null;
|
this.totalVolume = null;
|
this.$refs.batchCode.focus();
|
},
|
// 勾选装箱清单
|
outerPacking() {
|
localStorage["isOuter_Packinglist"] = this.formData.isOuter_Packinglist;
|
},
|
// 换箱
|
changeBox() {
|
var batchNo = this.formData.batchCode;
|
if (batchNo === null) {
|
this.$message({
|
message: "请先扫描出库单号!",
|
type: "warning"
|
});
|
return;
|
}
|
var currentRow = JSON.stringify(this.currentRow);
|
if (currentRow === "{}") {
|
this.$message({
|
message: "请先扫描物料信息!",
|
type: "warning"
|
});
|
return;
|
}
|
if (this.formData.isOuter_Packinglist) {
|
// 打印装箱单
|
this.printCase();
|
// 重新生成箱号
|
this.generateCaseNumber();
|
} else {
|
this.$message({
|
message: "请勾选打印装箱清单!",
|
type: "warning"
|
});
|
return;
|
}
|
},
|
// 生成箱号
|
generateCaseNumber() {
|
var batchNo = this.formData.batchCode;
|
var max = 1;
|
var num = this.formData.caseNumber;
|
if (num.indexOf("-") >= 0) {
|
var nums = num.split("-");
|
num = nums[nums.length - 1];
|
} else {
|
num = num.substr(num.length - 4);
|
}
|
num = parseInt(num);
|
++num;
|
if (num > max) max = num;
|
max = "00000" + max;
|
max = max.substr(max.length - 2);
|
var caseNumber = batchNo + "-" + max;
|
this.formData.caseNumber = caseNumber;
|
},
|
// 一品一箱
|
addRow_1() {
|
const rowData = this.tableData.find(item => {
|
const exist = this.checkProductModelExist(this.formData.productModel, item);
|
return exist && item.unFinishedQuantity > 0;
|
});
|
if (!rowData) {
|
this.$message.error("没有可扫描的物料条码");
|
this.playError();
|
return;
|
}
|
|
// 箱号存在
|
var existCaseRow = this.tableData.find(item => {
|
return item.caseNumber === this.formData.caseNumber && item.unFinishedQuantity > 0;
|
});
|
if (!existCaseRow) {
|
var newRow = JSON.parse(JSON.stringify(rowData));
|
rowData.unFinishedQuantity = 0;
|
|
const scanQty = this.getScanQty(); // 默认扫描数量为1
|
newRow.finishedQuantity = scanQty;
|
newRow.unFinishedQuantity -= scanQty;
|
newRow.caseNumber = this.formData.caseNumber;
|
this.tableData.splice(0, 0, newRow);
|
this.currentRow = newRow;
|
}
|
this.currentRow.scanWeight = Math.Round(this.currentRow.weight * this.currentRow.finishedQuantity, 2);
|
this.generateCaseNumber();
|
this.play();
|
},
|
// 多品一箱
|
addRow_2() {
|
const rowData = this.tableData.find(item => {
|
const exist = this.checkProductModelExist(this.formData.productModel, item);
|
return exist && item.unFinishedQuantity > 0;
|
});
|
if (!rowData) {
|
this.$message.error("没有可扫描的物料条码");
|
this.playError();
|
return;
|
}
|
|
const scanQty = this.getScanQty(); // 默认扫描数量为1
|
if (rowData.caseNumber === this.formData.caseNumber) {
|
rowData.unFinishedQuantity -= scanQty;
|
rowData.finishedQuantity += scanQty;
|
this.currentRow = rowData;
|
} else {
|
if (!rowData.caseNumber) {
|
rowData.unFinishedQuantity -= scanQty;
|
rowData.finishedQuantity += scanQty;
|
rowData.caseNumber = this.formData.caseNumber;
|
this.currentRow = rowData;
|
} else {
|
var newRow = JSON.parse(JSON.stringify(rowData));
|
rowData.unFinishedQuantity = 0;
|
|
newRow.finishedQuantity = scanQty;
|
newRow.unFinishedQuantity -= scanQty;
|
newRow.caseNumber = this.formData.caseNumber;
|
this.tableData.splice(0, 0, newRow);
|
this.currentRow = newRow;
|
}
|
}
|
this.currentRow.scanWeight = Math.Round(this.currentRow.weight * this.currentRow.finishedQuantity, 2);
|
this.play();
|
|
this.currentRow.sortIndex = 1;
|
// 置顶排序
|
this.tableData.sort(function(a, b) {
|
return b.sortIndex - a.sortIndex;
|
});
|
|
this.tableData.forEach(element => {
|
element.sortIndex = 0;
|
});
|
},
|
// 获得打印模板
|
// 获取运单信息和打印机名称
|
getPrintTemplate() {
|
var url = "/api/sys/printTemplate/getPrintTemplate";
|
var params = {
|
openNodeApi: true,
|
menu_Id: 200013 // 打印模板MenuID
|
};
|
this.common.ajax(
|
url,
|
params,
|
res => {
|
this.common.showMsg(res);
|
if (res.result) {
|
this.printCaseVueData = res.data;
|
}
|
},
|
true
|
);
|
},
|
// 打印装箱单
|
printCase() {
|
// 获取装箱数据
|
const caseDataList = this.tableData.filter(item => {
|
item.rowTotal = item.finishedQuantity * item.salePrice;
|
return item.caseNumber === this.formData.caseNumber;
|
});
|
if (!caseDataList.length) {
|
this.$message.error("没有可打印的数据");
|
return;
|
}
|
// 箱号
|
this.orderInfo.caseNumber = this.formData.caseNumber;
|
const billDataInfo = {
|
mainInfo: this.orderInfo,
|
detailList: {
|
total: caseDataList.length,
|
rows: caseDataList
|
}
|
};
|
var Profile = Vue.extend(PrintCase);
|
var m = new Profile({
|
propsData: {
|
vueData: this.printCaseVueData,
|
billDataInfo: billDataInfo,
|
printInfo: {
|
printerName: this.formData.printerName
|
},
|
billCodeField: "orderCode"
|
}
|
}).$mount();
|
var mountPrint = document.getElementById("mount-print");
|
var firstChild = mountPrint.firstChild;
|
mountPrint.insertBefore(m.$el, firstChild);
|
m.lodopPrint();
|
window.setTimeout(() => {
|
document.getElementById(this.orderInfo.orderCode).remove();
|
}, 2 * 60 * 1000);
|
},
|
// 打印机改变
|
changePrint() {
|
localStorage["printerName"] = this.formData.printerName;
|
},
|
// 获得打印机列表
|
getPrintList() {
|
window.setTimeout(() => {
|
const LODOP = getLodop();
|
var iPrinterCount = LODOP.GET_PRINTER_COUNT();
|
for (var i = 0; i < iPrinterCount; i++) {
|
this.printList.push(LODOP.GET_PRINTER_NAME(i));
|
}
|
// 设置默认打印机
|
const printerName = localStorage["printerName"];
|
if (printerName) {
|
this.formData.printerName = printerName;
|
}
|
}, 1000);
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
@import "../../../styles/scan.scss";
|
</style>
|