提交生成合同
This commit is contained in:
parent
8b93c763c3
commit
626d6424f0
3
pom.xml
3
pom.xml
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.ruoyi</groupId>
|
||||
|
Binary file not shown.
@ -119,18 +119,6 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- itextpdf-->
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>kernel</artifactId>
|
||||
<version>7.1.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>layout</artifactId>
|
||||
<version>7.1.12</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -3,7 +3,6 @@ package com.ruoyi.web.controller.common;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.model.Contract;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
@ -13,7 +12,6 @@ import org.slf4j.LoggerFactory;
|
||||
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.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
@ -3,7 +3,6 @@ package com.ruoyi.web.controller.custom;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.model.Contract;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
@ -13,7 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 合同Controller
|
||||
@ -92,27 +93,35 @@ public class SysContractController extends BaseController {
|
||||
|
||||
@GetMapping("/file/{id}")
|
||||
public AjaxResult getfile(@PathVariable long id) {
|
||||
try {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// ajax.put("url", "/login");
|
||||
ajax.put("data", id);
|
||||
return ajax;
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
SysContract contract = sysContractService.selectSysContractById(id);
|
||||
if (contract.getPath() != null) {
|
||||
ajax.put("url", contract.getPath());
|
||||
} else {
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("name", contract.getName());
|
||||
data.put("amount", contract.getAmount().toString());
|
||||
data.put("serveTime", contract.getServeTime().toString());
|
||||
ajax.put("data", data);
|
||||
}
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合同签单
|
||||
*/
|
||||
@PostMapping("/sign")
|
||||
public AjaxResult signContract(@RequestBody Contract contract) throws Exception {
|
||||
try {
|
||||
public AjaxResult signContract(@RequestBody SysContract sysContract) {
|
||||
sysContract.setStatus(1);
|
||||
String path = "/file/" + sysContract.getId() + ".pdf";
|
||||
sysContract.setPath(path);
|
||||
int count = sysContractService.updateSysContract(sysContract);
|
||||
if (count > 0) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("result", "hi");
|
||||
ajax.put("url", path);
|
||||
return ajax;
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
} else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
package com.ruoyi.common.core.domain.model;
|
||||
|
||||
public class Contract {
|
||||
|
||||
private String name;
|
||||
|
||||
private String phone;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
}
|
||||
|
@ -23,5 +23,23 @@
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- itextpdf-->
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>io</artifactId>
|
||||
<version>7.1.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>kernel</artifactId>
|
||||
<version>7.1.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.5.13.2</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
@ -1,10 +1,11 @@
|
||||
package com.ruoyi.custom.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
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;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 合同对象 sys_contract
|
||||
@ -12,87 +13,128 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
||||
* @author wonder
|
||||
* @date 2020-10-23
|
||||
*/
|
||||
public class SysContract extends BaseEntity
|
||||
{
|
||||
public class SysContract extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 合同编号 */
|
||||
/**
|
||||
* 合同编号
|
||||
*/
|
||||
@Excel(name = "合同编号")
|
||||
private Long id;
|
||||
|
||||
/** 客户姓名 */
|
||||
/**
|
||||
* 客户姓名
|
||||
*/
|
||||
@Excel(name = "客户姓名")
|
||||
private String name;
|
||||
|
||||
/** 电话 */
|
||||
/**
|
||||
* 客户身份证
|
||||
*/
|
||||
private String cusId;
|
||||
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
@Excel(name = "电话")
|
||||
private String phone;
|
||||
|
||||
/** 服务时间 */
|
||||
/**
|
||||
* 服务时间
|
||||
*/
|
||||
@Excel(name = "服务时间")
|
||||
private Integer serveTime;
|
||||
|
||||
/** 金额 */
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
@Excel(name = "金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
/** 文件路径 */
|
||||
private String amountUpper;
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
@Excel(name = "文件路径")
|
||||
private String path;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
/**
|
||||
* 合同状态
|
||||
* 0-未签订;1-已签订
|
||||
*/
|
||||
private int Status;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
public void setPhone(String phone)
|
||||
{
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getPhone()
|
||||
{
|
||||
return phone;
|
||||
public Integer getServeTime() {
|
||||
return serveTime;
|
||||
}
|
||||
public void setServeTime(Integer serveTime)
|
||||
{
|
||||
|
||||
public void setServeTime(Integer serveTime) {
|
||||
this.serveTime = serveTime;
|
||||
}
|
||||
|
||||
public Integer getServeTime()
|
||||
{
|
||||
return serveTime;
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
public void setAmount(BigDecimal amount)
|
||||
{
|
||||
|
||||
public String getAmountUpper() {
|
||||
return amountUpper;
|
||||
}
|
||||
|
||||
public void setAmountUpper(String amountUpper) {
|
||||
this.amountUpper = amountUpper;
|
||||
}
|
||||
|
||||
public void setAmount(BigDecimal amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount()
|
||||
{
|
||||
return amount;
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
public void setPath(String path)
|
||||
{
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
public int getStatus() {
|
||||
return Status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
Status = status;
|
||||
}
|
||||
|
||||
public String getCusId() {
|
||||
return cusId;
|
||||
}
|
||||
|
||||
public void setCusId(String cusId) {
|
||||
this.cusId = cusId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,6 +142,8 @@ public class SysContract extends BaseEntity
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("name", getName())
|
||||
.append("cusId", getCusId())
|
||||
.append("status", getStatus())
|
||||
.append("phone", getPhone())
|
||||
.append("serveTime", getServeTime())
|
||||
.append("amount", getAmount())
|
||||
|
@ -58,4 +58,6 @@ public interface ISysContractService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysContractById(Long id);
|
||||
|
||||
public int signContract(SysContract sysContract);
|
||||
}
|
||||
|
@ -1,12 +1,21 @@
|
||||
package com.ruoyi.custom.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.pdf.*;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.custom.domain.SysContract;
|
||||
import com.ruoyi.custom.mapper.SysContractMapper;
|
||||
import com.ruoyi.custom.service.ISysContractService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.custom.mapper.SysContractMapper;
|
||||
import com.ruoyi.custom.domain.SysContract;
|
||||
import com.ruoyi.custom.service.ISysContractService;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 合同Service业务层处理
|
||||
@ -15,8 +24,7 @@ import com.ruoyi.custom.service.ISysContractService;
|
||||
* @date 2020-10-23
|
||||
*/
|
||||
@Service
|
||||
public class SysContractServiceImpl implements ISysContractService
|
||||
{
|
||||
public class SysContractServiceImpl implements ISysContractService {
|
||||
@Autowired
|
||||
private SysContractMapper sysContractMapper;
|
||||
|
||||
@ -27,8 +35,7 @@ public class SysContractServiceImpl implements ISysContractService
|
||||
* @return 合同
|
||||
*/
|
||||
@Override
|
||||
public SysContract selectSysContractById(Long id)
|
||||
{
|
||||
public SysContract selectSysContractById(Long id) {
|
||||
return sysContractMapper.selectSysContractById(id);
|
||||
}
|
||||
|
||||
@ -39,8 +46,7 @@ public class SysContractServiceImpl implements ISysContractService
|
||||
* @return 合同
|
||||
*/
|
||||
@Override
|
||||
public List<SysContract> selectSysContractList(SysContract sysContract)
|
||||
{
|
||||
public List<SysContract> selectSysContractList(SysContract sysContract) {
|
||||
return sysContractMapper.selectSysContractList(sysContract);
|
||||
}
|
||||
|
||||
@ -51,8 +57,8 @@ public class SysContractServiceImpl implements ISysContractService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysContract(SysContract sysContract)
|
||||
{
|
||||
public int insertSysContract(SysContract sysContract) {
|
||||
sysContract.setId(DateUtils.getNowDate().getTime());
|
||||
sysContract.setCreateTime(DateUtils.getNowDate());
|
||||
return sysContractMapper.insertSysContract(sysContract);
|
||||
}
|
||||
@ -64,8 +70,7 @@ public class SysContractServiceImpl implements ISysContractService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysContract(SysContract sysContract)
|
||||
{
|
||||
public int updateSysContract(SysContract sysContract) {
|
||||
sysContract.setUpdateTime(DateUtils.getNowDate());
|
||||
return sysContractMapper.updateSysContract(sysContract);
|
||||
}
|
||||
@ -77,8 +82,7 @@ public class SysContractServiceImpl implements ISysContractService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysContractByIds(Long[] ids)
|
||||
{
|
||||
public int deleteSysContractByIds(Long[] ids) {
|
||||
return sysContractMapper.deleteSysContractByIds(ids);
|
||||
}
|
||||
|
||||
@ -89,8 +93,55 @@ public class SysContractServiceImpl implements ISysContractService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysContractById(Long id)
|
||||
{
|
||||
public int deleteSysContractById(Long id) {
|
||||
return sysContractMapper.deleteSysContractById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int signContract(SysContract sysContract) {
|
||||
String templatePath = "/Users/wonder/Documents/Workspaces/java/RuoYi-Vue/running/pdf/contract.pdf";
|
||||
String filePath = "/Users/wonder/Documents/Workspaces/java/RuoYi-Vue/running" + sysContract.getPath();
|
||||
PdfReader reader;
|
||||
FileOutputStream out;
|
||||
ByteArrayOutputStream bos;
|
||||
PdfStamper stamper;
|
||||
|
||||
try {
|
||||
out = new FileOutputStream(filePath);// 输出流到新的pdf,没有b2.pdf时会创建
|
||||
reader = new PdfReader(templatePath);// 读取pdf模板
|
||||
bos = new ByteArrayOutputStream();
|
||||
stamper = new PdfStamper(reader, bos);
|
||||
AcroFields form = stamper.getAcroFields();
|
||||
|
||||
form.setField("name", sysContract.getName());
|
||||
form.setField("phone", sysContract.getName());
|
||||
form.setField("money", sysContract.getAmount().toString());
|
||||
form.setField("moneyUpper", sysContract.getAmountUpper());
|
||||
form.setField("date", sysContract.getName());
|
||||
form.setField("cusId", sysContract.getCusId());
|
||||
|
||||
|
||||
stamper.setFormFlattening(true);// 如果为false那么生成的PDF文件还能编辑,一定要设为true
|
||||
stamper.close();
|
||||
|
||||
Document doc = new Document();
|
||||
|
||||
PdfCopy copy = new PdfCopy(doc, out);
|
||||
doc.open();
|
||||
PdfImportedPage importPage = null;
|
||||
for (int i = 1; i <= reader.getNumberOfPages(); i++) {
|
||||
importPage = copy
|
||||
.getImportedPage(new PdfReader(bos.toByteArray()), i);
|
||||
copy.addPage(importPage);
|
||||
}
|
||||
doc.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<resultMap type="SysContract" id="SysContractResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="status" column="status" />
|
||||
<result property="name" column="name" />
|
||||
<result property="cusId" column="cus_id" />
|
||||
<result property="phone" column="phone" />
|
||||
<result property="serveTime" column="serve_time" />
|
||||
<result property="amount" column="amount" />
|
||||
@ -19,13 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysContractVo">
|
||||
select id, name, phone, serve_time, amount, path, create_by, create_time, update_by, update_time, remark from sys_contract
|
||||
select id, status, name, phone, cus_id, serve_time, amount, path, create_by, create_time, update_by, update_time, remark from sys_contract
|
||||
</sql>
|
||||
|
||||
<select id="selectSysContractList" parameterType="SysContract" resultMap="SysContractResult">
|
||||
<include refid="selectSysContractVo"/>
|
||||
<where>
|
||||
<if test="id != null "> and id = #{id}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
|
||||
</where>
|
||||
@ -39,7 +42,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<insert id="insertSysContract" parameterType="SysContract" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sys_contract
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="name != null and name != ''">name,</if>
|
||||
<if test="cusId != null and cusId != ''">cus_id,</if>
|
||||
<if test="phone != null">phone,</if>
|
||||
<if test="serveTime != null">serve_time,</if>
|
||||
<if test="amount != null">amount,</if>
|
||||
@ -51,7 +57,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
<if test="cusId != null and cusId != ''">#{cus_id},</if>
|
||||
<if test="phone != null">#{phone},</if>
|
||||
<if test="serveTime != null">#{serveTime},</if>
|
||||
<if test="amount != null">#{amount},</if>
|
||||
@ -67,7 +76,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updateSysContract" parameterType="SysContract">
|
||||
update sys_contract
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="status != null">name = #{status},</if>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="cusId != null and cusId != ''">name = #{cus_id},</if>
|
||||
<if test="phone != null">phone = #{phone},</if>
|
||||
<if test="serveTime != null">serve_time = #{serveTime},</if>
|
||||
<if test="amount != null">amount = #{amount},</if>
|
||||
|
@ -58,3 +58,11 @@ export function getFile(id) {
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function signContract(data) {
|
||||
return request({
|
||||
url: '/custom/contract/',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
handleTree,
|
||||
parseTime,
|
||||
resetForm,
|
||||
searchToParams,
|
||||
digitUppercase,
|
||||
selectDictLabel,
|
||||
selectDictLabels,
|
||||
toThousands
|
||||
@ -43,7 +43,7 @@ Vue.prototype.selectDictLabels = selectDictLabels
|
||||
Vue.prototype.download = download
|
||||
Vue.prototype.handleTree = handleTree
|
||||
Vue.prototype.toThousands = toThousands
|
||||
Vue.prototype.searchToParams = searchToParams
|
||||
Vue.prototype.digitUppercase = digitUppercase
|
||||
|
||||
Vue.prototype.msgSuccess = function (msg) {
|
||||
this.$message({showClose: true, message: msg, type: "success"});
|
||||
|
@ -49,7 +49,7 @@ router.beforeEach((to, from, next) => {
|
||||
}
|
||||
} else {
|
||||
// 没有token
|
||||
if (whiteList.indexOf(to.path) !== -1 || to.path.startsWith('/contract')) {
|
||||
if (whiteList.indexOf(to.path) !== -1 || to.path.startsWith('/file')) {
|
||||
// 在免登录白名单,直接进入
|
||||
next()
|
||||
} else {
|
||||
|
@ -125,7 +125,7 @@ export const constantRoutes = [
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/contract/:id(\\d+)',
|
||||
path: '/file/contract/:id(\\d+)',
|
||||
hidden: true,
|
||||
component: (resolve) => require(['@/views/custom/signContract'], resolve),
|
||||
meta: { title: '合同' }
|
||||
|
@ -167,13 +167,33 @@ export function toThousands(num) {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function searchToParams(paramStr) {
|
||||
if (!paramStr) {
|
||||
return {}
|
||||
export function digitUppercase(n) {
|
||||
const fraction = ['角', '分'];
|
||||
const digit = [
|
||||
'零', '壹', '贰', '叁', '肆',
|
||||
'伍', '陆', '柒', '捌', '玖'
|
||||
];
|
||||
const unit = [
|
||||
['元', '万', '亿'],
|
||||
['', '拾', '佰', '仟']
|
||||
];
|
||||
const head = n < 0 ? '欠' : '';
|
||||
n = Math.abs(n);
|
||||
let s = '';
|
||||
for (let i = 0; i < fraction.length; i++) {
|
||||
s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
|
||||
}
|
||||
return paramStr.split('&').reduce((obj, cur) => {
|
||||
const tarObj = cur.split('=');
|
||||
obj[tarObj[0]] = tarObj[1];
|
||||
return obj;
|
||||
}, {})
|
||||
s = s || '整';
|
||||
n = Math.floor(n);
|
||||
for (let i = 0; i < unit[0].length && n > 0; i++) {
|
||||
const p = '';
|
||||
for (let j = 0; j < unit[1].length && n > 0; j++) {
|
||||
p = digit[n % 10] + unit[1][j] + p;
|
||||
n = Math.floor(n / 10);
|
||||
}
|
||||
s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
|
||||
}
|
||||
return head + s.replace(/(零.)*零元/, '元')
|
||||
.replace(/(零.)+/g, '零')
|
||||
.replace(/^整$/, '零元整');
|
||||
};
|
||||
|
@ -42,7 +42,8 @@
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['custom:contract:add']"
|
||||
>新增</el-button>
|
||||
>新增
|
||||
</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
@ -79,7 +80,17 @@
|
||||
<el-table v-loading="loading" :data="contractList" @selection-change="handleSelectionChange">
|
||||
<!-- <el-table-column type="selection" width="55" align="center" />-->
|
||||
<el-table-column label="合同编号" align="center" prop="id"/>
|
||||
<el-table-column label="合同状态" align="center" prop="status">
|
||||
<template slot-scope="scope">
|
||||
<el-tag
|
||||
:type="scope.row.status ? 'success' : 'danger'"
|
||||
disable-transitions>
|
||||
{{scope.row.status ? '已签订':'未签订'}}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="客户姓名" align="center" prop="name"/>
|
||||
<el-table-column label="证件号" align="center" prop="cusId"/>
|
||||
<el-table-column label="电话" align="center" prop="phone"/>
|
||||
<el-table-column label="服务时间" align="center" prop="serveTime" :formatter="serveTimeFormat"/>
|
||||
<el-table-column label="金额" align="center" prop="amount"/>
|
||||
@ -100,7 +111,8 @@
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['custom:contract:remove']"
|
||||
>删除</el-button>
|
||||
>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -151,7 +163,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listContract, getContract, delContract, addContract, updateContract, exportContract } from "@/api/custom/contract";
|
||||
import {
|
||||
addContract,
|
||||
delContract,
|
||||
exportContract,
|
||||
getContract,
|
||||
listContract,
|
||||
updateContract
|
||||
} from "@/api/custom/contract";
|
||||
|
||||
export default {
|
||||
name: "Contract",
|
||||
@ -305,7 +324,8 @@ export default {
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
}).catch(function() {});
|
||||
}).catch(function () {
|
||||
});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
@ -318,7 +338,8 @@ export default {
|
||||
return exportContract(queryParams);
|
||||
}).then(response => {
|
||||
this.download(response.msg);
|
||||
}).catch(function() {});
|
||||
}).catch(function () {
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,37 +1,179 @@
|
||||
<template>
|
||||
<div v-if="show">
|
||||
<div v-if="show" class="sign-contract-container">
|
||||
<div class="contract-title">合同简要</div>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="姓名" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入客户姓名"/>
|
||||
<el-form-item label="服务方" style="margin: 0">
|
||||
<span>深圳市胜唐科技有限公司</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="服务费" style="margin: 0">
|
||||
<span>¥{{form.amount}}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="服务时长" style="margin: 0">
|
||||
<span>{{form.serveTime}}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="userName">
|
||||
<el-input v-model="form.userName" placeholder="请输入客户姓名"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="证件号" prop="cusId">
|
||||
<el-input v-model="form.cusId" placeholder="请输入证件号"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="电话" prop="phone">
|
||||
<el-input v-model="form.phone" placeholder="请输入电话"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-button type="primary" @click="submitForm">提交</el-button>
|
||||
<div>
|
||||
<el-checkbox v-model="read" @change="handleRadioChange" style="margin-bottom: 12px">已阅读合同相关
|
||||
</el-checkbox>
|
||||
<span class="detail" @click="dialogVisible = true">详情</span>
|
||||
</div>
|
||||
<el-button type="primary" style="width: 100%" @click="submitForm" :disabled="!read">提交签约</el-button>
|
||||
<el-dialog
|
||||
title="服务合同"
|
||||
:visible.sync="dialogVisible"
|
||||
width="90%"
|
||||
custom-class="contract_dialog"
|
||||
center>
|
||||
<div class="dialog-detail">
|
||||
<p>甲方:胜唐体控(深圳市胜唐科技有限公司)</p>
|
||||
<p>乙方:<b>{{form.name}}</b></p>
|
||||
<p>甲乙双方本着诚信合作、互惠互利的原则,依据中华人民共和国有关法律,经友好协商,现就胜唐体控减肥咨询指导服务合作相关事宣达成一致协议,以兹共同遵守。
|
||||
如果需要减脂的乙方未成年,由应由乙方法定监护人代签本合同,乙方享受同等法律权益。</p>
|
||||
<p>
|
||||
第一条甲方资质与服务保证
|
||||
<div class="line-rule">1、甲方保证是在工商部门注册、合法经营的正规公司。</div>
|
||||
<div class="line-rule">2、甲方保证为乙方提供知名体重管理专家导师全程服务。</div>
|
||||
<div class="line-rule">3、甲方保证按承诺的方式(即:靠一日三餐吃瘦、绝不使用仪器及针药、亦不服用药物等)达到双方约定效果。</div>
|
||||
<div class="line-rule">4、甲方保证全程为乙方提供本合同所承诺的服务内容。</div>
|
||||
<div class="line-rule">5、服务标准</div>
|
||||
<div style="margin-left: 24px">a、拥有体重管理专家导师亲自每天主动服务。(节假日除外)</div>
|
||||
<div style="margin-left: 24px">b、享受免费赠送营养基础知识学习,肥胖与生活习惯知识学习,享受专家亲自培训初級自我管理体重知识。</div>
|
||||
</p>
|
||||
|
||||
<p>第二条 合作内容及费用
|
||||
<div class="line-rule">11、经甲乙双方协商确定,乙方向甲方购买<b>{{form.serveTime}}</b>“胜唐体控瘦身指导服务”(以下简称服务)。</div>
|
||||
<div class="line-rule">12、乙方向甲方购买<b>{{form.serveTime}}</b>,经甲乙双方协商确定,乙方向甲方支付疗程费用共为人民币:<b>{{form.amount}}</b>元,大写:<b>{{form.amountUppercase}}</b>)。
|
||||
</div>
|
||||
</p>
|
||||
|
||||
<p>第三条 服务期约定
|
||||
<div class="line-rule">1、服务时间阶段(服务指导期、服务跟踪期、免费咨询期)具体安排,由甲方根据乙方的实际情况与乙方协商确定。</div>
|
||||
<div class="line-rule">2、因不可抗拒的因素(如意外怀孕等)而暂停服务指导,其后续服务期限由甲乙方协商确定。</div>
|
||||
<div class="line-rule">3、减肥需要双方的配合,在不是甲方技术问题的情况下,乙方不执行营养师的指导导致没有达到预期效果,责任由乙方承担。根据个人体质不同,在调理营养健康的前提下,健康吃瘦25-35斤
|
||||
</div>
|
||||
<div class="line-rule">
|
||||
4、乙方应按甲方制定的饮食方案来饮食,承诺在未与甲方沟通前,不擅自吃方案之外的高热量、高油、高盐、高糖等不利于健康和减脂的饮食,服务期内擅自暴食导致体重上涨,次数超过3次视为乙方主动放弃营养减脂,且甲方无需免费延长服务时间。
|
||||
</div>
|
||||
<div class="line-rule">
|
||||
5、乙方在一个疗程内享有2次暂停服务的机会,在暂停前应与甲方沟通,确认暂停前已减重斤数,累积到总减重结果中。在暂停结束后,从新体重开始,甲方服务乙方继续完成承诺的减重斤数,即:包瘦斤数 - 暂停前已成功减重数。
|
||||
</div>
|
||||
</p>
|
||||
|
||||
<p>公司地址:深圳市宝安区西乡街道宝立方中心创意研发大厦B座708</p>
|
||||
<p>联系电话:0755-23213903</p>
|
||||
</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="handleConfirm">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {getFile} from "@/api/custom/contract";
|
||||
import {getFile, signContract} from "@/api/custom/contract";
|
||||
import {digitUppercase} from "../../../utils/ruoyi";
|
||||
|
||||
export default {
|
||||
name: 'sign',
|
||||
data() {
|
||||
|
||||
const checkUserName = (rule, value, callback) => {
|
||||
if (!value) {
|
||||
return callback(new Error('姓名不能为空'))
|
||||
}
|
||||
if(value !== this.form.name){
|
||||
return callback(new Error('输入姓名不匹配,请联系客服核对'))
|
||||
}
|
||||
callback();
|
||||
}
|
||||
|
||||
const checkPhone = (rule, value, callback) => {
|
||||
const phoneReg = /^1[3|4|5|7|8][0-9]{9}$/
|
||||
if (!value) {
|
||||
return callback(new Error('电话号码不能为空'))
|
||||
}
|
||||
setTimeout(() => {
|
||||
// Number.isInteger是es6验证数字是否为整数的方法,实际输入的数字总是识别成字符串
|
||||
// 所以在前面加了一个+实现隐式转换
|
||||
if (!Number.isInteger(+value)) {
|
||||
callback(new Error('请输入数字值'))
|
||||
} else {
|
||||
if (phoneReg.test(value)) {
|
||||
callback()
|
||||
} else {
|
||||
callback(new Error('电话号码格式不正确'))
|
||||
}
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
|
||||
const checkcusId = (rule, value, callback) => {
|
||||
const phoneReg = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/
|
||||
if (!value) {
|
||||
return callback(new Error('证件号码不能为空'))
|
||||
}
|
||||
setTimeout(() => {
|
||||
// Number.isInteger是es6验证数字是否为整数的方法,实际输入的数字总是识别成字符串
|
||||
// 所以在前面加了一个+实现隐式转换
|
||||
if (!Number.isInteger(+value)) {
|
||||
callback(new Error('请输入数字值'))
|
||||
} else {
|
||||
if (phoneReg.test(value)) {
|
||||
callback()
|
||||
} else {
|
||||
callback(new Error('证件号码格式不正确'))
|
||||
}
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
|
||||
return {
|
||||
show: false,
|
||||
form: {},
|
||||
read: false,
|
||||
dialogVisible: false,
|
||||
serveTimeIdOption: [
|
||||
{label: '7天', value: 7},
|
||||
{label: '1个月', value: 30},
|
||||
{label: '2个月', value: 60},
|
||||
{label: '3个月', value: 90},
|
||||
{label: '4个月', value: 120},
|
||||
{label: '5个月', value: 150},
|
||||
{label: '6个月', value: 180},
|
||||
{label: '7个月', value: 210},
|
||||
{label: '8个月', value: 240},
|
||||
{label: '9个月', value: 270},
|
||||
{label: '10个月', value: 300},
|
||||
{label: '11个月', value: 330},
|
||||
{label: '12个月', value: 360},
|
||||
],
|
||||
rules: {
|
||||
name: [
|
||||
{required: true, message: "姓名不能为空", trigger: "blur"}
|
||||
userName: [
|
||||
{required: true, trigger: "blur", validator: checkUserName}
|
||||
],
|
||||
phone: [
|
||||
{required: true, message: "电话不能为空", trigger: "blur"}
|
||||
{required: true, trigger: "blur", validator: checkPhone}
|
||||
],
|
||||
cusId: [
|
||||
{required: true, trigger: "blur", validator: checkcusId}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
document.title = this.$route.meta.title
|
||||
},
|
||||
created() {
|
||||
this.getContract();
|
||||
},
|
||||
@ -39,11 +181,15 @@
|
||||
getContract() {
|
||||
const {pathname} = window.location;
|
||||
const id = pathname.substring(pathname.lastIndexOf('/') + 1);
|
||||
console.log(id)
|
||||
// console.log(id)
|
||||
getFile(id).then(result => {
|
||||
if (result.url) {
|
||||
this.$router.push(result.url);
|
||||
} else if (result.data) {
|
||||
this.form = result.data;
|
||||
this.form.amount = parseInt(result.data.amount);
|
||||
this.form.amountUppercase = digitUppercase(this.form.amount);
|
||||
this.form.serveTime = this.serveTimeIdOption.find(obj => obj.value === parseInt(result.data.serveTime)).label
|
||||
this.show = true;
|
||||
}
|
||||
})
|
||||
@ -51,20 +197,62 @@
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
this.$emit('handleOnSubmit', this.form);
|
||||
signContract(this.form).then(result => {
|
||||
if (result.code === 200) {
|
||||
// this.$router.push(result.url);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
handleRadioChange(val) {
|
||||
this.read = val;
|
||||
},
|
||||
handleConfirm() {
|
||||
this.dialogVisible = false;
|
||||
this.read = true;
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.dashboard-editor-container {
|
||||
.sign-contract-container {
|
||||
font-family: Helvetica Neue, Helvetica, Arial, Microsoft Yahei, Hiragino Sans GB, Heiti SC, WenQuanYi Micro Hei, sans-serif;
|
||||
padding: 32px;
|
||||
background-color: rgb(240, 242, 245);
|
||||
/*background-color: rgb(240, 242, 245);*/
|
||||
position: relative;
|
||||
|
||||
.contract-title {
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
|
||||
.detail {
|
||||
color: #0066cc;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.contract_dialog {
|
||||
|
||||
|
||||
.dialog-detail {
|
||||
height: 60vh;
|
||||
margin-top: -12px;
|
||||
margin-bottom: -12px;
|
||||
overflow: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.line-rule {
|
||||
margin: 4px 0;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.chart-wrapper {
|
||||
background: #fff;
|
||||
padding: 16px 16px 0;
|
||||
|
@ -1,41 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="姓名" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入客户姓名"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="电话" prop="phone">
|
||||
<el-input v-model="form.phone" placeholder="请输入电话"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-button type="primary" @click="submitForm">提交</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'signContract',
|
||||
data() {
|
||||
return {
|
||||
form: {},
|
||||
rules: {
|
||||
name: [
|
||||
{required: true, message: "姓名不能为空", trigger: "blur"}
|
||||
],
|
||||
phone: [
|
||||
{required: true, message: "电话不能为空", trigger: "blur"}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
this.$emit('handleOnSubmit', this.form);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user