Commit 0d491074 by LJM

add

parent 0610131d
Showing with 394 additions and 0 deletions
<template>
<view class="print-index">
<view class="print-form">
<view class="box row verCenter">
<view class="label">打印类型</view>
<view class="tab row verCenter">
<view class="tab-pane row rowCenter verCenter" v-for="(item, index) in items_print_type" :key="index" :class="{ curr: index_print_type == index }" @click="change(index, 'print_type')">{{ item }}</view>
</view>
</view>
<view class="box row verCenter">
<view class="row verCenter" style="flex:0 0 93%">
<view class="label">入仓号</view>
<input type="text" v-model="form.erp_order_sn" placeholder-style="font-size:24rpx;color:#404547;" @input="handleInput($event)" class="uni-input" placeholder="请输入入仓号" />
</view>
<text class="scan iconfont icon-juxing6" @click="scanChange()"></text>
</view>
<view class="box row verCenter">
<view class="label">{{ text }}</view>
<input type="number" v-model="form.label_num" placeholder-style="font-size:24rpx;color:#404547;" class="uni-input" placeholder="请输入" />
</view>
<view class="box row verCenter">
<view class="label">批次</view>
<view class="pick-box row">
<picker @change="bindPickerChangeBatch" :value="form.batch" :range="batchArr" class="picker">
<view class="uni-input">{{ batchArr[form.batch] }}</view>
</picker>
</view>
</view>
<view class="box row verCenter" v-if="index_print_type == 0">
<view class="label">卡板数</view>
<view class="pick-box row">
<picker @change="bindPickerChange" :value="numberIndex" :range="numberArr" class="picker">
<view class="uni-input">{{ numberArr[numberIndex] }}</view>
</picker>
</view>
</view>
<view class="box row verCenter" v-for="(item, index) in numberList" :key="index" v-if="flag && index_print_type == 0">
<view class="label">{{ index + 1 }}卡板数量</view>
<input type="number" placeholder-style="font-size:24rpx;color:#404547;" class="uni-input" placeholder="请输入数量" @input="onInput($event, index)" />
</view>
</view>
<view class="btn row rowCenter verCenter" @click="submit()">提交打印</view>
</view>
</template>
<script>
import { API } from '@/util/api.js';
import { getPlatform, findIndexOrZero } from '@/util/util.js';
import debounce from 'lodash/debounce';
export default {
data() {
return {
print_number: 0,
serviceId: '',
deviceId: '',
device_name: '',
characteristics: '',
text: '标签数量',
index: -1,
index_erp_order_sn_pre: -1,
index_print_type: 1,
items_erp_order_sn_pre: ['A单号', 'B单号', 'D单号'],
items_print_type: ['卡板', '散箱'],
traySelectOption: [],
sendData64: '',
printLabelData: [],
print_text: '总箱数',
platform: '',
wstyptll_id: '',
batchArr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
flag: false,
numberList: [],
numberArr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
numberIndex: 0,
from: '', //标记成哪个页面来的
form: {
batch: 0, //批次
print_type: 2, //打印类型
erp_order_sn: '', //入仓号
label_num: '1', //总箱数
number: 1,
numbers: []
},
printParams: {
board_num: '', //板子数
box_num: '', //箱子数
erp_order_sn: '' //入仓号
}
};
},
onLoad(option) {
this.platform = getPlatform();
this.printParams.board_num = Number(option.board_num) || ''; //箱
this.printParams.box_num = Number(option.box_num) || ''; //板子
this.printParams.erp_order_sn = option.erp_order_sn || ''; //入仓号
this.from = option.from; //标记从哪个页面来
//从理货确认页面过来的
if (this.from == 'tallyGoods') {
//一直保持连接
this.form.erp_order_sn = this.printParams.erp_order_sn; //赋值入仓号
//检查是否存在 "-"
if (this.form.erp_order_sn.includes('-')) {
//分割字符串
var parts = this.form.erp_order_sn.split('-');
var firstPart = parts[0];
var secondPart = parts[1];
this.form.erp_order_sn = firstPart; //赋值切割后的入仓号
this.form.batch = findIndexOrZero(this.numberArr, Number(secondPart)); //匹配批次号就选中,否则就是默认0
}
}
//如果【理货确认-板/箱 均不为0】,则【打印标签】打印类型只继承入仓号,打印类型默认为【散箱】标签数量1 批次为0(保持原默认值)
if (this.printParams.box_num && this.printParams.board_num) {
this.index_print_type = 0;
this.form.label_num = this.printParams.box_num;
this.numberIndex = findIndexOrZero(this.numberArr, Number(this.printParams.board_num)); //匹配到卡板数就选中,否则就是默认0
return false;
}
//如果【理货确认-箱】有数值,则【打印标签】打印类型为【散箱】并继承数据【标签数量】
if (this.printParams.box_num) {
this.index_print_type = 1;
this.form.label_num = this.printParams.box_num;
}
//如果【理货确认-板】有数值,则【打印标签】打印类型为【卡板】并继承卡板数
if (this.printParams.board_num) {
this.index_print_type = 0;
this.numberIndex = findIndexOrZero(this.numberArr, Number(this.printParams.board_num)); //匹配到卡板数就选中,否则就是默认0
}
},
methods: {
handleInput: debounce(function(event) {
var val = event.target.value;
if (val) {
//检查是否存在 "-"
if (this.form.erp_order_sn.includes('-')) {
//分割字符串
var parts = this.form.erp_order_sn.split('-');
var firstPart = parts[0];
var secondPart = parts[1];
this.form.erp_order_sn = firstPart; //赋值切割后的入仓号
this.form.batch = findIndexOrZero(this.numberArr, Number(secondPart)); //匹配批次号就选中,否则就是默认0
}
}
}, 800),
/**
* 打印类型切换
* @param {Object} index
* @param {Object} type
*/
change(index, type) {
if (type == 'print_type') {
//打印类型
this.index_print_type = index;
if (index == 0) {
this.form.print_type = 1;
this.text = '总箱数';
this.print_text = '总箱数';
this.numberIndex = 0;
} else if (index == 1) {
this.form.print_type = 2;
this.text = '标签数量';
this.print_text = '箱号';
//置空卡板
this.flag = false;
this.form.number = '';
this.form.numbers = [];
}
}
},
/**
* 入仓号扫描
*/
scanChange() {
uni.scanCode({
success: res => {
if (res.errMsg == 'scanCode:ok') {
this.form.erp_order_sn = res.result;
//检查是否存在 "-"
if (this.form.erp_order_sn.includes('-')) {
//分割字符串
var parts = this.form.erp_order_sn.split('-');
var firstPart = parts[0];
var secondPart = parts[1];
this.form.erp_order_sn = firstPart; //赋值切割后的入仓号
this.form.batch = findIndexOrZero(this.numberArr, Number(secondPart)); //匹配批次号就选中,否则就是默认0
}
}
},
fail: function(res) {
uni.showToast({
title: '扫码失败',
icon: 'error'
});
}
});
},
/**
* 卡板数监听
*/
bindPickerChange(e) {
this.numberIndex = Number(e.detail.value);
this.form.number = Number(e.target.value) + 1;
if (this.form.number > 1) {
this.flag = true;
this.numberList = [];
this.form.numbers = [];
for (var i = 0; i < this.form.number; i++) {
if (i < this.form.number - 1) {
this.numberList.push(i);
this.form.numbers.push({
value: ''
});
}
}
} else {
this.flag = false;
this.numberList = [];
this.form.numbers = [];
}
},
/**
* 批次监听
*/
bindPickerChangeBatch(e) {
this.form.batch = e.target.value;
},
/**
* 卡板数量list监听
*/
onInput(e, index) {
this.form.numbers[index].value = e.detail.value;
},
/**
* 提交打印
*/
submit() {
if (!this.form.erp_order_sn) {
uni.showModal({
title: '提示',
content: '请输入入仓号',
showCancel: false
});
return false;
}
// 判断入仓号是否包含字符"-"
if (this.form.erp_order_sn.includes('-')) {
// 含有非法字符,提示用户
uni.showToast({
title: '入仓号包含非法字符 "-" ',
icon: 'none'
});
return false;
}
// 判断第一个字符是否为大写字母
var firstChar = this.form.erp_order_sn.charAt(0);
if (!/[A-Z]/.test(firstChar)) {
uni.showToast({
title: '入仓号第一个字符必须是大写字母',
icon: 'none'
});
return false;
}
if (!this.form.label_num) {
uni.showModal({
title: '提示',
content: '请输入' + this.text,
showCancel: false
});
return false;
}
if (!/(^[0-9]*$)/.test(this.form.label_num)) {
uni.showModal({
title: '提示',
content: this.text + '为纯数字',
showCancel: false
});
return false;
}
if (this.index_print_type == 0 && this.form.number > 1) {
let label_num = this.form.label_num * 1; //总箱数
let num = 0;
if (this.form.numbers.length > 0) {
for (let i = 0; i < this.form.numbers.length; i++) {
num += this.form.numbers[i].value * 1;
}
}
if (label_num != num) {
uni.showModal({
title: '提示',
content: '卡板数量总和必须等于总箱数',
showCancel: false
});
return false;
}
}
let params = Object.assign(this.form, {
is_add: 0
});
this.request(API.checkRepeatPrintLabel, 'POST', params, true).then(res => {
if (res.err_code === 0) {
this.printLabelChange();
} else {
uni.showModal({
title: '提示',
content: res.err_msg,
confirmText: '继续打印',
success: res => {
if (res.confirm) {
this.printLabelChange();
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
});
},
/**
* 打印标签
*/
printLabelChange() {
this.request(API.printLabel, 'POST', this.form, true).then(res => {
if (res.err_code === 0) {
this.printLabelData = res.data;
this.wstyptll_id = res.data[0].wstyptll_id;
if (res.data.length > 0) {
this.addSupplyChainData(JSON.stringify(res.data));
}
} else {
uni.showModal({
title: '提示',
content: res.err_msg,
confirmText: '关闭'
});
}
});
},
/**
* 调取蓝牙wifi打印
*/
addSupplyChainData(params) {
this.request(API.addSupplyChainData, 'POST', { print_json: params }, true).then(res => {
if (res.code === 0) {
uni.showToast({
title: '正在打印中',
icon: 'success'
});
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
});
},
/**
* 打印失败的时候作废
*/
delErpOrderSnCodeManage() {
this.request(API.delWstyptllIdErpOrderSnCodeManage, 'POST', { wstyptll_id: this.wstyptll_id }, false).then(res => {
if (res.err_code === 0) {} else {
uni.showModal({
title: '提示',
content: res.err_msg,
showCancel: false,
confirmText: '关闭'
});
}
});
}
}
};
</script>
<style scoped lang="scss">
@import '../../assets/css/tag/print.scss';
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment