业务员管理
parent
3cc4ba9953
commit
134ace1ffb
|
|
@ -0,0 +1,69 @@
|
|||
package com.wyh.admin.controller;
|
||||
|
||||
import com.wyh.admin.aop.Log;
|
||||
import com.wyh.admin.service.ISalesmanService;
|
||||
import com.wyh.admin.validate.commons.IdValidate;
|
||||
import com.wyh.admin.validate.commons.PageValidate;
|
||||
import com.wyh.common.core.AjaxResult;
|
||||
import com.wyh.common.core.PageResult;
|
||||
import com.wyh.common.validator.SalesmanCreateValidate;
|
||||
import com.wyh.common.validator.SalesmanSearchValidate;
|
||||
import com.wyh.common.validator.SalesmanUpdateValidate;
|
||||
import com.wyh.common.validator.annotation.IDMust;
|
||||
import com.wyh.common.vo.SalesmanDetailVo;
|
||||
import com.wyh.common.vo.SalesmanListedVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/salesman")
|
||||
@Api(tags = "业务员信息管理")
|
||||
public class SalesmanController {
|
||||
|
||||
@Resource
|
||||
ISalesmanService iSalesmanService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value="业务员信息列表")
|
||||
public AjaxResult<PageResult<SalesmanListedVo>> list(@Validated PageValidate pageValidate,
|
||||
@Validated SalesmanSearchValidate searchValidate) {
|
||||
PageResult<SalesmanListedVo> list = iSalesmanService.list(pageValidate, searchValidate);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
@ApiOperation(value="业务员信息详情")
|
||||
public AjaxResult<SalesmanDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
SalesmanDetailVo detail = iSalesmanService.detail(id);
|
||||
return AjaxResult.success(detail);
|
||||
}
|
||||
|
||||
@Log(title = "业务员信息新增")
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value="业务员信息新增")
|
||||
public AjaxResult<Object> add(@Validated @RequestBody SalesmanCreateValidate createValidate) {
|
||||
iSalesmanService.add(createValidate);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Log(title = "业务员信息编辑")
|
||||
@PostMapping("/edit")
|
||||
@ApiOperation(value="业务员信息编辑")
|
||||
public AjaxResult<Object> edit(@Validated @RequestBody SalesmanUpdateValidate updateValidate) {
|
||||
iSalesmanService.edit(updateValidate);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Log(title = "业务员信息删除")
|
||||
@PostMapping("/del")
|
||||
@ApiOperation(value="业务员信息删除")
|
||||
public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
|
||||
iSalesmanService.del(idValidate.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.wyh.admin.service;
|
||||
|
||||
import com.wyh.admin.validate.commons.PageValidate;
|
||||
import com.wyh.common.core.PageResult;
|
||||
import com.wyh.common.validator.SalesmanCreateValidate;
|
||||
import com.wyh.common.validator.SalesmanSearchValidate;
|
||||
import com.wyh.common.validator.SalesmanUpdateValidate;
|
||||
import com.wyh.common.vo.SalesmanDetailVo;
|
||||
import com.wyh.common.vo.SalesmanListedVo;
|
||||
|
||||
/**
|
||||
* 业务员信息服务接口类
|
||||
* @author wyh
|
||||
*/
|
||||
public interface ISalesmanService {
|
||||
|
||||
/**
|
||||
* 业务员信息列表
|
||||
*
|
||||
* @author wyh
|
||||
* @param pageValidate 分页参数
|
||||
* @param searchValidate 搜索参数
|
||||
* @return PageResult<SalesmanListedVo>
|
||||
*/
|
||||
PageResult<SalesmanListedVo> list(PageValidate pageValidate, SalesmanSearchValidate searchValidate);
|
||||
|
||||
/**
|
||||
* 业务员信息详情
|
||||
*
|
||||
* @author wyh
|
||||
* @param id 主键ID
|
||||
* @return SalesmanDetailVo
|
||||
*/
|
||||
SalesmanDetailVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 业务员信息新增
|
||||
*
|
||||
* @author wyh
|
||||
* @param createValidate 参数
|
||||
*/
|
||||
void add(SalesmanCreateValidate createValidate);
|
||||
|
||||
/**
|
||||
* 业务员信息编辑
|
||||
*
|
||||
* @author wyh
|
||||
* @param updateValidate 参数
|
||||
*/
|
||||
void edit(SalesmanUpdateValidate updateValidate);
|
||||
|
||||
/**
|
||||
* 业务员信息删除
|
||||
*
|
||||
* @author wyh
|
||||
* @param id 主键ID
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
package com.wyh.admin.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.wyh.admin.service.ISalesmanService;
|
||||
import com.wyh.admin.validate.commons.PageValidate;
|
||||
import com.wyh.common.core.PageResult;
|
||||
import com.wyh.common.entity.Salesman;
|
||||
import com.wyh.common.mapper.SalesmanMapper;
|
||||
import com.wyh.common.util.TimeUtils;
|
||||
import com.wyh.common.validator.SalesmanCreateValidate;
|
||||
import com.wyh.common.validator.SalesmanSearchValidate;
|
||||
import com.wyh.common.validator.SalesmanUpdateValidate;
|
||||
import com.wyh.common.vo.SalesmanDetailVo;
|
||||
import com.wyh.common.vo.SalesmanListedVo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务员信息实现类
|
||||
* @author wyh
|
||||
*/
|
||||
@Service
|
||||
public class SalesmanServiceImpl implements ISalesmanService {
|
||||
|
||||
@Resource
|
||||
SalesmanMapper salesmanMapper;
|
||||
|
||||
/**
|
||||
* 业务员信息列表
|
||||
*
|
||||
* @author wyh
|
||||
* @param pageValidate 分页参数
|
||||
* @param searchValidate 搜索参数
|
||||
* @return PageResult<SalesmanListedVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SalesmanListedVo> list(PageValidate pageValidate, SalesmanSearchValidate searchValidate) {
|
||||
Integer page = pageValidate.getPageNo();
|
||||
Integer limit = pageValidate.getPageSize();
|
||||
|
||||
QueryWrapper<Salesman> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_delete", 0);
|
||||
queryWrapper.orderByDesc("id");
|
||||
|
||||
salesmanMapper.setSearch(queryWrapper, searchValidate, new String[]{
|
||||
"like:mobile:str",
|
||||
"like:name:str",
|
||||
"=:address:str",
|
||||
"=:coordinate:str",
|
||||
});
|
||||
|
||||
IPage<Salesman> iPage = salesmanMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<SalesmanListedVo> list = new LinkedList<>();
|
||||
for(Salesman item : iPage.getRecords()) {
|
||||
SalesmanListedVo vo = new SalesmanListedVo();
|
||||
BeanUtils.copyProperties(item, vo);
|
||||
vo.setCreateTime(TimeUtils.timestampToDate(item.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtils.timestampToDate(item.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务员信息详情
|
||||
*
|
||||
* @author wyh
|
||||
* @param id 主键参数
|
||||
* @return Salesman
|
||||
*/
|
||||
@Override
|
||||
public SalesmanDetailVo detail(Integer id) {
|
||||
Salesman model = salesmanMapper.selectOne(
|
||||
new QueryWrapper<Salesman>()
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在");
|
||||
|
||||
SalesmanDetailVo vo = new SalesmanDetailVo();
|
||||
BeanUtils.copyProperties(model, vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务员信息新增
|
||||
*
|
||||
* @author wyh
|
||||
* @param createValidate 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(SalesmanCreateValidate createValidate) {
|
||||
Salesman model = new Salesman();
|
||||
model.setMobile(createValidate.getMobile());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
model.setName(createValidate.getName());
|
||||
model.setAddress(createValidate.getAddress());
|
||||
model.setCoordinate(createValidate.getCoordinate());
|
||||
salesmanMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务员信息编辑
|
||||
*
|
||||
* @author wyh
|
||||
* @param updateValidate 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(SalesmanUpdateValidate updateValidate) {
|
||||
Salesman model = salesmanMapper.selectOne(
|
||||
new QueryWrapper<Salesman>()
|
||||
.eq("id", updateValidate.getId())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在!");
|
||||
|
||||
model.setId(updateValidate.getId());
|
||||
model.setMobile(updateValidate.getMobile());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
model.setName(updateValidate.getName());
|
||||
model.setAddress(updateValidate.getAddress());
|
||||
model.setCoordinate(updateValidate.getCoordinate());
|
||||
salesmanMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务员信息删除
|
||||
*
|
||||
* @author wyh
|
||||
* @param id 主键ID
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
Salesman model = salesmanMapper.selectOne(
|
||||
new QueryWrapper<Salesman>()
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在!");
|
||||
|
||||
model.setIsDelete(1);
|
||||
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
salesmanMapper.updateById(model);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.wyh.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("业务员信息实体")
|
||||
public class Salesman implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "是否删除: 0=否, 1=是")
|
||||
private Integer isDelete;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Long createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Long updateTime;
|
||||
|
||||
@ApiModelProperty(value = "删除时间")
|
||||
private Long deleteTime;
|
||||
|
||||
@ApiModelProperty(value = "业务员名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "负责地区")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "坐标")
|
||||
private String coordinate;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package com.wyh.common.entity.user;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("地址信息实体")
|
||||
public class UserAddress implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "是否删除: 0=否, 1=是")
|
||||
private Integer isDelete;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Long createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Long updateTime;
|
||||
|
||||
@ApiModelProperty(value = "删除时间")
|
||||
private Long deleteTime;
|
||||
|
||||
@ApiModelProperty(value = "工作单位")
|
||||
private String unit;
|
||||
|
||||
@ApiModelProperty(value = "收货人")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty(value = "所在地区")
|
||||
private String area;
|
||||
|
||||
@ApiModelProperty(value = "详细地址")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "是否默认地址")
|
||||
private Integer isDefault;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer userId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.wyh.common.mapper;
|
||||
|
||||
import com.wyh.common.core.basics.IBaseMapper;
|
||||
import com.wyh.common.entity.Salesman;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 业务员信息Mapper
|
||||
* @author wyh
|
||||
*/
|
||||
@Mapper
|
||||
public interface SalesmanMapper extends IBaseMapper<Salesman> {
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.wyh.common.mapper.user;
|
||||
|
||||
import com.wyh.common.core.basics.IBaseMapper;
|
||||
import com.wyh.common.entity.user.UserAddress;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 地址信息Mapper
|
||||
* @author wyh
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserAddressMapper extends IBaseMapper<UserAddress> {
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.wyh.common.validator;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("业务员信息创建参数")
|
||||
public class SalesmanCreateValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "mobile参数缺失")
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@NotNull(message = "name参数缺失")
|
||||
@ApiModelProperty(value = "业务员名称")
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "address参数缺失")
|
||||
@ApiModelProperty(value = "负责地区")
|
||||
private String address;
|
||||
|
||||
@NotNull(message = "coordinate参数缺失")
|
||||
@ApiModelProperty(value = "坐标")
|
||||
private String coordinate;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.wyh.common.validator;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("业务员信息搜素参数")
|
||||
public class SalesmanSearchValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "业务员名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "负责地区")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "坐标")
|
||||
private String coordinate;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.wyh.common.validator;
|
||||
|
||||
import com.wyh.common.validator.annotation.IDMust;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 业务员信息参数
|
||||
* @author wyh
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("业务员信息更新参数")
|
||||
public class SalesmanUpdateValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0")
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "mobile参数缺失")
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@NotNull(message = "name参数缺失")
|
||||
@ApiModelProperty(value = "业务员名称")
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "address参数缺失")
|
||||
@ApiModelProperty(value = "负责地区")
|
||||
private String address;
|
||||
|
||||
@NotNull(message = "coordinate参数缺失")
|
||||
@ApiModelProperty(value = "坐标")
|
||||
private String coordinate;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.wyh.common.validator.user;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("地址信息创建参数")
|
||||
public class UserAddressCreateValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "mobile参数缺失")
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@NotNull(message = "unit参数缺失")
|
||||
@ApiModelProperty(value = "工作单位")
|
||||
private String unit;
|
||||
|
||||
@NotNull(message = "userName参数缺失")
|
||||
@ApiModelProperty(value = "收货人")
|
||||
private String userName;
|
||||
|
||||
@NotNull(message = "area参数缺失")
|
||||
@ApiModelProperty(value = "所在地区")
|
||||
private String area;
|
||||
|
||||
@NotNull(message = "address参数缺失")
|
||||
@ApiModelProperty(value = "详细地址")
|
||||
private String address;
|
||||
|
||||
@NotNull(message = "isDefault参数缺失")
|
||||
@ApiModelProperty(value = "是否默认地址,0:否,1:是")
|
||||
private Integer isDefault;
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer userId;
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.wyh.common.validator.user;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("地址信息搜素参数")
|
||||
public class UserAddressSearchValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "工作单位")
|
||||
private String unit;
|
||||
|
||||
@ApiModelProperty(value = "收货人")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty(value = "所在地区")
|
||||
private String area;
|
||||
|
||||
@ApiModelProperty(value = "详细地址")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "是否默认地址")
|
||||
private Integer isDefault;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer userId;
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.wyh.common.validator.user;
|
||||
|
||||
import com.wyh.common.validator.annotation.IDMust;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 地址信息参数
|
||||
* @author wyh
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("地址信息更新参数")
|
||||
public class UserAddressUpdateValidate implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@IDMust(message = "id参数必传且需大于0")
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "mobile参数缺失")
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@NotNull(message = "unit参数缺失")
|
||||
@ApiModelProperty(value = "工作单位")
|
||||
private String unit;
|
||||
|
||||
@NotNull(message = "userName参数缺失")
|
||||
@ApiModelProperty(value = "收货人")
|
||||
private String userName;
|
||||
|
||||
@NotNull(message = "area参数缺失")
|
||||
@ApiModelProperty(value = "所在地区")
|
||||
private String area;
|
||||
|
||||
@NotNull(message = "address参数缺失")
|
||||
@ApiModelProperty(value = "详细地址")
|
||||
private String address;
|
||||
|
||||
@NotNull(message = "isDefault参数缺失")
|
||||
@ApiModelProperty(value = "是否默认地址")
|
||||
private Integer isDefault;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer userId;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.wyh.common.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("业务员信息详情Vo")
|
||||
public class SalesmanDetailVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "业务员名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "负责地区")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "坐标")
|
||||
private String coordinate;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.wyh.common.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("业务员信息列表Vo")
|
||||
public class SalesmanListedVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private String updateTime;
|
||||
|
||||
@ApiModelProperty(value = "业务员名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "负责地区")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "坐标")
|
||||
private String coordinate;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.wyh.common.vo.user;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("地址信息详情Vo")
|
||||
public class UserAddressDetailVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "工作单位")
|
||||
private String unit;
|
||||
|
||||
@ApiModelProperty(value = "收货人")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty(value = "所在地区")
|
||||
private String area;
|
||||
|
||||
@ApiModelProperty(value = "详细地址")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "是否默认地址")
|
||||
private Integer isDefault;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer userId;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.wyh.common.vo.user;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("地址信息列表Vo")
|
||||
public class UserAddressListedVo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private String updateTime;
|
||||
|
||||
@ApiModelProperty(value = "工作单位")
|
||||
private String unit;
|
||||
|
||||
@ApiModelProperty(value = "收货人")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty(value = "所在地区")
|
||||
private String area;
|
||||
|
||||
@ApiModelProperty(value = "详细地址")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "是否默认地址")
|
||||
private Integer isDefault;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer userId;
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.wyh.front.controller;
|
||||
|
||||
|
||||
import com.wyh.common.core.AjaxResult;
|
||||
import com.wyh.common.core.PageResult;
|
||||
import com.wyh.common.validator.annotation.IDMust;
|
||||
import com.wyh.common.validator.user.UserAddressCreateValidate;
|
||||
import com.wyh.common.validator.user.UserAddressSearchValidate;
|
||||
import com.wyh.common.validator.user.UserAddressUpdateValidate;
|
||||
import com.wyh.common.vo.user.UserAddressDetailVo;
|
||||
import com.wyh.common.vo.user.UserAddressListedVo;
|
||||
import com.wyh.front.service.IUserAddressService;
|
||||
import com.wyh.front.validate.common.IdValidate;
|
||||
import com.wyh.front.validate.common.PageValidate;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("front/address")
|
||||
@Api(tags = "地址信息管理")
|
||||
public class UserAddressController {
|
||||
|
||||
@Resource
|
||||
IUserAddressService iUserAddressService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value="地址信息列表")
|
||||
public AjaxResult<PageResult<UserAddressListedVo>> list(@Validated PageValidate pageValidate,
|
||||
@Validated UserAddressSearchValidate searchValidate) {
|
||||
PageResult<UserAddressListedVo> list = iUserAddressService.list(pageValidate, searchValidate);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
@ApiOperation(value="地址信息详情")
|
||||
public AjaxResult<UserAddressDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||
UserAddressDetailVo detail = iUserAddressService.detail(id);
|
||||
return AjaxResult.success(detail);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value="地址信息新增")
|
||||
public AjaxResult<Object> add(@Validated @RequestBody UserAddressCreateValidate createValidate) {
|
||||
iUserAddressService.add(createValidate);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/edit")
|
||||
@ApiOperation(value="地址信息编辑")
|
||||
public AjaxResult<Object> edit(@Validated @RequestBody UserAddressUpdateValidate updateValidate) {
|
||||
iUserAddressService.edit(updateValidate);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("/del")
|
||||
@ApiOperation(value="地址信息删除")
|
||||
public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
|
||||
iUserAddressService.del(idValidate.getId());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package com.wyh.front.service;
|
||||
|
||||
|
||||
import com.wyh.common.core.PageResult;
|
||||
import com.wyh.common.validator.user.UserAddressCreateValidate;
|
||||
import com.wyh.common.validator.user.UserAddressSearchValidate;
|
||||
import com.wyh.common.validator.user.UserAddressUpdateValidate;
|
||||
import com.wyh.common.vo.user.UserAddressDetailVo;
|
||||
import com.wyh.common.vo.user.UserAddressListedVo;
|
||||
import com.wyh.front.validate.common.PageValidate;
|
||||
|
||||
/**
|
||||
* 地址信息服务接口类
|
||||
* @author wyh
|
||||
*/
|
||||
public interface IUserAddressService {
|
||||
|
||||
/**
|
||||
* 地址信息列表
|
||||
*
|
||||
* @author wyh
|
||||
* @param pageValidate 分页参数
|
||||
* @param searchValidate 搜索参数
|
||||
* @return PageResult<UserAddressListedVo>
|
||||
*/
|
||||
PageResult<UserAddressListedVo> list(PageValidate pageValidate, UserAddressSearchValidate searchValidate);
|
||||
|
||||
/**
|
||||
* 地址信息详情
|
||||
*
|
||||
* @author wyh
|
||||
* @param id 主键ID
|
||||
* @return UserAddressDetailVo
|
||||
*/
|
||||
UserAddressDetailVo detail(Integer id);
|
||||
|
||||
/**
|
||||
* 地址信息新增
|
||||
*
|
||||
* @author wyh
|
||||
* @param createValidate 参数
|
||||
*/
|
||||
void add(UserAddressCreateValidate createValidate);
|
||||
|
||||
/**
|
||||
* 地址信息编辑
|
||||
*
|
||||
* @author wyh
|
||||
* @param updateValidate 参数
|
||||
*/
|
||||
void edit(UserAddressUpdateValidate updateValidate);
|
||||
|
||||
/**
|
||||
* 地址信息删除
|
||||
*
|
||||
* @author wyh
|
||||
* @param id 主键ID
|
||||
*/
|
||||
void del(Integer id);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,165 @@
|
|||
package com.wyh.front.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.wyh.common.core.PageResult;
|
||||
import com.wyh.common.entity.user.UserAddress;
|
||||
import com.wyh.common.mapper.user.UserAddressMapper;
|
||||
import com.wyh.common.util.TimeUtils;
|
||||
import com.wyh.common.validator.user.UserAddressCreateValidate;
|
||||
import com.wyh.common.validator.user.UserAddressSearchValidate;
|
||||
import com.wyh.common.validator.user.UserAddressUpdateValidate;
|
||||
import com.wyh.common.vo.user.UserAddressDetailVo;
|
||||
import com.wyh.common.vo.user.UserAddressListedVo;
|
||||
import com.wyh.front.service.IUserAddressService;
|
||||
import com.wyh.front.validate.common.PageValidate;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地址信息实现类
|
||||
* @author wyh
|
||||
*/
|
||||
@Service
|
||||
public class UserAddressServiceImpl implements IUserAddressService {
|
||||
|
||||
@Resource
|
||||
UserAddressMapper userAddressMapper;
|
||||
|
||||
/**
|
||||
* 地址信息列表
|
||||
*
|
||||
* @author wyh
|
||||
* @param pageValidate 分页参数
|
||||
* @param searchValidate 搜索参数
|
||||
* @return PageResult<UserAddressListedVo>
|
||||
*/
|
||||
@Override
|
||||
public PageResult<UserAddressListedVo> list(PageValidate pageValidate, UserAddressSearchValidate searchValidate) {
|
||||
Integer page = pageValidate.getPageNo();
|
||||
Integer limit = pageValidate.getPageSize();
|
||||
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("is_delete", 0);
|
||||
queryWrapper.orderByDesc("id");
|
||||
|
||||
userAddressMapper.setSearch(queryWrapper, searchValidate, new String[]{
|
||||
"like:mobile:str",
|
||||
"=:unit:str",
|
||||
"like:userName@user_name:str",
|
||||
"=:area:str",
|
||||
"=:address:str",
|
||||
"=:isDefault@is_default:int",
|
||||
});
|
||||
|
||||
IPage<UserAddress> iPage = userAddressMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||
|
||||
List<UserAddressListedVo> list = new LinkedList<>();
|
||||
for(UserAddress item : iPage.getRecords()) {
|
||||
UserAddressListedVo vo = new UserAddressListedVo();
|
||||
BeanUtils.copyProperties(item, vo);
|
||||
vo.setCreateTime(TimeUtils.timestampToDate(item.getCreateTime()));
|
||||
vo.setUpdateTime(TimeUtils.timestampToDate(item.getUpdateTime()));
|
||||
list.add(vo);
|
||||
}
|
||||
|
||||
return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址信息详情
|
||||
*
|
||||
* @author wyh
|
||||
* @param id 主键参数
|
||||
* @return UserAddress
|
||||
*/
|
||||
@Override
|
||||
public UserAddressDetailVo detail(Integer id) {
|
||||
UserAddress model = userAddressMapper.selectOne(
|
||||
new QueryWrapper<UserAddress>()
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在");
|
||||
|
||||
UserAddressDetailVo vo = new UserAddressDetailVo();
|
||||
BeanUtils.copyProperties(model, vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址信息新增
|
||||
*
|
||||
* @author wyh
|
||||
* @param createValidate 参数
|
||||
*/
|
||||
@Override
|
||||
public void add(UserAddressCreateValidate createValidate) {
|
||||
UserAddress model = new UserAddress();
|
||||
model.setMobile(createValidate.getMobile());
|
||||
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUnit(createValidate.getUnit());
|
||||
model.setUserName(createValidate.getUserName());
|
||||
model.setArea(createValidate.getArea());
|
||||
model.setAddress(createValidate.getAddress());
|
||||
model.setIsDefault(createValidate.getIsDefault());
|
||||
userAddressMapper.insert(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址信息编辑
|
||||
*
|
||||
* @author wyh
|
||||
* @param updateValidate 参数
|
||||
*/
|
||||
@Override
|
||||
public void edit(UserAddressUpdateValidate updateValidate) {
|
||||
UserAddress model = userAddressMapper.selectOne(
|
||||
new QueryWrapper<UserAddress>()
|
||||
.eq("id", updateValidate.getId())
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在!");
|
||||
|
||||
model.setId(updateValidate.getId());
|
||||
model.setMobile(updateValidate.getMobile());
|
||||
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
model.setUnit(updateValidate.getUnit());
|
||||
model.setUserName(updateValidate.getUserName());
|
||||
model.setArea(updateValidate.getArea());
|
||||
model.setAddress(updateValidate.getAddress());
|
||||
model.setIsDefault(updateValidate.getIsDefault());
|
||||
userAddressMapper.updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址信息删除
|
||||
*
|
||||
* @author wyh
|
||||
* @param id 主键ID
|
||||
*/
|
||||
@Override
|
||||
public void del(Integer id) {
|
||||
UserAddress model = userAddressMapper.selectOne(
|
||||
new QueryWrapper<UserAddress>()
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
|
||||
Assert.notNull(model, "数据不存在!");
|
||||
|
||||
model.setIsDelete(1);
|
||||
model.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
userAddressMapper.updateById(model);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 业务员信息列表
|
||||
export function salesmanLists(params?: Record<string, any>) {
|
||||
return request.get({ url: '/salesman/list', params })
|
||||
}
|
||||
|
||||
// 业务员信息详情
|
||||
export function salesmanDetail(params: Record<string, any>) {
|
||||
return request.get({ url: '/salesman/detail', params })
|
||||
}
|
||||
|
||||
// 业务员信息新增
|
||||
export function salesmanAdd(params: Record<string, any>) {
|
||||
return request.post({ url: '/salesman/add', params })
|
||||
}
|
||||
|
||||
// 业务员信息编辑
|
||||
export function salesmanEdit(params: Record<string, any>) {
|
||||
return request.post({ url: '/salesman/edit', params })
|
||||
}
|
||||
|
||||
// 业务员信息删除
|
||||
export function salesmanDelete(params: Record<string, any>) {
|
||||
return request.post({ url: '/salesman/del', params })
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
<template>
|
||||
<div class="edit-popup">
|
||||
<popup
|
||||
ref="popupRef"
|
||||
:title="popupTitle"
|
||||
:async="true"
|
||||
width="550px"
|
||||
:clickModalClose="true"
|
||||
@confirm="handleSubmit"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
|
||||
<el-form-item label="手机号" prop="mobile">
|
||||
<el-input v-model="formData.mobile" placeholder="请输入手机号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="业务员名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入业务员名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="负责地区" prop="address">
|
||||
<el-input v-model="formData.address" placeholder="请输入负责地区" />
|
||||
</el-form-item>
|
||||
<el-form-item label="坐标" prop="coordinate">
|
||||
<el-input v-model="formData.coordinate" placeholder="请输入坐标" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</popup>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import { salesmanEdit, salesmanAdd, salesmanDetail } from '@/api/salesman'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import feedback from '@/utils/feedback'
|
||||
import type { PropType } from 'vue'
|
||||
defineProps({
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['success', 'close'])
|
||||
const formRef = shallowRef<FormInstance>()
|
||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||
const mode = ref('add')
|
||||
const popupTitle = computed(() => {
|
||||
return mode.value == 'edit' ? '编辑业务员信息' : '新增业务员信息'
|
||||
})
|
||||
|
||||
const formData = reactive({
|
||||
id: '',
|
||||
mobile: '',
|
||||
name: '',
|
||||
address: '',
|
||||
coordinate: '',
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
id: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入主键',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
mobile: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入手机号',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入业务员名称',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
address: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入负责地区',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
coordinate: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入坐标',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate()
|
||||
const data: any = { ...formData }
|
||||
mode.value == 'edit' ? await salesmanEdit(data) : await salesmanAdd(data)
|
||||
popupRef.value?.close()
|
||||
feedback.msgSuccess('操作成功')
|
||||
emit('success')
|
||||
}
|
||||
|
||||
const open = (type = 'add') => {
|
||||
mode.value = type
|
||||
popupRef.value?.open()
|
||||
}
|
||||
|
||||
const setFormData = async (data: Record<string, any>) => {
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
const data = await salesmanDetail({
|
||||
id: row.id
|
||||
})
|
||||
setFormData(data)
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
setFormData,
|
||||
getDetail
|
||||
})
|
||||
</script>
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
<template>
|
||||
<div class="index-lists">
|
||||
<el-card class="!border-none" shadow="never">
|
||||
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
|
||||
<el-form-item label="手机号" prop="mobile">
|
||||
<el-input class="w-[280px]" v-model="queryParams.mobile" />
|
||||
</el-form-item>
|
||||
<el-form-item label="业务员名称" prop="name">
|
||||
<el-input class="w-[280px]" v-model="queryParams.name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="负责地区" prop="address">
|
||||
<el-input class="w-[280px]" v-model="queryParams.address" />
|
||||
</el-form-item>
|
||||
<el-form-item label="坐标" prop="coordinate">
|
||||
<el-input class="w-[280px]" v-model="queryParams.coordinate" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="!border-none mt-4" shadow="never">
|
||||
<div>
|
||||
<el-button v-perms="['salesman:add']" type="primary" @click="handleAdd()">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
新增
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table
|
||||
class="mt-4"
|
||||
size="large"
|
||||
v-loading="pager.loading"
|
||||
:data="pager.lists"
|
||||
>
|
||||
<el-table-column label="手机号" prop="mobile" min-width="100" />
|
||||
<el-table-column label="创建时间" prop="createTime" min-width="100" />
|
||||
<el-table-column label="更新时间" prop="updateTime" min-width="100" />
|
||||
<el-table-column label="业务员名称" prop="name" min-width="100" />
|
||||
<el-table-column label="负责地区" prop="address" min-width="100" />
|
||||
<el-table-column label="坐标" prop="coordinate" min-width="100" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['salesman:edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['salesman:del']"
|
||||
type="danger"
|
||||
link
|
||||
@click="handleDelete(row.id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="flex justify-end mt-4">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
<edit-popup
|
||||
v-if="showEdit"
|
||||
ref="editRef"
|
||||
@success="getLists"
|
||||
@close="showEdit = false"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup name="salesman">
|
||||
import { salesmanDelete, salesmanLists } from '@/api/salesman'
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import feedback from '@/utils/feedback'
|
||||
import EditPopup from './edit.vue'
|
||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||
const showEdit = ref(false)
|
||||
const queryParams = reactive({
|
||||
mobile: '',
|
||||
name: '',
|
||||
address: '',
|
||||
coordinate: '',
|
||||
})
|
||||
|
||||
const { pager, getLists, resetPage, resetParams } = usePaging({
|
||||
fetchFun: salesmanLists,
|
||||
params: queryParams
|
||||
})
|
||||
|
||||
|
||||
|
||||
const handleAdd = async () => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('add')
|
||||
}
|
||||
|
||||
const handleEdit = async (data: any) => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('edit')
|
||||
editRef.value?.getDetail(data)
|
||||
}
|
||||
|
||||
const handleDelete = async (id: number) => {
|
||||
await feedback.confirm('确定要删除?')
|
||||
await salesmanDelete({ id })
|
||||
feedback.msgSuccess('删除成功')
|
||||
getLists()
|
||||
}
|
||||
|
||||
getLists()
|
||||
</script>
|
||||
Loading…
Reference in New Issue