Commit f6aeb97e by liangjianmin

feat(logistics): 优化订单号输入事件以获取客户名称

根据输入的订单号请求客户名称,添加防抖处理,避免频繁请求。
如果订单号为空,则清空客户名称。请求失败时显示提示信息。
parent e3b7f6c3
Showing with 24 additions and 9 deletions
......@@ -66,6 +66,9 @@
</template>
<script>
import { API } from '@/util/api.js';
import debounce from 'lodash/debounce';
export default {
data() {
return {
......@@ -90,11 +93,7 @@
{ name: '货拉拉', value: 'huolala' },
{ name: '公司车辆', value: 'company' },
{ name: '其它', value: 'other' }
],
orderCustomerMap: {
SO20260529001: '广州宜春供应链有限公司',
SO20260529002: '深圳华南电子商务有限公司'
}
]
};
},
methods: {
......@@ -139,13 +138,29 @@
},
/**
* 根据写死订单号展示客户名称
* 订单号输入事件,防抖获取客户名称
* @return {void}
*/
handleOrderNoInput() {
handleOrderNoInput: debounce(function() {
var orderSn = this.form.order_sn.trim();
this.form.customer_name = this.orderCustomerMap[orderSn] || '';
},
if (!orderSn) {
this.form.customer_name = '';
return;
}
this.request(API.getCustomerName, 'GET', { order_sn: orderSn }, true).then(res => {
if (res.code === 0) {
this.form.customer_name = res.data;
} else {
this.form.customer_name = '';
uni.showToast({
title: res.msg || '获取客户名称失败',
icon: 'none'
});
}
});
}, 500),
/**
* 展示省市暂未接入提示
......
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