Commit 764012aa by LJM

add

parent 61238b1c
Showing with 71 additions and 44 deletions
...@@ -468,13 +468,19 @@ ...@@ -468,13 +468,19 @@
// A、物流单号为"SF"开头(不区分大小写),则自动选择物流公司为"顺丰速运" // A、物流单号为"SF"开头(不区分大小写),则自动选择物流公司为"顺丰速运"
this.logistics_company_index = this.logistics_company.findIndex(company => company === '顺丰速运'); this.logistics_company_index = this.logistics_company.findIndex(company => company === '顺丰速运');
this.formParams.logistics_company = '顺丰速运'; this.formParams.logistics_company = '顺丰速运';
} } else if (first.startsWith('1Z')) {
if (first.startsWith('1Z')) {
// B、物流单号为"1Z"开头(不区分大小写),则自动选择物流公司为"UPS" // B、物流单号为"1Z"开头(不区分大小写),则自动选择物流公司为"UPS"
this.logistics_company_index = this.logistics_company.findIndex(company => company === 'UPS'); this.logistics_company_index = this.logistics_company.findIndex(company => company === 'UPS');
this.formParams.logistics_company = 'UPS'; this.formParams.logistics_company = 'UPS';
} else if (/^\d{10}$/.test(first)) {
// C、物流单号为数字开头且位数为10位,则自动选择物流公司为"DHL国际快递"
this.logistics_company_index = this.logistics_company.findIndex(company => company === 'DHL国际快递');
this.formParams.logistics_company = 'DHL国际快递';
} else if (/^\d{12}$/.test(first)) {
this.logistics_company_index = this.logistics_company.findIndex(company => company === '联邦快递');
this.formParams.logistics_company = '联邦快递';
} }
// 处理联邦快递的情况 // 处理联邦快递的情况
if (this.formParams.logistics_company == '联邦快递') { if (this.formParams.logistics_company == '联邦快递') {
if (!this.logistics_sn_temp_flag) { if (!this.logistics_sn_temp_flag) {
...@@ -681,7 +687,6 @@ ...@@ -681,7 +687,6 @@
*/ */
ruleChange() { ruleChange() {
let shipping_name_match = this.list.length > 0 ? this.list[0].shipping_name : ''; let shipping_name_match = this.list.length > 0 ? this.list[0].shipping_name : '';
//选择了其他物流,货品名称按钮 //选择了其他物流,货品名称按钮
if (this.index == 0 || this.index == 1) { if (this.index == 0 || this.index == 1) {
var shipment_number = ''; //物流单号 var shipment_number = ''; //物流单号
...@@ -720,19 +725,44 @@ ...@@ -720,19 +725,44 @@
// 物流单号不论是否匹配都需要更新 // 物流单号不论是否匹配都需要更新
this.formParams.logistics_sn = shipment_number; this.formParams.logistics_sn = shipment_number;
this.logistics_sn = shipment_number + '\n'; this.logistics_sn = shipment_number + '\n';
this.verifyAgain(shipment_number);
} else if (this.index == 2) { } else if (this.index == 2) {
//选择了fedex弹窗则自动选中联邦快递 //选择了fedex弹窗则自动选中联邦快递
this.logistics_company_index = this.logistics_company.findIndex(company => company === '联邦快递');; this.logistics_company_index = this.logistics_company.findIndex(company => company === '联邦快递');;
this.formParams.logistics_company = '联邦快递'; this.formParams.logistics_company = '联邦快递';
this.formParams.logistics_sn = this.searchParams.shipment_number; //赋值表单里的值 this.formParams.logistics_sn = this.searchParams.shipment_number; //赋值表单里的值
this.logistics_sn = this.searchParams.shipment_number + '\n'; //注意这里是搜索的fedex 已经截取了的数据 this.logistics_sn = this.searchParams.shipment_number + '\n'; //注意这里是搜索的fedex 已经截取了的数据
this.verifyAgain(this.searchParams.shipment_number);
}
},
/**
* 再次验证
*/
verifyAgain(first) {
var lowerFirst = first.toLowerCase();
if (lowerFirst.startsWith('sf')) {
// A、物流单号为"SF"开头(不区分大小写),则自动选择物流公司为"顺丰速运"
this.logistics_company_index = this.logistics_company.findIndex(company => company === '顺丰速运');
this.formParams.logistics_company = '顺丰速运';
} else if (lowerFirst.startsWith('1z')) {
// B、物流单号为"1Z"开头(不区分大小写),则自动选择物流公司为"UPS"
this.logistics_company_index = this.logistics_company.findIndex(company => company === 'UPS');
this.formParams.logistics_company = 'UPS';
} else if (/^\d{10}$/.test(first)) {
// C、物流单号为数字开头且位数为10位,则自动选择物流公司为"DHL国际快递"
this.logistics_company_index = this.logistics_company.findIndex(company => company === 'DHL国际快递');
this.formParams.logistics_company = 'DHL国际快递';
} else if (/^\d{12}$/.test(first)) {
this.logistics_company_index = this.logistics_company.findIndex(company => company === '联邦快递');
this.formParams.logistics_company = '联邦快递';
} }
}, },
/** /**
* 确认登记 * 确认登记
*/ */
addSeparateStockInRegister() { addSeparateStockInRegister() {
const { logistics_company, logistics_sn } = this.formParams;
if (!this.formParams.logistics_company) { if (!this.formParams.logistics_company) {
uni.showToast({ uni.showToast({
title: '请选择物流公司', title: '请选择物流公司',
...@@ -740,7 +770,7 @@ ...@@ -740,7 +770,7 @@
}); });
return false; return false;
} }
if (this.formParams.logistics_company !== '自提' && this.formParams.logistics_company !== '供应商配送') { if (!['自提', '供应商配送'].includes(this.formParams.logistics_company)) {
if (!this.formParams.logistics_sn) { if (!this.formParams.logistics_sn) {
uni.showToast({ uni.showToast({
title: '请输入物流单号', title: '请输入物流单号',
...@@ -748,60 +778,57 @@ ...@@ -748,60 +778,57 @@
}); });
return false; return false;
} }
if (logistics_sn) {
//A、当物流公司为“顺丰速运”时,校验本次登记的所有物流单号,是否为“SF”开头,是则正常登记成功,否则提示:您选择的是顺丰速运,但是物流单号存在非“SF”开头的物流单号,请检查 const logistics_sn_arr = logistics_sn.split(',').map(sn => sn.trim().toUpperCase()); //物流单号转数组
if (this.formParams.logistics_company == '顺丰速运') { // 校验逻辑
let isValid = true;
// 将数组中的每个元素转为大写 let companyText = '';
var logistics_sn = this.formParams.logistics_sn.split(',').map(sn => sn.toUpperCase());
// 校验“顺丰速运”
// 检查是否所有元素都以"SF"开头 if (logistics_company === '顺丰速运') {
var allStartWithSF = logistics_sn.every(sn => sn.startsWith('SF')); if (!logistics_sn_arr.every(sn => sn.toLowerCase().startsWith('sf'))) {
isValid = false;
// 返回提示信息 companyText = '物流公司为“顺丰速运”时,填写的物流单号需全部为“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;
} }
}
// 校验“UPS”
if (logistics_company === 'UPS') {
if (!logistics_sn_arr.every(sn => sn.toLowerCase().startsWith('1z'))) {
isValid = false;
companyText = '物流公司为“UPS”时,填写的物流单号需全部为“1Z”开头';
}
}
//B、当物流公司为“UPS”时,校验本次登记的所有物流单号,是否为“1Z”开头,是则正常登记成功,否则提示:您选择的是UPS,但是物流单号存在非“1Z”开头的物流单号,请检查 // 校验“联邦快递”
if (this.formParams.logistics_company == 'UPS') { if (logistics_company === '联邦快递') {
// 将数组中的每个元素转为大写 if (!logistics_sn_arr.every(sn => /^\d{12}$/.test(sn))) {
var logistics_sn = this.formParams.logistics_sn.split(',').map(sn => sn.toUpperCase()); isValid = false;
companyText = '物流公司为“联邦快递”时,填写的物流单号需全部为数字开头且12位';
}
}
// 检查是否所有元素都以"1Z"开头 // 校验“DHL国际快递”
var allStartWithUPS = logistics_sn.every(sn => sn.startsWith('1Z')); if (logistics_company === 'DHL国际快递') {
if (!logistics_sn_arr.every(sn => /^\d{10}$/.test(sn))) {
isValid = false;
companyText = '物流公司为“DHL国际快递”时,填写的物流单号需全部为数字开头且10位';
}
}
// 返回提示信息 if (!isValid) {
if (!allStartWithUPS) {
uni.showModal({ uni.showModal({
content: '您选择的是UPS,但是物流单号存在非“1Z”开头的物流单号,请检查', content: `${companyText}`,
showCancel: false, showCancel: false,
success: function(res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
console.log('用户点击确定'); console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
} }
} }
}); });
return false; return false;
} }
} }
} }
if (!this.formParams.num) { if (!this.formParams.num) {
uni.showToast({ 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