Browse Source

客户管理新增“保存的时候判断客户名称是否已经存在”功能

songxy 8 tháng trước cách đây
mục cha
commit
f44335b46c

+ 21 - 0
client/src/views/OaSystem/marketCenter/khxjPage/index.vue

@@ -264,6 +264,14 @@ const getCustomerDetail = async (id, child?: boolean) => {
 
 // 保存客户信息
 const onSaveCustomer = async () => {
+  const isExist = await getCustomerList(queryParams.value.customerName as string)
+  if (!isEditType.value && isExist) {
+    ElMessage({
+      message: '客户名称已存在!',
+      type: 'warning'
+    })
+    return
+  }
   if (!queryParams.value.customerNumber || queryParams.value.customerNumber == '') {
     ElMessage({
       message: '请先点击生成客户编号后再点击保存!',
@@ -306,6 +314,19 @@ const onSaveCustomer = async () => {
     })
 }
 
+// 获取客户管理数据
+const getCustomerList = async (customerName: string): Promise<boolean> => {
+  if (!customerName) return false
+  return await request.get(
+    {
+      url: '/customer/exist',
+      params: {
+        customerName: customerName
+      }
+    },
+    '/business'
+  )
+}
 /* 客户联系人 */
 
 // 回填客户联系人

+ 6 - 0
zjugis-business/src/main/java/com/zjugis/business/controller/CustomerController.java

@@ -88,6 +88,12 @@ public class CustomerController {
         return CommonResult.success(customerService.getList(new Page<>(customer.getPageNo(),customer.getPageSize()), customer));
     }
 
+    @GetMapping("/customer/exist")
+    @Operation(summary = "客户管理数据是否存在")
+    public CommonResult<Boolean> exist(Customer customer){
+        return CommonResult.success(customerService.exist(customer));
+    }
+
 
     /**
      * 客户编号生成

+ 8 - 1
zjugis-business/src/main/java/com/zjugis/business/mapper/CustomerMapper.java

@@ -3,9 +3,9 @@ package com.zjugis.business.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zjugis.business.bean.dto.CustomerDto;
-import com.zjugis.business.bean.entity.Contract;
 import com.zjugis.business.bean.entity.Customer;
 import com.zjugis.business.bean.response.CustomerResponse;
+import com.zjugis.framework.mybatis.core.query.QueryWrapperX;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
@@ -26,5 +26,12 @@ public interface CustomerMapper extends BaseMapper<Customer> {
     List<CustomerResponse> getChildren(String id);
 
     Integer getIndexCode(@Param("params") Customer customer);
+
+    default Boolean getExist(Customer customer){
+        QueryWrapperX<Customer> queryWrapper = new QueryWrapperX<>();
+        queryWrapper.eq("customer_name", customer.getCustomerName());
+        List<Customer> results = this.selectList(queryWrapper);
+        return results.size() > 0 ? true : false;
+    }
 }
 

+ 2 - 0
zjugis-business/src/main/java/com/zjugis/business/service/CustomerService.java

@@ -53,6 +53,8 @@ public interface CustomerService {
 
     Page<CustomerResponse> getList(Page<CustomerDto> page, CustomerDto customer);
 
+    Boolean exist(Customer customer);
+
     String createNumber(Customer customer);
 }
 

+ 5 - 0
zjugis-business/src/main/java/com/zjugis/business/service/impl/CustomerServiceImpl.java

@@ -110,6 +110,11 @@ public class CustomerServiceImpl implements CustomerService {
         return customers;
     }
 
+    @Override
+    public Boolean exist(Customer customer) {
+        return customerMapper.getExist(customer);
+    }
+
     @Override
     public String createNumber(Customer customer) {
         String area=AreaConstants.getAbbreviationByProvinceName(customer.getXzqdm().substring(0,2));