前面我把主要功能的代码都贴出来了,这是最后一个内容,是个合集,我把全部代码都贴出来,供大家学习参考。
项目结构截图
数据库
drop table if exists ap_customer;
CREATE TABLE `ap_customer` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`name` varchar(50) DEFAULT NULL COMMENT '客户名称',
`company_address` varchar(255) DEFAULT NULL COMMENT '公司地址',
`person` varchar(20) DEFAULT NULL COMMENT '联系人',
`phone` varchar(15) DEFAULT NULL COMMENT '手机',
`profession` varchar(30) DEFAULT NULL COMMENT '行业',
`province` varchar(10) DEFAULT NULL COMMENT '省份',
`city` varchar(10) DEFAULT NULL COMMENT '城市',
`user_id` bigint(20) DEFAULT NULL COMMENT '负责人id',
`customer_state` int(11) DEFAULT NULL COMMENT '客户状态:0新建完成 1跟进中 2即将成交 3成交过的',
`competitor` varchar(255) DEFAULT NULL COMMENT '竞争对手',
`note` varchar(1000) DEFAULT NULL COMMENT '客户备注',
`bank_name` varchar(255) DEFAULT NULL COMMENT '开户行',
`bank_no` varchar(255) DEFAULT NULL COMMENT '开户账号',
`bill_address` varchar(400) DEFAULT NULL COMMENT '发票地址',
`bill_person` varchar(20) DEFAULT NULL COMMENT '开票人',
`bill_phone` varchar(20) DEFAULT NULL COMMENT '发票手机号',
`bill_note` varchar(500) DEFAULT NULL COMMENT '开票备注',
`is_deleted` tinyint default 0 comment '是否删除,0正常,1删除',
PRIMARY KEY (`id`)
) COMMENT='客户表';
insert into ap_customer(name,user_id,customer_state) values ('湖南汽配厂',2,1);
insert into ap_customer(name,user_id,customer_state) values ('江南汽配厂',2,1);
drop table if exists ap_customer_follow;
CREATE TABLE `ap_customer_follow` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`customer_id` bigint(20) DEFAULT NULL COMMENT '客户id',
`user_id` bigint(20) DEFAULT NULL COMMENT '创建用户id',
`create_time` datetime DEFAULT NULL COMMENT '跟进时间',
`subject` varchar(255) DEFAULT NULL COMMENT '主题',
`content` varchar(255) DEFAULT NULL COMMENT '跟进内容',
`next_time` datetime DEFAULT NULL COMMENT '下次跟进时间',
`next_content` varchar(255) DEFAULT NULL COMMENT '下次跟进内容',
`is_deleted` tinyint default 0 comment '是否删除,0正常,1删除',
PRIMARY KEY (`id`)
) COMMENT='客户跟进表';
insert into ap_customer_follow(customer_id,user_id,create_time,subject) values (1,2,'2023-01-01','谈生意');
insert into ap_customer_follow(customer_id,user_id,create_time,subject) values (2,2,'2023-01-01','谈生意');
drop table if exists ap_order;
CREATE TABLE `ap_order` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`user_id` bigint(20) DEFAULT NULL COMMENT '创建用户id',
`customer_id` bigint(20) DEFAULT NULL COMMENT '客户id',
`create_date` datetime DEFAULT NULL COMMENT '创建日期',
`total_money` decimal(10,2) DEFAULT NULL COMMENT '总金额',
`already_pay` decimal(10,2) DEFAULT NULL COMMENT '已经支付的钱数',
`next_pay_time` datetime DEFAULT NULL COMMENT '下次支付时间',
`discount` decimal(10,2) DEFAULT NULL COMMENT '回扣',
`product_state` tinyint(2) DEFAULT NULL COMMENT '0未发货 1发货部分产品 2全部发货完成',
`pay_state` tinyint(2) DEFAULT NULL COMMENT '订单支付状态: 0未支付 1支付部分 2支付完成',
`send_time` datetime DEFAULT NULL COMMENT '发货时间',
`send_address` varchar(200) DEFAULT NULL COMMENT '地址',
`send_price` decimal(10,2) DEFAULT NULL COMMENT '运费',
`send_way` varchar(255) DEFAULT NULL COMMENT '发货方式',
`is_deleted` tinyint default 0 comment '是否删除,0正常,1删除',
PRIMARY KEY (`id`)
) COMMENT='订单表';
insert into ap_order(user_id,customer_id,create_date,total_money,product_state,pay_state) values(2,1,'2023-01-01',10000,0,0);
insert into ap_order(user_id,customer_id,create_date,total_money,product_state,pay_state) values(2,2,'2023-01-01',9999,0,0);
drop table if exists ap_order_detail;
CREATE TABLE `ap_order_detail` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`order_id` bigint(20) DEFAULT NULL COMMENT '订单id',
`product_id` bigint(20) DEFAULT NULL COMMENT '产品id',
`product_code` varchar(50) DEFAULT NULL COMMENT '产品编码',
`product_name` varchar(255) DEFAULT NULL COMMENT '产品名称',
`amount` int(11) DEFAULT NULL COMMENT '数量',
`univalent` decimal(10,2) DEFAULT NULL COMMENT '单价',
`total_price` decimal(10,2) DEFAULT NULL COMMENT '总价',
`is_deleted` tinyint default 0 comment '是否删除,0正常,1删除',
PRIMARY KEY (`id`),
KEY `index_order_product_id` (`order_id`,`product_id`) USING BTREE
) COMMENT='订单明细表';
insert into ap_order_detail(order_id,product_id,amount) values (1,1,50);
insert into ap_order_detail(order_id,product_id,amount) values (2,1,50);
drop table if exists ap_order_target;
CREATE TABLE `ap_order_target` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`start_time` datetime DEFAULT NULL COMMENT '目标开始时间',
`end_time` datetime DEFAULT NULL COMMENT '目标结束时间',
`target` varchar(100) DEFAULT NULL COMMENT '目标',
`has_done` varchar(100) DEFAULT NULL COMMENT '已经完成',
`target_state` tinyint(1) DEFAULT NULL COMMENT '目标状态:0未完成 1已完成',
`user_id` bigint(20) NOT NULL COMMENT '关联用户',
`is_deleted` tinyint default 0 comment '是否删除,0正常,1删除',
PRIMARY KEY (`id`)
) COMMENT='订单目标记录';
insert into ap_order_target(target,user_id) values ('10000',2);
drop table if exists ap_product;
CREATE TABLE `ap_product` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`name` varchar(50) DEFAULT NULL COMMENT '产品名称',
`code` varchar(50) DEFAULT NULL COMMENT '产品编码',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`supplier` varchar(200) DEFAULT NULL COMMENT '供应商',
`note` varchar(200) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '备注',
`product_unit` varchar(20) DEFAULT NULL COMMENT '产品单位',
`is_deleted` tinyint default 0 comment '是否删除,0正常,1删除',
PRIMARY KEY (`id`) ) COMMENT='产品表';
insert into ap_product(name,supplier) values ('继电器','广东得利电器');
insert into ap_product(name,supplier) values ('断开器','深圳南山电器');
drop table if exists ap_todo_list;
CREATE TABLE `ap_todo_list` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`user_id` bigint(20) NOT NULL COMMENT '用户id',
`content` varchar(300) DEFAULT NULL COMMENT '待办事项内容',
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
`done_time` datetime DEFAULT NULL COMMENT '计划完成时间',
`work_state` tinyint(1) DEFAULT NULL COMMENT '任务状态:0未完成, 1已完成',
`is_deleted` tinyint default 0 comment '是否删除,0正常,1删除',
PRIMARY KEY (`id`)
) COMMENT='待办事项表';
insert into ap_todo_list(user_id,content) values (2,'开发票');
drop table if exists ap_user;
CREATE TABLE `ap_user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`user_name` varchar(50) not NULL COMMENT '用户名',
`password` varchar(200) not NULL COMMENT '密码',
`name` varchar(50) DEFAULT NULL COMMENT '名字',
`age` int(11) DEFAULT NULL COMMENT '年龄',
`phone` char(16) DEFAULT NULL COMMENT '手机号',
`role` tinyint(1) DEFAULT 1 COMMENT '身份:0普通用户 1管理员',
`user_state` tinyint(1) DEFAULT 0 COMMENT '当前用户状态:0正常 1限制登录 2已删除用户',
`is_deleted` tinyint default 0 comment '是否删除,1删除,0正常',
PRIMARY KEY (`id`)
) COMMENT='用户表';
insert into ap_user(user_name,password,name) values ('admin','1234','管理员');
springboot后端
Pom.xml
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.17</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.shrimpking</groupId>
<artifactId>springboot-back</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-back</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.30</version>
</dependency>
<!--swagger依赖-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<!--swagger ui-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<!-- 验证码 -->
<dependency>
<groupId>com.github.whvcse</groupId>
<artifactId>easy-captcha</artifactId>
<version>1.6.2</version>
</dependency>
<!-- jwt验证 -->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.10.3</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>paketobuildpacks/builder-jammy-base:latest</builder>
</image>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
application.properties
server.port=8089
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimeZone=UTC
spring.datasource.username=root
spring.datasource.password=mysql123
#格式化时间
spring.jackson.date-format= yyyy-MM-dd
spring.jackson.time-zone= GMT+8
#日志
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
#配置别名
mybatis-plus.type-aliases-package=com.shrimpking.pojo
#开启逻辑删除,标识字段
mybatis-plus.global-config.db-config.logic-delete-field=is_deleted
#删除
mybatis-plus.global-config.db-config.logic-delete-value=1
#未删除
mybatis-plus.global-config.db-config.logic-not-delete-value=0
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
Pojo
customer.java
package com.shrimpking.pojo;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 客户表
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("ap_customer")
@ApiModel(value="Customer对象", description="客户表")
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "客户名称")
private String name;
@ApiModelProperty(value = "公司地址")
private String companyAddress;
@ApiModelProperty(value = "联系人")
private String person;
@ApiModelProperty(value = "手机")
private String phone;
@ApiModelProperty(value = "行业")
private String profession;
@ApiModelProperty(value = "省份")
private String province;
@ApiModelProperty(value = "城市")
private String city;
@ApiModelProperty(value = "负责人id")
private Long userId;
@ApiModelProperty(value = "客户状态:0新建完成 1跟进中 2即将成交 3成交过的")
private Integer customerState;
@ApiModelProperty(value = "竞争对手")
private String competitor;
@ApiModelProperty(value = "客户备注")
private String note;
@ApiModelProperty(value = "开户行")
private String bankName;
@ApiModelProperty(value = "开户账号")
private String bankNo;
@ApiModelProperty(value = "发票地址")
private String billAddress;
@ApiModelProperty(value = "发票人")
private String billPerson;
@ApiModelProperty(value = "发票手机号")
private String billPhone;
@ApiModelProperty(value = "开票备注")
private String billNote;
@TableLogic
@ApiModelProperty(value = "是否删除,0正常,1删除")
private Integer isDeleted;
}
customerFollow.java
package com.shrimpking.pojo;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 客户跟进表
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("ap_customer_follow")
@ApiModel(value="CustomerFollow对象", description="客户跟进表")
public class CustomerFollow implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "客户id")
private Long customerId;
@ApiModelProperty(value = "创建用户id")
private Long userId;
@ApiModelProperty(value = "跟进时间")
private Date createTime;
@ApiModelProperty(value = "主题")
private String subject;
@ApiModelProperty(value = "跟进内容")
private String content;
@ApiModelProperty(value = "下次跟进时间")
private Date nextTime;
@ApiModelProperty(value = "下次跟进内容")
private String nextContent;
@TableLogic
@ApiModelProperty(value = "是否删除,0正常,1删除")
private Integer isDeleted;
}
order.java
package com.shrimpking.pojo;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 订单表
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("ap_order")
@ApiModel(value="Order对象", description="订单表")
public class Order implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "创建用户id")
private Long userId;
@ApiModelProperty(value = "客户id")
private Long customerId;
@ApiModelProperty(value = "创建日期")
private Date createDate;
@ApiModelProperty(value = "总金额")
private BigDecimal totalMoney;
@ApiModelProperty(value = "已经支付的钱数")
private BigDecimal alreadyPay;
@ApiModelProperty(value = "下次支付时间")
private Date nextPayTime;
@ApiModelProperty(value = "回扣")
private BigDecimal discount;
@ApiModelProperty(value = "0未发货 1发货部分产品 2全部发货完成")
private Integer productState;
@ApiModelProperty(value = "订单支付状态: 0未支付 1支付部分 2支付完成")
private Integer payState;
@ApiModelProperty(value = "发货时间")
private Date sendTime;
@ApiModelProperty(value = "地址")
private String sendAddress;
@ApiModelProperty(value = "运费")
private BigDecimal sendPrice;
@ApiModelProperty(value = "发货方式")
private String sendWay;
@TableLogic
@ApiModelProperty(value = "发货方式")
private Integer isDeleted;
}
orderDetail.java
package com.shrimpking.pojo;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 订单明细表
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("ap_order_detail")
@ApiModel(value="OrderDetail对象", description="订单明细表")
public class OrderDetail implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "订单id")
private Long orderId;
@ApiModelProperty(value = "产品id")
private Long productId;
@ApiModelProperty(value = "产品编码")
private String productCode;
@ApiModelProperty(value = "产品名称")
private String productName;
@ApiModelProperty(value = "数量")
private Integer amount;
@ApiModelProperty(value = "单价")
private BigDecimal univalent;
@ApiModelProperty(value = "总价")
private BigDecimal totalPrice;
@TableLogic
@ApiModelProperty(value = "是否删除,0正常,1删除")
private Integer isDeleted;
}
orderTarget.java
package com.shrimpking.pojo;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 订单目标记录
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("ap_order_target")
@ApiModel(value="OrderTarget对象", description="订单目标记录")
public class OrderTarget implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "目标开始时间")
private Date startTime;
@ApiModelProperty(value = "目标结束时间")
private Date endTime;
@ApiModelProperty(value = "目标")
private String target;
@ApiModelProperty(value = "已经完成")
private String hasDone;
@ApiModelProperty(value = "目标状态:0未完成 1已完成")
private Integer targetState;
@ApiModelProperty(value = "关联用户")
private Long userId;
@TableLogic
@ApiModelProperty(value = "是否删除,0正常,1删除")
private Integer isDeleted;
}
product.java
package com.shrimpking.pojo;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 产品表
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("ap_product")
@ApiModel(value="Product对象", description="产品表")
public class Product implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "产品名称")
private String name;
@ApiModelProperty(value = "产品编码")
private String code;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "供应商")
private String supplier;
@ApiModelProperty(value = "备注")
private String note;
@ApiModelProperty(value = "产品单位")
private String productUnit;
@TableLogic
@ApiModelProperty(value = "是否删除,0正常,1删除")
private Integer isDeleted;
}
todolist.java
package com.shrimpking.pojo;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 待办事项表
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("ap_todo_list")
@ApiModel(value="TodoList对象", description="待办事项表")
public class TodoList implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "用户id")
private Long userId;
@ApiModelProperty(value = "待办事项内容")
private String content;
@ApiModelProperty(value = "创建日期")
private Date createTime;
@ApiModelProperty(value = "计划完成时间")
private Date doneTime;
@ApiModelProperty(value = "任务状态:0未完成, 1已完成")
private Integer workState;
@TableLogic
@ApiModelProperty(value = "是否删除,0正常,1删除")
private Integer isDeleted;
}
user.java
package com.shrimpking.pojo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
/**
* <p>
* 用户表
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("ap_user")
@ApiModel(value="User对象", description="用户表")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "用户名")
private String userName;
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "名字")
private String name;
@ApiModelProperty(value = "年龄")
private Integer age;
@ApiModelProperty(value = "手机号")
private String phone;
@ApiModelProperty(value = "身份:0普通用户 1管理员")
private Integer role;
@ApiModelProperty(value = "当前用户状态:0正常 1限制登录 2已删除用户")
private Integer userState;
@TableField(exist = false)
private String token;
@TableLogic
@ApiModelProperty(value = "是否删除,1删除,0正常")
private Integer isDeleted;
}
mapper
customerFollowMapper.java
package com.shrimpking.mapper;
import com.shrimpking.pojo.CustomerFollow;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 客户跟进表 Mapper 接口
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface CustomerFollowMapper extends BaseMapper<CustomerFollow> {
}
customermapper.java
package com.shrimpking.mapper;
import com.shrimpking.pojo.Customer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 客户表 Mapper 接口
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface CustomerMapper extends BaseMapper<Customer> {
}
orderDetailmapper.java
package com.shrimpking.mapper;
import com.shrimpking.pojo.OrderDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 订单明细表 Mapper 接口
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface OrderDetailMapper extends BaseMapper<OrderDetail> {
}
ordermapper.java
package com.shrimpking.mapper;
import com.shrimpking.pojo.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 订单表 Mapper 接口
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface OrderMapper extends BaseMapper<Order> {
}
orderTargetMapper.java
package com.shrimpking.mapper;
import com.shrimpking.pojo.OrderTarget;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 订单目标记录 Mapper 接口
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface OrderTargetMapper extends BaseMapper<OrderTarget> {
}
productMapper.java
package com.shrimpking.mapper;
import com.shrimpking.pojo.Product;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 产品表 Mapper 接口
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface ProductMapper extends BaseMapper<Product> {
}
todolist.java
package com.shrimpking.mapper;
import com.shrimpking.pojo.TodoList;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 待办事项表 Mapper 接口
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface TodoListMapper extends BaseMapper<TodoList> {
}
Usermapper.java
package com.shrimpking.mapper;
import com.shrimpking.pojo.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 用户表 Mapper 接口
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface UserMapper extends BaseMapper<User> {
}
mapperxml
customerfollowMapper.xml
<?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.shrimpking.mapper.CustomerFollowMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.shrimpking.pojo.CustomerFollow">
<id column="id" property="id" />
<result column="customer_id" property="customerId" />
<result column="user_id" property="userId" />
<result column="create_time" property="createTime" />
<result column="subject" property="subject" />
<result column="content" property="content" />
<result column="next_time" property="nextTime" />
<result column="next_content" property="nextContent" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, customer_id, user_id, create_time, subject, content, next_time, next_content
</sql>
</mapper>
Customermapper.xml
<?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.shrimpking.mapper.CustomerMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.shrimpking.pojo.Customer">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="company_address" property="companyAddress" />
<result column="person" property="person" />
<result column="phone" property="phone" />
<result column="profession" property="profession" />
<result column="province" property="province" />
<result column="city" property="city" />
<result column="user_id" property="userId" />
<result column="customer_state" property="customerState" />
<result column="competitor" property="competitor" />
<result column="note" property="note" />
<result column="bank_name" property="bankName" />
<result column="bank_no" property="bankNo" />
<result column="bill_address" property="billAddress" />
<result column="bill_person" property="billPerson" />
<result column="bill_phone" property="billPhone" />
<result column="bill_note" property="billNote" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, name, company_address, person, phone, profession, province, city, user_id, customer_state, competitor, note, bank_name, bank_no, bill_address, bill_person, bill_phone, bill_note
</sql>
</mapper>
orderDetailmapper.xml
<?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.shrimpking.mapper.OrderDetailMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.shrimpking.pojo.OrderDetail">
<id column="id" property="id" />
<result column="order_id" property="orderId" />
<result column="product_id" property="productId" />
<result column="product_code" property="productCode" />
<result column="product_name" property="productName" />
<result column="amount" property="amount" />
<result column="univalent" property="univalent" />
<result column="total_price" property="totalPrice" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, order_id, product_id, product_code, product_name, amount, univalent, total_price
</sql>
</mapper>
orderMapper.xml
<?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.shrimpking.mapper.OrderMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.shrimpking.pojo.Order">
<id column="id" property="id" />
<result column="user_id" property="userId" />
<result column="customer_id" property="customerId" />
<result column="create_date" property="createDate" />
<result column="total_money" property="totalMoney" />
<result column="already_pay" property="alreadyPay" />
<result column="next_pay_time" property="nextPayTime" />
<result column="discount" property="discount" />
<result column="product_state" property="productState" />
<result column="pay_state" property="payState" />
<result column="send_time" property="sendTime" />
<result column="send_address" property="sendAddress" />
<result column="send_price" property="sendPrice" />
<result column="send_way" property="sendWay" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_id, customer_id, create_date, total_money, already_pay, next_pay_time, discount, product_state, pay_state, send_time, send_address, send_price, send_way
</sql>
</mapper>
orderTargetMapper.xml
<?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.shrimpking.mapper.OrderTargetMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.shrimpking.pojo.OrderTarget">
<id column="id" property="id" />
<result column="start_time" property="startTime" />
<result column="end_time" property="endTime" />
<result column="target" property="target" />
<result column="has_done" property="hasDone" />
<result column="target_state" property="targetState" />
<result column="user_id" property="userId" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, start_time, end_time, target, has_done, target_state, user_id
</sql>
</mapper>
productMapper.xml
<?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.shrimpking.mapper.ProductMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.shrimpking.pojo.Product">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="code" property="code" />
<result column="create_time" property="createTime" />
<result column="supplier" property="supplier" />
<result column="note" property="note" />
<result column="product_unit" property="productUnit" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, name, code, create_time, supplier, note, product_unit
</sql>
</mapper>
todolistMapper.xml
<?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.shrimpking.mapper.TodoListMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.shrimpking.pojo.TodoList">
<id column="id" property="id" />
<result column="user_id" property="userId" />
<result column="content" property="content" />
<result column="create_time" property="createTime" />
<result column="done_time" property="doneTime" />
<result column="work_state" property="workState" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_id, content, create_time, done_time, work_state
</sql>
</mapper>
userMapper.xml
<?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.shrimpking.mapper.UserMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.shrimpking.pojo.User">
<id column="id" property="id" />
<result column="user_name" property="userName" />
<result column="password" property="password" />
<result column="name" property="name" />
<result column="age" property="age" />
<result column="phone" property="phone" />
<result column="role" property="role" />
<result column="user_state" property="userState" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_name, password, name, age, phone, role, user_state
</sql>
</mapper>
Service
cusomterFollowService.java
package com.shrimpking.service;
import com.shrimpking.pojo.CustomerFollow;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 客户跟进表 服务类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface CustomerFollowService extends IService<CustomerFollow> {
}
customerService.java
package com.shrimpking.service;
import com.shrimpking.pojo.Customer;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 客户表 服务类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface CustomerService extends IService<Customer> {
}
orderDetailService.java
package com.shrimpking.service;
import com.shrimpking.pojo.OrderDetail;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 订单明细表 服务类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface OrderDetailService extends IService<OrderDetail> {
}
orderService.java
package com.shrimpking.service;
import com.shrimpking.pojo.Order;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 订单表 服务类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface OrderService extends IService<Order> {
}
orderTarget.java
package com.shrimpking.service;
import com.shrimpking.pojo.OrderTarget;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 订单目标记录 服务类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface OrderTargetService extends IService<OrderTarget> {
}
productService.java
package com.shrimpking.service;
import com.shrimpking.pojo.Product;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 产品表 服务类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface ProductService extends IService<Product> {
}
todilistService.java
package com.shrimpking.service;
import com.shrimpking.pojo.TodoList;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 待办事项表 服务类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface TodoListService extends IService<TodoList> {
}
userService.java
package com.shrimpking.service;
import com.shrimpking.pojo.User;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletRequest;
/**
* <p>
* 用户表 服务类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
public interface UserService extends IService<User> {
}
ServiceImpl
customerFollowServiceImpl.java
package com.shrimpking.service.impl;
import com.shrimpking.pojo.CustomerFollow;
import com.shrimpking.mapper.CustomerFollowMapper;
import com.shrimpking.service.CustomerFollowService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 客户跟进表 服务实现类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Service
public class CustomerFollowServiceImpl extends ServiceImpl<CustomerFollowMapper, CustomerFollow> implements CustomerFollowService {
}
customerServiceImpl.java
package com.shrimpking.service.impl;
import com.shrimpking.pojo.Customer;
import com.shrimpking.mapper.CustomerMapper;
import com.shrimpking.service.CustomerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 客户表 服务实现类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
}
orderDetailServiceImpl.java
package com.shrimpking.service.impl;
import com.shrimpking.pojo.OrderDetail;
import com.shrimpking.mapper.OrderDetailMapper;
import com.shrimpking.service.OrderDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 订单明细表 服务实现类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Service
public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, OrderDetail> implements OrderDetailService {
}
orderServiceImpl.java
package com.shrimpking.service.impl;
import com.shrimpking.pojo.Order;
import com.shrimpking.mapper.OrderMapper;
import com.shrimpking.service.OrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 订单表 服务实现类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
}
orderTargetServiceImpl.java
package com.shrimpking.service.impl;
import com.shrimpking.pojo.OrderTarget;
import com.shrimpking.mapper.OrderTargetMapper;
import com.shrimpking.service.OrderTargetService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 订单目标记录 服务实现类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Service
public class OrderTargetServiceImpl extends ServiceImpl<OrderTargetMapper, OrderTarget> implements OrderTargetService {
}
productServiceImpl.java
package com.shrimpking.service.impl;
import com.shrimpking.pojo.Product;
import com.shrimpking.mapper.ProductMapper;
import com.shrimpking.service.ProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 产品表 服务实现类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
}
todolistServiceImpl.java
package com.shrimpking.service.impl;
import com.shrimpking.pojo.TodoList;
import com.shrimpking.mapper.TodoListMapper;
import com.shrimpking.service.TodoListService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 待办事项表 服务实现类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Service
public class TodoListServiceImpl extends ServiceImpl<TodoListMapper, TodoList> implements TodoListService {
}
UserServiceImpl.java
package com.shrimpking.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.shrimpking.exception.CustomException;
import com.shrimpking.pojo.User;
import com.shrimpking.mapper.UserMapper;
import com.shrimpking.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wf.captcha.utils.CaptchaUtil;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
/**
* <p>
* 用户表 服务实现类
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
}
Controller
customerController.java
package com.shrimpking.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shrimpking.pojo.Customer;
import com.shrimpking.pojo.User;
import com.shrimpking.req.CustomerParams;
import com.shrimpking.req.UserParams;
import com.shrimpking.res.Result;
import com.shrimpking.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 客户表 前端控制器
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@RestController
@RequestMapping("/customer")
public class CustomerController {
@Autowired
private CustomerService customerService;
@GetMapping("/listPage")
public Result listPage(CustomerParams customerParams){
IPage<Customer> page = new Page<>(customerParams.getCurrentPage(), customerParams.getPageSize());
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtils.isNotBlank(customerParams.getName()), Customer::getName, customerParams.getName());
queryWrapper.eq(ObjectUtil.isNotNull(customerParams.getCustomerState()),Customer::getCustomerState,customerParams.getCustomerState());
IPage<Customer> resultPage = this.customerService.page(page, queryWrapper);
return Result.success(resultPage);
}
@PostMapping("/save")
public Result save(@RequestBody Customer customer){
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Customer::getName,customer.getName());
int count = this.customerService.count(queryWrapper);
if(count > 0){ return Result.fail("此客户已存在");}
boolean save = this.customerService.save(customer);
if(!save) { return Result.fail("保存失败");}
return Result.success("保存成功");
}
@PostMapping("/update")
public Result update(@RequestBody Customer customer){
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Customer::getName,customer.getName());
Customer one = this.customerService.getOne(queryWrapper);
if(one != null && !one.getId().equals(customer.getId())){
return Result.fail("此客户已存在");
}
boolean update = this.customerService.updateById(customer);
if(!update){ return Result.fail("更新失败");}
return Result.success("更新成功");
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable("id") Long customerId){
if(ObjectUtil.isNull(customerId)){
return Result.fail("未选择客户,无法删除");
}
boolean remove = this.customerService.removeById(customerId);
if(!remove) { return Result.fail("删除失败");}
return Result.success("删除成功");
}
@GetMapping("/list")
public Result list(){
List<Customer> list = this.customerService.list();
return Result.success(list);
}
}
customerFollowController.java
package com.shrimpking.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shrimpking.pojo.Customer;
import com.shrimpking.pojo.CustomerFollow;
import com.shrimpking.req.FollowParams;
import com.shrimpking.res.Result;
import com.shrimpking.service.CustomerFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 客户跟进表 前端控制器
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@RestController
@RequestMapping("/customerFollow")
public class CustomerFollowController {
@Autowired
private CustomerFollowService customerFollowService;
@GetMapping("/listPage")
public Result listPage(FollowParams followParams){
IPage<CustomerFollow> page = new Page<>(followParams.getCurrentPage(), followParams.getPageSize());
LambdaQueryWrapper<CustomerFollow> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ObjectUtil.isNotNull(followParams.getUserId()), CustomerFollow::getUserId, followParams.getUserId());
queryWrapper.eq(ObjectUtil.isNotNull(followParams.getCustomerId()),CustomerFollow::getCustomerId,followParams.getCustomerId());
IPage<CustomerFollow> resultPage = this.customerFollowService.page(page, queryWrapper);
return Result.success(resultPage);
}
@PostMapping("/save")
public Result save(@RequestBody CustomerFollow customerFollow){
boolean save = this.customerFollowService.save(customerFollow);
if(!save) { return Result.fail("保存失败");}
return Result.success("保存成功");
}
@PostMapping("/update")
public Result update(@RequestBody CustomerFollow customerFollow){
boolean update = this.customerFollowService.updateById(customerFollow);
if(!update){ return Result.fail("更新失败");}
return Result.success("更新成功");
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable("id") Long customerId){
if(ObjectUtil.isNull(customerId)){
return Result.fail("未选择记录,无法删除");
}
boolean remove = this.customerFollowService.removeById(customerId);
if(!remove) { return Result.fail("删除失败");}
return Result.success("删除成功");
}
}
orderController.java
package com.shrimpking.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shrimpking.pojo.CustomerFollow;
import com.shrimpking.pojo.Order;
import com.shrimpking.req.FollowParams;
import com.shrimpking.req.OrderParams;
import com.shrimpking.res.Result;
import com.shrimpking.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 订单表 前端控制器
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@RestController
@RequestMapping("/order")
public class OrderController {
@Autowired
private OrderService orderService;
@GetMapping("/listPage")
public Result listPage(OrderParams orderParams){
IPage<Order> page = new Page<>(orderParams.getCurrentPage(), orderParams.getPageSize());
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ObjectUtil.isNotNull(orderParams.getUserId()), Order::getUserId, orderParams.getUserId());
queryWrapper.eq(ObjectUtil.isNotNull(orderParams.getCustomerId()),Order::getCustomerId,orderParams.getCustomerId());
queryWrapper.eq(ObjectUtil.isNotNull(orderParams.getProductState()),Order::getProductState,orderParams.getProductState());
queryWrapper.eq(ObjectUtil.isNotNull(orderParams.getPayState()),Order::getPayState,orderParams.getPayState());
IPage<Order> resultPage = this.orderService.page(page, queryWrapper);
return Result.success(resultPage);
}
@PostMapping("/save")
public Result save(@RequestBody Order order){
boolean save = this.orderService.save(order);
if(!save) { return Result.fail("保存失败");}
return Result.success("保存成功");
}
@PostMapping("/update")
public Result update(@RequestBody Order order){
boolean update = this.orderService.updateById(order);
if(!update){ return Result.fail("更新失败");}
return Result.success("更新成功");
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable("id") Long orderId){
if(ObjectUtil.isNull(orderId)){
return Result.fail("未选择记录,无法删除");
}
boolean remove = this.orderService.removeById(orderId);
if(!remove) { return Result.fail("删除失败");}
return Result.success("删除成功");
}
@GetMapping("/list")
public Result list(){
List<Order> list = this.orderService.list();
return Result.success(list);
}
}
orderDetailController.java
package com.shrimpking.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shrimpking.pojo.Order;
import com.shrimpking.pojo.OrderDetail;
import com.shrimpking.req.OrderDetailParams;
import com.shrimpking.req.OrderParams;
import com.shrimpking.res.Result;
import com.shrimpking.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 订单明细表 前端控制器
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@RestController
@RequestMapping("/orderDetail")
public class OrderDetailController {
@Autowired
private OrderDetailService orderDetailService;
@GetMapping("/listPage")
public Result listPage(OrderDetailParams orderDetailParams){
IPage<OrderDetail> page = new Page<>(orderDetailParams.getCurrentPage(), orderDetailParams.getPageSize());
LambdaQueryWrapper<OrderDetail> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ObjectUtil.isNotNull(orderDetailParams.getOrderId()), OrderDetail::getOrderId, orderDetailParams.getOrderId());
queryWrapper.eq(ObjectUtil.isNotNull(orderDetailParams.getProductId()),OrderDetail::getProductId,orderDetailParams.getProductId());
IPage<OrderDetail> resultPage = this.orderDetailService.page(page, queryWrapper);
return Result.success(resultPage);
}
@PostMapping("/save")
public Result save(@RequestBody OrderDetail orderDetail){
boolean save = this.orderDetailService.save(orderDetail);
if(!save) { return Result.fail("保存失败");}
return Result.success("保存成功");
}
@PostMapping("/update")
public Result update(@RequestBody OrderDetail orderDetail){
boolean update = this.orderDetailService.updateById(orderDetail);
if(!update){ return Result.fail("更新失败");}
return Result.success("更新成功");
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable("id") Long oderDetailId){
if(ObjectUtil.isNull(oderDetailId)){
return Result.fail("未选择记录,无法删除");
}
boolean remove = this.orderDetailService.removeById(oderDetailId);
if(!remove) { return Result.fail("删除失败");}
return Result.success("删除成功");
}
}
orderTargetController.java
package com.shrimpking.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shrimpking.pojo.Customer;
import com.shrimpking.pojo.OrderTarget;
import com.shrimpking.req.CustomerParams;
import com.shrimpking.req.TargetParams;
import com.shrimpking.res.Result;
import com.shrimpking.service.OrderTargetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 订单目标记录 前端控制器
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@RestController
@RequestMapping("/orderTarget")
public class OrderTargetController {
@Autowired
private OrderTargetService orderTargetService;
@GetMapping("/listPage")
public Result listPage(TargetParams targetParams){
IPage<OrderTarget> page = new Page<>(targetParams.getCurrentPage(), targetParams.getPageSize());
LambdaQueryWrapper<OrderTarget> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtils.isNotBlank(targetParams.getTarget()), OrderTarget::getTarget, targetParams.getTarget());
queryWrapper.eq(ObjectUtil.isNotNull(targetParams.getTargetState()),OrderTarget::getTargetState,targetParams.getTargetState());
IPage<OrderTarget> resultPage = this.orderTargetService.page(page, queryWrapper);
return Result.success(resultPage);
}
@PostMapping("/save")
public Result save(@RequestBody OrderTarget orderTarget){
boolean save = this.orderTargetService.save(orderTarget);
if(!save) { return Result.fail("保存失败");}
return Result.success("保存成功");
}
@PostMapping("/update")
public Result update(@RequestBody OrderTarget orderTarget){
boolean update = this.orderTargetService.updateById(orderTarget);
if(!update){ return Result.fail("更新失败");}
return Result.success("更新成功");
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable("id") Long targetId){
if(ObjectUtil.isNull(targetId)){
return Result.fail("未选择客户,无法删除");
}
boolean remove = this.orderTargetService.removeById(targetId);
if(!remove) { return Result.fail("删除失败");}
return Result.success("删除成功");
}
}
productcontroller.java
package com.shrimpking.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shrimpking.pojo.Customer;
import com.shrimpking.pojo.Product;
import com.shrimpking.req.CustomerParams;
import com.shrimpking.req.ProductParams;
import com.shrimpking.res.Result;
import com.shrimpking.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 产品表 前端控制器
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@RestController
@RequestMapping("/product")
public class ProductController {
@Autowired
private ProductService productService;
@GetMapping("/listPage")
public Result listPage(ProductParams productParams){
IPage<Product> page = new Page<>(productParams.getCurrentPage(), productParams.getPageSize());
LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtils.isNotBlank(productParams.getName()), Product::getName, productParams.getName());
queryWrapper.like(StringUtils.isNotBlank(productParams.getSupplier()),Product::getSupplier,productParams.getSupplier());
IPage<Product> resultPage = this.productService.page(page, queryWrapper);
return Result.success(resultPage);
}
@PostMapping("/save")
public Result save(@RequestBody Product product){
LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Product::getName,product.getName());
int count = this.productService.count(queryWrapper);
if(count > 0){ return Result.fail("此商品已存在");}
boolean save = this.productService.save(product);
if(!save) { return Result.fail("保存失败");}
return Result.success("保存成功");
}
@PostMapping("/update")
public Result update(@RequestBody Product product){
LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Product::getName,product.getName());
Product one = this.productService.getOne(queryWrapper);
if(one != null && !one.getId().equals(product.getId())){
return Result.fail("此商品已存在");
}
boolean update = this.productService.updateById(product);
if(!update){ return Result.fail("更新失败");}
return Result.success("更新成功");
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable("id") Long productId){
if(ObjectUtil.isNull(productId)){
return Result.fail("未选择商品,无法删除");
}
boolean remove = this.productService.removeById(productId);
if(!remove) { return Result.fail("删除失败");}
return Result.success("删除成功");
}
@GetMapping("/list")
public Result list(){
List<Product> list = this.productService.list();
return Result.success(list);
}
}
todolistController.java
package com.shrimpking.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shrimpking.pojo.OrderTarget;
import com.shrimpking.pojo.TodoList;
import com.shrimpking.req.TargetParams;
import com.shrimpking.req.TodoParams;
import com.shrimpking.res.Result;
import com.shrimpking.service.TodoListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 待办事项表 前端控制器
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@RestController
@RequestMapping("/todoList")
public class TodoListController {
@Autowired
private TodoListService todoListService;
@GetMapping("/listPage")
public Result listPage(TodoParams todoParams){
IPage<TodoList> page = new Page<>(todoParams.getCurrentPage(), todoParams.getPageSize());
LambdaQueryWrapper<TodoList> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtils.isNotBlank(todoParams.getContent()), TodoList::getContent, todoParams.getContent());
queryWrapper.eq(ObjectUtil.isNotNull(todoParams.getUserId()), TodoList::getUserId, todoParams.getUserId());
queryWrapper.eq(ObjectUtil.isNotNull(todoParams.getWorkState()), TodoList::getWorkState, todoParams.getWorkState());
IPage<TodoList> resultPage = this.todoListService.page(page, queryWrapper);
return Result.success(resultPage);
}
@PostMapping("/save")
public Result save(@RequestBody TodoList todoList){
boolean save = this.todoListService.save(todoList);
if(!save) { return Result.fail("保存失败");}
return Result.success("保存成功");
}
@PostMapping("/update")
public Result update(@RequestBody TodoList todoList){
boolean update = this.todoListService.updateById(todoList);
if(!update){ return Result.fail("更新失败");}
return Result.success("更新成功");
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable("id") Long todoId){
if(ObjectUtil.isNull(todoId)){
return Result.fail("未选择客户,无法删除");
}
boolean remove = this.todoListService.removeById(todoId);
if(!remove) { return Result.fail("删除失败");}
return Result.success("删除成功");
}
}
Usercontroller.java
package com.shrimpking.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shrimpking.pojo.User;
import com.shrimpking.req.UserParams;
import com.shrimpking.res.Result;
import com.shrimpking.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 用户表 前端控制器
* </p>
*
* @author shrimpking
* @since 2023-11-20
*/
@RestController
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@PostMapping("/login")
public Result login(@RequestBody User user){
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(User::getUserName, user.getUserName());
User one = this.userService.getOne(queryWrapper);
if(one != null && one.getPassword().equals(user.getPassword())){
one.setPassword("***");
return Result.success("登录成功",one);
}
return Result.fail("用户名或密码错误!");
}
@GetMapping("/listPage")
public Result listPage(UserParams userParams){
IPage<User> page = new Page<>(userParams.getCurrentPage(),userParams.getPageSize());
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtils.isNotBlank(userParams.getUserName()),User::getUserName,userParams.getUserName());
IPage<User> resultPage = this.userService.page(page, queryWrapper);
return Result.success(resultPage);
}
@PostMapping("/save")
public Result save(@RequestBody User user){
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(User::getUserName,user.getUserName());
int count = this.userService.count(queryWrapper);
if(count > 0){ return Result.fail("此用户名已存在,请更换");}
boolean save = this.userService.save(user);
if(!save) { return Result.fail("保存失败");}
return Result.success("保存成功");
}
@PostMapping("/update")
public Result update(@RequestBody User user){
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(User::getUserName,user.getUserName());
User one = this.userService.getOne(queryWrapper);
if(one != null && !one.getId().equals(user.getId())){
return Result.fail("此用户名已存在");
}
boolean update = this.userService.updateById(user);
if(!update){ return Result.fail("更新失败");}
return Result.success("更新成功");
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable("id") Long userId){
if(ObjectUtil.isNull(userId)){
return Result.fail("未选择删除人员,无法删除");
}
if(userId <= 1L){
return Result.fail("系统管理员无法删除!");
}
boolean remove = this.userService.removeById(userId);
if(!remove) { return Result.fail("删除失败");}
return Result.success("删除成功");
}
@GetMapping("/list")
public Result list(){
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
//除去管理员
queryWrapper.ne(User::getId,1L);
List<User> list = this.userService.list(queryWrapper);
return Result.success(list);
}
}
config
apiconfing.java
package com.shrimpking.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/12 14:39
*/
@Configuration
public class ApiConfig implements WebMvcConfigurer
{
@Override
public void configurePathMatch(PathMatchConfigurer configurer)
{
//指定controller的统一接口前缀,增加接口前缀
configurer.addPathPrefix("/api",clazz-> clazz.isAnnotationPresent(RestController.class));
}
}
corsConfig.java
package com.shrimpking.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
// 案例 一
@Configuration
public class CorsConfig implements WebMvcConfigurer
{
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
//是否发送Cookie
.allowCredentials(true)
//放行哪些原始域
.allowedOriginPatterns("*")
.allowedMethods(new String[]{"GET", "POST", "PUT", "DELETE"})
.allowedHeaders("*")
.exposedHeaders("*");
}
/**
* 增加了自定义拦截器后,需要使用此方法,才可以解决跨域,
* 前一个方法maps,自动失效了。
* @return
*/
@Bean
public CorsFilter corsFilter(){
//添加cors配置
CorsConfiguration config = new CorsConfiguration();
//允许的域,不要写*号
config.addAllowedOrigin("http://localhost:8080");
//是否发送cookie
config.setAllowCredentials(true);
//允许的请求方式
config.addAllowedMethod("OPTIONS");
config.addAllowedMethod("HEAD");
config.addAllowedMethod("GET");
config.addAllowedMethod("PUT");
config.addAllowedMethod("POST");
config.addAllowedMethod("DELETE");
config.addAllowedMethod("PATCH");
//允许的头信息
config.addAllowedHeader("*");
//添加映射路径
UrlBasedCorsConfigurationSource configurationSource = new UrlBasedCorsConfigurationSource();
configurationSource.registerCorsConfiguration("/**",config);
return new CorsFilter(configurationSource);
}
}
mybatisplusConfig.java
package com.shrimpking.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@MapperScan("com.shrimpking.mapper")
public class MybatisPlusConfig
{
/**
* 配置分页插件的
* @return
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor()
{
MybatisPlusInterceptor interceptor
= new MybatisPlusInterceptor();
//分页插件
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
//防止全表更新插件
interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
return interceptor;
}
}
swagggerConfig.java
package com.shrimpking.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/9/10 14:58
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig
{
@Bean
public Docket createRestApi(){
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()).build();
}
private ApiInfo apiInfo(){
return new ApiInfoBuilder()
.title("系统接口文档")
.description("接口文档的描述")
.version("1.0")
.contact(new Contact("weixin","http://www.baidu.com","1@1.com"))
.build();
}
}
exception
customerException
package com.shrimpking.exception;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/11 11:04
*/
public class CustomException extends RuntimeException
{
private String message;
public CustomException(String message)
{
this.message = message;
}
@Override
public String getMessage()
{
return this.message;
}
}
globalExceptionHandler
package com.shrimpking.exception;
import com.shrimpking.res.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.servlet.http.HttpServletRequest;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/11 11:01
*/
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler
{
@ExceptionHandler(Exception.class)
public Result error(HttpServletRequest request,Exception e){
log.error("异常信息:",e);
return Result.fail(e.getMessage());
}
@ExceptionHandler(CustomException.class)
public Result customException(HttpServletRequest request,CustomException e){
log.error("异常信息:",e);
return Result.fail(e.getMessage());
}
}
req
customerParams.java
package com.shrimpking.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/21 18:24
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class CustomerParams extends QueryParams
{
private String name;
private Integer customerState;
}
followParams.java
package com.shrimpking.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/21 18:24
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class FollowParams extends QueryParams
{
private Integer userId;
private Integer customerId;
}
orderDetailPrams.java
package com.shrimpking.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/21 18:24
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class OrderDetailParams extends QueryParams
{
private Integer orderId;
private Integer productId;
}
orderPrams.java
package com.shrimpking.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/21 18:24
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class OrderParams extends QueryParams
{
private Integer userId;
private Integer customerId;
private Integer productState;
private Integer payState;
}
productParams.java
package com.shrimpking.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/21 15:59
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class ProductParams extends QueryParams
{
private String name;
private String supplier;
}
queryParams.java
package com.shrimpking.req;
import lombok.Data;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/21 15:57
*/
@Data
public class QueryParams
{
private Long currentPage;
private Long pageSize;
}
targetPrams.java
package com.shrimpking.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/21 18:24
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class TargetParams extends QueryParams
{
private String target;
private Integer targetState;
}
todoParams.java
package com.shrimpking.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/21 18:24
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class TodoParams extends QueryParams
{
private String content;
private Integer userId;
private Integer workState;
}
userParams.java
package com.shrimpking.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/21 15:59
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class UserParams extends QueryParams
{
private String userName;
}
res
result.java
package com.shrimpking.res;
import lombok.Data;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2023/11/20 16:51
*/
@Data
public class Result
{
private static final Integer SUCCESS_CODE = 200;
private static final Integer ERROR_CODE = 500;
private static final String SUCCESS_MSG = "成功";
private static final String ERROR_MSG = "失败";
private Integer code;
private String msg;
private Object data;
/**
* 返回成功,默认
* @return
*/
public static Result success(){
Result result = new Result();
result.setCode(Result.SUCCESS_CODE);
result.setMsg(Result.SUCCESS_MSG);
result.setData(null);
return result;
}
/**
* 返回成功,消息
* @return
*/
public static Result success(String msg){
Result result = success();
result.setMsg(msg);
return result;
}
/**
* 返回成功,数据
* @return
*/
public static Result success(Object data){
Result result = success();
result.setData(data);
return result;
}
/**
* 返回成功,消息和数据
* @return
*/
public static Result success(String msg,Object data){
Result result = success(msg);
result.setData(data);
return result;
}
/**
* 返回失败,默认
* @return
*/
public static Result fail(){
Result result = new Result();
result.setCode(Result.ERROR_CODE);
result.setMsg(Result.ERROR_MSG);
result.setData(null);
return result;
}
/**
* 返回失败,消息
* @return
*/
public static Result fail(String msg){
Result result = fail();
result.setMsg(msg);
return result;
}
/**
* 返回失败,消息和数据
* @return
*/
public static Result fail(String msg,Object data){
Result result = fail(msg);
result.setData(data);
return result;
}
}
启动类
package com.shrimpking;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan("com.shrimpking.mapper")
public class SpringbootBackApplication
{
public static void main(String[] args)
{
SpringApplication.run(SpringbootBackApplication.class, args);
}
}
Vue前端
router
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
{
path: '/',
redirect: '/login',
},
{
path: '/login',
name:'LoginView',
component: ()=> import('@/views/LoginView.vue'),
},
{
path: '/home',
name: 'HomeView',
redirect: '/index',
component: ()=> import('@/views/HomeView.vue'),
children:[
{
path: '/index',
name: 'IndexView',
component: ()=> import('@/views/IndexView.vue'),
meta: {
title: '首页'
}
},
{
path: '/user',
name: 'UserView',
component: ()=> import('@/views/User/UserView.vue'),
meta: {
title: '用户信息'
}
},
{
path: '/customer',
name: 'CustomerView',
component: ()=> import('@/views/Customer/CustomerView.vue'),
meta: {
title: '客户信息'
}
},
{
path: '/follow',
name: 'CustomerFollow',
component: ()=> import('@/views/Customer/CustomerFollow.vue'),
meta: {
title: '客户跟进'
}
},
{
path: '/product',
name: 'ProductView',
component: ()=> import('@/views/Product/ProductView.vue'),
meta: {
title: '产品信息'
}
},
{
path: '/order',
name: 'OrderView',
component: ()=> import('@/views/Order/OrderView.vue'),
meta: {
title: '订单信息'
}
},
{
path: '/orderDetail',
name: 'OrderDetail',
component: ()=> import('@/views/Order/OrderDetail.vue'),
meta: {
title: '订单明细'
}
},
{
path: '/target',
name: 'TargetView',
component: ()=> import('@/views/Target/TargetView.vue'),
meta: {
title: '订单目标'
}
},
{
path: '/todo',
name: 'TodoList',
component: ()=> import('@/views/Todo/TodoList.vue'),
meta: {
title: '待办事项'
}
},
]
}
]
const router = new VueRouter({
routes
})
//路由错误时,解决问题
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject);
return originalPush.call(this, location).catch(err => err)
};
//白名单
const IGNORE_URLS = ['/login'];
//前置守卫
router.beforeEach((to, from, next) => {
//在白名单中,放行
if(IGNORE_URLS.includes(to.path)){
next();
}
//获取用户
let admin = JSON.parse(window.localStorage.getItem('access-admin'));
if(!admin && !IGNORE_URLS.includes(to.path)){
//没有登录 ,没有在白名单中,跳转登录
return next('/login');
}
next();
});
export default router
store
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
},
getters: {
},
mutations: {
},
actions: {
},
modules: {
}
})
request.js
import axios from 'axios'
const request = axios.create({
baseURL: 'http://localhost:8089/api', //
timeout: 5000,
});
//request 拦截器
request.interceptors.request.use( config =>{
config.headers['Content-Type'] = 'application/json;charset=utf-8';
//获取token
// const admin = JSON.parse(window.localStorage.getItem('access-admin'));
// if(admin){
// config.headers['z-token'] = admin.token;
// }
return config;
},error => {
return Promise.reject(error);
});
//respose 拦截器
request.interceptors.response.use( response => {
//response.data即为后端返回的result, 也就是脱壳
let res = response.data;
//兼容服务端返回的字符串数据
if(typeof res === 'string'){
res = res ? JSON.parse(res) : res;
}
return res;
},error => {
console.log('error:' + error);
return Promise.reject(error);
});
export default request;
customerFollow.vue
<template>
<div class="user-area">
<el-card show="always" class="search">
<el-row>
<el-form :inline="true">
<el-form-item>
<el-select
v-model="searchForm.customerId"
placeholder="选择客户"
@clear="doSearch"
clearable>
<el-option
v-for="item in customerList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-select
v-model="searchForm.userId"
placeholder="选择用户"
style="margin-left: 1px;"
@clear="doSearch"
clearable>
<el-option
v-for="item in userList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-toilet-paper" @click="doClean">清空</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-plus" @click="addBtn">新增</el-button>
</el-form-item>
</el-form>
</el-row>
</el-card>
<div class="data-table">
<el-table
:data="tableData"
border
:height="tableHeight"
size="mini"
style="width: 100%">
<el-table-column
prop="id"
width="50px"
label="ID">
</el-table-column>
<el-table-column
prop="customerId"
label="客户名称"
show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ customerList.find(item => item.id === scope.row.customerId).name }} </span>
</template>
</el-table-column>
<el-table-column
prop="userId"
label="负责人"
show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ userList.find(item => item.id === scope.row.userId).name }} </span>
</template>
</el-table-column>
<el-table-column
prop="createTime"
label="跟进时间"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="subject"
label="主题"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="content"
label="跟进内容"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="nextTime"
label="下次跟进时间"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="nextContent"
label="下次跟进内容"
show-overflow-tooltip>
</el-table-column>
<el-table-column label="操作" fixed="right" width="200px">
<template slot-scope="scope">
<el-button type="primary" icon="el-icon-edit" @click="handleEdit(scope.row)" size="mini">编辑</el-button>
<el-button type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)" size="mini">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="data-page">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="searchForm.currentPage"
:page-sizes="[2, 5, 10, 50]"
:page-size="searchForm.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
<!-- 新增对话框 -->
<div>
<el-dialog
:title="dialogTitle"
:visible.sync="addDialogVisible"
:close-on-click-modal="false"
width="50%"
:before-close="handleClose">
<el-form
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="120px"
label-position="left"
class="demo-ruleForm">
<el-row>
<el-col :span="10" :offset="1">
<el-form-item label="客户" prop="customerId">
<el-select v-model="ruleForm.customerId" style="width: 100%;" clearable>
<el-option
v-for="item in customerList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="负责人" prop="userId">
<el-select v-model="ruleForm.userId" style="width: 100%;" clearable>
<el-option
v-for="item in userList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="跟进时间" prop="createTime" >
<el-date-picker
v-model="ruleForm.createTime"
type="date"
placeholder="选择日期"
style="width: 100%;">
</el-date-picker>
</el-form-item>
<el-form-item label="主题" prop="subject">
<el-input v-model="ruleForm.subject" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="10" :offset="1">
<el-form-item label="跟进内容" prop="content">
<el-input v-model="ruleForm.content" clearable></el-input>
</el-form-item>
<el-form-item label="下次跟进时间" prop="nextTime">
<el-date-picker
v-model="ruleForm.nextTime"
type="date"
placeholder="选择日期"
style="width: 100%;">
</el-date-picker>
</el-form-item>
<el-form-item label="下次跟进内容">
<el-input v-model="ruleForm.nextContent" clearable></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogReset" v-if="dialogTitle==='新增跟进'">重 置</el-button>
<el-button type="primary" @click="dialogSubmit">确 定</el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import request from "@/utils/request";
export default {
name: "CustomerFollow",
data(){
return {
//客户列表
customerList:[],
//用户列表
userList:[],
//对话框标题
dialogTitle: '',
//对话框可见
addDialogVisible: false,
//搜索区域
searchForm: {
customerId:'',
userId:'',
currentPage:1,
pageSize:5,
},
//总记录数
total:0,
//表格数据
tableData:[],
//表格高度
tableHeight:0,
//新增表单
ruleForm: {
customerId: '',
userId: '',
createTime: '',
subject: '',
content: '',
nextTime: '',
nextContent: '',
},
rules: {
customerId: [
{ required: true, message: '请选择客户', trigger: 'change' },
],
userId: [
{ required: true, message: '请选择用户', trigger: 'change' },
],
createTime: [
{ required: true, message: '请选择跟进时间', trigger: 'change' },
],
subject: [
{ required: true, message: '请输入主题', trigger: 'blur' },
],
content: [
{ required: true, message: '请输入跟进内容', trigger: 'blur' },
],
}
}
},
methods: {
//获取用户列表
getCustomerList(){
request.get('/customer/list').then(res=>{
//console.log(res)
if(res.code === 200){
this.customerList = res.data;
}
})
},
//获取用户列表
getUserList(){
request.get('/user/list').then(res=>{
//console.log(res)
if(res.code === 200){
this.userList = res.data;
}
})
},
//删除
handleDelete(row){
this.$confirm(`您确定要删除吗?`,'删除提示',{
confirmButtonText:'删除',
cancelButtonText:'取消',
type: 'warning'
}).then(()=>{
request.delete('/customerFollow/delete/' + row.id)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
});
}).catch(_=>{
this.$message.warning("已取消删除");
})
},
//编辑
handleEdit(row){
//深度拷贝
let obj = JSON.parse(JSON.stringify(row));
this.ruleForm = obj;
this.dialogTitle = '编辑跟进';
this.addDialogVisible = true;
},
//新增
addBtn(){
this.ruleForm = {};
this.dialogTitle = '新增跟进';
this.addDialogVisible = true;
},
//对话框提交
dialogSubmit(){
this.$refs.ruleForm.validate((valid)=>{
if(valid){
request.post(this.ruleForm.id ? '/customerFollow/update':'/customerFollow/save',this.ruleForm)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.handleClose();
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
})
}
})
},
//对话框重置
dialogReset(){
this.$refs.ruleForm.resetFields();
this.ruleForm = {};
},
//对话框关闭
handleClose(){
this.dialogReset();
this.addDialogVisible = false;
},
//清空
doClean(){
this.searchForm.customerId = '';
this.searchForm.userId = '';
this.doSearch();
},
//搜索
doSearch(){
this.searchForm.currentPage = 1;
this.getData();
},
//获取数据
getData(){
request.get("/customerFollow/listPage",{
params: this.searchForm
}).then(res=>{
if(res.code === 200){
this.tableData = res.data.records;
this.searchForm.currentPage = res.data.current;
this.searchForm.pageSize = res.data.size;
this.total = res.data.total;
}else {
this.$message.error("获取数据失败!");
}
})
},
handleSizeChange(val){
this.searchForm.pageSize = val;
this.searchForm.currentPage = 1;
this.getData();
},
handleCurrentChange(val){
this.searchForm.currentPage = val;
this.getData();
}
},
created(){
//计算表格高度
this.$nextTick(()=>{
this.tableHeight = window.innerHeight - 275;
});
//获取数据
this.getData();
//获取用户列表
this.getUserList();
//获取客户列表
this.getCustomerList();
}
}
</script>
<style lang="scss" scoped>
.user-area{
width: 100%;
height: 100%;
margin-top: 15px;
.search{
}
.data-table{
margin-top: 15px;
}
.data-page{
text-align: left;
margin-top: 5px;
}
}
</style>
customerView.vue
<template>
<div class="user-area">
<el-card show="always" class="search">
<el-row>
<el-form :inline="true">
<el-form-item>
<el-input
v-model="searchForm.name"
placeholder="输入客户名称搜索"
@clear="doSearch"
@keypress.native.enter="doSearch"
clearable></el-input>
</el-form-item>
<el-form-item>
<el-select
v-model="searchForm.customerState"
placeholder="选择客户状态"
style="margin-left: 1px;"
@clear="doSearch"
clearable>
<el-option label="新建完成" value="0"></el-option>
<el-option label="跟进中" value="1"></el-option>
<el-option label="即将成交" value="2"></el-option>
<el-option label="成交过的" value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-toilet-paper" @click="doClean">清空</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-plus" @click="addBtn">新增</el-button>
</el-form-item>
</el-form>
</el-row>
</el-card>
<div class="data-table">
<el-table
:data="tableData"
border
:height="tableHeight"
size="mini"
style="width: 100%">
<el-table-column
fixed
prop="id"
width="50px"
label="ID">
</el-table-column>
<el-table-column
fixed
prop="name"
label="客户名称"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="companyAddress"
label="公司地址"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="person"
label="联系人"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="phone"
label="手机"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="profession"
label="行业"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="province"
label="省份"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="city"
label="城市"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="userId"
label="负责人"
width="200px"
show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ userList.find(item =>item.id === scope.row.userId).name }} </span>
</template>
</el-table-column>
<el-table-column
prop="customerState"
label="客户状态"
width="200px"
show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="scope.row.customerState === 0">新建完成</span>
<span v-if="scope.row.customerState === 1">跟进中</span>
<span v-if="scope.row.customerState === 2">即将成交</span>
<span v-if="scope.row.customerState === 3">成交过的</span>
</template>
</el-table-column>
<el-table-column
prop="competitor"
label="竞争对手"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="note"
label="客户备注"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="bankName"
label="开户行"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="bankNo"
label="开户行账号"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="billAddress"
label="发票地址"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="billPerson"
label="发票人"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="billPhone"
label="发票手机号"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="billNote"
label="开票备注"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column label="操作" fixed="right" width="200px">
<template slot-scope="scope">
<el-button type="primary" icon="el-icon-edit" @click="handleEdit(scope.row)" size="mini">编辑</el-button>
<el-button type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)" size="mini">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="data-page">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="searchForm.currentPage"
:page-sizes="[2, 5, 10, 50]"
:page-size="searchForm.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
<!-- 新增对话框 -->
<div>
<el-dialog
:title="dialogTitle"
:visible.sync="addDialogVisible"
:close-on-click-modal="false"
width="75%"
:before-close="handleClose">
<el-form
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="85px"
label-position="left"
class="demo-ruleForm">
<el-row>
<el-col :span="7" :offset="1">
<el-form-item label="客户名称" prop="name">
<el-input v-model="ruleForm.name" clearable></el-input>
</el-form-item>
<el-form-item label="公司地址" prop="companyAddress">
<el-input v-model="ruleForm.companyAddress" clearable></el-input>
</el-form-item>
<el-form-item label="联系人" prop="person">
<el-input v-model="ruleForm.person" clearable></el-input>
</el-form-item>
<el-form-item label="手机" prop="phone">
<el-input v-model="ruleForm.phone" clearable></el-input>
</el-form-item>
<el-form-item label="省份" prop="province">
<el-input v-model="ruleForm.province" clearable></el-input>
</el-form-item>
<el-form-item label="城市" prop="city">
<el-input v-model="ruleForm.city" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="7" :offset="1">
<el-form-item label="行业" prop="profession">
<el-input v-model="ruleForm.profession" clearable></el-input>
</el-form-item>
<el-form-item label="负责人" prop="userId">
<el-select v-model="ruleForm.userId" style="width: 100%;" clearable>
<el-option
v-for="item in userList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="客户状态" prop="customerState">
<el-select v-model="ruleForm.customerState" style="width: 100%;" clearable>
<el-option label="新建完成" :value="0"></el-option>
<el-option label="跟进中" :value="1"></el-option>
<el-option label="即将成交" :value="2"></el-option>
<el-option label="成交过的" :value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item label="竞争对手" prop="competitor">
<el-input v-model="ruleForm.competitor" clearable></el-input>
</el-form-item>
<el-form-item label="客户备注" prop="note">
<el-input v-model="ruleForm.province" clearable></el-input>
</el-form-item>
<el-form-item label="开户行" prop="bankName">
<el-input v-model="ruleForm.bankName" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="7" :offset="1">
<el-form-item label="开户行账号" prop="bankNo">
<el-input v-model="ruleForm.bankNo" clearable></el-input>
</el-form-item>
<el-form-item label="发票地址" prop="billAddress">
<el-input v-model="ruleForm.billAddress" clearable></el-input>
</el-form-item>
<el-form-item label="开票人" prop="billPerson">
<el-input v-model="ruleForm.billPerson" clearable></el-input>
</el-form-item>
<el-form-item label="发票手机号" prop="billPhone">
<el-input v-model="ruleForm.billPhone" clearable></el-input>
</el-form-item>
<el-form-item label="开票备注" prop="billNote">
<el-input v-model="ruleForm.billNote" clearable></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogReset" v-if="dialogTitle==='新增用户'">重 置</el-button>
<el-button type="primary" @click="dialogSubmit">确 定</el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import request from "@/utils/request";
export default {
name: "CustomerView",
data(){
return {
//用户列表
userList:[],
//对话框标题
dialogTitle: '',
//对话框可见
addDialogVisible: false,
//搜索区域
searchForm: {
name:'',
customerState:'',
currentPage:1,
pageSize:5,
},
//总记录数
total:0,
//表格数据
tableData:[],
//表格高度
tableHeight:0,
//新增表单
ruleForm: {
name: '',
companyAddress: '',
person: '',
phone: '',
profession: '',
province: '',
city: '',
userId: '',
customerState: '',
competitor: '',
note: '',
bankName: '',
bankNo: '',
billAddress: '',
billPerson: '',
billPhone: '',
billNote: '',
},
rules: {
name: [
{ required: true, message: '请输入客户名称', trigger: 'blur' },
],
companyAddress: [
{ required: true, message: '请输入公司地址', trigger: 'blur' },
],
userId: [
{ required: true, message: '请选择负责人', trigger: 'change' },
],
customerState: [
{ required: true, message: '请选择客户状态', trigger: 'change' },
],
}
}
},
methods: {
//获取用户列表
getUserList(){
request.get('/user/list').then(res=>{
//console.log(res)
if(res.code === 200){
this.userList = res.data;
}
})
},
//删除
handleDelete(row){
this.$confirm(`您确定要删除【${ row.name }】吗?`,'删除提示',{
confirmButtonText:'删除',
cancelButtonText:'取消',
type: 'warning'
}).then(()=>{
request.delete('/customer/delete/' + row.id)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
});
}).catch(_=>{
this.$message.warning("已取消删除");
})
},
//编辑
handleEdit(row){
//深度拷贝
let obj = JSON.parse(JSON.stringify(row));
this.ruleForm = obj;
this.dialogTitle = '编辑客户';
this.addDialogVisible = true;
},
//新增
addBtn(){
this.ruleForm = {};
this.dialogTitle = '新增客户';
this.addDialogVisible = true;
},
//对话框提交
dialogSubmit(){
this.$refs.ruleForm.validate((valid)=>{
if(valid){
request.post(this.ruleForm.id ? '/customer/update':'/customer/save',this.ruleForm)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.handleClose();
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
})
}
})
},
//对话框重置
dialogReset(){
this.$refs.ruleForm.resetFields();
this.ruleForm = {};
},
//对话框关闭
handleClose(){
this.dialogReset();
this.addDialogVisible = false;
},
//清空
doClean(){
this.searchForm.name = '';
this.searchForm.customerState = '';
this.doSearch();
},
//搜索
doSearch(){
this.searchForm.currentPage = 1;
this.getData();
},
//获取数据
getData(){
request.get("/customer/listPage",{
params: this.searchForm
}).then(res=>{
if(res.code === 200){
//console.log(res);
this.tableData = res.data.records;
this.searchForm.currentPage = res.data.current;
this.searchForm.pageSize = res.data.size;
this.total = res.data.total;
}else {
this.$message.error("获取数据失败!");
}
})
},
handleSizeChange(val){
this.searchForm.pageSize = val;
this.searchForm.currentPage = 1;
this.getData();
},
handleCurrentChange(val){
this.searchForm.currentPage = val;
this.getData();
}
},
created(){
//计算表格高度
this.$nextTick(()=>{
this.tableHeight = window.innerHeight - 275;
});
//获取数据
this.getData();
//获取用户列表
this.getUserList();
}
}
</script>
<style lang="scss" scoped>
.user-area{
width: 100%;
height: 100%;
margin-top: 15px;
.search{
}
.data-table{
margin-top: 15px;
}
.data-page{
text-align: left;
margin-top: 5px;
}
}
</style>
orderDetail.vue
<template>
<div class="user-area">
<el-card show="always" class="search">
<el-row>
<el-form :inline="true">
<el-form-item>
<el-input
v-model="searchForm.orderId"
placeholder="输入订单号搜索"
@clear="doSearch"
@keypress.native.enter="doSearch"
clearable>
</el-input>
</el-form-item>
<el-form-item>
<el-select
v-model="searchForm.productId"
placeholder="选择产品"
style="margin-left: 1px;"
@clear="doSearch"
clearable>
<el-option
v-for="item in productList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-toilet-paper" @click="doClean">清空</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-plus" @click="addBtn">新增</el-button>
</el-form-item>
</el-form>
</el-row>
</el-card>
<div class="data-table">
<el-table
:data="tableData"
border
:height="tableHeight"
size="mini"
style="width: 100%">
<el-table-column
prop="id"
width="50px"
label="ID">
</el-table-column>
<el-table-column
prop="orderId"
label="订单号"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="productId"
label="产品名称"
width="200px"
show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ productList.find(item => item.id === scope.row.productId).name }} </span>
</template>
</el-table-column>
<el-table-column
prop="productCode"
label="产品编码"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="productName"
label="产品名称(旧)"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="amount"
label="数量"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="univalent"
label="单价"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="totalPrice"
label="总价"
show-overflow-tooltip>
</el-table-column>
<el-table-column label="操作" fixed="right" width="200px">
<template slot-scope="scope">
<el-button type="primary" icon="el-icon-edit" @click="handleEdit(scope.row)" size="mini">编辑</el-button>
<el-button type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)" size="mini">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="data-page">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="searchForm.currentPage"
:page-sizes="[2, 5, 10, 50]"
:page-size="searchForm.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
<!-- 新增对话框 -->
<div>
<el-dialog
:title="dialogTitle"
:visible.sync="addDialogVisible"
:close-on-click-modal="false"
width="50%"
:before-close="handleClose">
<el-form
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="100px"
label-position="left"
class="demo-ruleForm">
<el-row>
<el-col :span="10" :offset="1">
<el-form-item label="订单号" prop="orderId">
<el-input-number v-model="ruleForm.orderId" :step="1" :min="1" style="width: 100%;"></el-input-number>
</el-form-item>
<el-form-item label="产品" prop="productId">
<el-select
v-model="ruleForm.productId"
@change="productIdChange"
style="width: 100%;"
clearable>
<el-option
v-for="item in productList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="产品编码" prop="productCode">
<el-input v-model="ruleForm.productCode" clearable></el-input>
</el-form-item>
<el-form-item label="产品名称" prop="productName">
<el-input v-model="ruleForm.productName" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="10" :offset="1">
<el-form-item label="数量" prop="amount">
<el-input-number
v-model="ruleForm.amount"
:step="1.0"
:min="0.0"
@change="handleTotalMoney"
@blur="handleTotalMoney"
style="width: 100%;"></el-input-number>
</el-form-item>
<el-form-item label="单价" prop="univalent">
<el-input-number
v-model="ruleForm.univalent"
:precision="2"
:step="1.0"
:min="0.0"
@change="handleTotalMoney"
@blur="handleTotalMoney"
style="width: 100%;"></el-input-number>
</el-form-item>
<el-form-item label="总金额" prop="totalPrice">
<el-input-number v-model="ruleForm.totalPrice" :precision="2" :step="1.0" :min="0.0" style="width: 100%;"></el-input-number>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogReset" v-if="dialogTitle==='新增订单明细'">重 置</el-button>
<el-button type="primary" @click="dialogSubmit">确 定</el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import request from "@/utils/request";
export default {
name: "OrderDetail",
data(){
return {
//产品列表
productList:[],
//对话框标题
dialogTitle: '',
//对话框可见
addDialogVisible: false,
//搜索区域
searchForm: {
orderId:'',
productId:'',
currentPage:1,
pageSize:5,
},
//总记录数
total:0,
//表格数据
tableData:[],
//表格高度
tableHeight:0,
//新增表单
ruleForm: {
orderId: '',
productId: '',
productCode: '',
productName: '',
amount: '',
univalent: '',
totalPrice: '',
},
rules: {
orderId: [
{ required: true, message: '请输入订单号', trigger: 'blur' },
],
productId: [
{ required: true, message: '请选择产品', trigger: 'change' },
],
productCode: [
{ required: true, message: '请输入产品编码', trigger: 'blur' },
],
productName: [
{ required: true, message: '请输入产品名称', trigger: 'blur' },
],
amount: [
{ required: true, message: '请输入数量', trigger: 'blur' },
],
univalent: [
{ required: true, message: '请输入单价', trigger: 'blur' },
],
totalPrice: [
{ required: true, message: '请输入总金额', trigger: 'blur' },
],
}
}
},
methods: {
//计算总金额
handleTotalMoney(){
if(this.ruleForm.amount && this.ruleForm.univalent){
this.ruleForm.totalPrice = this.ruleForm.amount * this.ruleForm.univalent;
}
},
productIdChange(val){
let product = this.productList.find(item=> item.id === val);
this.ruleForm.productName = product.name;
this.ruleForm.productCode = product.code;
},
//获取产品列表
getProductList(){
request.get('/product/list').then(res=>{
if(res.code === 200){
this.productList = res.data;
}
})
},
//删除
handleDelete(row){
this.$confirm(`您确定要删除吗?`,'删除提示',{
confirmButtonText:'删除',
cancelButtonText:'取消',
type: 'warning'
}).then(()=>{
request.delete('/orderDetail/delete/' + row.id)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
});
}).catch(_=>{
this.$message.warning("已取消删除");
})
},
//编辑
handleEdit(row){
//深度拷贝
let obj = JSON.parse(JSON.stringify(row));
this.ruleForm = obj;
this.dialogTitle = '编辑订单明细';
this.addDialogVisible = true;
},
//新增
addBtn(){
this.ruleForm = {};
this.dialogTitle = '新增订单明细';
this.addDialogVisible = true;
},
//对话框提交
dialogSubmit(){
this.$refs.ruleForm.validate((valid)=>{
if(valid){
request.post(this.ruleForm.id ? '/orderDetail/update':'/orderDetail/save',this.ruleForm)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.handleClose();
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
})
}
})
},
//对话框重置
dialogReset(){
this.$refs.ruleForm.resetFields();
this.ruleForm = {};
},
//对话框关闭
handleClose(){
this.dialogReset();
this.addDialogVisible = false;
},
//清空
doClean(){
this.searchForm.orderId = '';
this.searchForm.productId = '';
this.doSearch();
},
//搜索
doSearch(){
this.searchForm.currentPage = 1;
this.getData();
},
//获取数据
getData(){
request.get("/orderDetail/listPage",{
params: this.searchForm
}).then(res=>{
if(res.code === 200){
this.tableData = res.data.records;
this.searchForm.currentPage = res.data.current;
this.searchForm.pageSize = res.data.size;
this.total = res.data.total;
}else {
this.$message.error("获取数据失败!");
}
})
},
handleSizeChange(val){
this.searchForm.pageSize = val;
this.searchForm.currentPage = 1;
this.getData();
},
handleCurrentChange(val){
this.searchForm.currentPage = val;
this.getData();
}
},
created(){
//计算表格高度
this.$nextTick(()=>{
this.tableHeight = window.innerHeight - 275;
});
//获取数据
this.getData();
//获取用户列表
this.getProductList();
}
}
</script>
<style lang="scss" scoped>
.user-area{
width: 100%;
height: 100%;
margin-top: 15px;
.search{
}
.data-table{
margin-top: 15px;
}
.data-page{
text-align: left;
margin-top: 5px;
}
}
</style>
orderView.vue
<template>
<div class="user-area">
<el-card show="always" class="search">
<el-row>
<el-form :inline="true">
<el-form-item>
<el-select
v-model="searchForm.customerId"
placeholder="选择客户"
@clear="doSearch"
clearable>
<el-option
v-for="item in customerList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-select
v-model="searchForm.userId"
placeholder="选择用户"
style="margin-left: 1px;"
@clear="doSearch"
clearable>
<el-option
v-for="item in userList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-select
v-model="searchForm.productState"
placeholder="选择发货状态"
style="margin-left: 1px;"
@clear="doSearch"
clearable>
<el-option label="未发货" value="0"></el-option>
<el-option label="部分发货" value="1"></el-option>
<el-option label="全部发货" value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-select
v-model="searchForm.payState"
placeholder="选择支付状态"
style="margin-left: 1px;"
@clear="doSearch"
clearable>
<el-option label="未支付" value="0"></el-option>
<el-option label="部分支付" value="1"></el-option>
<el-option label="全部支付" value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-toilet-paper" @click="doClean">清空</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-plus" @click="addBtn">新增</el-button>
</el-form-item>
</el-form>
</el-row>
</el-card>
<div class="data-table">
<el-table
:data="tableData"
border
:height="tableHeight"
size="mini"
style="width: 100%">
<el-table-column
fixed
prop="id"
width="50px"
label="ID">
</el-table-column>
<el-table-column
fixed
prop="customerId"
label="客户名称"
width="200px"
show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ customerList.find(item => item.id === scope.row.customerId).name }} </span>
</template>
</el-table-column>
<el-table-column
prop="userId"
label="负责人"
width="200px"
show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ userList.find(item => item.id === scope.row.userId).name }} </span>
</template>
</el-table-column>
<el-table-column
prop="createDate"
label="创建日期"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="totalMoney"
label="总金额"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="alreadyPay"
label="已支付金额"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="nextPayTime"
label="下次支付时间"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="discount"
label="打折"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="product_state"
label="发货状态"
width="200px"
show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="scope.row.productState === 0">未发货</span>
<span v-if="scope.row.productState === 1">部分发货</span>
<span v-if="scope.row.productState === 2">全部发货</span>
</template>
</el-table-column>
<el-table-column
prop="payState"
label="支付状态"
width="200px"
show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="scope.row.payState === 0">未支付</span>
<span v-if="scope.row.payState === 1">部分支付</span>
<span v-if="scope.row.payState === 2">全部支付</span>
</template>
</el-table-column>
<el-table-column
prop="sendTime"
label="发货时间"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="sendAddress"
label="发货地址"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="sendPrice"
label="运费"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="sendway"
label="发货方式"
width="200px"
show-overflow-tooltip>
</el-table-column>
<el-table-column label="操作" fixed="right" width="200px">
<template slot-scope="scope">
<el-button type="primary" icon="el-icon-edit" @click="handleEdit(scope.row)" size="mini">编辑</el-button>
<el-button type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)" size="mini">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="data-page">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="searchForm.currentPage"
:page-sizes="[2, 5, 10, 50]"
:page-size="searchForm.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
<!-- 新增对话框 -->
<div>
<el-dialog
:title="dialogTitle"
:visible.sync="addDialogVisible"
:close-on-click-modal="false"
width="50%"
:before-close="handleClose">
<el-form
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="100px"
label-position="left"
class="demo-ruleForm">
<el-row>
<el-col :span="10" :offset="1">
<el-form-item label="客户" prop="customerId">
<el-select v-model="ruleForm.customerId" style="width: 100%;" clearable>
<el-option
v-for="item in customerList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="负责人" prop="userId">
<el-select v-model="ruleForm.userId" style="width: 100%;" clearable>
<el-option
v-for="item in userList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="创建日期" prop="createDate" >
<el-date-picker
v-model="ruleForm.createDate"
type="date"
placeholder="选择日期"
style="width: 100%;">
</el-date-picker>
</el-form-item>
<el-form-item label="总金额" prop="totalMoney">
<el-input-number v-model="ruleForm.totalMoney" :precision="2" :step="1.0" :min="0.0" style="width: 70%;"></el-input-number>
</el-form-item>
<el-form-item label="已支付金额">
<el-input-number v-model="ruleForm.alreadyPay" :precision="2" :step="1.0" :min="0.0" style="width: 70%;"></el-input-number>
</el-form-item>
<el-form-item label="下次支付时间">
<el-date-picker
v-model="ruleForm.nextPayTime"
type="date"
placeholder="选择日期"
style="width: 100%;">
</el-date-picker>
</el-form-item>
<el-form-item label="打折" >
<el-input v-model="ruleForm.discount" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="10" :offset="1">
<el-form-item label="发货状态" prop="productState">
<el-select v-model="ruleForm.productState" style="width: 100%;" clearable>
<el-option label="未发货" :value="0"></el-option>
<el-option label="部分发货" :value="1"></el-option>
<el-option label="全部发货" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="支付状态" prop="payState">
<el-select v-model="ruleForm.payState" style="width: 100%;" clearable>
<el-option label="未支付" :value="0"></el-option>
<el-option label="部分支付" :value="1"></el-option>
<el-option label="全部支付" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="发货时间">
<el-date-picker
v-model="ruleForm.sendTime"
type="date"
placeholder="选择日期"
style="width: 100%;">
</el-date-picker>
</el-form-item>
<el-form-item label="发货地址">
<el-input v-model="ruleForm.sendAddress" clearable></el-input>
</el-form-item>
<el-form-item label="运费">
<el-input-number v-model="ruleForm.sendPrice" :precision="2" :step="0.5" :min="0" style="width: 70%;"></el-input-number>
</el-form-item>
<el-form-item label="发货方式" >
<el-input v-model="ruleForm.sendWay" clearable></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogReset" v-if="dialogTitle==='新增订单'">重 置</el-button>
<el-button type="primary" @click="dialogSubmit">确 定</el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import request from "@/utils/request";
export default {
name: "OrderView",
data(){
return {
//客户列表
customerList:[],
//用户列表
userList:[],
//对话框标题
dialogTitle: '',
//对话框可见
addDialogVisible: false,
//搜索区域
searchForm: {
customerId:'',
userId:'',
productState:'',
payState:'',
currentPage:1,
pageSize:5,
},
//总记录数
total:0,
//表格数据
tableData:[],
//表格高度
tableHeight:0,
//新增表单
ruleForm: {
customerId: '',
userId: '',
createDate: '',
totalMoney: '',
alreadyPay: '',
nextPayTime: '',
discount: '',
productState:'',
payState:'',
sendTime:'',
sendAddress:'',
sendPrice:'',
sendWay:'',
},
rules: {
customerId: [
{ required: true, message: '请选择客户', trigger: 'change' },
],
userId: [
{ required: true, message: '请选择用户', trigger: 'change' },
],
createDate: [
{ required: true, message: '请选择创建日期', trigger: 'change' },
],
totalMoney: [
{ required: true, message: '请输入总金额', trigger: 'blur' },
],
productState: [
{ required: true, message: '请选择发货状态', trigger: 'change' },
],
payState: [
{ required: true, message: '请选择支付状态', trigger: 'change' },
],
}
}
},
methods: {
//获取用户列表
getCustomerList(){
request.get('/customer/list').then(res=>{
if(res.code === 200){
this.customerList = res.data;
}
})
},
//获取用户列表
getUserList(){
request.get('/user/list').then(res=>{
if(res.code === 200){
this.userList = res.data;
}
})
},
//删除
handleDelete(row){
this.$confirm(`您确定要删除吗?`,'删除提示',{
confirmButtonText:'删除',
cancelButtonText:'取消',
type: 'warning'
}).then(()=>{
request.delete('/order/delete/' + row.id)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
});
}).catch(_=>{
this.$message.warning("已取消删除");
})
},
//编辑
handleEdit(row){
//深度拷贝
let obj = JSON.parse(JSON.stringify(row));
this.ruleForm = obj;
this.dialogTitle = '编辑订单';
this.addDialogVisible = true;
},
//新增
addBtn(){
this.ruleForm = {};
this.dialogTitle = '新增订单';
this.addDialogVisible = true;
},
//对话框提交
dialogSubmit(){
this.$refs.ruleForm.validate((valid)=>{
if(valid){
request.post(this.ruleForm.id ? '/order/update':'/order/save',this.ruleForm)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.handleClose();
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
})
}
})
},
//对话框重置
dialogReset(){
this.$refs.ruleForm.resetFields();
this.ruleForm = {};
},
//对话框关闭
handleClose(){
this.dialogReset();
this.addDialogVisible = false;
},
//清空
doClean(){
this.searchForm.customerId = '';
this.searchForm.userId = '';
this.searchForm.productState = '';
this.searchForm.payState = '';
this.doSearch();
},
//搜索
doSearch(){
this.searchForm.currentPage = 1;
this.getData();
},
//获取数据
getData(){
request.get("/order/listPage",{
params: this.searchForm
}).then(res=>{
if(res.code === 200){
this.tableData = res.data.records;
this.searchForm.currentPage = res.data.current;
this.searchForm.pageSize = res.data.size;
this.total = res.data.total;
}else {
this.$message.error("获取数据失败!");
}
})
},
handleSizeChange(val){
this.searchForm.pageSize = val;
this.searchForm.currentPage = 1;
this.getData();
},
handleCurrentChange(val){
this.searchForm.currentPage = val;
this.getData();
}
},
created(){
//计算表格高度
this.$nextTick(()=>{
this.tableHeight = window.innerHeight - 275;
});
//获取数据
this.getData();
//获取用户列表
this.getUserList();
//获取客户列表
this.getCustomerList();
}
}
</script>
<style lang="scss" scoped>
.user-area{
width: 100%;
height: 100%;
margin-top: 15px;
.search{
}
.data-table{
margin-top: 15px;
}
.data-page{
text-align: left;
margin-top: 5px;
}
}
</style>
prodcutView.vue
<template>
<div class="user-area">
<el-card show="always" class="search">
<el-row>
<el-form :inline="true">
<el-form-item>
<el-input
v-model="searchForm.name"
placeholder="输入产品名称搜索"
@clear="doSearch"
@keypress.native.enter="doSearch"
clearable></el-input>
</el-form-item>
<el-form-item>
<el-input
v-model="searchForm.supplier"
placeholder="输入供应商搜索"
@clear="doSearch"
@keypress.native.enter="doSearch"
clearable></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-toilet-paper" @click="doClean">清空</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-plus" @click="addBtn">新增</el-button>
</el-form-item>
</el-form>
</el-row>
</el-card>
<div class="data-table">
<el-table
:data="tableData"
border
:height="tableHeight"
style="width: 100%">
<el-table-column
prop="id"
label="ID">
</el-table-column>
<el-table-column
prop="name"
label="产品名称"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="code"
label="产品编码"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="createTime"
label="创建时间"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="supplier"
label="供应商"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="note"
label="备注"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="productUnit"
label="产品单位"
show-overflow-tooltip>
</el-table-column>
<el-table-column label="操作" width="300px;">
<template slot-scope="scope">
<el-button type="primary" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
<el-button type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="data-page">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="searchForm.currentPage"
:page-sizes="[2, 5, 10, 50]"
:page-size="searchForm.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
<!-- 新增对话框 -->
<div>
<el-dialog
:title="dialogTitle"
:visible.sync="addDialogVisible"
:close-on-click-modal="false"
width="50%"
:before-close="handleClose">
<el-form
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="80px"
label-position="left"
class="demo-ruleForm">
<el-row>
<el-col :span="10" :offset="1">
<el-form-item label="产品名称" prop="name">
<el-input v-model="ruleForm.name" clearable></el-input>
</el-form-item>
<el-form-item label="产品编码" prop="code">
<el-input v-model="ruleForm.code" clearable></el-input>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="ruleForm.createTime"
type="date"
style="width: 100%;"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="10" :offset="1">
<el-form-item label="供应商" prop="supplier">
<el-input v-model="ruleForm.supplier" clearable></el-input>
</el-form-item>
<el-form-item label="备注">
<el-input v-model="ruleForm.note" clearable></el-input>
</el-form-item>
<el-form-item label="产品单位" prop="productUnit" >
<el-input v-model="ruleForm.productUnit" clearable></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogReset" v-if="dialogTitle==='新增产品'">重 置</el-button>
<el-button type="primary" @click="dialogSubmit">确 定</el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import request from "@/utils/request";
export default {
name: "ProductView",
data(){
return {
//对话框标题
dialogTitle: '',
//对话框可见
addDialogVisible: false,
//搜索区域
searchForm: {
name:'',
supplier:'',
currentPage:1,
pageSize:5,
},
//总记录数
total:0,
//表格数据
tableData:[],
//表格高度
tableHeight:0,
//新增表单
ruleForm: {
name: '',
code: '',
createTime: '',
supplier: '',
note: '',
productUnit: '',
},
rules: {
name: [
{ required: true, message: '请输入产品名称', trigger: 'blur' },
],
code: [
{ required: true, message: '请输入产品编码', trigger: 'blur' },
],
createTime: [
{ required: true, message: '请选择创建时间', trigger: 'change' },
],
supplier: [
{ required: true, message: '请输入供应商', trigger: 'blur' },
],
productUnit: [
{ required: true, message: '请输入产品单位', trigger: 'blur' },
],
}
}
},
methods: {
//删除
handleDelete(row){
this.$confirm(`您确定要删除【${ row.name }】吗?`,'删除提示',{
confirmButtonText:'删除',
cancelButtonText:'取消',
type: 'warning'
}).then(()=>{
request.delete('/product/delete/' + row.id)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
});
}).catch(_=>{
this.$message.warning("已取消删除");
})
},
//编辑
handleEdit(row){
//深度拷贝
let obj = JSON.parse(JSON.stringify(row));
this.ruleForm = obj;
this.dialogTitle = '编辑产品';
this.addDialogVisible = true;
},
//新增
addBtn(){
this.ruleForm = {};
this.dialogTitle = '新增产品';
this.addDialogVisible = true;
},
//对话框提交
dialogSubmit(){
this.$refs.ruleForm.validate((valid)=>{
if(valid){
request.post(this.ruleForm.id ? '/product/update':'/product/save',this.ruleForm)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.handleClose();
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
})
}
})
},
//对话框重置
dialogReset(){
this.$refs.ruleForm.resetFields();
this.ruleForm = {};
},
//对话框关闭
handleClose(){
this.dialogReset();
this.addDialogVisible = false;
},
//清空
doClean(){
this.searchForm.name = '';
this.searchForm.supplier = '';
this.doSearch();
},
//搜索
doSearch(){
this.searchForm.currentPage = 1;
this.getData();
},
//获取数据
getData(){
request.get("/product/listPage",{
params: this.searchForm
}).then(res=>{
if(res.code === 200){
//console.log(res);
this.tableData = res.data.records;
this.searchForm.currentPage = res.data.current;
this.searchForm.pageSize = res.data.size;
this.total = res.data.total;
}else {
this.$message.error("获取数据失败!");
}
})
},
handleSizeChange(val){
this.searchForm.pageSize = val;
this.searchForm.currentPage = 1;
this.getData();
},
handleCurrentChange(val){
this.searchForm.currentPage = val;
this.getData();
}
},
created(){
//计算表格高度
this.$nextTick(()=>{
this.tableHeight = window.innerHeight - 275;
});
//获取数据
this.getData();
}
}
</script>
<style lang="scss" scoped>
.user-area{
width: 100%;
height: 100%;
margin-top: 15px;
.search{
}
.data-table{
margin-top: 15px;
}
.data-page{
text-align: left;
margin-top: 5px;
}
}
</style>
targetview.vue
<template>
<div class="user-area">
<el-card show="always" class="search">
<el-row>
<el-form :inline="true">
<el-form-item>
<el-input
v-model="searchForm.target"
placeholder="输入订单目标搜索"
@clear="doSearch"
@keypress.native.enter="doSearch"
clearable></el-input>
</el-form-item>
<el-form-item>
<el-select
v-model="searchForm.targetState"
placeholder="选择目标状态"
style="margin-left: 1px;"
@clear="doSearch"
clearable>
<el-option label="未完成" value="0"></el-option>
<el-option label="已完成" value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-toilet-paper" @click="doClean">清空</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-plus" @click="addBtn">新增</el-button>
</el-form-item>
</el-form>
</el-row>
</el-card>
<div class="data-table">
<el-table
:data="tableData"
border
:height="tableHeight"
size="mini"
style="width: 100%">
<el-table-column
prop="id"
width="50px"
label="ID">
</el-table-column>
<el-table-column
prop="userId"
label="负责人"
show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ userList.find(item =>item.id === scope.row.userId).name }} </span>
</template>
</el-table-column>
<el-table-column
prop="startTime"
label="目标开始时间"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="endTime"
label="目标结束时间"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="target"
label="订单目标"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="hasDone"
label="已经完成"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="targetState"
label="目标状态"
show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="scope.row.targetState === 0">未完成</span>
<span v-if="scope.row.targetState === 1">已完成</span>
</template>
</el-table-column>
<el-table-column label="操作" width="200px">
<template slot-scope="scope">
<el-button type="primary" icon="el-icon-edit" @click="handleEdit(scope.row)" size="mini">编辑</el-button>
<el-button type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)" size="mini">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="data-page">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="searchForm.currentPage"
:page-sizes="[2, 5, 10, 50]"
:page-size="searchForm.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
<!-- 新增对话框 -->
<div>
<el-dialog
:title="dialogTitle"
:visible.sync="addDialogVisible"
:close-on-click-modal="false"
width="50%"
:before-close="handleClose">
<el-form
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="85px"
label-position="left"
class="demo-ruleForm">
<el-row>
<el-col :span="10" :offset="1">
<el-form-item label="负责人" prop="userId">
<el-select v-model="ruleForm.userId" style="width: 100%;" clearable>
<el-option
v-for="item in userList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="开始时间" prop="startTime">
<el-date-picker
v-model="ruleForm.startTime"
type="date"
style="width: 100%;"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间" prop="endTime">
<el-date-picker
v-model="ruleForm.endTime"
type="date"
style="width: 100%;"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="10" :offset="1">
<el-form-item label="订单目标" prop="target">
<el-input v-model="ruleForm.target" clearable></el-input>
</el-form-item>
<el-form-item label="已经完成" prop="hasDone">
<el-input v-model="ruleForm.hasDone" clearable></el-input>
</el-form-item>
<el-form-item label="目标状态" prop="targetState">
<el-select v-model="ruleForm.targetState" style="width: 100%;">
<el-option label="未完成" :value="0"></el-option>
<el-option label="已完成" :value="1"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogReset" v-if="dialogTitle==='新增订单目标'">重 置</el-button>
<el-button type="primary" @click="dialogSubmit">确 定</el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import request from "@/utils/request";
export default {
name: "TargetView",
data(){
return {
//用户列表
userList:[],
//对话框标题
dialogTitle: '',
//对话框可见
addDialogVisible: false,
//搜索区域
searchForm: {
target:'',
targetState:'',
currentPage:1,
pageSize:5,
},
//总记录数
total:0,
//表格数据
tableData:[],
//表格高度
tableHeight:0,
//新增表单
ruleForm: {
userId: '',
startTime: '',
endTime: '',
target: '',
hasDone: '',
targetState: '',
},
rules: {
userId: [
{ required: true, message: '请选择负责人', trigger: 'change' },
],
startTime: [
{ required: true, message: '请选择开始时间', trigger: 'change' },
],
endTime: [
{ required: true, message: '请选择结束时间', trigger: 'change' },
],
target: [
{ required: true, message: '请输入订单目标', trigger: 'blur' },
],
hasDone: [
{ required: true, message: '请输入已完成', trigger: 'blur' },
],
targetState: [
{ required: true, message: '请选择目标状态', trigger: 'change' },
],
}
}
},
methods: {
//获取用户列表
getUserList(){
request.get('/user/list').then(res=>{
if(res.code === 200){
this.userList = res.data;
}
})
},
//删除
handleDelete(row){
this.$confirm(`您确定要删除吗?`,'删除提示',{
confirmButtonText:'删除',
cancelButtonText:'取消',
type: 'warning'
}).then(()=>{
request.delete('/orderTarget/delete/' + row.id)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
});
}).catch(_=>{
this.$message.warning("已取消删除");
})
},
//编辑
handleEdit(row){
//深度拷贝
let obj = JSON.parse(JSON.stringify(row));
this.ruleForm = obj;
this.dialogTitle = '编辑订单目标';
this.addDialogVisible = true;
},
//新增
addBtn(){
this.ruleForm = {};
this.dialogTitle = '新增订单目标';
this.addDialogVisible = true;
},
//对话框提交
dialogSubmit(){
this.$refs.ruleForm.validate((valid)=>{
if(valid){
request.post(this.ruleForm.id ? '/orderTarget/update':'/orderTarget/save',this.ruleForm)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.handleClose();
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
})
}
})
},
//对话框重置
dialogReset(){
this.$refs.ruleForm.resetFields();
this.ruleForm = {};
},
//对话框关闭
handleClose(){
this.dialogReset();
this.addDialogVisible = false;
},
//清空
doClean(){
this.searchForm.target = '';
this.searchForm.targetState = '';
this.doSearch();
},
//搜索
doSearch(){
this.searchForm.currentPage = 1;
this.getData();
},
//获取数据
getData(){
request.get("/orderTarget/listPage",{
params: this.searchForm
}).then(res=>{
if(res.code === 200){
this.tableData = res.data.records;
this.searchForm.currentPage = res.data.current;
this.searchForm.pageSize = res.data.size;
this.total = res.data.total;
}else {
this.$message.error("获取数据失败!");
}
})
},
handleSizeChange(val){
this.searchForm.pageSize = val;
this.searchForm.currentPage = 1;
this.getData();
},
handleCurrentChange(val){
this.searchForm.currentPage = val;
this.getData();
}
},
created(){
//计算表格高度
this.$nextTick(()=>{
this.tableHeight = window.innerHeight - 275;
});
//获取数据
this.getData();
//获取用户列表
this.getUserList();
}
}
</script>
<style lang="scss" scoped>
.user-area{
width: 100%;
height: 100%;
margin-top: 15px;
.search{
}
.data-table{
margin-top: 15px;
}
.data-page{
text-align: left;
margin-top: 5px;
}
}
</style>
todolist.vue
<template>
<div class="user-area">
<el-card show="always" class="search">
<el-row>
<el-form :inline="true">
<el-form-item>
<el-input
v-model="searchForm.content"
placeholder="输入待办事项搜索"
@clear="doSearch"
@keypress.native.enter="doSearch"
clearable></el-input>
</el-form-item>
<el-form-item>
<el-select
v-model="searchForm.userId"
placeholder="选择用户"
style="margin-left: 1px;"
@clear="doSearch"
clearable>
<el-option
v-for="item in userList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-select
v-model="searchForm.workState"
placeholder="选择任务状态"
style="margin-left: 1px;"
@clear="doSearch"
clearable>
<el-option label="未完成" value="0"></el-option>
<el-option label="已完成" value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-toilet-paper" @click="doClean">清空</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-plus" @click="addBtn">新增</el-button>
</el-form-item>
</el-form>
</el-row>
</el-card>
<div class="data-table">
<el-table
:data="tableData"
border
:height="tableHeight"
size="mini"
style="width: 100%">
<el-table-column
prop="id"
width="50px"
label="ID">
</el-table-column>
<el-table-column
prop="userId"
label="负责人"
show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ userList.find(item =>item.id === scope.row.userId).name }} </span>
</template>
</el-table-column>
<el-table-column
prop="content"
label="待办事项"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="createTime"
label="创建日期"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="doneTime"
label="计划完成时间"
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="workState"
label="任务状态"
show-overflow-tooltip>
<template slot-scope="scope">
<span v-if="scope.row.workState === 0">未完成</span>
<span v-if="scope.row.workState === 1">已完成</span>
</template>
</el-table-column>
<el-table-column label="操作" width="200px">
<template slot-scope="scope">
<el-button type="primary" icon="el-icon-edit" @click="handleEdit(scope.row)" size="mini">编辑</el-button>
<el-button type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)" size="mini">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="data-page">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="searchForm.currentPage"
:page-sizes="[2, 5, 10, 50]"
:page-size="searchForm.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
<!-- 新增对话框 -->
<div>
<el-dialog
:title="dialogTitle"
:visible.sync="addDialogVisible"
:close-on-click-modal="false"
width="50%"
:before-close="handleClose">
<el-form
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="110px"
label-position="left"
class="demo-ruleForm">
<el-row>
<el-col :span="10" :offset="1">
<el-form-item label="负责人" prop="userId">
<el-select v-model="ruleForm.userId" style="width: 100%;" clearable>
<el-option
v-for="item in userList"
:label="item.name"
:value="item.id"
:key="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="待办事项" prop="content">
<el-input v-model="ruleForm.content" clearable></el-input>
</el-form-item>
<el-form-item label="创建日期" prop="createTime">
<el-date-picker
v-model="ruleForm.createTime"
type="date"
style="width: 100%;"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="10" :offset="1">
<el-form-item label="计划完成时间" prop="doneTime">
<el-date-picker
v-model="ruleForm.doneTime"
type="date"
style="width: 100%;"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
<el-form-item label="任务状态" prop="workState">
<el-select v-model="ruleForm.workState" style="width: 100%;">
<el-option label="未完成" :value="0"></el-option>
<el-option label="已完成" :value="1"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogReset" v-if="dialogTitle==='新增待办事项'">重 置</el-button>
<el-button type="primary" @click="dialogSubmit">确 定</el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import request from "@/utils/request";
export default {
name: "TodoList",
data(){
return {
//用户列表
userList:[],
//对话框标题
dialogTitle: '',
//对话框可见
addDialogVisible: false,
//搜索区域
searchForm: {
content:'',
userId:'',
workState:'',
currentPage:1,
pageSize:5,
},
//总记录数
total:0,
//表格数据
tableData:[],
//表格高度
tableHeight:0,
//新增表单
ruleForm: {
userId: '',
content: '',
createTime: '',
doneTime: '',
workState: '',
},
rules: {
userId: [
{ required: true, message: '请选择负责人', trigger: 'change' },
],
content: [
{ required: true, message: '请输入待办事项', trigger: 'blur' },
],
createTime: [
{ required: true, message: '请选择开始时间', trigger: 'change' },
],
doneTime: [
{ required: true, message: '请选择结束时间', trigger: 'change' },
],
workState: [
{ required: true, message: '请选择任务状态', trigger: 'change' },
],
}
}
},
methods: {
//获取用户列表
getUserList(){
request.get('/user/list').then(res=>{
if(res.code === 200){
this.userList = res.data;
}
})
},
//删除
handleDelete(row){
this.$confirm(`您确定要删除吗?`,'删除提示',{
confirmButtonText:'删除',
cancelButtonText:'取消',
type: 'warning'
}).then(()=>{
request.delete('/todoList/delete/' + row.id)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
});
}).catch(_=>{
this.$message.warning("已取消删除");
})
},
//编辑
handleEdit(row){
//深度拷贝
let obj = JSON.parse(JSON.stringify(row));
this.ruleForm = obj;
this.dialogTitle = '编辑待办事项';
this.addDialogVisible = true;
},
//新增
addBtn(){
this.ruleForm = {};
this.dialogTitle = '新增待办事项';
this.addDialogVisible = true;
},
//对话框提交
dialogSubmit(){
this.$refs.ruleForm.validate((valid)=>{
if(valid){
request.post(this.ruleForm.id ? '/todoList/update':'/todoList/save',this.ruleForm)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.handleClose();
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
})
}
})
},
//对话框重置
dialogReset(){
this.$refs.ruleForm.resetFields();
this.ruleForm = {};
},
//对话框关闭
handleClose(){
this.dialogReset();
this.addDialogVisible = false;
},
//清空
doClean(){
this.searchForm.content = '';
this.searchForm.userId = '';
this.searchForm.workState = '';
this.doSearch();
},
//搜索
doSearch(){
this.searchForm.currentPage = 1;
this.getData();
},
//获取数据
getData(){
request.get("/todoList/listPage",{
params: this.searchForm
}).then(res=>{
if(res.code === 200){
this.tableData = res.data.records;
this.searchForm.currentPage = res.data.current;
this.searchForm.pageSize = res.data.size;
this.total = res.data.total;
}else {
this.$message.error("获取数据失败!");
}
})
},
handleSizeChange(val){
this.searchForm.pageSize = val;
this.searchForm.currentPage = 1;
this.getData();
},
handleCurrentChange(val){
this.searchForm.currentPage = val;
this.getData();
}
},
created(){
//计算表格高度
this.$nextTick(()=>{
this.tableHeight = window.innerHeight - 275;
});
//获取数据
this.getData();
//获取用户列表
this.getUserList();
}
}
</script>
<style lang="scss" scoped>
.user-area{
width: 100%;
height: 100%;
margin-top: 15px;
.search{
}
.data-table{
margin-top: 15px;
}
.data-page{
text-align: left;
margin-top: 5px;
}
}
</style>
userview.vue
<template>
<div class="user-area">
<el-card show="always" class="search">
<el-row>
<el-form :inline="true">
<el-form-item>
<el-input
v-model="searchForm.userName"
placeholder="输入用户名搜索"
@clear="doSearch"
@keypress.native.enter="doSearch"
clearable></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-toilet-paper" @click="doClean">清空</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-plus" @click="addBtn">新增</el-button>
</el-form-item>
</el-form>
</el-row>
</el-card>
<div class="data-table">
<el-table
:data="tableData"
border
:height="tableHeight"
style="width: 100%">
<el-table-column
prop="id"
label="ID">
</el-table-column>
<el-table-column
prop="userName"
label="用户名">
</el-table-column>
<el-table-column
prop="password"
label="密码">
</el-table-column>
<el-table-column
prop="name"
label="姓名">
</el-table-column>
<el-table-column
prop="age"
label="年龄">
</el-table-column>
<el-table-column
prop="phone"
label="电话">
</el-table-column>
<el-table-column
prop="role"
label="角色">
<template slot-scope="scope">
<span v-if="scope.row.role === 0">普通用户</span>
<span v-if="scope.row.role === 1">系统管理员</span>
</template>
</el-table-column>
<el-table-column
prop="userState"
label="用户状态">
<template slot-scope="scope">
<span v-if="scope.row.userState === 0">正常</span>
<span v-if="scope.row.userState === 1">限制登录</span>
<span v-if="scope.row.userState === 2">已删除用户</span>
</template>
</el-table-column>
<el-table-column label="操作" width="300px;">
<template slot-scope="scope">
<el-button type="primary" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
<el-button type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="data-page">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="searchForm.currentPage"
:page-sizes="[2, 5, 10, 50]"
:page-size="searchForm.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
<!-- 新增对话框 -->
<div>
<el-dialog
:title="dialogTitle"
:visible.sync="addDialogVisible"
:close-on-click-modal="false"
width="45%"
:before-close="handleClose">
<el-form
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="80px"
label-position="left"
class="demo-ruleForm">
<el-row>
<el-col :span="10" :offset="1">
<el-form-item label="用户名" prop="userName">
<el-input v-model="ruleForm.userName" clearable></el-input>
</el-form-item>
<el-form-item label="姓名" prop="name">
<el-input v-model="ruleForm.name" clearable></el-input>
</el-form-item>
<el-form-item label="电话">
<el-input v-model="ruleForm.phone" clearable></el-input>
</el-form-item>
<el-form-item label="状态" prop="userState">
<el-select v-model="ruleForm.userState" style="width: 100%;" clearable>
<el-option label="正常" :value="0"></el-option>
<el-option label="限制登录" :value="1"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="10" :offset="1">
<el-form-item label="密码" prop="password">
<el-input v-model="ruleForm.password" show-password clearable></el-input>
</el-form-item>
<el-form-item label="年龄">
<el-input-number v-model="ruleForm.age" :min="1" :max="120"></el-input-number>
</el-form-item>
<el-form-item label="角色" prop="role" >
<el-select v-model="ruleForm.role" style="width: 100%;" clearable>
<el-option label="普通用户" :value="0"></el-option>
<el-option label="系统管理员" :value="1"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogReset" v-if="dialogTitle==='新增用户'">重 置</el-button>
<el-button type="primary" @click="dialogSubmit">确 定</el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import request from "@/utils/request";
export default {
name: "UserView",
data(){
return {
//对话框标题
dialogTitle: '',
//对话框可见
addDialogVisible: false,
//搜索区域
searchForm: {
userName:'',
currentPage:1,
pageSize:5,
},
//总记录数
total:0,
//表格数据
tableData:[],
//表格高度
tableHeight:0,
//新增表单
ruleForm: {
userName: '',
password: '',
name: '',
age: '',
phone: '',
role: '',
userState: '',
},
rules: {
userName: [
{ required: true, message: '请输入用户名称', trigger: 'blur' },
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' },
],
name: [
{ required: true, message: '请输入姓名', trigger: 'blur' },
],
role: [
{ required: true, message: '请选择角色', trigger: 'change' },
],
userState: [
{ required: true, message: '请选择状态', trigger: 'change' },
],
}
}
},
methods: {
//删除
handleDelete(row){
this.$confirm(`您确定要删除【${ row.name }】吗?`,'删除提示',{
confirmButtonText:'删除',
cancelButtonText:'取消',
type: 'warning'
}).then(()=>{
request.delete('/user/delete/' + row.id)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
});
}).catch(_=>{
this.$message.warning("已取消删除");
})
},
//编辑
handleEdit(row){
//深度拷贝
let obj = JSON.parse(JSON.stringify(row));
this.ruleForm = obj;
this.dialogTitle = '编辑用户';
this.addDialogVisible = true;
},
//新增
addBtn(){
this.ruleForm = {};
this.dialogTitle = '新增用户';
this.addDialogVisible = true;
},
//对话框提交
dialogSubmit(){
this.$refs.ruleForm.validate((valid)=>{
if(valid){
request.post(this.ruleForm.id ? '/user/update':'/user/save',this.ruleForm)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
this.handleClose();
this.doSearch();
}else {
this.$message.error(res.msg);
this.doSearch();
}
})
}
})
},
//对话框重置
dialogReset(){
this.$refs.ruleForm.resetFields();
this.ruleForm = {};
},
//对话框关闭
handleClose(){
this.dialogReset();
this.addDialogVisible = false;
},
//清空
doClean(){
this.searchForm.userName = '';
this.doSearch();
},
//搜索
doSearch(){
this.searchForm.currentPage = 1;
this.getData();
},
//获取数据
getData(){
request.get("/user/listPage",{
params: this.searchForm
}).then(res=>{
if(res.code === 200){
//console.log(res);
this.tableData = res.data.records;
this.searchForm.currentPage = res.data.current;
this.searchForm.pageSize = res.data.size;
this.total = res.data.total;
}else {
this.$message.error("获取数据失败!");
}
})
},
handleSizeChange(val){
this.searchForm.pageSize = val;
this.searchForm.currentPage = 1;
this.getData();
},
handleCurrentChange(val){
this.searchForm.currentPage = val;
this.getData();
}
},
created(){
//计算表格高度
this.$nextTick(()=>{
this.tableHeight = window.innerHeight - 275;
});
//获取数据
this.getData();
}
}
</script>
<style lang="scss" scoped>
.user-area{
width: 100%;
height: 100%;
margin-top: 15px;
.search{
}
.data-table{
margin-top: 15px;
}
.data-page{
text-align: left;
margin-top: 5px;
}
}
</style>
homeview.vue
<template>
<div>
<el-container class="home-area">
<el-header class="home-header">
<span class="header-title">销售管理系统</span>
<span class="header-user">
用户:{{ admin.name }}
<el-button type="info" icon="el-icon-switch-button" @click="exitBtn" circle></el-button>
</span>
</el-header>
<el-container class="home-main">
<el-aside class="main-aside" width="210px">
<el-menu
:default-active="$route.path"
class="el-menu-vertical-demo"
background-color="#545c64"
text-color="#fff"
active-text-color="#ffd04b"
:unique-opened="true"
router>
<el-menu-item index="/index">
<i class="el-icon-s-home"></i>
<span slot="title">首页</span>
</el-menu-item>
<el-submenu index="/user" v-if="admin.role === 1">
<template slot="title">
<i class="el-icon-menu"></i>
<span>用户管理</span>
</template>
<el-menu-item index="/user">
<i class="el-icon-mobile-phone"></i>
<span slot="title">用户信息</span>
</el-menu-item>
</el-submenu>
<el-submenu index="/customer">
<template slot="title">
<i class="el-icon-menu"></i>
<span>客户管理</span>
</template>
<el-menu-item index="/customer">
<i class="el-icon-mobile-phone"></i>
<span slot="title">客户信息</span>
</el-menu-item>
<el-menu-item index="/follow">
<i class="el-icon-mobile-phone"></i>
<span slot="title">客户跟进</span>
</el-menu-item>
</el-submenu>
<el-submenu index="/product">
<template slot="title">
<i class="el-icon-menu"></i>
<span>产品管理</span>
</template>
<el-menu-item index="/product">
<i class="el-icon-mobile-phone"></i>
<span slot="title">产品信息</span>
</el-menu-item>
</el-submenu>
<el-submenu index="/order">
<template slot="title">
<i class="el-icon-menu"></i>
<span>订单管理</span>
</template>
<el-menu-item index="/order">
<i class="el-icon-mobile-phone"></i>
<span slot="title">订单信息</span>
</el-menu-item>
<el-menu-item index="/orderDetail">
<i class="el-icon-mobile-phone"></i>
<span slot="title">订单明细</span>
</el-menu-item>
</el-submenu>
<el-submenu index="/target">
<template slot="title">
<i class="el-icon-menu"></i>
<span>目标管理</span>
</template>
<el-menu-item index="/target">
<i class="el-icon-mobile-phone"></i>
<span slot="title">订单目标</span>
</el-menu-item>
</el-submenu>
<el-submenu index="/todo">
<template slot="title">
<i class="el-icon-menu"></i>
<span>事项管理</span>
</template>
<el-menu-item index="/todo">
<i class="el-icon-mobile-phone"></i>
<span slot="title">待办事项</span>
</el-menu-item>
</el-submenu>
</el-menu>
</el-aside>
<el-main class="main-content">
<el-breadcrumb separator-class="el-icon-arrow-right">
<el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
<el-breadcrumb-item :to="{ path: this.$route.path}">{{ $route.meta.title }}</el-breadcrumb-item>
</el-breadcrumb>
<router-view/>
</el-main>
</el-container>
</el-container>
</div>
</template>
<script>
export default {
name: "HomeView",
computed: {
admin(){
return JSON.parse(window.localStorage.getItem('access-admin'));
}
},
methods: {
exitBtn(){
this.$confirm('您确定要退出系统吗','退出提示',{
confirmButtonText: '退出',
cancelButtonText: '取消',
type: 'warning'
}).then(()=>{
this.$message.success("退出成功");
window.localStorage.clear();
this.$router.replace('/login');
}).catch(_=>{
this.$message.warning("已取消退出");
});
}
}
}
</script>
<style lang="scss" scoped>
.home-area{
width: 100%;
height: 100vh;
.home-header{
background-color: #545c64;
.header-title{
line-height: 60px;
font-size: 28px;
font-weight: bolder;
font-family: 华文彩云,Sans-serif,serif;
color: white;
}
.header-user{
width: 280px;
float: right;
line-height: 60px;
color: white;
text-align: center;
}
}
.home-main{
height: 100%;
.main-aside{
width: 210px;
.el-menu-vertical-demo{
height: 100%;
border-right: none;
}
}
.main-content{
width: 100%;
height: 100%;
overflow: hidden;
padding: 15px;
}
}
}
</style>
index.vue
<template>
<div>index</div>
</template>
<script>
export default {
name: "IndexView"
}
</script>
<style scoped>
</style>
login.vue
<template>
<div class="register-area">
<h1 class="title">销售管理系统</h1>
<el-form
:model="loginForm"
:rules="rules"
ref="loginForm"
class="form-demo"
label-width="100px;"
label-postion="left">
<el-form-item prop="userName">
<el-input
v-model="loginForm.userName"
placeholder="用户名"
clearable>
<template slot="prepend"><i class="el-icon-user-solid"></i></template>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
v-model="loginForm.password"
placeholder="密码"
show-password
clearable>
<template slot="prepend"><i class="el-icon-lock"></i></template>
</el-input>
</el-form-item>
<el-button type="primary" @click="login" class="login-btn">登 录</el-button>
</el-form>
<div>
</div>
</div>
</template>
<script>
import request from "@/utils/request";
export default {
name: "LoginView",
data(){
return {
loginForm: {
userName:'',
password:'',
},
rules: {
userName: [{ required: true ,message: '请输入用户名', trigger: 'blur'}],
password: [{ required: true ,message: '请输入密码', trigger: 'blur'}],
}
}
},
methods: {
login(){
this.$refs.loginForm.validate((valid)=>{
if(valid){
request.post('/user/login',this.loginForm)
.then(res=>{
if(res.code === 200){
this.$message.success(res.msg);
window.localStorage.setItem('access-admin',JSON.stringify(res.data));
this.$router.replace('/home');
}else {
this.$message.error(res.msg);
}
})
}
})
}
},
created(){
}
}
</script>
<style lang="scss" scoped>
.register-area{
width: 400px;
height: 310px;
border-radius: 15px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-75%);
padding: 10px;
background-color: rgba(107,149,224,0.5);
.title{
text-align: center;
margin-bottom: 30px;
}
.form-demo{
width: 80%;
margin: 0 auto;
.login-btn{
width: 100%;
margin-top: 24px;
height: 40px;
}
.register-btn{
width: 100%;
margin-top: 8px;
text-align: center;
color: #ffffff;
}
}
}
</style>
app.vue
<template>
<div id="app">
<router-view/>
</div>
</template>
<style lang="scss">
* {
margin: 0;
padding: 0;
}
</style>
main.js
import Vue from 'vue'
import App from './App.vue'
import store from '@/store'
import router from "@/router";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from "axios";
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts;
axios.defaults.baseURL='http://localhost:8089';
Vue.prototype.$http = axios;
Vue.use(ElementUI,{size:'small'});
Vue.config.productionTip = false;
new Vue({
render: h => h(App),
store,
router
}).$mount('#app');