Browse Source

Merge remote-tracking branch 'origin/dev' into dev

dev
zhangsiqi 5 months ago
parent
commit
fa6f261093
  1. 2
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerQuoteServiceImpl.java
  2. 146
      ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html

2
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerQuoteServiceImpl.java

@ -129,6 +129,7 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
@Override
@Transactional
public int insertSysCustomerQuote(SysCustomerQuote sysCustomerQuote) {
String loginName = ShiroUtils.getLoginName();
sysCustomerQuote.setCreateBy(loginName);
@ -275,7 +276,6 @@ public class SysCustomerQuoteServiceImpl implements ISysCustomerQuoteService {
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ProcessInstance submitApply(SysCustomerQuote sysCustomerQuote) {
SysUser user = ShiroUtils.getSysUser();
sysCustomerQuote.setApplyUser(user.getLoginName());

146
ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html

@ -25,22 +25,20 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">客户编号:</label>
<label class="col-sm-4 control-label is-required">客户编号:</label>
<div class="col-sm-8">
<select class="form-control" id="customerCode" name="customerCode" required>
<!-- 这里动态生成客户编号选项 -->
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">客户名称:</label>
<div class="col-sm-8">
<select id="customerName" name="customerName" class="form-control m-b">
<option value="">请选择</option>
</select>
<input name="customerName" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label">报价币种:</label>
<div class="col-sm-8">
@ -170,92 +168,70 @@
}
}
//获取客户信息
$(function(){
$("#customerCode").select2({
theme: "bootstrap",
allowClear: true,
placeholder: "请选择客户",
ajax:{
type: "post",
url:ctx + "system/customer/customerList",
dataType:"json",
delay:250,
cache:true,
processResults: function (res, params) {
var resultList = res.rows;
console.log("传输的数值");
console.log(resultList);
var options = [];
for(var i= 0, len=resultList.length;i<len;i++){
var option = resultList[i];
option.id = resultList[i]["enterpriseCode"];
option.text = resultList[i]["enterpriseCode"];
option.title = resultList[i]["enterpriseName"];
options.push(option);
}
return {
results: options,
pagination: {
// more:res["data"]["more"]
}
};
$(document).ready(function() {
// 初始化时默认加载客户编号列表
loadCustomerIds();
// 监听客户编号下拉框的变化
$('#customerCode').on('change', function() {
var selectedCustomerCode = $(this).val(); // 获取选中的客户ID
if (selectedCustomerCode) {
// 发起Ajax请求获取客户名称
$.ajax({
type: 'GET',
url: ctx +'system/customer/getCustomerNameByEnterpriseCode/' + selectedCustomerCode, // 替换为你的实际API路径
dataType: 'json', // 假设返回的数据格式是JSON
success: function(data) {
console.log(data);
// 将获取到的客户名称填充到输入框
if(data.data == null){
// 如果返回的数据有问题,可以给出提示或处理
$.modal.alertWarning('未能获取到客户名称!');
}
$('input[name="customerName"]').val(data.data.customerName);
},
escapeMarkup: function (markup) { return markup; },
// minimumInputLength: 1
error: function(jqXHR, textStatus, errorThrown) {
console.error('Error:', textStatus, errorThrown);
$.modal.alertWarning('查询客户名称时发生错误!');
}
});
$("#customerName").select2({
theme: "bootstrap",
allowClear: true,
placeholder: "请选择客户",
ajax: {
type: "post",
url: ctx + "system/customer/customerList",
dataType: "json",
delay: 250,
cache: true,
processResults: function (res, params) {
var resultList = res.rows;
console.log("传输的数值");
console.log(resultList);
var options = [];
for (let i in resultList) {
var option = resultList[i];
option.id = resultList[i]["enterpriseName"];
option.text = resultList[i]["enterpriseName"];
option.title = resultList[i]["enterpriseCode"];
options.push(option);
}
return {results: options,}
},
escapeMarkup: function (markup) {return markup;},
} else {
// 如果没有选择客户ID,清空客户名称输入框
$('input[name="customerName"]').val('');
}
});
})
$('#customerCode').on('select2:select', function (e) {
var data = e.params.data;
console.log("data",data);
$("input[name='customerName']").val(data.enterpriseName);
$("select[name='commonCurrency']").val(data.commonCurrency).trigger('change');
$("input[name='customerFax']").val(data.customerFax);
$("input[name='rmbTax']").val(data.taxRate);
$("input[name='confirmFax']").val(data.confirmTax);
$("#commonCurrency_add").val(data.commonCurrency).trigger('change');
commonCurrency = $("#commonCurrency_add option:selected").val();
console.log("commonCurrency",commonCurrency);
});
$('#customerName').on('select2:select', function (e) {
var data = e.params.data;
console.log("data",data);
$("input[name='customerCode']").val(data.enterpriseName);
$("select[name='commonCurrency']").val(data.commonCurrency).trigger('change');
$("input[name='customerFax']").val(data.customerFax);
$("input[name='rmbTax']").val(data.taxRate);
$("input[name='confirmFax']").val(data.confirmTax);
$("#commonCurrency_add").val(data.commonCurrency).trigger('change');
commonCurrency = $("#commonCurrency_add option:selected").val();
console.log("commonCurrency",commonCurrency);
// 假设的加载客户编号列表函数
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 = $('#customerCode'); // 获取客户编号下拉框元素
// 清空下拉框现有选项
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>');
});
$('#customerCode').val(customerId);
} else {
$.modal.errMsg("数据为空");
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('Failed to fetch customer IDs: ' + textStatus + ', ' + errorThrown);
}
});
}

Loading…
Cancel
Save