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

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

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