Commit 7ab6a724 authored by 耿迪迪's avatar 耿迪迪

借贷

parent 3b84e55c
package com.zehong.web.controller.debit;
import java.util.List;
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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TDebitCredit;
import com.zehong.system.service.ITDebitCreditService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
/**
* 借贷Controller
*
* @author zehong
* @date 2023-06-20
*/
@RestController
@RequestMapping("/debit/credit")
public class TDebitCreditController extends BaseController
{
@Autowired
private ITDebitCreditService tDebitCreditService;
/**
* 查询借贷列表
*/
@PreAuthorize("@ss.hasPermi('system:credit:list')")
@GetMapping("/list")
public TableDataInfo list(TDebitCredit tDebitCredit)
{
startPage();
List<TDebitCredit> list = tDebitCreditService.selectTDebitCreditList(tDebitCredit);
return getDataTable(list);
}
/**
* 导出借贷列表
*/
@PreAuthorize("@ss.hasPermi('system:credit:export')")
@Log(title = "借贷", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TDebitCredit tDebitCredit)
{
List<TDebitCredit> list = tDebitCreditService.selectTDebitCreditList(tDebitCredit);
ExcelUtil<TDebitCredit> util = new ExcelUtil<TDebitCredit>(TDebitCredit.class);
return util.exportExcel(list, "借贷数据");
}
/**
* 获取借贷详细信息
*/
@PreAuthorize("@ss.hasPermi('system:credit:query')")
@GetMapping(value = "/{debitId}")
public AjaxResult getInfo(@PathVariable("debitId") Long debitId)
{
return AjaxResult.success(tDebitCreditService.selectTDebitCreditById(debitId));
}
/**
* 新增借贷
*/
@PreAuthorize("@ss.hasPermi('system:credit:add')")
@Log(title = "借贷", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TDebitCredit tDebitCredit)
{
return toAjax(tDebitCreditService.insertTDebitCredit(tDebitCredit));
}
/**
* 修改借贷
*/
@PreAuthorize("@ss.hasPermi('system:credit:edit')")
@Log(title = "借贷", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TDebitCredit tDebitCredit)
{
return toAjax(tDebitCreditService.updateTDebitCredit(tDebitCredit));
}
/**
* 删除借贷
*/
@PreAuthorize("@ss.hasPermi('system:credit:remove')")
@Log(title = "借贷", businessType = BusinessType.DELETE)
@DeleteMapping("/{debitIds}")
public AjaxResult remove(@PathVariable Long[] debitIds)
{
return toAjax(tDebitCreditService.deleteTDebitCreditByIds(debitIds));
}
}
package com.zehong.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* 借贷对象 t_debit_credit
*
* @author zehong
* @date 2023-06-20
*/
public class TDebitCredit extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 借贷主键 */
private Long debitId;
/** 借贷部门 */
@Excel(name = "借贷部门")
private Long debitDeptId;
/** 经办人/申领人 */
@Excel(name = "经办人/申领人")
private Long operatorId;
/** 出借部门 */
@Excel(name = "出借部门")
private Long lendDeptId;
/** 登记日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "登记日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date registerTime;
/** 使用说明 */
@Excel(name = "使用说明")
private String useDescribe;
/** 使用人 */
@Excel(name = "使用人")
private Long useId;
/** 大写合计 */
@Excel(name = "大写合计")
private String capitalTotal;
/** 小写合计 */
@Excel(name = "小写合计")
private BigDecimal littleTotal;
/** 日利率 */
@Excel(name = "日利率")
private BigDecimal dayRate;
/** 计息日 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "计息日", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date sumInterestDate;
/** 预计还款日 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "预计还款日", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date expectedRepaymentDate;
/** 审核人 */
@Excel(name = "审核人")
private Long approvalId;
/** 借贷状态:0待借贷部门确认 1待核算部审核 2完成 3驳回 */
@Excel(name = "借贷状态:0待借贷部门确认 1待核算部审核 2完成 3驳回")
private String debitStatus;
/** 附件 */
@Excel(name = "附件")
private String attachmentUrl;
/** 实际还款日期 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "实际还款日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date realPaymentDate;
/** 实际还款金额 */
@Excel(name = "实际还款金额")
private Long realPaymentAcount;
/** 是否删除:0否,1是 */
@Excel(name = "是否删除:0否,1是")
private String isDel;
private String debitDeptName;
private String operatorName;
private String lendDeptName;
private String useName;
private String approvalName;
public void setDebitId(Long debitId)
{
this.debitId = debitId;
}
public Long getDebitId()
{
return debitId;
}
public void setDebitDeptId(Long debitDeptId)
{
this.debitDeptId = debitDeptId;
}
public Long getDebitDeptId()
{
return debitDeptId;
}
public void setOperatorId(Long operatorId)
{
this.operatorId = operatorId;
}
public Long getOperatorId()
{
return operatorId;
}
public void setLendDeptId(Long lendDeptId)
{
this.lendDeptId = lendDeptId;
}
public Long getLendDeptId()
{
return lendDeptId;
}
public void setRegisterTime(Date registerTime)
{
this.registerTime = registerTime;
}
public Date getRegisterTime()
{
return registerTime;
}
public void setUseDescribe(String useDescribe)
{
this.useDescribe = useDescribe;
}
public String getUseDescribe()
{
return useDescribe;
}
public void setUseId(Long useId)
{
this.useId = useId;
}
public Long getUseId()
{
return useId;
}
public void setCapitalTotal(String capitalTotal)
{
this.capitalTotal = capitalTotal;
}
public String getCapitalTotal()
{
return capitalTotal;
}
public void setLittleTotal(BigDecimal littleTotal)
{
this.littleTotal = littleTotal;
}
public BigDecimal getLittleTotal()
{
return littleTotal;
}
public void setDayRate(BigDecimal dayRate)
{
this.dayRate = dayRate;
}
public BigDecimal getDayRate()
{
return dayRate;
}
public void setSumInterestDate(Date sumInterestDate)
{
this.sumInterestDate = sumInterestDate;
}
public Date getSumInterestDate()
{
return sumInterestDate;
}
public void setExpectedRepaymentDate(Date expectedRepaymentDate)
{
this.expectedRepaymentDate = expectedRepaymentDate;
}
public Date getExpectedRepaymentDate()
{
return expectedRepaymentDate;
}
public void setApprovalId(Long approvalId)
{
this.approvalId = approvalId;
}
public Long getApprovalId()
{
return approvalId;
}
public void setDebitStatus(String debitStatus)
{
this.debitStatus = debitStatus;
}
public String getDebitStatus()
{
return debitStatus;
}
public void setAttachmentUrl(String attachmentUrl)
{
this.attachmentUrl = attachmentUrl;
}
public String getAttachmentUrl()
{
return attachmentUrl;
}
public void setRealPaymentDate(Date realPaymentDate)
{
this.realPaymentDate = realPaymentDate;
}
public Date getRealPaymentDate()
{
return realPaymentDate;
}
public void setRealPaymentAcount(Long realPaymentAcount)
{
this.realPaymentAcount = realPaymentAcount;
}
public Long getRealPaymentAcount()
{
return realPaymentAcount;
}
public void setIsDel(String isDel)
{
this.isDel = isDel;
}
public String getIsDel()
{
return isDel;
}
public String getDebitDeptName() {
return debitDeptName;
}
public void setDebitDeptName(String debitDeptName) {
this.debitDeptName = debitDeptName;
}
public String getOperatorName() {
return operatorName;
}
public void setOperatorName(String operatorName) {
this.operatorName = operatorName;
}
public String getLendDeptName() {
return lendDeptName;
}
public void setLendDeptName(String lendDeptName) {
this.lendDeptName = lendDeptName;
}
public String getUseName() {
return useName;
}
public void setUseName(String useName) {
this.useName = useName;
}
public String getApprovalName() {
return approvalName;
}
public void setApprovalName(String approvalName) {
this.approvalName = approvalName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("debitId", getDebitId())
.append("debitDeptId", getDebitDeptId())
.append("operatorId", getOperatorId())
.append("lendDeptId", getLendDeptId())
.append("registerTime", getRegisterTime())
.append("useDescribe", getUseDescribe())
.append("useId", getUseId())
.append("capitalTotal", getCapitalTotal())
.append("littleTotal", getLittleTotal())
.append("dayRate", getDayRate())
.append("sumInterestDate", getSumInterestDate())
.append("expectedRepaymentDate", getExpectedRepaymentDate())
.append("approvalId", getApprovalId())
.append("debitStatus", getDebitStatus())
.append("attachmentUrl", getAttachmentUrl())
.append("realPaymentDate", getRealPaymentDate())
.append("realPaymentAcount", getRealPaymentAcount())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("isDel", getIsDel())
.append("remark", getRemark())
.toString();
}
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.TDebitCredit;
/**
* 借贷Mapper接口
*
* @author zehong
* @date 2023-06-20
*/
public interface TDebitCreditMapper
{
/**
* 查询借贷
*
* @param debitId 借贷ID
* @return 借贷
*/
public TDebitCredit selectTDebitCreditById(Long debitId);
/**
* 查询借贷列表
*
* @param tDebitCredit 借贷
* @return 借贷集合
*/
public List<TDebitCredit> selectTDebitCreditList(TDebitCredit tDebitCredit);
/**
* 新增借贷
*
* @param tDebitCredit 借贷
* @return 结果
*/
public int insertTDebitCredit(TDebitCredit tDebitCredit);
/**
* 修改借贷
*
* @param tDebitCredit 借贷
* @return 结果
*/
public int updateTDebitCredit(TDebitCredit tDebitCredit);
/**
* 删除借贷
*
* @param debitId 借贷ID
* @return 结果
*/
public int deleteTDebitCreditById(Long debitId);
/**
* 批量删除借贷
*
* @param debitIds 需要删除的数据ID
* @return 结果
*/
public int deleteTDebitCreditByIds(Long[] debitIds);
}
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.TDebitCredit;
/**
* 借贷Service接口
*
* @author zehong
* @date 2023-06-20
*/
public interface ITDebitCreditService
{
/**
* 查询借贷
*
* @param debitId 借贷ID
* @return 借贷
*/
public TDebitCredit selectTDebitCreditById(Long debitId);
/**
* 查询借贷列表
*
* @param tDebitCredit 借贷
* @return 借贷集合
*/
public List<TDebitCredit> selectTDebitCreditList(TDebitCredit tDebitCredit);
/**
* 新增借贷
*
* @param tDebitCredit 借贷
* @return 结果
*/
public int insertTDebitCredit(TDebitCredit tDebitCredit);
/**
* 修改借贷
*
* @param tDebitCredit 借贷
* @return 结果
*/
public int updateTDebitCredit(TDebitCredit tDebitCredit);
/**
* 批量删除借贷
*
* @param debitIds 需要删除的借贷ID
* @return 结果
*/
public int deleteTDebitCreditByIds(Long[] debitIds);
/**
* 删除借贷信息
*
* @param debitId 借贷ID
* @return 结果
*/
public int deleteTDebitCreditById(Long debitId);
}
package com.zehong.system.service.impl;
import java.util.List;
import com.zehong.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TDebitCreditMapper;
import com.zehong.system.domain.TDebitCredit;
import com.zehong.system.service.ITDebitCreditService;
/**
* 借贷Service业务层处理
*
* @author zehong
* @date 2023-06-20
*/
@Service
public class TDebitCreditServiceImpl implements ITDebitCreditService
{
@Autowired
private TDebitCreditMapper tDebitCreditMapper;
/**
* 查询借贷
*
* @param debitId 借贷ID
* @return 借贷
*/
@Override
public TDebitCredit selectTDebitCreditById(Long debitId)
{
return tDebitCreditMapper.selectTDebitCreditById(debitId);
}
/**
* 查询借贷列表
*
* @param tDebitCredit 借贷
* @return 借贷
*/
@Override
public List<TDebitCredit> selectTDebitCreditList(TDebitCredit tDebitCredit)
{
return tDebitCreditMapper.selectTDebitCreditList(tDebitCredit);
}
/**
* 新增借贷
*
* @param tDebitCredit 借贷
* @return 结果
*/
@Override
public int insertTDebitCredit(TDebitCredit tDebitCredit)
{
tDebitCredit.setCreateTime(DateUtils.getNowDate());
return tDebitCreditMapper.insertTDebitCredit(tDebitCredit);
}
/**
* 修改借贷
*
* @param tDebitCredit 借贷
* @return 结果
*/
@Override
public int updateTDebitCredit(TDebitCredit tDebitCredit)
{
tDebitCredit.setUpdateTime(DateUtils.getNowDate());
return tDebitCreditMapper.updateTDebitCredit(tDebitCredit);
}
/**
* 批量删除借贷
*
* @param debitIds 需要删除的借贷ID
* @return 结果
*/
@Override
public int deleteTDebitCreditByIds(Long[] debitIds)
{
return tDebitCreditMapper.deleteTDebitCreditByIds(debitIds);
}
/**
* 删除借贷信息
*
* @param debitId 借贷ID
* @return 结果
*/
@Override
public int deleteTDebitCreditById(Long debitId)
{
return tDebitCreditMapper.deleteTDebitCreditById(debitId);
}
}
<?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.zehong.system.mapper.TDebitCreditMapper">
<resultMap type="TDebitCredit" id="TDebitCreditResult">
<result property="debitId" column="debit_id" />
<result property="debitDeptId" column="debit_dept_id" />
<result property="operatorId" column="operator_id" />
<result property="lendDeptId" column="lend_dept_id" />
<result property="registerTime" column="register_time" />
<result property="useDescribe" column="use_describe" />
<result property="useId" column="use_id" />
<result property="capitalTotal" column="capital_total" />
<result property="littleTotal" column="little_total" />
<result property="dayRate" column="day_rate" />
<result property="sumInterestDate" column="sum_interest_date" />
<result property="expectedRepaymentDate" column="expected_repayment_date" />
<result property="approvalId" column="approval_id" />
<result property="debitStatus" column="debit_status" />
<result property="attachmentUrl" column="attachment_url" />
<result property="realPaymentDate" column="real_payment_date" />
<result property="realPaymentAcount" column="real_payment_acount" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="isDel" column="is_del" />
<result property="remark" column="remark" />
<result property="debitDeptName" column="debit_dept_name" />
<result property="operatorName" column="operator_name" />
<result property="lendDeptName" column="lend_dept_name" />
<result property="useName" column="use_name" />
<result property="approvalName" column="approval_name" />
</resultMap>
<sql id="selectTDebitCreditVo">
SELECT
debit_id,
debit_dept_id,
operator_id,
lend_dept_id,
register_time,
use_describe,
use_id,
capital_total,
little_total,
day_rate,
sum_interest_date,
expected_repayment_date,
approval_id,
debit_status,
attachment_url,
real_payment_date,
real_payment_acount,
create_time,
update_time,
is_del,
remark,
(SELECT dept_name FROM sys_dept WHERE dept_id = debit_dept_id) AS debit_dept_name,
(SELECT nick_name FROM sys_user WHERE user_id = operator_id) AS operator_name,
(SELECT dept_name FROM sys_dept WHERE dept_id = lend_dept_id) AS lend_dept_name,
(SELECT nick_name FROM sys_user WHERE user_id = use_id) AS use_name,
(SELECT nick_name FROM sys_user WHERE user_id = approval_id) AS approval_name
FROM
t_debit_credit
</sql>
<select id="selectTDebitCreditList" parameterType="TDebitCredit" resultMap="TDebitCreditResult">
<include refid="selectTDebitCreditVo"/>
<where>
<if test="debitDeptId != null "> and debit_dept_id = #{debitDeptId}</if>
<if test="operatorId != null "> and operator_id = #{operatorId}</if>
<if test="lendDeptId != null "> and lend_dept_id = #{lendDeptId}</if>
<if test="registerTime != null "> and register_time = #{registerTime}</if>
<if test="useDescribe != null and useDescribe != ''"> and use_describe = #{useDescribe}</if>
<if test="useId != null "> and use_id = #{useId}</if>
<if test="capitalTotal != null "> and capital_total = #{capitalTotal}</if>
<if test="littleTotal != null "> and little_total = #{littleTotal}</if>
<if test="dayRate != null "> and day_rate = #{dayRate}</if>
<if test="sumInterestDate != null "> and sum_interest_date = #{sumInterestDate}</if>
<if test="expectedRepaymentDate != null "> and expected_repayment_date = #{expectedRepaymentDate}</if>
<if test="approvalId != null "> and approval_id = #{approvalId}</if>
<if test="debitStatus != null and debitStatus != ''"> and debit_status = #{debitStatus}</if>
<if test="attachmentUrl != null and attachmentUrl != ''"> and attachment_url = #{attachmentUrl}</if>
<if test="realPaymentDate != null "> and real_payment_date = #{realPaymentDate}</if>
<if test="realPaymentAcount != null "> and real_payment_acount = #{realPaymentAcount}</if>
<if test="isDel != null and isDel != ''"> and is_del = #{isDel}</if>
</where>
</select>
<select id="selectTDebitCreditById" parameterType="Long" resultMap="TDebitCreditResult">
<include refid="selectTDebitCreditVo"/>
where debit_id = #{debitId}
</select>
<insert id="insertTDebitCredit" parameterType="TDebitCredit" useGeneratedKeys="true" keyProperty="debitId">
insert into t_debit_credit
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="debitDeptId != null">debit_dept_id,</if>
<if test="operatorId != null">operator_id,</if>
<if test="lendDeptId != null">lend_dept_id,</if>
<if test="registerTime != null">register_time,</if>
<if test="useDescribe != null">use_describe,</if>
<if test="useId != null">use_id,</if>
<if test="capitalTotal != null">capital_total,</if>
<if test="littleTotal != null">little_total,</if>
<if test="dayRate != null">day_rate,</if>
<if test="sumInterestDate != null">sum_interest_date,</if>
<if test="expectedRepaymentDate != null">expected_repayment_date,</if>
<if test="approvalId != null">approval_id,</if>
<if test="debitStatus != null">debit_status,</if>
<if test="attachmentUrl != null">attachment_url,</if>
<if test="realPaymentDate != null">real_payment_date,</if>
<if test="realPaymentAcount != null">real_payment_acount,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="isDel != null">is_del,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="debitDeptId != null">#{debitDeptId},</if>
<if test="operatorId != null">#{operatorId},</if>
<if test="lendDeptId != null">#{lendDeptId},</if>
<if test="registerTime != null">#{registerTime},</if>
<if test="useDescribe != null">#{useDescribe},</if>
<if test="useId != null">#{useId},</if>
<if test="capitalTotal != null">#{capitalTotal},</if>
<if test="littleTotal != null">#{littleTotal},</if>
<if test="dayRate != null">#{dayRate},</if>
<if test="sumInterestDate != null">#{sumInterestDate},</if>
<if test="expectedRepaymentDate != null">#{expectedRepaymentDate},</if>
<if test="approvalId != null">#{approvalId},</if>
<if test="debitStatus != null">#{debitStatus},</if>
<if test="attachmentUrl != null">#{attachmentUrl},</if>
<if test="realPaymentDate != null">#{realPaymentDate},</if>
<if test="realPaymentAcount != null">#{realPaymentAcount},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="isDel != null">#{isDel},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateTDebitCredit" parameterType="TDebitCredit">
update t_debit_credit
<trim prefix="SET" suffixOverrides=",">
<if test="debitDeptId != null">debit_dept_id = #{debitDeptId},</if>
<if test="operatorId != null">operator_id = #{operatorId},</if>
<if test="lendDeptId != null">lend_dept_id = #{lendDeptId},</if>
<if test="registerTime != null">register_time = #{registerTime},</if>
<if test="useDescribe != null">use_describe = #{useDescribe},</if>
<if test="useId != null">use_id = #{useId},</if>
<if test="capitalTotal != null">capital_total = #{capitalTotal},</if>
<if test="littleTotal != null">little_total = #{littleTotal},</if>
<if test="dayRate != null">day_rate = #{dayRate},</if>
<if test="sumInterestDate != null">sum_interest_date = #{sumInterestDate},</if>
<if test="expectedRepaymentDate != null">expected_repayment_date = #{expectedRepaymentDate},</if>
<if test="approvalId != null">approval_id = #{approvalId},</if>
<if test="debitStatus != null">debit_status = #{debitStatus},</if>
<if test="attachmentUrl != null">attachment_url = #{attachmentUrl},</if>
<if test="realPaymentDate != null">real_payment_date = #{realPaymentDate},</if>
<if test="realPaymentAcount != null">real_payment_acount = #{realPaymentAcount},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where debit_id = #{debitId}
</update>
<delete id="deleteTDebitCreditById" parameterType="Long">
delete from t_debit_credit where debit_id = #{debitId}
</delete>
<delete id="deleteTDebitCreditByIds" parameterType="String">
delete from t_debit_credit where debit_id in
<foreach item="debitId" collection="array" open="(" separator="," close=")">
#{debitId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
import request from '@/utils/request'
// 查询借贷列表
export function listCredit(query) {
return request({
url: '/debit/credit/list',
method: 'get',
params: query
})
}
// 查询借贷详细
export function getCredit(debitId) {
return request({
url: '/debit/credit/' + debitId,
method: 'get'
})
}
// 新增借贷
export function addCredit(data) {
return request({
url: '/debit/credit',
method: 'post',
data: data
})
}
// 修改借贷
export function updateCredit(data) {
return request({
url: '/debit/credit',
method: 'put',
data: data
})
}
// 删除借贷
export function delCredit(debitId) {
return request({
url: '/debit/credit/' + debitId,
method: 'delete'
})
}
// 导出借贷
export function exportCredit(query) {
return request({
url: '/debit/credit/export',
method: 'get',
params: query
})
}
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="借贷部门" prop="debitDeptId">
<el-input
v-model="queryParams.debitDeptId"
placeholder="请输入借贷部门"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="出借部门" prop="lendDeptId">
<el-input
v-model="queryParams.lendDeptId"
placeholder="请输入出借部门"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="登记日期" prop="registerTime">
<el-date-picker clearable size="small"
v-model="queryParams.registerTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择登记日期">
</el-date-picker>
</el-form-item>
<el-form-item label="使用人" prop="useId">
<el-input
v-model="queryParams.useId"
placeholder="请输入使用人"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="借贷状态" prop="debitStatus">
<el-select v-model="queryParams.debitStatus" placeholder="请选择借贷状态" clearable size="small">
<el-option label="请选择字典生成" 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="['system:credit: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="['system:credit: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="['system:credit:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
:loading="exportLoading"
@click="handleExport"
v-hasPermi="['system:credit:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="creditList">
<el-table-column label="借贷部门" align="center" prop="debitDeptName" :show-overflow-tooltip="true" width="150"/>
<el-table-column label="经办人" align="center" prop="operatorName" />
<el-table-column label="出借部门" align="center" prop="lendDeptName" :show-overflow-tooltip="true" width="150"/>
<el-table-column label="登记日期" align="center" prop="registerTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.registerTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="使用说明" align="center" prop="useDescribe" />
<el-table-column label="使用人" align="center" prop="useName" />
<el-table-column label="小写合计" align="center" prop="littleTotal" />
<el-table-column label="计息日" align="center" prop="sumInterestDate" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.sumInterestDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="预计还款日" align="center" prop="expectedRepaymentDate" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.expectedRepaymentDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
<template slot-scope="scope">
<!-- <el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:credit:edit']"
>修改</el-button>-->
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:credit:remove']"
v-if="(scope.row.debitStatus == '0' || scope.row.debitStatus == '3') && scope.row.operatorId == $store.state.user.userId"
>删除</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="800px" append-to-body :close-on-click-modal="false" destroy-on-close>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-row>
<el-col :span="12">
<el-form-item label="出借部门" prop="lendDeptId">
<treeselect
v-model="form.lendDeptId"
:options="formDeptOptions"
:show-count="true"
placeholder="请输入出借部门"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="使用人" prop="useId">
<el-select v-model="form.useId" placeholder="请选择使用人" style="width: 100%">
<el-option v-for="item in usersList"
:key="item.userId"
:label="item.nickName"
:value="item.userId"/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="使用说明" prop="useDescribe">
<el-input v-model="form.useDescribe" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="小写合计" prop="littleTotal">
<el-input v-model="form.littleTotal" placeholder="请输入小写合计(精确到分)" @blur="getCapitalTotal"
oninput="value=value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="大写合计" prop="capitalTotal">
<el-input v-model="form.capitalTotal" placeholder="请输入大写合计" disabled/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="计息日" prop="sumInterestDate">
<el-date-picker clearable size="small"
v-model="form.sumInterestDate"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择计息日"
style="width: 100%">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="预计还款日" prop="expectedRepaymentDate">
<el-date-picker clearable size="small"
v-model="form.expectedRepaymentDate"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择预计还款日"
style="width: 100%">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="附件" prop="attachmentUrl">
<FileUpload
listType="picture"
@resFun="getFileInfo"
@remove="listRemove"
:fileArr="fileList"
:fileSize="500"
:fileType="['png','jpg','jpeg','mp4','doc','xls','ppt','txt','pdf',]"/>
<el-input v-show="false" disabled v-model="form.attachmentUrl"></el-input>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer" style="text-align: center">
<el-button style="width: 150px; border-color: #1890ff; color: #1890ff" @click="reset">内容重置</el-button>
<el-button type="primary" style="width: 150px" @click="submitForm">提交申请</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listCredit, getCredit, delCredit, addCredit, updateCredit, exportCredit } from "@/api/debit/credit";
import FileUpload from "@/components/FileUpload";
import uploadfile from "@/assets/uploadfile.png";
import { selectTransactorByDeptId } from "@/api/system/user";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
name: "Credit",
components: {
Treeselect,
FileUpload
},
data() {
let validateExpectedRepaymentDate = (rule, value, callback) => {
if (this.form.expectedRepaymentDate > this.form.sumInterestDate) {
callback()
} else {
callback(
new Error("预计还款日期不能小于计息日!")
)
}
}
return {
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 借贷表格数据
creditList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
debitDeptId: null,
operatorId: null,
lendDeptId: null,
registerTime: null,
useDescribe: null,
useId: null,
capitalTotal: null,
littleTotal: null,
dayRate: null,
sumInterestDate: null,
expectedRepaymentDate: null,
approvalId: null,
debitStatus: null,
attachmentUrl: null,
realPaymentDate: null,
realPaymentAcount: null,
isDel: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
lendDeptId: [
{ required: true, message: "请选择出借部门", trigger: "change" },
],
operatorId: [
{ required: true, message: "请选择使用人", trigger: "change" },
],
useDescribe: [
{ required: true, message: "请输入使用说明", trigger: "blur" },
],
littleTotal: [
{ required: true, message: "请输入小写合计", trigger: "blur" },
],
sumInterestDate: [
{ required: true, message: "请选择计息日期", trigger: "change" },
],
expectedRepaymentDate: [
{ required: true, message: "请选择预计还款日期", trigger: "change" },
{ validator: validateExpectedRepaymentDate, trigger: 'change' }
],
},
fileList: [],
usersList: [],
formDeptOptions: [],
};
},
created() {
this.getList();
//获取使用人
this.getUsers();
//获取部门
this.getTreeselect();
},
methods: {
/** 查询借贷列表 */
getList() {
this.loading = true;
listCredit(this.queryParams).then(response => {
this.creditList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
debitId: null,
debitDeptId: null,
operatorId: null,
lendDeptId: null,
registerTime: null,
useDescribe: null,
useId: null,
capitalTotal: null,
littleTotal: null,
dayRate: null,
sumInterestDate: null,
expectedRepaymentDate: null,
approvalId: null,
debitStatus: "0",
attachmentUrl: null,
realPaymentDate: null,
realPaymentAcount: null,
createTime: null,
updateTime: null,
isDel: null,
remark: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.debitId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加借贷";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const debitId = row.debitId || this.ids
getCredit(debitId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改借贷";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.debitId != null) {
updateCredit(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
this.form.debitDeptId = this.$store.state.user.deptId;
this.form.operatorId = this.$store.state.user.userId;
this.form.dayRate = 0.08/360;
addCredit(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const debitIds = row.debitId || this.ids;
this.$confirm('是否确认删除借贷编号为"' + debitIds + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delCredit(debitIds);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有借贷数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true;
return exportCredit(queryParams);
}).then(response => {
this.download(response.msg);
this.exportLoading = false;
}).catch(() => {});
},
getCapitalTotal(){
this.form.capitalTotal = this.smallToBig(this.form.littleTotal);
},
//小写转大写
smallToBig(money) {
// 汉字的数字
const cnNums = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];
// 基本单位
const cnIntRadice = ["", "拾", "佰", "仟"];
// 对应整数部分扩展单位
const cnIntUnits = ["", "万", "亿", "兆"];
// 对应小数部分单位
const cnDecUnits = ["角", "分"];
// 整数金额时后面跟的字符
const cnInteger = "整";
// 整型完以后的单位
const cnIntLast = "元";
// 最大处理的数字
const maxNum = 9999999999999999.99;
// 金额整数部分
let integerNum;
// 金额小数部分
let decimalNum;
// 输出的中文金额字符串
let chineseStr = "";
// 分离金额后用的数组,预定义
let parts;
if (money === "") {
return "";
}
money = parseFloat(money);
if (money >= maxNum) {
// 超出最大处理数字
return "";
}
if (money === 0) {
chineseStr = cnNums[0] + cnIntLast + cnInteger;
return chineseStr;
}
// 转换为字符串
money = money.toString();
if (money.indexOf(".") === -1) {
integerNum = money;
decimalNum = "";
} else {
parts = money.split(".");
integerNum = parts[0];
decimalNum = parts[1].substr(0, 4);
}
// 获取整型部分转换
if (parseInt(integerNum, 10) > 0) {
let zeroCount = 0;
const IntLen = integerNum.length;
for (let i = 0; i < IntLen; i++) {
const n = integerNum.substr(i, 1);
const p = IntLen - i - 1;
const q = p / 4;
const m = p % 4;
if (n === "0") {
zeroCount++;
} else {
if (zeroCount > 0) {
chineseStr += cnNums[0];
}
// 归零
zeroCount = 0;
//alert(cnNums[parseInt(n)])
chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
}
if (m === 0 && zeroCount < 4) {
chineseStr += cnIntUnits[q];
}
}
chineseStr += cnIntLast;
}
// 小数部分
if (decimalNum !== "") {
const decLen = decimalNum.length;
for (let i = 0; i < decLen; i++) {
const n = decimalNum.substr(i, 1);
if (n !== "0") {
chineseStr += cnNums[Number(n)] + cnDecUnits[i];
}
}
}
if (chineseStr === "") {
chineseStr += cnNums[0] + cnIntLast + cnInteger;
} else if (decimalNum === "") {
chineseStr += cnInteger;
}
return chineseStr;
},
getFileInfo(res) {
this.form.attachmentUrl = res.url;
this.fileList = [
{
name: res.fileName,
url: uploadfile,
},
];
},
listRemove(e) {
this.fileList = [];
this.form.attachmentUrl = "";
},
getUsers() {
this.form.userId = null;
selectTransactorByDeptId({ deptId: this.$store.state.user.deptId }).then((res) => {
this.usersList = res.data;
});
},
/** 查询部门下拉树结构 */
getTreeselect() {
treeselect().then((response) => {
this.formDeptOptions = response.data;
// 申请服务时买方不能选自己部门
var items = this.formDeptOptions[0].children;
var result = [];
var j=0;
for(var i=0; i<items.length; i++){
if(items[i].id != this.$store.state.user.deptId){
result[j] = items[i];
j++;
}
}
this.formDeptOptions[0].children = result;
});
},
}
};
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment