|
|
@ -9,34 +9,37 @@ |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">客户编号:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<select class="form-control" id="customerId" name="customerId" required> |
|
|
|
<select class="form-control" id="customerId" name="customerId" onchange="loadMakeNos()" required> |
|
|
|
<!-- 这里动态生成客户编号选项 --> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">客户名称:</label> |
|
|
|
<label class="col-sm-4 control-label">客户名称:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="customerName" class="form-control" type="text"> |
|
|
|
<input name="customerName" class="form-control" type="text" readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">生产单号:</label> |
|
|
|
<label class="col-sm-4 control-label">生产单号:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="makeNo" class="form-control" type="text"> |
|
|
|
<select class="form-control" id="makeNo" name="makeNo" required> |
|
|
|
<!-- 这里动态生成生产单号选项 --> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">紧急程度:</label> |
|
|
|
<label class="col-sm-4 control-label">紧急程度:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<select name="emergencyDegree" class="form-control m-b" th:with="type=${@dict.getType('aftersales_emergency_degree')}"> |
|
|
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">备注信息:</label> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">备注:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="remark" class="form-control" type="text"> |
|
|
|
<textarea name="remark" class="form-control"></textarea> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</form> |
|
|
@ -74,24 +77,113 @@ |
|
|
|
} |
|
|
|
|
|
|
|
//获取客户信息 |
|
|
|
|
|
|
|
$(document).ready(function() { |
|
|
|
// 初始化客户编号下拉框 |
|
|
|
$.getJSON(ctx + "system/customer/getCustomers", function(customers) { |
|
|
|
$.each(customers, function(index, customer) { |
|
|
|
$('#customerId').append(new Option(customer.customerId, customer.customerId)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
// 初始化时默认加载客户编号列表 |
|
|
|
loadCustomerIds(); |
|
|
|
|
|
|
|
// 监听客户编号选择事件 |
|
|
|
// 监听客户编号下拉框的变化 |
|
|
|
$('#customerId').on('change', function() { |
|
|
|
const customerId = $(this).val(); |
|
|
|
$.getJSON(prefix + "/getCustomerDetails?customerId=" + encodeURIComponent(customerId), function(customer) { |
|
|
|
$('#customerName').val(customer.customerName); |
|
|
|
}); |
|
|
|
var selectedCustomerId = $(this).val(); // 获取选中的客户ID |
|
|
|
if (selectedCustomerId) { |
|
|
|
// 发起Ajax请求获取客户名称 |
|
|
|
$.ajax({ |
|
|
|
type: 'GET', |
|
|
|
url: ctx +'system/customer/getCustomerNameByEnterpriseCode/' + selectedCustomerId, // 替换为你的实际API路径 |
|
|
|
dataType: 'json', // 假设返回的数据格式是JSON |
|
|
|
success: function(data) { |
|
|
|
console.log(data); |
|
|
|
// 将获取到的客户名称填充到输入框 |
|
|
|
if(data.data == null){ |
|
|
|
// 如果返回的数据有问题,可以给出提示或处理 |
|
|
|
alert('未能获取到客户名称!'); |
|
|
|
} |
|
|
|
$('input[name="customerName"]').val(data.data.customerName); |
|
|
|
}, |
|
|
|
error: function(jqXHR, textStatus, errorThrown) { |
|
|
|
console.error('Error:', textStatus, errorThrown); |
|
|
|
alert('查询客户名称时发生错误!'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 如果没有选择客户ID,清空客户名称输入框 |
|
|
|
$('input[name="customerName"]').val(''); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//获取已经选择客户Id相关的生产单号 |
|
|
|
function loadMakeNos() { |
|
|
|
var selectedCustomerId = $('#customerId').val(); // 获取选中的客户ID |
|
|
|
if (!selectedCustomerId) { |
|
|
|
// 如果没有选中客户,则清空生产单号下拉框并可添加提示信息 |
|
|
|
$('#makeNo').empty().append('<option value="">请选择客户编号后加载生产单号</option>'); |
|
|
|
return; // 直接返回,不发起请求 |
|
|
|
} |
|
|
|
|
|
|
|
var makeNoUrl = ctx + 'aftersales/complaintNotice/getMakeNosByCustomerId/' + selectedCustomerId; // 假定的后端接口URL,根据实际调整 |
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
type: 'GET', |
|
|
|
url: makeNoUrl, |
|
|
|
dataType: 'json', |
|
|
|
success: function(data) { |
|
|
|
console.log(data); |
|
|
|
if (data && Array.isArray(data)) { |
|
|
|
var selectElement = $('#makeNo'); // 获取生产单号下拉框元素 |
|
|
|
selectElement.empty(); // 清空现有选项 |
|
|
|
|
|
|
|
// 添加默认选项(如果需要) |
|
|
|
selectElement.append('<option value="">请选择生产单号</option>'); |
|
|
|
|
|
|
|
// 遍历返回的数据,添加为下拉框的选项 |
|
|
|
$.each(data, function(index, item) { |
|
|
|
// 假设item有makeNo属性,代表生产单号 |
|
|
|
selectElement.append('<option value="' + item.makeNo + '">' + item.makeNo + '</option>'); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
console.error('Data is not an array or is empty.'); |
|
|
|
// 可能还需要处理UI显示,比如提示无相关生产单号 |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(jqXHR, textStatus, errorThrown) { |
|
|
|
console.error('Failed to fetch make numbers: ' + textStatus + ', ' + errorThrown); |
|
|
|
// 同样考虑UI反馈,如提示加载失败 |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
// 假设的加载客户编号列表函数 |
|
|
|
function loadCustomerIds() { |
|
|
|
var url = ctx + 'system/customer/getCustomers'; |
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
type: 'GET', // 请求类型 |
|
|
|
url: url, // 后端接口URL |
|
|
|
dataType: 'json', // 预期服务器返回的数据类型 |
|
|
|
success: function(data) { |
|
|
|
if (data && Array.isArray(data)) { |
|
|
|
var selectElement = $('#customerId'); // 获取客户编号下拉框元素 |
|
|
|
|
|
|
|
// 清空下拉框现有选项 |
|
|
|
selectElement.empty(); |
|
|
|
|
|
|
|
// 添加默认选项(如果需要) |
|
|
|
selectElement.append('<option value="">请选择客户编号</option>'); |
|
|
|
|
|
|
|
// 遍历返回的数据,添加为下拉框的选项 |
|
|
|
$.each(data, function(index, item) { |
|
|
|
// 假设item有id和name两个属性,分别代表客户ID和客户编号 |
|
|
|
selectElement.append('<option value="' + item.customerId + '">' + item.customerId + '</option>'); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
console.error('Data is not an array or is empty.'); |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(jqXHR, textStatus, errorThrown) { |
|
|
|
console.error('Failed to fetch customer IDs: ' + textStatus + ', ' + errorThrown); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html> |