|
@ -72,18 +72,19 @@ |
|
|
<!-- <input id="salesOrderCode" name="salesOrderCode" class="form-control" type="text">--> |
|
|
<!-- <input id="salesOrderCode" name="salesOrderCode" class="form-control" type="text">--> |
|
|
<!-- </div>--> |
|
|
<!-- </div>--> |
|
|
<!-- </div>--> |
|
|
<!-- </div>--> |
|
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label class="col-sm-3 control-label is-required">客户ID:</label> |
|
|
<label class="col-sm-3 control-label">客户名称:</label> |
|
|
<div class="col-sm-8"> |
|
|
<div class="col-sm-8"> |
|
|
<select id="enterpriseCode" name="enterpriseCode" class="form-control m-b" required> |
|
|
<select id="enterpriseName" name="enterpriseName" class="form-control m-b" required> |
|
|
<option value="">请选择</option> |
|
|
<option value="">请选择</option> |
|
|
</select> |
|
|
</select> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label class="col-sm-3 control-label">客户名称:</label> |
|
|
<label class="col-sm-3 control-label is-required">客户ID:</label> |
|
|
<div class="col-sm-8"> |
|
|
<div class="col-sm-8"> |
|
|
<input id="enterpriseName" name="enterpriseName" class="form-control" type="text" readonly> |
|
|
<input id="enterpriseCode" name="enterpriseCode" class="form-control" type="text" readonly> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
@ -586,7 +587,7 @@ |
|
|
// minimumInputLength: 1 |
|
|
// minimumInputLength: 1 |
|
|
// } |
|
|
// } |
|
|
// }); |
|
|
// }); |
|
|
$("select[name='enterpriseCode']").select2({ |
|
|
$("select[name='enterpriseName']").select2({ |
|
|
theme: "bootstrap", |
|
|
theme: "bootstrap", |
|
|
allowClear: true, |
|
|
allowClear: true, |
|
|
placeholder: "请选择客户", |
|
|
placeholder: "请选择客户", |
|
@ -605,8 +606,8 @@ |
|
|
// console.log(customerList); |
|
|
// console.log(customerList); |
|
|
for(var i= 0, len=resultList.length;i<len;i++){ |
|
|
for(var i= 0, len=resultList.length;i<len;i++){ |
|
|
var option = resultList[i]; |
|
|
var option = resultList[i]; |
|
|
option.id = resultList[i]["enterpriseCode"]; |
|
|
option.id = resultList[i]["enterpriseName"]; |
|
|
option.text = resultList[i]["enterpriseCode"]; |
|
|
option.text = resultList[i]["enterpriseName"]; |
|
|
options.push(option); |
|
|
options.push(option); |
|
|
} |
|
|
} |
|
|
return { |
|
|
return { |
|
@ -624,32 +625,32 @@ |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
$('#enterpriseName').on('input', function () { |
|
|
$('#enterpriseCode').on('input', function () { |
|
|
var enterpriseName = $(this).val().trim(); |
|
|
var enterpriseName = $(this).val().trim(); |
|
|
// 触发一次搜索以确保选项被加载 |
|
|
// 触发一次搜索以确保选项被加载 |
|
|
$("select[name='enterpriseCode']").val('').trigger('change'); // 清空下拉框 |
|
|
$("select[name='enterpriseName']").val('').trigger('change'); // 清空下拉框 |
|
|
$("select[name='enterpriseCode']").val('').trigger('input'); // 触发输入事件,以重新加载下拉框 |
|
|
$("select[name='enterpriseName']").val('').trigger('input'); // 触发输入事件,以重新加载下拉框 |
|
|
// 查找匹配的客户编号 |
|
|
// 查找匹配的客户编号 |
|
|
var matchingCustomer = customerList.find(function (customer) { |
|
|
var matchingCustomer = customerList.find(function (customer) { |
|
|
return customer.enterpriseName === enterpriseName; |
|
|
return customer.enterpriseCode === enterpriseCode; |
|
|
}); |
|
|
}); |
|
|
// console.log(customerList); |
|
|
// console.log(customerList); |
|
|
console.log(matchingCustomer); |
|
|
console.log(matchingCustomer); |
|
|
if (matchingCustomer) { |
|
|
if (matchingCustomer) { |
|
|
// 确保值已经存在于下拉框中 |
|
|
// 确保值已经存在于下拉框中 |
|
|
var enterpriseCode = matchingCustomer.enterpriseCode; |
|
|
var enterpriseName = matchingCustomer.enterpriseName; |
|
|
|
|
|
|
|
|
console.log("下拉框的所有选项:"); |
|
|
console.log("下拉框的所有选项:"); |
|
|
var allOptions = $("select[name='enterpriseCode']").select2('data'); |
|
|
var allOptions = $("select[name='enterpriseName']").select2('data'); |
|
|
allOptions.forEach(function(option) { |
|
|
allOptions.forEach(function(option) { |
|
|
console.log("选项值:", option.id, "选项文本:", option.text); |
|
|
console.log("选项值:", option.id, "选项文本:", option.text); |
|
|
}); |
|
|
}); |
|
|
// 检查下拉框是否包含该值 |
|
|
// 检查下拉框是否包含该值 |
|
|
if ($("select[name='enterpriseCode']").find("option[value='" + enterpriseCode + "']").length > 0) { |
|
|
if ($("select[name='enterpriseName']").find("option[value='" + enterpriseName + "']").length > 0) { |
|
|
// 设置下拉框的值 |
|
|
// 设置下拉框的值 |
|
|
$("select[name='enterpriseCode']").val(enterpriseCode).trigger('change'); |
|
|
$("select[name='enterpriseName']").val(enterpriseName).trigger('change'); |
|
|
} else { |
|
|
} else { |
|
|
console.error("尝试设置的值不存在于下拉框中:", enterpriseCode); |
|
|
console.error("尝试设置的值不存在于下拉框中:", enterpriseName); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
// 清空下拉框的值 |
|
|
// 清空下拉框的值 |
|
@ -789,16 +790,16 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#enterpriseCode').on('select2:select', function (e) { |
|
|
$('#enterpriseName').on('select2:select', function (e) { |
|
|
var data = e.params.data; |
|
|
var data = e.params.data; |
|
|
$("input[name='enterpriseName']").val(data.enterpriseName); |
|
|
$("input[name='enterpriseCode']").val(data.enterpriseCode); |
|
|
$("input[name='customerPurser']").val(data.customerPurser); |
|
|
$("input[name='customerPurser']").val(data.customerPurser); |
|
|
$("select[name='customerContact']").select2({ |
|
|
$("select[name='customerContact']").select2({ |
|
|
theme: "bootstrap", |
|
|
theme: "bootstrap", |
|
|
allowClear: true, |
|
|
allowClear: true, |
|
|
ajax:{ |
|
|
ajax:{ |
|
|
type: "post", |
|
|
type: "post", |
|
|
url:ctx + "system/customer/contactsList", |
|
|
url:ctx + "system/customer/contactsList2", |
|
|
dataType:"json", |
|
|
dataType:"json", |
|
|
delay:250, |
|
|
delay:250, |
|
|
cache:true, |
|
|
cache:true, |
|
@ -815,8 +816,8 @@ |
|
|
var options = []; |
|
|
var options = []; |
|
|
for(var i= 0, len=resultList.length;i<len;i++){ |
|
|
for(var i= 0, len=resultList.length;i<len;i++){ |
|
|
var option = resultList[i]; |
|
|
var option = resultList[i]; |
|
|
option.id = resultList[i]["customerName"]; |
|
|
option.id = resultList[i]["enterpriseCode"]; |
|
|
option.text = resultList[i]["customerName"]; |
|
|
option.text = resultList[i]["enterpriseCode"]; |
|
|
options.push(option); |
|
|
options.push(option); |
|
|
} |
|
|
} |
|
|
return { |
|
|
return { |
|
|