Commit 38469bf3 by LJM

分货登记--配合清关功能优化

parent 801a086a
Showing with 158 additions and 3 deletions
......@@ -133,7 +133,7 @@
<text class="label-title">物流单号:</text>
</view>
<view class="input-box">
<input type="text" class="uni-input" placeholder-style="color:#919399" placeholder="请输入物流单号" v-model="formParams.logistics_sn" @input="handleInput(4, $event)" />
<textarea class="uni-textarea" placeholder-style="color:#919399" placeholder="请输入物流单号" v-model="logistics_sn" @input="handleInputTextArea($event)" />
</view>
</view>
<view class="input-wrap column" style="margin-top: 20rpx;">
......@@ -245,6 +245,8 @@
image_list: [], //图片列表
maxNum: 10, //最大上传图片数量
curr: 0,
logistics_sn: '',
logistics_sn_temp_flag: false, //临时存储
formParams: {
warehouse_id: '',
register_time: this.getCurrentDateTime(),
......@@ -394,6 +396,7 @@
this.searchParams.goods_name = '';
this.resetChange();
if (val) {
this.logistics_sn_temp_flag = false;
if (type == 1) {
//全量搜索
this.searchParams.shipment_number = val;
......@@ -405,6 +408,7 @@
this.input_flag = true;
this.getData();
} else if (type == 3) {
this.logistics_sn_temp_flag = true;
//FedEx
if (val.length > 22) {
let last22 = val.slice(22); // 截取后22位
......@@ -426,11 +430,66 @@
}
}
} else {
this.logistics_sn_temp_flag = false;
this.input_flag = false;
this.getData();
}
}, 500),
/**
* 处理物流单号 批量输入
* @param {Object} event
*/
handleInputTextArea: debounce(function(event) {
var value = event.target.value;
if (value) {
// 将输入按换行符分割并过滤空行
var lines = value.split('\n').filter(Boolean);
if (lines.length > 1) {
this.logistics_sn_temp_flag = false;
}
const first = lines[0].toUpperCase(); // 转换为大写以便不区分大小写比较
if (first.startsWith('SF')) {
// A、物流单号为"SF"开头(不区分大小写),则自动选择物流公司为"顺丰速运"
this.logistics_company_index = this.logistics_company.findIndex(company => company === '顺丰速运');
this.formParams.logistics_company = '顺丰速运';
}
if (first.startsWith('1Z')) {
// B、物流单号为"1Z"开头(不区分大小写),则自动选择物流公司为"UPS"
this.logistics_company_index = this.logistics_company.findIndex(company => company === 'UPS');
this.formParams.logistics_company = 'UPS';
}
// 处理联邦快递的情况
if (this.formParams.logistics_company == '联邦快递') {
if (!this.logistics_sn_temp_flag) {
// 对显示用的logistics_sn进行处理
this.logistics_sn = lines.map(line => line.length > 22 ? line.slice(22) : line).join('\n') + '\n';
// 对后台用的formParams.logistics_sn进行处理
this.formParams.logistics_sn = lines.map(line => line.length > 22 ? line.slice(22) : line).join(',');
} else {
this.logistics_sn = lines.join('\n');
this.formParams.logistics_sn = lines.join(',');
}
} else {
// 非联邦快递的情况,保持原样 数据给后台
this.logistics_sn = lines.join('\n') + '\n';
this.formParams.logistics_sn = lines.join(',');
}
// 统计非空行数
this.formParams.num = lines.length;
} else {
//暂时不处理
this.logistics_sn_temp_flag = false;
}
}, 1000),
/**
* 货品查询特殊处理 自动查询时间改为1S响应
* @param {Object} type
* @param {Object} event
......@@ -594,15 +653,57 @@
this.formParams.logistics_company = ''; //物流公司
this.logistics_company_index = -1;
this.formParams.logistics_sn = ''; //物流单号
this.formParams.num = ''; //件数
this.formParams.num = '1'; //件数 默认值1
this.formParams.other_info = ''; //其他信息
this.formParams.register_pic = ''; //登记照片
//匹配物流公司和物流单号规则
this.ruleChange();
},
/**
* 匹配规则
*/
ruleChange() {
//选择了其他物流,货品名称按钮
if (this.index == 0 || this.index == 1) {
var shipment_number = ''; //物流单号
if (this.index == 0) {
//其他物流
var upperShipmentNumber = this.searchParams.shipment_number.toUpperCase(); // 转换为大写以便不区分大小写比较
shipment_number = this.searchParams.shipment_number;
}
if (this.index == 1) {
//货品名称
var upperShipmentNumber = this.searchParams.goods_name.toUpperCase(); // 转换为大写以便不区分大小写比较
shipment_number = this.searchParams.goods_name;
}
if (upperShipmentNumber.startsWith('SF')) {
// A、物流单号为"SF"开头(不区分大小写),则自动选择物流公司为"顺丰速运"
this.logistics_company_index = this.logistics_company.findIndex(company => company === '顺丰速运');
this.formParams.logistics_company = '顺丰速运';
this.logistics_sn = shipment_number;
} else if (upperShipmentNumber.startsWith('1Z')) {
// B、物流单号为"1Z"开头(不区分大小写),则自动选择物流公司为"UPS"
this.logistics_company_index = this.logistics_company.findIndex(company => company === 'UPS');
this.formParams.logistics_company = 'UPS';
this.logistics_sn = shipment_number;
} else {
//如果未识别到,则不更新物流公司 物流单号也清空
this.logistics_sn = shipment_number;
}
} else if (this.index == 2) {
//选择了fedex弹窗则自动选中联邦快递
this.logistics_company_index = this.logistics_company.findIndex(company => company === '联邦快递');;
this.formParams.logistics_company = '联邦快递';
this.logistics_sn = this.searchParams.shipment_number; //注意这里是搜索的fedex 已经截取了的数据
}
},
/**
* 确认登记
*/
addSeparateStockInRegister() {
if (!this.formParams.logistics_company) {
uni.showToast({
title: '请选择物流公司',
......@@ -618,6 +719,60 @@
});
return false;
}
//A、当物流公司为“顺丰速运”时,校验本次登记的所有物流单号,是否为“SF”开头,是则正常登记成功,否则提示:您选择的是顺丰速运,但是物流单号存在非“SF”开头的物流单号,请检查
if (this.formParams.logistics_company == '顺丰速运') {
// 将数组中的每个元素转为大写
var logistics_sn = this.formParams.logistics_sn.split(',').map(sn => sn.toUpperCase());
// 检查是否所有元素都以"SF"开头
var allStartWithSF = logistics_sn.every(sn => sn.startsWith('SF'));
// 返回提示信息
if (!allStartWithSF) {
uni.showModal({
content: '您选择的是顺丰速运,但是物流单号存在非“SF”开头的物流单号,请检查',
showCancel: false,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
return false;
}
}
//B、当物流公司为“UPS”时,校验本次登记的所有物流单号,是否为“1Z”开头,是则正常登记成功,否则提示:您选择的是UPS,但是物流单号存在非“1Z”开头的物流单号,请检查
if (this.formParams.logistics_company == 'UPS') {
// 将数组中的每个元素转为大写
var logistics_sn = this.formParams.logistics_sn.split(',').map(sn => sn.toUpperCase());
// 检查是否所有元素都以"1Z"开头
var allStartWithUPS = logistics_sn.every(sn => sn.startsWith('1Z'));
// 返回提示信息
if (!allStartWithUPS) {
uni.showModal({
content: '您选择的是UPS,但是物流单号存在非“1Z”开头的物流单号,请检查',
showCancel: false,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
return false;
}
}
}
if (!this.formParams.num) {
uni.showToast({
......
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