Browse Source

[feat]

销售管理 客户资料
修改mapper、service接口,新增按前缀模糊查找客户信息列表的方法;
新增返回查询客户资料列表的接口,用以销售订单选择客户下拉框搜索功能的实现;
销售管理 销售订单
修改添加销售订单页面select2下拉框绑定数据源,实现下拉框搜索功能;
修改添加销售订单页面业务员输入框为只读,修改绑定数据源为当前登录名称;
dev
王晓迪 7 months ago
parent
commit
240311e7c3
  1. 11
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerController.java
  2. 7
      ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerMapper.java
  3. 2
      ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerService.java
  4. 6
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerServiceImpl.java
  5. 8
      ruoyi-admin/src/main/resources/mapper/system/SysCustomerMapper.xml
  6. 110
      ruoyi-admin/src/main/resources/templates/system/salesOrder/add.html

11
ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerController.java

@ -287,6 +287,17 @@ public class SysCustomerController extends BaseController
List<SysCustomer> list = sysCustomerService.selectSysCustomerToList();
return getDataTable(list);
}
// 前缀查询客户列表
@RequestMapping("/matchCustomerList")
@ResponseBody
public AjaxResult getMatchCustomerList(@RequestParam(value = "q",defaultValue = "") String prefix){
if (prefix == null || prefix.isEmpty()){
List<SysCustomer> list = sysCustomerService.selectSysCustomerToList();
return success(list);
}
List<SysCustomer> list = sysCustomerService.getMatchCustomerList(prefix);
return success(list);
}
@PostMapping("/contactsList")
@ResponseBody
public TableDataInfo list(SysContacts sysContacts)

7
ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysCustomerMapper.java

@ -24,6 +24,13 @@ public interface SysCustomerMapper
List<SysCustomer> selectSysCustomerToList();
/**
* 前缀匹配查询客户信息列表
*
* @param enterpriseCode 客户ID
* @return 客户基本信息集合
*/
List<SysCustomer> searchCustomersByPrefix(String enterpriseCode);
/**
* 查询客户基本信息列表

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

@ -97,4 +97,6 @@ public interface ISysCustomerService
CustomerDto selectCustomerDtoByEnterpriseCode(String customerId);
List<SysCustomer> selectSysCustomerWithComplaintNotice();
List<SysCustomer> getMatchCustomerList(String customerCode);
}

6
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerServiceImpl.java

@ -147,6 +147,7 @@ public class SysCustomerServiceImpl implements ISysCustomerService
return sysCustomerMapper.selectSysCustomerToList();
}
/**
* 新增客户基本信息
*
@ -243,6 +244,11 @@ public class SysCustomerServiceImpl implements ISysCustomerService
return sysCustomers;
}
@Override
public List<SysCustomer> getMatchCustomerList(String customerCode) {
return sysCustomerMapper.searchCustomersByPrefix(customerCode);
}
@Override
public int deleteSysCustomerByIds(String[] ids) {
return sysCustomerMapper.deleteSysCustomerByIds(ids);

8
ruoyi-admin/src/main/resources/mapper/system/SysCustomerMapper.xml

@ -87,6 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and use_status = '1' and use_status = '1'
</where>
</select>
<select id="selectSysCustomerList" parameterType="SysCustomerVo" resultMap="SysCustomerResult">
select s.id,s.enterprise_code,s.enterprise_name,s.english_name,s.customer_abbreviation ,s.customer_purser ,
s.export_sales,s.customer_country,s.postal_code,s.customer_address,s.legal_representative,s.established_time,
@ -337,4 +339,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update sys_customer set customer_sign = #{customerSign}
where id = #{id}
</update>
<select id="searchCustomersByPrefix" parameterType="String" resultMap="SysCustomerResult">
<include refid="selectSysCustomerVo"/>
where use_status = '1' and use_status = '1'
and enterprise_code like concat(#{prefix}, '%') escape '\\'
</select>
</mapper>

110
ruoyi-admin/src/main/resources/templates/system/salesOrder/add.html

@ -83,7 +83,7 @@
<div class="form-group">
<label class="col-sm-3 control-label">客户名称:</label>
<div class="col-sm-8">
<input name="enterpriseName" class="form-control" type="text" readonly>
<input id="enterpriseName" name="enterpriseName" class="form-control" type="text">
</div>
</div>
<div class="form-group">
@ -262,8 +262,9 @@
<div class="form-group">
<label class="col-sm-3 control-label">业务员:</label>
<div class="col-sm-8">
<select name="businessMembers" id="businessMembers_add" class="form-control" required >
</select>
<input name="businessMembers" id="businessMembers_add" class="form-control" type="text" readonly required>
<!-- <select name="businessMembers" id="businessMembers_add" class="form-control" required >-->
<!-- </select>-->
</div>
</div>
<div class="container">
@ -318,8 +319,10 @@
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]];
var customerList = [];
var prefix = ctx + "system/salesOrder"
$(function() {
$("#businessMembers_add").val(loginName);
var options = {
id:'bootstrap-sub-table-order',
pagination: false,
@ -511,22 +514,22 @@
function selectBuniesessMembers(){
//获取业务员
$.ajax({
url: ctx + 'system/salesOrder/getBinessMembers',
type: 'get',
success: function (res) {
console.log(res)
if (res.rows.length > 0) {
var usertData = res.rows;
for (let i in usertData) {
$("select[name='businessMembers']").append(
"<option value='" + usertData[i].userName + "'>" + usertData[i].userName + "</option>");
}
} else {
$.modal.msgError(res.msg);
}
}
});
// $.ajax({
// url: ctx + 'system/salesOrder/getBinessMembers',
// type: 'get',
// success: function (res) {
// console.log(res)
// if (res.rows.length > 0) {
// var usertData = res.rows;
// for (let i in usertData) {
// $("select[name='businessMembers']").append(
// "<option value='" + usertData[i].userName + "'>" + usertData[i].userName + "</option>");
// }
// } else {
// $.modal.msgError(res.msg);
// }
// }
// });
//获取单号
$.ajax({
url: prefix + "/getId",
@ -543,33 +546,72 @@
allowClear: true,
placeholder: "请选择客户",
ajax:{
type: "post",
url:ctx + "system/customer/customerList",
type: "get",
url:ctx + "system/customer/matchCustomerList",
dataType:"json",
delay:250,
timeout: 10000, // 设置超时时间为10秒
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"];
options.push(option);
}
return {
results: options,
pagination: {
if(res.code==0){
var resultList = res.data;
customerList = resultList;
// console.log(customerList);
for(var i= 0, len=resultList.length;i<len;i++){
var option = resultList[i];
option.id = resultList[i]["enterpriseCode"];
option.text = resultList[i]["enterpriseCode"];
options.push(option);
}
return {
results: options
}
};
return {
results: [],
// pagination: {
// }
};
},
escapeMarkup: function (markup) { return markup; },
// minimumInputLength: 1
minimumInputLength: 1
}
});
}
$('#enterpriseName').on('input', function () {
var enterpriseName = $(this).val().trim();
// 触发一次搜索以确保选项被加载
$("select[name='enterpriseCode']").val('').trigger('change'); // 清空下拉框
$("select[name='enterpriseCode']").val('').trigger('input'); // 触发输入事件,以重新加载下拉框
// 查找匹配的客户编号
var matchingCustomer = customerList.find(function (customer) {
return customer.enterpriseName === enterpriseName;
});
// console.log(customerList);
console.log(matchingCustomer);
if (matchingCustomer) {
// 确保值已经存在于下拉框中
var enterpriseCode = matchingCustomer.enterpriseCode;
console.log("下拉框的所有选项:");
var allOptions = $("select[name='enterpriseCode']").select2('data');
allOptions.forEach(function(option) {
console.log("选项值:", option.id, "选项文本:", option.text);
});
// 检查下拉框是否包含该值
if ($("select[name='enterpriseCode']").find("option[value='" + enterpriseCode + "']").length > 0) {
// 设置下拉框的值
$("select[name='enterpriseCode']").val(enterpriseCode).trigger('change');
} else {
console.error("尝试设置的值不存在于下拉框中:", enterpriseCode);
}
} else {
// 清空下拉框的值
// $("select[name='enterpriseCode']").val(null).trigger('change');
}
});
$('#enterpriseCode').on('select2:select', function (e) {
var data = e.params.data;
$("input[name='enterpriseName']").val(data.enterpriseName);

Loading…
Cancel
Save