Browse Source

[fix] 销售管理

销售订单新增 据客户名称查询客户信息后端接口
修改销售订单新增页面前端客户id查询客户名称的js方法:新实现客户名称可关键词搜索输入,客户ID跟随客户名称自动填充,不可修改
修改销售订单新增页面客户名称和客户id前端页面的样式
dev
liuxiaoxu 1 week ago
parent
commit
7f32530c7c
  1. 23
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerController.java
  2. 4
      ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerService.java
  3. 8
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerServiceImpl.java
  4. 2
      ruoyi-admin/src/main/resources/mapper/system/SysCustomerMapper.xml
  5. 43
      ruoyi-admin/src/main/resources/templates/system/salesOrder/add.html

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

@ -339,6 +339,29 @@ public class SysCustomerController extends BaseController
list.add(0,sysContacts1); list.add(0,sysContacts1);
return getDataTable(list); return getDataTable(list);
} }
/**
*根据客户名称查询客户信息
*/
@PostMapping("/contactsList2")
@ResponseBody
public TableDataInfo list2(SysContacts sysContacts)
{
startPage();
List<SysContacts> list = sysContactsService.selectSysContactsList(sysContacts);
SysCustomer customer = sysCustomerService.selectSysCustomerByEnterpriseName(sysContacts.getEnterpriseName());
SysContacts sysContacts1 = new SysContacts();
sysContacts1.setEnterpriseCode(customer.getEnterpriseCode());
sysContacts1.setCustomerName(customer.getCustomerContact());
sysContacts1.setCustomerPosition(customer.getCustomerOffice());
sysContacts1.setCellPhone(customer.getContactNumber());
sysContacts1.setCommonEmail(customer.getCustomerEmail());
sysContacts1.setCustomerFax(customer.getCustomerFax());
list.add(0,sysContacts1);
return getDataTable(list);
}
@PostMapping("/shippingList") @PostMapping("/shippingList")
@ResponseBody @ResponseBody
public TableDataInfo list(SysShippingAddress sysShippingAddress) public TableDataInfo list(SysShippingAddress sysShippingAddress)

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

@ -123,4 +123,8 @@ public interface ISysCustomerService
* */ * */
String convertName(SysCustomerVo sysCustomerVo); String convertName(SysCustomerVo sysCustomerVo);
/**
* 根据客户名称查询客户信息
* */
SysCustomer selectSysCustomerByEnterpriseName(String enterpriseName);
} }

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

@ -165,6 +165,14 @@ public class SysCustomerServiceImpl implements ISysCustomerService
} }
/**
* 根据客户名称查询客户信息
* */
@Override
public SysCustomer selectSysCustomerByEnterpriseName(String enterpriseName) {
return sysCustomerMapper.selectSysCustomerByEnterpriseName(enterpriseName);
}
/** /**
* 新增客户基本信息 * 新增客户基本信息
* *

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

@ -376,7 +376,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="searchCustomersByPrefix" parameterType="String" resultMap="SysCustomerResult"> <select id="searchCustomersByPrefix" parameterType="String" resultMap="SysCustomerResult">
<include refid="selectSysCustomerVo"/> <include refid="selectSysCustomerVo"/>
where audit_status = '1' and use_status = '1' where audit_status = '1' and use_status = '1'
and enterprise_code like concat(#{prefix}, '%') escape '\\' and enterprise_name like concat(#{prefix}, '%') escape '\\'
</select> </select>
</mapper> </mapper>

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

@ -72,18 +72,19 @@
<!-- <input id="salesOrderCode" name="salesOrderCode" class="form-control" type="text">--> <!-- <input id="salesOrderCode" name="salesOrderCode" class="form-control" type="text">-->
<!-- </div>--> <!-- </div>-->
<!-- </div>--> <!-- </div>-->
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label is-required">客户ID</label> <label class="col-sm-3 control-label">客户名称</label>
<div class="col-sm-8"> <div class="col-sm-8">
<select id="enterpriseCode" name="enterpriseCode" class="form-control m-b" required> <select id="enterpriseName" name="enterpriseName" class="form-control m-b" required>
<option value="">请选择</option> <option value="">请选择</option>
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">客户名称</label> <label class="col-sm-3 control-label is-required">客户ID</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="enterpriseName" name="enterpriseName" class="form-control" type="text" readonly> <input id="enterpriseCode" name="enterpriseCode" class="form-control" type="text" readonly>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -586,7 +587,7 @@
// minimumInputLength: 1 // minimumInputLength: 1
// } // }
// }); // });
$("select[name='enterpriseCode']").select2({ $("select[name='enterpriseName']").select2({
theme: "bootstrap", theme: "bootstrap",
allowClear: true, allowClear: true,
placeholder: "请选择客户", placeholder: "请选择客户",
@ -605,8 +606,8 @@
// console.log(customerList); // console.log(customerList);
for(var i= 0, len=resultList.length;i<len;i++){ for(var i= 0, len=resultList.length;i<len;i++){
var option = resultList[i]; var option = resultList[i];
option.id = resultList[i]["enterpriseCode"]; option.id = resultList[i]["enterpriseName"];
option.text = resultList[i]["enterpriseCode"]; option.text = resultList[i]["enterpriseName"];
options.push(option); options.push(option);
} }
return { return {
@ -624,32 +625,32 @@
} }
}); });
} }
$('#enterpriseName').on('input', function () { $('#enterpriseCode').on('input', function () {
var enterpriseName = $(this).val().trim(); var enterpriseName = $(this).val().trim();
// 触发一次搜索以确保选项被加载 // 触发一次搜索以确保选项被加载
$("select[name='enterpriseCode']").val('').trigger('change'); // 清空下拉框 $("select[name='enterpriseName']").val('').trigger('change'); // 清空下拉框
$("select[name='enterpriseCode']").val('').trigger('input'); // 触发输入事件,以重新加载下拉框 $("select[name='enterpriseName']").val('').trigger('input'); // 触发输入事件,以重新加载下拉框
// 查找匹配的客户编号 // 查找匹配的客户编号
var matchingCustomer = customerList.find(function (customer) { var matchingCustomer = customerList.find(function (customer) {
return customer.enterpriseName === enterpriseName; return customer.enterpriseCode === enterpriseCode;
}); });
// console.log(customerList); // console.log(customerList);
console.log(matchingCustomer); console.log(matchingCustomer);
if (matchingCustomer) { if (matchingCustomer) {
// 确保值已经存在于下拉框中 // 确保值已经存在于下拉框中
var enterpriseCode = matchingCustomer.enterpriseCode; var enterpriseName = matchingCustomer.enterpriseName;
console.log("下拉框的所有选项:"); console.log("下拉框的所有选项:");
var allOptions = $("select[name='enterpriseCode']").select2('data'); var allOptions = $("select[name='enterpriseName']").select2('data');
allOptions.forEach(function(option) { allOptions.forEach(function(option) {
console.log("选项值:", option.id, "选项文本:", option.text); console.log("选项值:", option.id, "选项文本:", option.text);
}); });
// 检查下拉框是否包含该值 // 检查下拉框是否包含该值
if ($("select[name='enterpriseCode']").find("option[value='" + enterpriseCode + "']").length > 0) { if ($("select[name='enterpriseName']").find("option[value='" + enterpriseName + "']").length > 0) {
// 设置下拉框的值 // 设置下拉框的值
$("select[name='enterpriseCode']").val(enterpriseCode).trigger('change'); $("select[name='enterpriseName']").val(enterpriseName).trigger('change');
} else { } else {
console.error("尝试设置的值不存在于下拉框中:", enterpriseCode); console.error("尝试设置的值不存在于下拉框中:", enterpriseName);
} }
} else { } else {
// 清空下拉框的值 // 清空下拉框的值
@ -789,16 +790,16 @@
$('#enterpriseCode').on('select2:select', function (e) { $('#enterpriseName').on('select2:select', function (e) {
var data = e.params.data; var data = e.params.data;
$("input[name='enterpriseName']").val(data.enterpriseName); $("input[name='enterpriseCode']").val(data.enterpriseCode);
$("input[name='customerPurser']").val(data.customerPurser); $("input[name='customerPurser']").val(data.customerPurser);
$("select[name='customerContact']").select2({ $("select[name='customerContact']").select2({
theme: "bootstrap", theme: "bootstrap",
allowClear: true, allowClear: true,
ajax:{ ajax:{
type: "post", type: "post",
url:ctx + "system/customer/contactsList", url:ctx + "system/customer/contactsList2",
dataType:"json", dataType:"json",
delay:250, delay:250,
cache:true, cache:true,
@ -815,8 +816,8 @@
var options = []; var options = [];
for(var i= 0, len=resultList.length;i<len;i++){ for(var i= 0, len=resultList.length;i<len;i++){
var option = resultList[i]; var option = resultList[i];
option.id = resultList[i]["customerName"]; option.id = resultList[i]["enterpriseCode"];
option.text = resultList[i]["customerName"]; option.text = resultList[i]["enterpriseCode"];
options.push(option); options.push(option);
} }
return { return {

Loading…
Cancel
Save