This commit is contained in:
xd 2024-03-25 14:26:31 +08:00
parent 8e37de0c7a
commit 76854b7890
9 changed files with 1454 additions and 0 deletions

View File

@ -0,0 +1,104 @@
package com.ruoyi.web.controller.customer;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.customer.domain.Customer;
import com.ruoyi.customer.service.ICustomerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 客户管理Controller
*
* @author ruoyi
* @date 2024-03-25
*/
@RestController
@RequestMapping("/customer/customer")
public class CustomerController extends BaseController
{
@Autowired
private ICustomerService customerService;
/**
* 查询客户管理列表
*/
@PreAuthorize("@ss.hasPermi('customer:customer:list')")
@GetMapping("/list")
public TableDataInfo list(Customer customer)
{
startPage();
List<Customer> list = customerService.selectCustomerList(customer);
return getDataTable(list);
}
/**
* 导出客户管理列表
*/
@PreAuthorize("@ss.hasPermi('customer:customer:export')")
@Log(title = "客户管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Customer customer)
{
List<Customer> list = customerService.selectCustomerList(customer);
ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
util.exportExcel(response, list, "客户管理数据");
}
/**
* 获取客户管理详细信息
*/
@PreAuthorize("@ss.hasPermi('customer:customer:query')")
@GetMapping(value = "/{cusId}")
public AjaxResult getInfo(@PathVariable("cusId") Long cusId)
{
return success(customerService.selectCustomerByCusId(cusId));
}
/**
* 新增客户管理
*/
@PreAuthorize("@ss.hasPermi('customer:customer:add')")
@Log(title = "客户管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Customer customer)
{
return toAjax(customerService.insertCustomer(customer));
}
/**
* 修改客户管理
*/
@PreAuthorize("@ss.hasPermi('customer:customer:edit')")
@Log(title = "客户管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Customer customer)
{
return toAjax(customerService.updateCustomer(customer));
}
/**
* 删除客户管理
*/
@PreAuthorize("@ss.hasPermi('customer:customer:remove')")
@Log(title = "客户管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{cusIds}")
public AjaxResult remove(@PathVariable Long[] cusIds)
{
return toAjax(customerService.deleteCustomerByCusIds(cusIds));
}
}

View File

@ -0,0 +1,79 @@
package com.ruoyi.customer.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 银行对象 bank
*
* @author ruoyi
* @date 2024-03-25
*/
public class Bank extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 银行ID */
private Long bankId;
/** 银行名称 */
@Excel(name = "银行名称")
private String bankName;
/** 银行账户 */
@Excel(name = "银行账户")
private String bankAccount;
/** 客户ID */
@Excel(name = "客户ID")
private Long cusId;
public void setBankId(Long bankId)
{
this.bankId = bankId;
}
public Long getBankId()
{
return bankId;
}
public void setBankName(String bankName)
{
this.bankName = bankName;
}
public String getBankName()
{
return bankName;
}
public void setBankAccount(String bankAccount)
{
this.bankAccount = bankAccount;
}
public String getBankAccount()
{
return bankAccount;
}
public void setCusId(Long cusId)
{
this.cusId = cusId;
}
public Long getCusId()
{
return cusId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("bankId", getBankId())
.append("bankName", getBankName())
.append("bankAccount", getBankAccount())
.append("cusId", getCusId())
.toString();
}
}

View File

@ -0,0 +1,317 @@
package com.ruoyi.customer.domain;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 客户管理对象 customer
*
* @author ruoyi
* @date 2024-03-25
*/
public class Customer extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 客户ID */
private Long cusId;
/** 客户编码 */
@Excel(name = "客户编码")
private String cusCode;
/** 客户名称 */
@Excel(name = "客户名称")
private String cusName;
/** SAP客户编码 */
@Excel(name = "SAP客户编码")
private String cusSapCode;
/** 街道/门牌号 */
private String cusStreet;
/** 付款条件 */
private String cusPaymentTerms;
/** 电话号码 */
private String cusPhoneNumber;
/** 行业代码 */
private String cusIndustryCode;
/** 客户组类别 */
private String cusGroup;
/** 增值税号 */
private String cusVatNo;
/** 客户类型 */
private String cusType;
/** 国家 */
private String cusCountry;
/** 语言 */
private String cusLanguage;
/** 客户标签 */
private String cusLabel;
/** 客户分类 */
private String cusClassification;
/** 电子发票接收邮箱 */
private String cusReceivingEmail;
/** 收件人 */
private String cusRecipient;
/** 收件人电话 */
private String cusRecipientPhone;
/** 备注 */
private String cusRemark;
/** 客户禁用状态 */
@Excel(name = "客户禁用状态")
private String cusState;
/** 客户审批状态 */
@Excel(name = "客户审批状态")
private String cusApprovalStatus;
/** 银行信息 */
private List<Bank> bankList;
public void setCusId(Long cusId)
{
this.cusId = cusId;
}
public Long getCusId()
{
return cusId;
}
public void setCusCode(String cusCode)
{
this.cusCode = cusCode;
}
public String getCusCode()
{
return cusCode;
}
public void setCusName(String cusName)
{
this.cusName = cusName;
}
public String getCusName()
{
return cusName;
}
public void setCusSapCode(String cusSapCode)
{
this.cusSapCode = cusSapCode;
}
public String getCusSapCode()
{
return cusSapCode;
}
public void setCusStreet(String cusStreet)
{
this.cusStreet = cusStreet;
}
public String getCusStreet()
{
return cusStreet;
}
public void setCusPaymentTerms(String cusPaymentTerms)
{
this.cusPaymentTerms = cusPaymentTerms;
}
public String getCusPaymentTerms()
{
return cusPaymentTerms;
}
public void setCusPhoneNumber(String cusPhoneNumber)
{
this.cusPhoneNumber = cusPhoneNumber;
}
public String getCusPhoneNumber()
{
return cusPhoneNumber;
}
public void setCusIndustryCode(String cusIndustryCode)
{
this.cusIndustryCode = cusIndustryCode;
}
public String getCusIndustryCode()
{
return cusIndustryCode;
}
public void setCusGroup(String cusGroup)
{
this.cusGroup = cusGroup;
}
public String getCusGroup()
{
return cusGroup;
}
public void setCusVatNo(String cusVatNo)
{
this.cusVatNo = cusVatNo;
}
public String getCusVatNo()
{
return cusVatNo;
}
public void setCusType(String cusType)
{
this.cusType = cusType;
}
public String getCusType()
{
return cusType;
}
public void setCusCountry(String cusCountry)
{
this.cusCountry = cusCountry;
}
public String getCusCountry()
{
return cusCountry;
}
public void setCusLanguage(String cusLanguage)
{
this.cusLanguage = cusLanguage;
}
public String getCusLanguage()
{
return cusLanguage;
}
public void setCusLabel(String cusLabel)
{
this.cusLabel = cusLabel;
}
public String getCusLabel()
{
return cusLabel;
}
public void setCusClassification(String cusClassification)
{
this.cusClassification = cusClassification;
}
public String getCusClassification()
{
return cusClassification;
}
public void setCusReceivingEmail(String cusReceivingEmail)
{
this.cusReceivingEmail = cusReceivingEmail;
}
public String getCusReceivingEmail()
{
return cusReceivingEmail;
}
public void setCusRecipient(String cusRecipient)
{
this.cusRecipient = cusRecipient;
}
public String getCusRecipient()
{
return cusRecipient;
}
public void setCusRecipientPhone(String cusRecipientPhone)
{
this.cusRecipientPhone = cusRecipientPhone;
}
public String getCusRecipientPhone()
{
return cusRecipientPhone;
}
public void setCusRemark(String cusRemark)
{
this.cusRemark = cusRemark;
}
public String getCusRemark()
{
return cusRemark;
}
public void setCusState(String cusState)
{
this.cusState = cusState;
}
public String getCusState()
{
return cusState;
}
public void setCusApprovalStatus(String cusApprovalStatus)
{
this.cusApprovalStatus = cusApprovalStatus;
}
public String getCusApprovalStatus()
{
return cusApprovalStatus;
}
public List<Bank> getBankList()
{
return bankList;
}
public void setBankList(List<Bank> bankList)
{
this.bankList = bankList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("cusId", getCusId())
.append("cusCode", getCusCode())
.append("cusName", getCusName())
.append("cusSapCode", getCusSapCode())
.append("cusStreet", getCusStreet())
.append("cusPaymentTerms", getCusPaymentTerms())
.append("cusPhoneNumber", getCusPhoneNumber())
.append("cusIndustryCode", getCusIndustryCode())
.append("cusGroup", getCusGroup())
.append("cusVatNo", getCusVatNo())
.append("cusType", getCusType())
.append("cusCountry", getCusCountry())
.append("cusLanguage", getCusLanguage())
.append("cusLabel", getCusLabel())
.append("cusClassification", getCusClassification())
.append("cusReceivingEmail", getCusReceivingEmail())
.append("cusRecipient", getCusRecipient())
.append("cusRecipientPhone", getCusRecipientPhone())
.append("cusRemark", getCusRemark())
.append("cusState", getCusState())
.append("cusApprovalStatus", getCusApprovalStatus())
.append("bankList", getBankList())
.toString();
}
}

View File

@ -0,0 +1,87 @@
package com.ruoyi.customer.mapper;
import java.util.List;
import com.ruoyi.customer.domain.Customer;
import com.ruoyi.customer.domain.Bank;
/**
* 客户管理Mapper接口
*
* @author ruoyi
* @date 2024-03-25
*/
public interface CustomerMapper
{
/**
* 查询客户管理
*
* @param cusId 客户管理主键
* @return 客户管理
*/
public Customer selectCustomerByCusId(Long cusId);
/**
* 查询客户管理列表
*
* @param customer 客户管理
* @return 客户管理集合
*/
public List<Customer> selectCustomerList(Customer customer);
/**
* 新增客户管理
*
* @param customer 客户管理
* @return 结果
*/
public int insertCustomer(Customer customer);
/**
* 修改客户管理
*
* @param customer 客户管理
* @return 结果
*/
public int updateCustomer(Customer customer);
/**
* 删除客户管理
*
* @param cusId 客户管理主键
* @return 结果
*/
public int deleteCustomerByCusId(Long cusId);
/**
* 批量删除客户管理
*
* @param cusIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteCustomerByCusIds(Long[] cusIds);
/**
* 批量删除银行
*
* @param cusIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteBankByCusIds(Long[] cusIds);
/**
* 批量新增银行
*
* @param bankList 银行列表
* @return 结果
*/
public int batchBank(List<Bank> bankList);
/**
* 通过客户管理主键删除银行信息
*
* @param cusId 客户管理ID
* @return 结果
*/
public int deleteBankByCusId(Long cusId);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.customer.service;
import java.util.List;
import com.ruoyi.customer.domain.Customer;
/**
* 客户管理Service接口
*
* @author ruoyi
* @date 2024-03-25
*/
public interface ICustomerService
{
/**
* 查询客户管理
*
* @param cusId 客户管理主键
* @return 客户管理
*/
public Customer selectCustomerByCusId(Long cusId);
/**
* 查询客户管理列表
*
* @param customer 客户管理
* @return 客户管理集合
*/
public List<Customer> selectCustomerList(Customer customer);
/**
* 新增客户管理
*
* @param customer 客户管理
* @return 结果
*/
public int insertCustomer(Customer customer);
/**
* 修改客户管理
*
* @param customer 客户管理
* @return 结果
*/
public int updateCustomer(Customer customer);
/**
* 批量删除客户管理
*
* @param cusIds 需要删除的客户管理主键集合
* @return 结果
*/
public int deleteCustomerByCusIds(Long[] cusIds);
/**
* 删除客户管理信息
*
* @param cusId 客户管理主键
* @return 结果
*/
public int deleteCustomerByCusId(Long cusId);
}

View File

@ -0,0 +1,131 @@
package com.ruoyi.customer.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.customer.domain.Bank;
import com.ruoyi.customer.mapper.CustomerMapper;
import com.ruoyi.customer.domain.Customer;
import com.ruoyi.customer.service.ICustomerService;
/**
* 客户管理Service业务层处理
*
* @author ruoyi
* @date 2024-03-25
*/
@Service
public class CustomerServiceImpl implements ICustomerService
{
@Autowired
private CustomerMapper customerMapper;
/**
* 查询客户管理
*
* @param cusId 客户管理主键
* @return 客户管理
*/
@Override
public Customer selectCustomerByCusId(Long cusId)
{
return customerMapper.selectCustomerByCusId(cusId);
}
/**
* 查询客户管理列表
*
* @param customer 客户管理
* @return 客户管理
*/
@Override
public List<Customer> selectCustomerList(Customer customer)
{
return customerMapper.selectCustomerList(customer);
}
/**
* 新增客户管理
*
* @param customer 客户管理
* @return 结果
*/
@Transactional
@Override
public int insertCustomer(Customer customer)
{
int rows = customerMapper.insertCustomer(customer);
insertBank(customer);
return rows;
}
/**
* 修改客户管理
*
* @param customer 客户管理
* @return 结果
*/
@Transactional
@Override
public int updateCustomer(Customer customer)
{
customerMapper.deleteBankByCusId(customer.getCusId());
insertBank(customer);
return customerMapper.updateCustomer(customer);
}
/**
* 批量删除客户管理
*
* @param cusIds 需要删除的客户管理主键
* @return 结果
*/
@Transactional
@Override
public int deleteCustomerByCusIds(Long[] cusIds)
{
customerMapper.deleteBankByCusIds(cusIds);
return customerMapper.deleteCustomerByCusIds(cusIds);
}
/**
* 删除客户管理信息
*
* @param cusId 客户管理主键
* @return 结果
*/
@Transactional
@Override
public int deleteCustomerByCusId(Long cusId)
{
customerMapper.deleteBankByCusId(cusId);
return customerMapper.deleteCustomerByCusId(cusId);
}
/**
* 新增银行信息
*
* @param customer 客户管理对象
*/
public void insertBank(Customer customer)
{
List<Bank> bankList = customer.getBankList();
Long cusId = customer.getCusId();
if (StringUtils.isNotNull(bankList))
{
List<Bank> list = new ArrayList<Bank>();
for (Bank bank : bankList)
{
bank.setCusId(cusId);
list.add(bank);
}
if (list.size() > 0)
{
customerMapper.batchBank(list);
}
}
}
}

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.customer.mapper.CustomerMapper">
<resultMap type="Customer" id="CustomerResult">
<result property="cusId" column="cus_id" />
<result property="cusCode" column="cus_code" />
<result property="cusName" column="cus_name" />
<result property="cusSapCode" column="cus_sap_code" />
<result property="cusStreet" column="cus_street" />
<result property="cusPaymentTerms" column="cus_payment_terms" />
<result property="cusPhoneNumber" column="cus_phone_number" />
<result property="cusIndustryCode" column="cus_industry_code" />
<result property="cusGroup" column="cus_group" />
<result property="cusVatNo" column="cus_vat_no" />
<result property="cusType" column="cus_type" />
<result property="cusCountry" column="cus_country" />
<result property="cusLanguage" column="cus_language" />
<result property="cusLabel" column="cus_label" />
<result property="cusClassification" column="cus_classification" />
<result property="cusReceivingEmail" column="cus_receiving_email" />
<result property="cusRecipient" column="cus_recipient" />
<result property="cusRecipientPhone" column="cus_recipient_phone" />
<result property="cusRemark" column="cus_remark" />
<result property="cusState" column="cus_state" />
<result property="cusApprovalStatus" column="cus_approval_status" />
</resultMap>
<resultMap id="CustomerBankResult" type="Customer" extends="CustomerResult">
<collection property="bankList" notNullColumn="sub_bank_id" javaType="java.util.List" resultMap="BankResult" />
</resultMap>
<resultMap type="Bank" id="BankResult">
<result property="bankId" column="sub_bank_id" />
<result property="bankName" column="sub_bank_name" />
<result property="bankAccount" column="sub_bank_account" />
<result property="cusId" column="sub_cus_id" />
</resultMap>
<sql id="selectCustomerVo">
select cus_id, cus_code, cus_name, cus_sap_code, cus_street, cus_payment_terms, cus_phone_number, cus_industry_code, cus_group, cus_vat_no, cus_type, cus_country, cus_language, cus_label, cus_classification, cus_receiving_email, cus_recipient, cus_recipient_phone, cus_remark, cus_state, cus_approval_status from customer
</sql>
<select id="selectCustomerList" parameterType="Customer" resultMap="CustomerResult">
<include refid="selectCustomerVo"/>
<where>
<if test="cusCode != null and cusCode != ''"> and cus_code like concat('%', #{cusCode}, '%')</if>
<if test="cusName != null and cusName != ''"> and cus_name like concat('%', #{cusName}, '%')</if>
<if test="cusSapCode != null and cusSapCode != ''"> and cus_sap_code like concat('%', #{cusSapCode}, '%')</if>
<if test="cusState != null and cusState != ''"> and cus_state = #{cusState}</if>
<if test="cusApprovalStatus != null and cusApprovalStatus != ''"> and cus_approval_status = #{cusApprovalStatus}</if>
</where>
</select>
<select id="selectCustomerByCusId" parameterType="Long" resultMap="CustomerBankResult">
select a.cus_id, a.cus_code, a.cus_name, a.cus_sap_code, a.cus_street, a.cus_payment_terms, a.cus_phone_number, a.cus_industry_code, a.cus_group, a.cus_vat_no, a.cus_type, a.cus_country, a.cus_language, a.cus_label, a.cus_classification, a.cus_receiving_email, a.cus_recipient, a.cus_recipient_phone, a.cus_remark, a.cus_state, a.cus_approval_status,
b.bank_id as sub_bank_id, b.bank_name as sub_bank_name, b.bank_account as sub_bank_account, b.cus_id as sub_cus_id
from customer a
left join bank b on b.cus_id = a.cus_id
where a.cus_id = #{cusId}
</select>
<insert id="insertCustomer" parameterType="Customer">
insert into customer
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="cusId != null">cus_id,</if>
<if test="cusCode != null">cus_code,</if>
<if test="cusName != null and cusName != ''">cus_name,</if>
<if test="cusSapCode != null">cus_sap_code,</if>
<if test="cusStreet != null and cusStreet != ''">cus_street,</if>
<if test="cusPaymentTerms != null and cusPaymentTerms != ''">cus_payment_terms,</if>
<if test="cusPhoneNumber != null and cusPhoneNumber != ''">cus_phone_number,</if>
<if test="cusIndustryCode != null and cusIndustryCode != ''">cus_industry_code,</if>
<if test="cusGroup != null and cusGroup != ''">cus_group,</if>
<if test="cusVatNo != null and cusVatNo != ''">cus_vat_no,</if>
<if test="cusType != null">cus_type,</if>
<if test="cusCountry != null and cusCountry != ''">cus_country,</if>
<if test="cusLanguage != null and cusLanguage != ''">cus_language,</if>
<if test="cusLabel != null">cus_label,</if>
<if test="cusClassification != null">cus_classification,</if>
<if test="cusReceivingEmail != null">cus_receiving_email,</if>
<if test="cusRecipient != null">cus_recipient,</if>
<if test="cusRecipientPhone != null">cus_recipient_phone,</if>
<if test="cusRemark != null">cus_remark,</if>
<if test="cusState != null">cus_state,</if>
<if test="cusApprovalStatus != null">cus_approval_status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="cusId != null">#{cusId},</if>
<if test="cusCode != null">#{cusCode},</if>
<if test="cusName != null and cusName != ''">#{cusName},</if>
<if test="cusSapCode != null">#{cusSapCode},</if>
<if test="cusStreet != null and cusStreet != ''">#{cusStreet},</if>
<if test="cusPaymentTerms != null and cusPaymentTerms != ''">#{cusPaymentTerms},</if>
<if test="cusPhoneNumber != null and cusPhoneNumber != ''">#{cusPhoneNumber},</if>
<if test="cusIndustryCode != null and cusIndustryCode != ''">#{cusIndustryCode},</if>
<if test="cusGroup != null and cusGroup != ''">#{cusGroup},</if>
<if test="cusVatNo != null and cusVatNo != ''">#{cusVatNo},</if>
<if test="cusType != null">#{cusType},</if>
<if test="cusCountry != null and cusCountry != ''">#{cusCountry},</if>
<if test="cusLanguage != null and cusLanguage != ''">#{cusLanguage},</if>
<if test="cusLabel != null">#{cusLabel},</if>
<if test="cusClassification != null">#{cusClassification},</if>
<if test="cusReceivingEmail != null">#{cusReceivingEmail},</if>
<if test="cusRecipient != null">#{cusRecipient},</if>
<if test="cusRecipientPhone != null">#{cusRecipientPhone},</if>
<if test="cusRemark != null">#{cusRemark},</if>
<if test="cusState != null">#{cusState},</if>
<if test="cusApprovalStatus != null">#{cusApprovalStatus},</if>
</trim>
</insert>
<update id="updateCustomer" parameterType="Customer">
update customer
<trim prefix="SET" suffixOverrides=",">
<if test="cusCode != null">cus_code = #{cusCode},</if>
<if test="cusName != null and cusName != ''">cus_name = #{cusName},</if>
<if test="cusSapCode != null">cus_sap_code = #{cusSapCode},</if>
<if test="cusStreet != null and cusStreet != ''">cus_street = #{cusStreet},</if>
<if test="cusPaymentTerms != null and cusPaymentTerms != ''">cus_payment_terms = #{cusPaymentTerms},</if>
<if test="cusPhoneNumber != null and cusPhoneNumber != ''">cus_phone_number = #{cusPhoneNumber},</if>
<if test="cusIndustryCode != null and cusIndustryCode != ''">cus_industry_code = #{cusIndustryCode},</if>
<if test="cusGroup != null and cusGroup != ''">cus_group = #{cusGroup},</if>
<if test="cusVatNo != null and cusVatNo != ''">cus_vat_no = #{cusVatNo},</if>
<if test="cusType != null">cus_type = #{cusType},</if>
<if test="cusCountry != null and cusCountry != ''">cus_country = #{cusCountry},</if>
<if test="cusLanguage != null and cusLanguage != ''">cus_language = #{cusLanguage},</if>
<if test="cusLabel != null">cus_label = #{cusLabel},</if>
<if test="cusClassification != null">cus_classification = #{cusClassification},</if>
<if test="cusReceivingEmail != null">cus_receiving_email = #{cusReceivingEmail},</if>
<if test="cusRecipient != null">cus_recipient = #{cusRecipient},</if>
<if test="cusRecipientPhone != null">cus_recipient_phone = #{cusRecipientPhone},</if>
<if test="cusRemark != null">cus_remark = #{cusRemark},</if>
<if test="cusState != null">cus_state = #{cusState},</if>
<if test="cusApprovalStatus != null">cus_approval_status = #{cusApprovalStatus},</if>
</trim>
where cus_id = #{cusId}
</update>
<delete id="deleteCustomerByCusId" parameterType="Long">
delete from customer where cus_id = #{cusId}
</delete>
<delete id="deleteCustomerByCusIds" parameterType="String">
delete from customer where cus_id in
<foreach item="cusId" collection="array" open="(" separator="," close=")">
#{cusId}
</foreach>
</delete>
<delete id="deleteBankByCusIds" parameterType="String">
delete from bank where cus_id in
<foreach item="cusId" collection="array" open="(" separator="," close=")">
#{cusId}
</foreach>
</delete>
<delete id="deleteBankByCusId" parameterType="Long">
delete from bank where cus_id = #{cusId}
</delete>
<insert id="batchBank">
insert into bank( bank_id, bank_name, bank_account, cus_id) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.bankId}, #{item.bankName}, #{item.bankAccount}, #{item.cusId})
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询客户管理列表
export function listCustomer(query) {
return request({
url: '/customer/customer/list',
method: 'get',
params: query
})
}
// 查询客户管理详细
export function getCustomer(cusId) {
return request({
url: '/customer/customer/' + cusId,
method: 'get'
})
}
// 新增客户管理
export function addCustomer(data) {
return request({
url: '/customer/customer',
method: 'post',
data: data
})
}
// 修改客户管理
export function updateCustomer(data) {
return request({
url: '/customer/customer',
method: 'put',
data: data
})
}
// 删除客户管理
export function delCustomer(cusId) {
return request({
url: '/customer/customer/' + cusId,
method: 'delete'
})
}

View File

@ -0,0 +1,461 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="客户名称" prop="cusName">
<el-input
v-model="queryParams.cusName"
placeholder="请输入客户名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="SAP客户编码" prop="cusSapCode">
<el-input
v-model="queryParams.cusSapCode"
placeholder="请输入SAP客户编码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="客户禁用状态" prop="cusState">
<el-select v-model="queryParams.cusState" placeholder="请选择客户禁用状态" clearable>
<el-option
v-for="dict in dict.type.common_state"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="客户审批状态" prop="cusApprovalStatus">
<el-select v-model="queryParams.cusApprovalStatus" placeholder="请选择客户审批状态" clearable>
<el-option
v-for="dict in dict.type.cus_approval_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['customer:customer:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['customer:customer:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['customer:customer:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['customer:customer:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="customerList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="客户ID" align="center" prop="cusId" />
<el-table-column label="客户编码" align="center" prop="cusCode" />
<el-table-column label="客户名称" align="center" prop="cusName" />
<el-table-column label="SAP客户编码" align="center" prop="cusSapCode" />
<el-table-column label="客户禁用状态" align="center" prop="cusState">
<template slot-scope="scope">
<dict-tag :options="dict.type.common_state" :value="scope.row.cusState"/>
</template>
</el-table-column>
<el-table-column label="客户审批状态" align="center" prop="cusApprovalStatus">
<template slot-scope="scope">
<dict-tag :options="dict.type.cus_approval_status" :value="scope.row.cusApprovalStatus"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['customer:customer:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['customer:customer:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改客户管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="客户编码" prop="cusCode">
<el-input v-model="form.cusCode" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="客户名称" prop="cusName">
<el-input v-model="form.cusName" placeholder="请输入客户名称" />
</el-form-item>
<el-form-item label="SAP客户编码" prop="cusSapCode">
<el-input v-model="form.cusSapCode" placeholder="请输入SAP客户编码" />
</el-form-item>
<el-form-item label="街道/门牌号" prop="cusStreet">
<el-input v-model="form.cusStreet" placeholder="请输入街道/门牌号" />
</el-form-item>
<el-form-item label="付款条件" prop="cusPaymentTerms">
<el-input v-model="form.cusPaymentTerms" placeholder="请输入付款条件" />
</el-form-item>
<el-form-item label="电话号码" prop="cusPhoneNumber">
<el-input v-model="form.cusPhoneNumber" placeholder="请输入电话号码" />
</el-form-item>
<el-form-item label="行业代码" prop="cusIndustryCode">
<el-input v-model="form.cusIndustryCode" placeholder="请输入行业代码" />
</el-form-item>
<el-form-item label="客户组类别" prop="cusGroup">
<el-input v-model="form.cusGroup" placeholder="请输入客户组类别" />
</el-form-item>
<el-form-item label="增值税号" prop="cusVatNo">
<el-input v-model="form.cusVatNo" placeholder="请输入增值税号" />
</el-form-item>
<el-form-item label="国家" prop="cusCountry">
<el-input v-model="form.cusCountry" placeholder="请输入国家" />
</el-form-item>
<el-form-item label="语言" prop="cusLanguage">
<el-input v-model="form.cusLanguage" placeholder="请输入语言" />
</el-form-item>
<el-form-item label="客户标签" prop="cusLabel">
<el-input v-model="form.cusLabel" placeholder="请输入客户标签" />
</el-form-item>
<el-form-item label="客户分类" prop="cusClassification">
<el-input v-model="form.cusClassification" placeholder="请输入客户分类" />
</el-form-item>
<el-form-item label="电子发票接收邮箱" prop="cusReceivingEmail">
<el-input v-model="form.cusReceivingEmail" placeholder="请输入电子发票接收邮箱" />
</el-form-item>
<el-form-item label="收件人" prop="cusRecipient">
<el-input v-model="form.cusRecipient" placeholder="请输入收件人" />
</el-form-item>
<el-form-item label="收件人电话" prop="cusRecipientPhone">
<el-input v-model="form.cusRecipientPhone" placeholder="请输入收件人电话" />
</el-form-item>
<el-form-item label="备注" prop="cusRemark">
<el-input v-model="form.cusRemark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="客户禁用状态" prop="cusState">
<el-select v-model="form.cusState" placeholder="请选择客户禁用状态">
<el-option
v-for="dict in dict.type.common_state"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="客户审批状态" prop="cusApprovalStatus">
<el-select v-model="form.cusApprovalStatus" placeholder="请选择客户审批状态">
<el-option
v-for="dict in dict.type.cus_approval_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-divider content-position="center">银行信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddBank">添加</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteBank">删除</el-button>
</el-col>
</el-row>
<el-table :data="bankList" :row-class-name="rowBankIndex" @selection-change="handleBankSelectionChange" ref="bank">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="银行名称" prop="bankName" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.bankName" placeholder="请输入银行名称" />
</template>
</el-table-column>
<el-table-column label="银行账户" prop="bankAccount" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.bankAccount" placeholder="请输入银行账户" />
</template>
</el-table-column>
</el-table>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listCustomer, getCustomer, delCustomer, addCustomer, updateCustomer } from "@/api/customer/customer";
export default {
name: "Customer",
dicts: ['cus_approval_status', 'common_state'],
data() {
return {
//
loading: true,
//
ids: [],
//
checkedBank: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
customerList: [],
//
bankList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
cusCode: null,
cusName: null,
cusSapCode: null,
cusState: null,
cusApprovalStatus: null
},
//
form: {},
//
rules: {
cusName: [
{ required: true, message: "客户名称不能为空", trigger: "blur" }
],
cusStreet: [
{ required: true, message: "街道/门牌号不能为空", trigger: "blur" }
],
cusPaymentTerms: [
{ required: true, message: "付款条件不能为空", trigger: "blur" }
],
cusPhoneNumber: [
{ required: true, message: "电话号码不能为空", trigger: "blur" }
],
cusIndustryCode: [
{ required: true, message: "行业代码不能为空", trigger: "blur" }
],
cusGroup: [
{ required: true, message: "客户组类别不能为空", trigger: "blur" }
],
cusVatNo: [
{ required: true, message: "增值税号不能为空", trigger: "blur" }
],
cusCountry: [
{ required: true, message: "国家不能为空", trigger: "blur" }
],
cusLanguage: [
{ required: true, message: "语言不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询客户管理列表 */
getList() {
this.loading = true;
listCustomer(this.queryParams).then(response => {
this.customerList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
cusId: null,
cusCode: null,
cusName: null,
cusSapCode: null,
cusStreet: null,
cusPaymentTerms: null,
cusPhoneNumber: null,
cusIndustryCode: null,
cusGroup: null,
cusVatNo: null,
cusType: null,
cusCountry: null,
cusLanguage: null,
cusLabel: null,
cusClassification: null,
cusReceivingEmail: null,
cusRecipient: null,
cusRecipientPhone: null,
cusRemark: null,
cusState: null,
cusApprovalStatus: null
};
this.bankList = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.cusId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加客户管理";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const cusId = row.cusId || this.ids
getCustomer(cusId).then(response => {
this.form = response.data;
this.bankList = response.data.bankList;
this.open = true;
this.title = "修改客户管理";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.form.bankList = this.bankList;
if (this.form.cusId != null) {
updateCustomer(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addCustomer(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const cusIds = row.cusId || this.ids;
this.$modal.confirm('是否确认删除客户管理编号为"' + cusIds + '"的数据项?').then(function() {
return delCustomer(cusIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 银行序号 */
rowBankIndex({ row, rowIndex }) {
row.index = rowIndex + 1;
},
/** 银行添加按钮操作 */
handleAddBank() {
let obj = {};
obj.bankName = "";
obj.bankAccount = "";
this.bankList.push(obj);
},
/** 银行删除按钮操作 */
handleDeleteBank() {
if (this.checkedBank.length == 0) {
this.$modal.msgError("请先选择要删除的银行数据");
} else {
const bankList = this.bankList;
const checkedBank = this.checkedBank;
this.bankList = bankList.filter(function(item) {
return checkedBank.indexOf(item.index) == -1
});
}
},
/** 复选框选中数据 */
handleBankSelectionChange(selection) {
this.checkedBank = selection.map(item => item.index)
},
/** 导出按钮操作 */
handleExport() {
this.download('customer/customer/export', {
...this.queryParams
}, `customer_${new Date().getTime()}.xlsx`)
}
}
};
</script>