|
@@ -370,7 +370,22 @@ if ($customerId > 0) {
|
|
|
|
|
|
// 客户搜索功能
|
|
|
var customerSearchTimeout = null;
|
|
|
- $(document).on('keyup', '.customer-search', function() {
|
|
|
+ var customerIsComposing = false;
|
|
|
+
|
|
|
+ // 监听输入法组合事件
|
|
|
+ $(document).on('compositionstart', '.customer-search', function() {
|
|
|
+ customerIsComposing = true;
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('compositionend', '.customer-search', function() {
|
|
|
+ customerIsComposing = false;
|
|
|
+ $(this).trigger('input'); // 手动触发一次input事件
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('input', '.customer-search', function() {
|
|
|
+ // 如果是输入法正在组合中文,不处理
|
|
|
+ if (customerIsComposing) return;
|
|
|
+
|
|
|
var $this = $(this);
|
|
|
var searchTerm = $this.val().trim();
|
|
|
var customerList = $('.customerlist');
|
|
@@ -382,7 +397,7 @@ if ($customerId > 0) {
|
|
|
customerList.hide();
|
|
|
|
|
|
// 如果搜索词少于2个字符,不执行搜索
|
|
|
- if (searchTerm.length < 2) {
|
|
|
+ if (searchTerm.length < 1) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -448,7 +463,22 @@ if ($customerId > 0) {
|
|
|
|
|
|
// 产品搜索功能 - 行内搜索
|
|
|
var productSearchTimeouts = {};
|
|
|
- $(document).on('keyup', '.product-search', function() {
|
|
|
+ var isComposing = false;
|
|
|
+
|
|
|
+ // 监听输入法组合事件
|
|
|
+ $(document).on('compositionstart', '.product-search', function() {
|
|
|
+ isComposing = true;
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('compositionend', '.product-search', function() {
|
|
|
+ isComposing = false;
|
|
|
+ $(this).trigger('input'); // 手动触发一次input事件
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('input', '.product-search', function() {
|
|
|
+ // 如果是输入法正在组合中文,不处理
|
|
|
+ if (isComposing) return;
|
|
|
+
|
|
|
var $this = $(this);
|
|
|
var rowIndex = $this.closest('.product-row').data('index');
|
|
|
var searchTerm = $this.val().trim();
|
|
@@ -461,9 +491,11 @@ if ($customerId > 0) {
|
|
|
productList.hide();
|
|
|
|
|
|
// 如果搜索词少于2个字符,不执行搜索
|
|
|
- if (searchTerm.length < 2) {
|
|
|
+ if (searchTerm.length < 1) {
|
|
|
return;
|
|
|
}
|
|
|
+ console.warn(searchTerm);
|
|
|
+
|
|
|
|
|
|
// 设置一个300毫秒的超时,以减少请求数量
|
|
|
productSearchTimeouts[rowIndex] = setTimeout(function() {
|