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. 158
      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());

158
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">
@ -169,93 +167,71 @@
} }
} }
} }
//获取客户信息 //获取客户信息
$(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); },
} error: function(jqXHR, textStatus, errorThrown) {
return { console.error('Error:', textStatus, errorThrown);
results: options, $.modal.alertWarning('查询客户名称时发生错误!');
pagination: {
// more:res["data"]["more"]
} }
}; });
}, } else {
escapeMarkup: function (markup) { return markup; }, // 如果没有选择客户ID,清空客户名称输入框
// minimumInputLength: 1 $('input[name="customerName"]').val('');
} }
});
}); });
$("#customerName").select2({ // 假设的加载客户编号列表函数
theme: "bootstrap", function loadCustomerIds() {
allowClear: true, var url = ctx + 'system/customer/getCustomers';
placeholder: "请选择客户", $.ajax({
ajax: { type: 'GET', // 请求类型
type: "post", url: url, // 后端接口URL
url: ctx + "system/customer/customerList", dataType: 'json', // 预期服务器返回的数据类型
dataType: "json", success: function(data) {
delay: 250, if (data && Array.isArray(data)) {
cache: true, var selectElement = $('#customerCode'); // 获取客户编号下拉框元素
processResults: function (res, params) { // 清空下拉框现有选项
var resultList = res.rows; selectElement.empty();
console.log("传输的数值");
console.log(resultList); // // 添加默认选项(如果需要)编辑时不需要添加默认选项
var options = []; selectElement.append('<option value="">请选择客户编号</option>');
for (let i in resultList) {
var option = resultList[i]; // 遍历返回的数据,添加为下拉框的选项
option.id = resultList[i]["enterpriseName"]; $.each(data, function(index, item) {
option.text = resultList[i]["enterpriseName"]; // 假设item有id和name两个属性,分别代表客户ID和客户编号
option.title = resultList[i]["enterpriseCode"]; selectElement.append('<option value="' + item.customerId + '">' + item.customerId + '</option>');
options.push(option); });
$('#customerCode').val(customerId);
} else {
$.modal.errMsg("数据为空");
} }
return {results: options,}
}, },
escapeMarkup: function (markup) {return markup;}, error: function(jqXHR, textStatus, errorThrown) {
} console.error('Failed to fetch customer IDs: ' + textStatus + ', ' + errorThrown);
}); }
}) });
$('#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);
});

Loading…
Cancel
Save