业务线/仓库

qhw-dev-0927
杨世强 1 year ago
parent 63b1b48d73
commit 6a709b2a42

@ -0,0 +1,102 @@
package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.yunxi.scm.framework.common.pojo.PageResult;
import com.yunxi.scm.framework.common.pojo.CommonResult;
import static com.yunxi.scm.framework.common.pojo.CommonResult.success;
import com.yunxi.scm.framework.excel.core.util.ExcelUtils;
import com.yunxi.scm.framework.operatelog.core.annotations.OperateLog;
import static com.yunxi.scm.framework.operatelog.core.enums.OperateTypeEnum.*;
import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*;
import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO;
import com.yunxi.scm.module.xxjj.convert.businesswarehouse.BusinessWarehouseConvert;
import com.yunxi.scm.module.xxjj.service.businesswarehouse.BusinessWarehouseService;
@Tag(name = "管理后台 - 业务线/仓库")
@RestController
@RequestMapping("/xxjj/business-warehouse")
@Validated
public class BusinessWarehouseController {
@Resource
private BusinessWarehouseService businessWarehouseService;
@PostMapping("/create")
@Operation(summary = "创建业务线/仓库")
@PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:create')")
public CommonResult<Long> createBusinessWarehouse(@Valid @RequestBody BusinessWarehouseCreateReqVO createReqVO) {
return success(businessWarehouseService.createBusinessWarehouse(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新业务线/仓库")
@PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:update')")
public CommonResult<Boolean> updateBusinessWarehouse(@Valid @RequestBody BusinessWarehouseUpdateReqVO updateReqVO) {
businessWarehouseService.updateBusinessWarehouse(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除业务线/仓库")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:delete')")
public CommonResult<Boolean> deleteBusinessWarehouse(@RequestParam("id") Long id) {
businessWarehouseService.deleteBusinessWarehouse(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得业务线/仓库")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:query')")
public CommonResult<BusinessWarehouseRespVO> getBusinessWarehouse(@RequestParam("id") Long id) {
BusinessWarehouseDO businessWarehouse = businessWarehouseService.getBusinessWarehouse(id);
return success(BusinessWarehouseConvert.INSTANCE.convert(businessWarehouse));
}
@GetMapping("/list")
@Operation(summary = "获得业务线/仓库列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:query')")
public CommonResult<List<BusinessWarehouseRespVO>> getBusinessWarehouseList(@RequestParam("ids") Collection<Long> ids) {
List<BusinessWarehouseDO> list = businessWarehouseService.getBusinessWarehouseList(ids);
return success(BusinessWarehouseConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得业务线/仓库分页")
@PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:query')")
public CommonResult<PageResult<BusinessWarehouseRespVO>> getBusinessWarehousePage(@Valid BusinessWarehousePageReqVO pageVO) {
PageResult<BusinessWarehouseDO> pageResult = businessWarehouseService.getBusinessWarehousePage(pageVO);
return success(BusinessWarehouseConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出业务线/仓库 Excel")
@PreAuthorize("@ss.hasPermission('xxjj:business-warehouse:export')")
@OperateLog(type = EXPORT)
public void exportBusinessWarehouseExcel(@Valid BusinessWarehouseExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<BusinessWarehouseDO> list = businessWarehouseService.getBusinessWarehouseList(exportReqVO);
// 导出 Excel
List<BusinessWarehouseExcelVO> datas = BusinessWarehouseConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "业务线/仓库.xls", "数据", BusinessWarehouseExcelVO.class, datas);
}
}

@ -0,0 +1,72 @@
package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import javax.validation.constraints.*;
import org.springframework.format.annotation.DateTimeFormat;
import static com.yunxi.scm.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 线/ Base VO VO 使
* VO Swagger
*/
@Data
public class BusinessWarehouseBaseVO {
@Schema(description = "业务线编号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "业务线编号不能为空")
private String businessCode;
@Schema(description = "业务线名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
@NotNull(message = "业务线名称不能为空")
private String name;
@Schema(description = "业务线简称")
private String businessSimple;
@Schema(description = "业务线LOGO")
private String businessLogo;
@Schema(description = "父id")
private Long parentId;
@Schema(description = "类型")
private String type;
@Schema(description = "所属行业")
private String industry;
@Schema(description = "所在城市")
private String city;
@Schema(description = "成立时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime establishDate;
@Schema(description = "归属人员")
private Long belongUserId;
@Schema(description = "品牌/业务线/事业群名称")
private String brandName;
@Schema(description = "电话")
private Integer phone;
@Schema(description = "传真")
private String fax;
@Schema(description = "网址", example = "https://www.iocoder.cn")
private String url;
@Schema(description = "介绍", example = "你猜")
private String description;
@Schema(description = "介绍", example = "你猜")
private String diffFlag;
}

@ -0,0 +1,14 @@
package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 业务线/仓库创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BusinessWarehouseCreateReqVO extends BusinessWarehouseBaseVO {
}

@ -0,0 +1,78 @@
package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yunxi.scm.framework.excel.core.annotations.DictFormat;
import com.yunxi.scm.framework.excel.core.convert.DictConvert;
/**
* 线/ Excel VO
*
* @author
*/
@Data
public class BusinessWarehouseExcelVO {
@ExcelProperty("业务id")
private Long id;
@ExcelProperty("业务线编号")
private String businessCode;
@ExcelProperty("业务线名称")
private String name;
@ExcelProperty("业务线简称")
private String businessSimple;
@ExcelProperty("业务线LOGO")
private String businessLogo;
@ExcelProperty("父id")
private Long parentId;
@ExcelProperty("类型")
private String type;
@ExcelProperty(value = "所属行业", converter = DictConvert.class)
@DictFormat("duty_type") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
private String industry;
@ExcelProperty("所在城市")
private String city;
@ExcelProperty("成立时间")
private LocalDateTime establishDate;
@ExcelProperty("归属人员")
private Long belongUserId;
@ExcelProperty("品牌/业务线/事业群名称")
private String brandName;
@ExcelProperty("电话")
private Integer phone;
@ExcelProperty("传真")
private String fax;
@ExcelProperty("网址")
private String url;
@ExcelProperty("介绍")
private String description;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@ExcelProperty("区分标志")
private String diffFlag;
}

@ -0,0 +1,69 @@
package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.yunxi.scm.framework.common.pojo.PageParam;
import java.time.LocalDateTime;
import org.springframework.format.annotation.DateTimeFormat;
import static com.yunxi.scm.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 业务线/仓库 Excel 导出 Request VO参数和 BusinessWarehousePageReqVO 是一致的")
@Data
public class BusinessWarehouseExportReqVO {
@Schema(description = "业务线编号")
private String businessCode;
@Schema(description = "业务线名称", example = "张三")
private String name;
@Schema(description = "业务线简称")
private String businessSimple;
@Schema(description = "业务线LOGO")
private String businessLogo;
@Schema(description = "父id", example = "6675")
private Long parentId;
@Schema(description = "类型", example = "1")
private String type;
@Schema(description = "所属行业")
private String industry;
@Schema(description = "所在城市")
private String city;
@Schema(description = "成立时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] establishDate;
@Schema(description = "归属人员", example = "19777")
private Long belongUserId;
@Schema(description = "品牌/业务线/事业群名称", example = "王五")
private String brandName;
@Schema(description = "电话")
private Integer phone;
@Schema(description = "传真")
private String fax;
@Schema(description = "网址", example = "https://www.iocoder.cn")
private String url;
@Schema(description = "介绍", example = "你猜")
private String description;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "区分标志", example = "你猜")
private String diffFlag;
}

@ -0,0 +1,71 @@
package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.yunxi.scm.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.yunxi.scm.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 业务线/仓库分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BusinessWarehousePageReqVO extends PageParam {
@Schema(description = "业务线编号")
private String businessCode;
@Schema(description = "业务线名称", example = "张三")
private String name;
@Schema(description = "业务线简称")
private String businessSimple;
@Schema(description = "业务线LOGO")
private String businessLogo;
@Schema(description = "父id", example = "6675")
private Long parentId;
@Schema(description = "类型", example = "1")
private String type;
@Schema(description = "所属行业")
private String industry;
@Schema(description = "所在城市")
private String city;
@Schema(description = "成立时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] establishDate;
@Schema(description = "归属人员", example = "19777")
private Long belongUserId;
@Schema(description = "品牌/业务线/事业群名称", example = "王五")
private String brandName;
@Schema(description = "电话")
private Integer phone;
@Schema(description = "传真")
private String fax;
@Schema(description = "网址", example = "https://www.iocoder.cn")
private String url;
@Schema(description = "介绍", example = "你猜")
private String description;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "区分标志", example = "你猜")
private String diffFlag;
}

@ -0,0 +1,19 @@
package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 业务线/仓库 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BusinessWarehouseRespVO extends BusinessWarehouseBaseVO {
@Schema(description = "业务id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27714")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

@ -0,0 +1,18 @@
package com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 业务线/仓库更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BusinessWarehouseUpdateReqVO extends BusinessWarehouseBaseVO {
@Schema(description = "业务id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27714")
@NotNull(message = "业务id不能为空")
private Long id;
}

@ -0,0 +1,34 @@
package com.yunxi.scm.module.xxjj.convert.businesswarehouse;
import java.util.*;
import com.yunxi.scm.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*;
import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO;
/**
* 线/ Convert
*
* @author
*/
@Mapper
public interface BusinessWarehouseConvert {
BusinessWarehouseConvert INSTANCE = Mappers.getMapper(BusinessWarehouseConvert.class);
BusinessWarehouseDO convert(BusinessWarehouseCreateReqVO bean);
BusinessWarehouseDO convert(BusinessWarehouseUpdateReqVO bean);
BusinessWarehouseRespVO convert(BusinessWarehouseDO bean);
List<BusinessWarehouseRespVO> convertList(List<BusinessWarehouseDO> list);
PageResult<BusinessWarehouseRespVO> convertPage(PageResult<BusinessWarehouseDO> page);
List<BusinessWarehouseExcelVO> convertList02(List<BusinessWarehouseDO> list);
}

@ -0,0 +1,98 @@
package com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.yunxi.scm.framework.mybatis.core.dataobject.BaseDO;
/**
* 线/ DO
*
* @author
*/
@TableName("xxjj_business_warehouse")
@KeySequence("xxjj_business_warehouse_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BusinessWarehouseDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
* 线
*/
private String businessCode;
/**
* 线
*/
private String name;
/**
* 线
*/
private String businessSimple;
/**
* 线LOGO
*/
private String businessLogo;
/**
* id
*/
private Long parentId;
/**
*
*/
private String type;
/**
*
*
* {@link TODO duty_type }
*/
private String industry;
/**
*
*/
private String city;
/**
*
*/
private LocalDateTime establishDate;
/**
*
*/
private Long belongUserId;
/**
* /线/
*/
private String brandName;
/**
*
*/
private Integer phone;
/**
*
*/
private String fax;
/**
*
*/
private String url;
/**
*
*/
private String description;
/**
*
*/
private String diffFlag;
}

@ -0,0 +1,62 @@
package com.yunxi.scm.module.xxjj.dal.mysql.businesswarehouse;
import java.util.*;
import com.yunxi.scm.framework.common.pojo.PageResult;
import com.yunxi.scm.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yunxi.scm.framework.mybatis.core.mapper.BaseMapperX;
import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO;
import org.apache.ibatis.annotations.Mapper;
import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*;
/**
* 线/ Mapper
*
* @author
*/
@Mapper
public interface BusinessWarehouseMapper extends BaseMapperX<BusinessWarehouseDO> {
default PageResult<BusinessWarehouseDO> selectPage(BusinessWarehousePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<BusinessWarehouseDO>()
.eqIfPresent(BusinessWarehouseDO::getBusinessCode, reqVO.getBusinessCode())
.likeIfPresent(BusinessWarehouseDO::getName, reqVO.getName())
.eqIfPresent(BusinessWarehouseDO::getBusinessSimple, reqVO.getBusinessSimple())
.eqIfPresent(BusinessWarehouseDO::getBusinessLogo, reqVO.getBusinessLogo())
.eqIfPresent(BusinessWarehouseDO::getParentId, reqVO.getParentId())
.eqIfPresent(BusinessWarehouseDO::getType, reqVO.getType())
.eqIfPresent(BusinessWarehouseDO::getIndustry, reqVO.getIndustry())
.eqIfPresent(BusinessWarehouseDO::getCity, reqVO.getCity())
.betweenIfPresent(BusinessWarehouseDO::getEstablishDate, reqVO.getEstablishDate())
.eqIfPresent(BusinessWarehouseDO::getBelongUserId, reqVO.getBelongUserId())
.likeIfPresent(BusinessWarehouseDO::getBrandName, reqVO.getBrandName())
.eqIfPresent(BusinessWarehouseDO::getPhone, reqVO.getPhone())
.eqIfPresent(BusinessWarehouseDO::getFax, reqVO.getFax())
.eqIfPresent(BusinessWarehouseDO::getUrl, reqVO.getUrl())
.eqIfPresent(BusinessWarehouseDO::getDescription, reqVO.getDescription())
.betweenIfPresent(BusinessWarehouseDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(BusinessWarehouseDO::getId));
}
default List<BusinessWarehouseDO> selectList(BusinessWarehouseExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<BusinessWarehouseDO>()
.eqIfPresent(BusinessWarehouseDO::getBusinessCode, reqVO.getBusinessCode())
.likeIfPresent(BusinessWarehouseDO::getName, reqVO.getName())
.eqIfPresent(BusinessWarehouseDO::getBusinessSimple, reqVO.getBusinessSimple())
.eqIfPresent(BusinessWarehouseDO::getBusinessLogo, reqVO.getBusinessLogo())
.eqIfPresent(BusinessWarehouseDO::getParentId, reqVO.getParentId())
.eqIfPresent(BusinessWarehouseDO::getType, reqVO.getType())
.eqIfPresent(BusinessWarehouseDO::getIndustry, reqVO.getIndustry())
.eqIfPresent(BusinessWarehouseDO::getCity, reqVO.getCity())
.betweenIfPresent(BusinessWarehouseDO::getEstablishDate, reqVO.getEstablishDate())
.eqIfPresent(BusinessWarehouseDO::getBelongUserId, reqVO.getBelongUserId())
.likeIfPresent(BusinessWarehouseDO::getBrandName, reqVO.getBrandName())
.eqIfPresent(BusinessWarehouseDO::getPhone, reqVO.getPhone())
.eqIfPresent(BusinessWarehouseDO::getFax, reqVO.getFax())
.eqIfPresent(BusinessWarehouseDO::getUrl, reqVO.getUrl())
.eqIfPresent(BusinessWarehouseDO::getDescription, reqVO.getDescription())
.betweenIfPresent(BusinessWarehouseDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(BusinessWarehouseDO::getId));
}
}

@ -41,6 +41,8 @@ public interface ErrorCodeConstants {
// ========== 质检报告 TODO 补充编号 ==========
ErrorCode QUALITY_INSPECTION_NOT_EXISTS = new ErrorCode(1002025114, "质检报告不存在");
// ========== 业务线/仓库 TODO 补充编号 ==========
ErrorCode BUSINESS_WAREHOUSE_NOT_EXISTS = new ErrorCode(1002025019, "业务线/仓库不存在");
// ========== 部门模块 1002004000 ==========

@ -0,0 +1,70 @@
package com.yunxi.scm.module.xxjj.service.businesswarehouse;
import java.util.*;
import javax.validation.*;
import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*;
import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO;
import com.yunxi.scm.framework.common.pojo.PageResult;
/**
* 线/ Service
*
* @author
*/
public interface BusinessWarehouseService {
/**
* 线/
*
* @param createReqVO
* @return
*/
Long createBusinessWarehouse(@Valid BusinessWarehouseCreateReqVO createReqVO);
/**
* 线/
*
* @param updateReqVO
*/
void updateBusinessWarehouse(@Valid BusinessWarehouseUpdateReqVO updateReqVO);
/**
* 线/
*
* @param id
*/
void deleteBusinessWarehouse(Long id);
/**
* 线/
*
* @param id
* @return 线/
*/
BusinessWarehouseDO getBusinessWarehouse(Long id);
/**
* 线/
*
* @param ids
* @return 线/
*/
List<BusinessWarehouseDO> getBusinessWarehouseList(Collection<Long> ids);
/**
* 线/
*
* @param pageReqVO
* @return 线/
*/
PageResult<BusinessWarehouseDO> getBusinessWarehousePage(BusinessWarehousePageReqVO pageReqVO);
/**
* 线/, Excel
*
* @param exportReqVO
* @return 线/
*/
List<BusinessWarehouseDO> getBusinessWarehouseList(BusinessWarehouseExportReqVO exportReqVO);
}

@ -0,0 +1,82 @@
package com.yunxi.scm.module.xxjj.service.businesswarehouse;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*;
import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO;
import com.yunxi.scm.framework.common.pojo.PageResult;
import com.yunxi.scm.module.xxjj.convert.businesswarehouse.BusinessWarehouseConvert;
import com.yunxi.scm.module.xxjj.dal.mysql.businesswarehouse.BusinessWarehouseMapper;
import static com.yunxi.scm.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.yunxi.scm.module.xxjj.enums.ErrorCodeConstants.*;
/**
* 线/ Service
*
* @author
*/
@Service
@Validated
public class BusinessWarehouseServiceImpl implements BusinessWarehouseService {
@Resource
private BusinessWarehouseMapper businessWarehouseMapper;
@Override
public Long createBusinessWarehouse(BusinessWarehouseCreateReqVO createReqVO) {
// 插入
BusinessWarehouseDO businessWarehouse = BusinessWarehouseConvert.INSTANCE.convert(createReqVO);
businessWarehouseMapper.insert(businessWarehouse);
// 返回
return businessWarehouse.getId();
}
@Override
public void updateBusinessWarehouse(BusinessWarehouseUpdateReqVO updateReqVO) {
// 校验存在
validateBusinessWarehouseExists(updateReqVO.getId());
// 更新
BusinessWarehouseDO updateObj = BusinessWarehouseConvert.INSTANCE.convert(updateReqVO);
businessWarehouseMapper.updateById(updateObj);
}
@Override
public void deleteBusinessWarehouse(Long id) {
// 校验存在
validateBusinessWarehouseExists(id);
// 删除
businessWarehouseMapper.deleteById(id);
}
private void validateBusinessWarehouseExists(Long id) {
if (businessWarehouseMapper.selectById(id) == null) {
throw exception(BUSINESS_WAREHOUSE_NOT_EXISTS);
}
}
@Override
public BusinessWarehouseDO getBusinessWarehouse(Long id) {
return businessWarehouseMapper.selectById(id);
}
@Override
public List<BusinessWarehouseDO> getBusinessWarehouseList(Collection<Long> ids) {
return businessWarehouseMapper.selectBatchIds(ids);
}
@Override
public PageResult<BusinessWarehouseDO> getBusinessWarehousePage(BusinessWarehousePageReqVO pageReqVO) {
return businessWarehouseMapper.selectPage(pageReqVO);
}
@Override
public List<BusinessWarehouseDO> getBusinessWarehouseList(BusinessWarehouseExportReqVO exportReqVO) {
return businessWarehouseMapper.selectList(exportReqVO);
}
}

@ -0,0 +1,12 @@
<?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.yunxi.scm.module.xxjj.dal.mysql.businesswarehouse.BusinessWarehouseMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,278 @@
package com.yunxi.scm.module.xxjj.service.businesswarehouse;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import javax.annotation.Resource;
import com.yunxi.scm.framework.test.core.ut.BaseDbUnitTest;
import com.yunxi.scm.module.xxjj.controller.admin.businesswarehouse.vo.*;
import com.yunxi.scm.module.xxjj.dal.dataobject.businesswarehouse.BusinessWarehouseDO;
import com.yunxi.scm.module.xxjj.dal.mysql.businesswarehouse.BusinessWarehouseMapper;
import com.yunxi.scm.framework.common.pojo.PageResult;
import javax.annotation.Resource;
import org.springframework.context.annotation.Import;
import java.util.*;
import java.time.LocalDateTime;
import static cn.hutool.core.util.RandomUtil.*;
import static com.yunxi.scm.module.xxjj.enums.ErrorCodeConstants.*;
import static com.yunxi.scm.framework.test.core.util.AssertUtils.*;
import static com.yunxi.scm.framework.test.core.util.RandomUtils.*;
import static com.yunxi.scm.framework.common.util.date.LocalDateTimeUtils.*;
import static com.yunxi.scm.framework.common.util.object.ObjectUtils.*;
import static com.yunxi.scm.framework.common.util.date.DateUtils.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
/**
* {@link BusinessWarehouseServiceImpl}
*
* @author
*/
@Import(BusinessWarehouseServiceImpl.class)
public class BusinessWarehouseServiceImplTest extends BaseDbUnitTest {
@Resource
private BusinessWarehouseServiceImpl businessWarehouseService;
@Resource
private BusinessWarehouseMapper businessWarehouseMapper;
@Test
public void testCreateBusinessWarehouse_success() {
// 准备参数
BusinessWarehouseCreateReqVO reqVO = randomPojo(BusinessWarehouseCreateReqVO.class);
// 调用
Long businessWarehouseId = businessWarehouseService.createBusinessWarehouse(reqVO);
// 断言
assertNotNull(businessWarehouseId);
// 校验记录的属性是否正确
BusinessWarehouseDO businessWarehouse = businessWarehouseMapper.selectById(businessWarehouseId);
assertPojoEquals(reqVO, businessWarehouse);
}
@Test
public void testUpdateBusinessWarehouse_success() {
// mock 数据
BusinessWarehouseDO dbBusinessWarehouse = randomPojo(BusinessWarehouseDO.class);
businessWarehouseMapper.insert(dbBusinessWarehouse);// @Sql: 先插入出一条存在的数据
// 准备参数
BusinessWarehouseUpdateReqVO reqVO = randomPojo(BusinessWarehouseUpdateReqVO.class, o -> {
o.setId(dbBusinessWarehouse.getId()); // 设置更新的 ID
});
// 调用
businessWarehouseService.updateBusinessWarehouse(reqVO);
// 校验是否更新正确
BusinessWarehouseDO businessWarehouse = businessWarehouseMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, businessWarehouse);
}
@Test
public void testUpdateBusinessWarehouse_notExists() {
// 准备参数
BusinessWarehouseUpdateReqVO reqVO = randomPojo(BusinessWarehouseUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> businessWarehouseService.updateBusinessWarehouse(reqVO), BUSINESS_WAREHOUSE_NOT_EXISTS);
}
@Test
public void testDeleteBusinessWarehouse_success() {
// mock 数据
BusinessWarehouseDO dbBusinessWarehouse = randomPojo(BusinessWarehouseDO.class);
businessWarehouseMapper.insert(dbBusinessWarehouse);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbBusinessWarehouse.getId();
// 调用
businessWarehouseService.deleteBusinessWarehouse(id);
// 校验数据不存在了
assertNull(businessWarehouseMapper.selectById(id));
}
@Test
public void testDeleteBusinessWarehouse_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> businessWarehouseService.deleteBusinessWarehouse(id), BUSINESS_WAREHOUSE_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetBusinessWarehousePage() {
// mock 数据
BusinessWarehouseDO dbBusinessWarehouse = randomPojo(BusinessWarehouseDO.class, o -> { // 等会查询到
o.setBusinessCode(null);
o.setName(null);
o.setBusinessSimple(null);
o.setBusinessLogo(null);
o.setParentId(null);
o.setType(null);
o.setIndustry(null);
o.setCity(null);
o.setEstablishDate(null);
o.setBelongUserId(null);
o.setBrandName(null);
o.setPhone(null);
o.setFax(null);
o.setUrl(null);
o.setDescription(null);
o.setCreateTime(null);
o.setDiffFlag(null);
});
businessWarehouseMapper.insert(dbBusinessWarehouse);
// 测试 businessCode 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessCode(null)));
// 测试 businessName 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setName(null)));
// 测试 businessSimple 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessSimple(null)));
// 测试 businessLogo 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessLogo(null)));
// 测试 parentId 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setParentId(null)));
// 测试 type 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setType(null)));
// 测试 industry 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setIndustry(null)));
// 测试 city 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setCity(null)));
// 测试 establishDate 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setEstablishDate(null)));
// 测试 belongUserId 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBelongUserId(null)));
// 测试 brandName 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBrandName(null)));
// 测试 phone 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setPhone(null)));
// 测试 fax 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setFax(null)));
// 测试 url 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setUrl(null)));
// 测试 description 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setDescription(null)));
// 测试 createTime 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setCreateTime(null)));
// 测试 diffFlag 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setDiffFlag(null)));
// 准备参数
BusinessWarehousePageReqVO reqVO = new BusinessWarehousePageReqVO();
reqVO.setBusinessCode(null);
reqVO.setName(null);
reqVO.setBusinessSimple(null);
reqVO.setBusinessLogo(null);
reqVO.setParentId(null);
reqVO.setType(null);
reqVO.setIndustry(null);
reqVO.setCity(null);
reqVO.setEstablishDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setBelongUserId(null);
reqVO.setBrandName(null);
reqVO.setPhone(null);
reqVO.setFax(null);
reqVO.setUrl(null);
reqVO.setDescription(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setDiffFlag(null);
// 调用
PageResult<BusinessWarehouseDO> pageResult = businessWarehouseService.getBusinessWarehousePage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbBusinessWarehouse, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetBusinessWarehouseList() {
// mock 数据
BusinessWarehouseDO dbBusinessWarehouse = randomPojo(BusinessWarehouseDO.class, o -> { // 等会查询到
o.setBusinessCode(null);
o.setName(null);
o.setBusinessSimple(null);
o.setBusinessLogo(null);
o.setParentId(null);
o.setType(null);
o.setIndustry(null);
o.setCity(null);
o.setEstablishDate(null);
o.setBelongUserId(null);
o.setBrandName(null);
o.setPhone(null);
o.setFax(null);
o.setUrl(null);
o.setDescription(null);
o.setCreateTime(null);
o.setDiffFlag(null);
});
businessWarehouseMapper.insert(dbBusinessWarehouse);
// 测试 businessCode 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessCode(null)));
// 测试 businessName 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setName(null)));
// 测试 businessSimple 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessSimple(null)));
// 测试 businessLogo 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBusinessLogo(null)));
// 测试 parentId 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setParentId(null)));
// 测试 type 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setType(null)));
// 测试 industry 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setIndustry(null)));
// 测试 city 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setCity(null)));
// 测试 establishDate 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setEstablishDate(null)));
// 测试 belongUserId 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBelongUserId(null)));
// 测试 brandName 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setBrandName(null)));
// 测试 phone 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setPhone(null)));
// 测试 fax 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setFax(null)));
// 测试 url 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setUrl(null)));
// 测试 description 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setDescription(null)));
// 测试 createTime 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setCreateTime(null)));
// 测试 diffFlag 不匹配
businessWarehouseMapper.insert(cloneIgnoreId(dbBusinessWarehouse, o -> o.setDiffFlag(null)));
// 准备参数
BusinessWarehouseExportReqVO reqVO = new BusinessWarehouseExportReqVO();
reqVO.setBusinessCode(null);
reqVO.setName(null);
reqVO.setBusinessSimple(null);
reqVO.setBusinessLogo(null);
reqVO.setParentId(null);
reqVO.setType(null);
reqVO.setIndustry(null);
reqVO.setCity(null);
reqVO.setEstablishDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setBelongUserId(null);
reqVO.setBrandName(null);
reqVO.setPhone(null);
reqVO.setFax(null);
reqVO.setUrl(null);
reqVO.setDescription(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setDiffFlag(null);
// 调用
List<BusinessWarehouseDO> list = businessWarehouseService.getBusinessWarehouseList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbBusinessWarehouse, list.get(0));
}
}

@ -0,0 +1,54 @@
import request from '@/utils/request'
// 创建业务线/仓库
export function createBusinessWarehouse(data) {
return request({
url: '/xxjj/business-warehouse/create',
method: 'post',
data: data
})
}
// 更新业务线/仓库
export function updateBusinessWarehouse(data) {
return request({
url: '/xxjj/business-warehouse/update',
method: 'put',
data: data
})
}
// 删除业务线/仓库
export function deleteBusinessWarehouse(id) {
return request({
url: '/xxjj/business-warehouse/delete?id=' + id,
method: 'delete'
})
}
// 获得业务线/仓库
export function getBusinessWarehouse(id) {
return request({
url: '/xxjj/business-warehouse/get?id=' + id,
method: 'get'
})
}
// 获得业务线/仓库分页
export function getBusinessWarehousePage(query) {
return request({
url: '/xxjj/business-warehouse/page',
method: 'get',
params: query
})
}
// 导出业务线/仓库 Excel
export function exportBusinessWarehouseExcel(query) {
return request({
url: '/xxjj/business-warehouse/export-excel',
method: 'get',
params: query,
responseType: 'blob'
})
}

@ -105,6 +105,7 @@ export const DICT_TYPE = {
// ============= BUSINESSLINE 模块=================
BUSINESS_TYPE: 'business_type', //业务线类型
DIFF_FLAG: 'diff_flag',
// ============= WAREHOUSE 模块=================
WAREHOUSE_TYPE: 'warehouse_type', //仓库类型

@ -2,99 +2,275 @@
<div class="app-container">
<doc-alert title="用户体系" url="https://doc.iocoder.cn/user-center/" />
<doc-alert title="三方登陆" url="https://doc.iocoder.cn/social-user/" />
<doc-alert title="Excel 导入导出" url="https://doc.iocoder.cn/excel-import-and-export/" />
<doc-alert
title="Excel 导入导出"
url="https://doc.iocoder.cn/excel-import-and-export/"
/>
<!-- 搜索工作栏 -->
<el-row :gutter="20">
<!--部门数据-->
<el-col :span="4" :xs="24">
<div class="head-container">
<el-input v-model="deptName" placeholder="请输入部门名称" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px"/>
<el-input
v-model="deptName"
placeholder="请输入部门名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</div>
<div class="head-container">
<el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode"
ref="tree" default-expand-all highlight-current @node-click="handleNodeClick"/>
<el-tree
:data="deptOptions"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
default-expand-all
highlight-current
@node-click="handleNodeClick"
/>
</div>
</el-col>
<!--用户数据-->
<el-col :span="20" :xs="24">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="用户名称" prop="username">
<el-input v-model="queryParams.username" placeholder="请输入用户名称" clearable style="width: 240px"
@keyup.enter.native="handleQuery"/>
<el-input
v-model="queryParams.username"
placeholder="请输入用户名称"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="手机号码" prop="mobile">
<el-input v-model="queryParams.mobile" placeholder="请输入手机号码" clearable style="width: 240px"
@keyup.enter.native="handleQuery"/>
<el-input
v-model="queryParams.mobile"
placeholder="请输入手机号码"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="用户状态" clearable style="width: 240px">
<el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
<el-select
v-model="queryParams.status"
placeholder="用户状态"
clearable
style="width: 240px"
>
<el-option
v-for="dict in statusDictDatas"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
<el-date-picker
v-model="queryParams.createTime"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" @click="resetQuery"></el-button>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['system:user:create']">新增</el-button>
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:user:create']"
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="info" icon="el-icon-upload2" size="mini" @click="handleImport"
v-hasPermi="['system:user:import']">导入</el-button>
<el-button
type="info"
icon="el-icon-upload2"
size="mini"
@click="handleImport"
v-hasPermi="['system:user:import']"
>导入</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
v-hasPermi="['system:user:export']">导出</el-button>
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['system:user:export']"
>导出</el-button
>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
:columns="columns"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="userList">
<el-table-column label="用户编号" align="center" key="id" prop="id" v-if="columns[0].visible" />
<el-table-column label="用户名称" align="center" key="username" prop="username" v-if="columns[1].visible" :show-overflow-tooltip="true" />
<el-table-column label="用户昵称" align="center" key="nickname" prop="nickname" v-if="columns[2].visible" :show-overflow-tooltip="true" />
<el-table-column label="部门" align="center" key="deptName" prop="dept.name" v-if="columns[3].visible" :show-overflow-tooltip="true" />
<el-table-column label="手机号码" align="center" key="mobile" prop="mobile" v-if="columns[4].visible" width="120" />
<el-table-column label="状态" key="status" v-if="columns[5].visible" align="center">
<el-table-column
label="用户编号"
align="center"
key="id"
prop="id"
v-if="columns[0].visible"
/>
<el-table-column
label="用户名称"
align="center"
key="username"
prop="username"
v-if="columns[1].visible"
:show-overflow-tooltip="true"
/>
<el-table-column
label="用户昵称"
align="center"
key="nickname"
prop="nickname"
v-if="columns[2].visible"
:show-overflow-tooltip="true"
/>
<el-table-column
label="部门"
align="center"
key="deptName"
prop="dept.name"
v-if="columns[3].visible"
:show-overflow-tooltip="true"
/>
<el-table-column
label="手机号码"
align="center"
key="mobile"
prop="mobile"
v-if="columns[4].visible"
width="120"
/>
<el-table-column
label="状态"
key="status"
v-if="columns[5].visible"
align="center"
>
<template v-slot="scope">
<el-switch v-model="scope.row.status" :active-value="0" :inactive-value="1" @change="handleStatusChange(scope.row)" />
<el-switch
v-model="scope.row.status"
:active-value="0"
:inactive-value="1"
@change="handleStatusChange(scope.row)"
/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[6].visible" width="160">
<el-table-column
label="创建时间"
align="center"
prop="createTime"
v-if="columns[6].visible"
width="160"
>
<template v-slot="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
<el-table-column
label="操作"
align="center"
width="160"
class-name="small-padding fixed-width"
>
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['system:user:update']">修改</el-button>
<el-dropdown @command="(command) => handleCommand(command, scope.$index, scope.row)"
v-hasPermi="['system:user:delete', 'system:user:update-password', 'system:permission:assign-user-role']">
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:user:update']"
>修改</el-button
>
<el-dropdown
@command="
(command) => handleCommand(command, scope.$index, scope.row)
"
v-hasPermi="[
'system:user:delete',
'system:user:update-password',
'system:permission:assign-user-role',
]"
>
<el-button size="mini" type="text" icon="el-icon-d-arrow-right"
>更多</el-button
>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleDelete" v-if="scope.row.id !== 1" size="mini" type="text" icon="el-icon-delete"
v-hasPermi="['system:user:delete']">删除</el-dropdown-item>
<el-dropdown-item command="handleResetPwd" size="mini" type="text" icon="el-icon-key"
v-hasPermi="['system:user:update-password']">重置密码</el-dropdown-item>
<el-dropdown-item command="handleRole" size="mini" type="text" icon="el-icon-circle-check"
v-hasPermi="['system:permission:assign-user-role']">分配角色</el-dropdown-item>
<el-dropdown-item
command="handleDelete"
v-if="scope.row.id !== 1"
size="mini"
type="text"
icon="el-icon-delete"
v-hasPermi="['system:user:delete']"
>删除</el-dropdown-item
>
<el-dropdown-item
command="handleResetPwd"
size="mini"
type="text"
icon="el-icon-key"
v-hasPermi="['system:user:update-password']"
>重置密码</el-dropdown-item
>
<el-dropdown-item
command="handleRole"
size="mini"
type="text"
icon="el-icon-circle-check"
v-hasPermi="['system:permission:assign-user-role']"
>分配角色</el-dropdown-item
>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-col>
</el-row>
@ -109,32 +285,59 @@
</el-col>
<el-col :span="12">
<el-form-item label="归属部门" prop="deptId">
<treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" :clearable="false"
placeholder="请选择归属部门" :normalizer="normalizer"/>
<treeselect
v-model="form.deptId"
:options="deptOptions"
:show-count="true"
:clearable="false"
placeholder="请选择归属部门"
:normalizer="normalizer"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="手机号码" prop="mobile">
<el-input v-model="form.mobile" placeholder="请输入手机号码" maxlength="11" />
<el-input
v-model="form.mobile"
placeholder="请输入手机号码"
maxlength="11"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="邮箱" prop="email">
<el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
<el-input
v-model="form.email"
placeholder="请输入邮箱"
maxlength="50"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item v-if="form.id === undefined" label="用户名称" prop="username">
<el-form-item
v-if="form.id === undefined"
label="用户名称"
prop="username"
>
<el-input v-model="form.username" placeholder="请输入用户名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item v-if="form.id === undefined" label="用户密码" prop="password">
<el-input v-model="form.password" placeholder="请输入用户密码" type="password" show-password />
<el-form-item
v-if="form.id === undefined"
label="用户密码"
prop="password"
>
<el-input
v-model="form.password"
placeholder="请输入用户密码"
type="password"
show-password
/>
</el-form-item>
</el-col>
</el-row>
@ -142,7 +345,12 @@
<el-col :span="12">
<el-form-item label="用户性别">
<el-select v-model="form.sex" placeholder="请选择">
<el-option v-for="dict in sexDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
<el-option
v-for="dict in sexDictDatas"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
</el-col>
@ -162,7 +370,11 @@
<el-row>
<el-col :span="24">
<el-form-item label="备注">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
<el-input
v-model="form.remark"
type="textarea"
placeholder="请输入内容"
></el-input>
</el-form-item>
</el-col>
</el-row>
@ -174,18 +386,39 @@
</el-dialog>
<!-- 用户导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
:on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
<el-dialog
:title="upload.title"
:visible.sync="upload.open"
width="400px"
append-to-body
>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<div class="el-upload__tip" slot="tip">
<el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
<el-checkbox v-model="upload.updateSupport" />
是否更新已经存在的用户数据
</div>
<span>仅允许导入xlsxlsx格式文件</span>
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate"></el-link>
<el-link
type="primary"
:underline="false"
style="font-size: 12px; vertical-align: baseline"
@click="importTemplate"
>下载模板</el-link
>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
@ -195,7 +428,12 @@
</el-dialog>
<!-- 分配角色 -->
<el-dialog title="分配角色" :visible.sync="openRole" width="500px" append-to-body>
<el-dialog
title="分配角色"
:visible.sync="openRole"
width="500px"
append-to-body
>
<el-form :model="form" label-width="80px">
<el-form-item label="用户名称">
<el-input v-model="form.username" :disabled="true" />
@ -219,7 +457,6 @@
<el-button @click="cancelRole"> </el-button>
</div>
</el-dialog>
</div>
</template>
@ -233,7 +470,7 @@ import {
importTemplate,
listUser,
resetUserPwd,
updateUser
updateUser,
} from "@/api/system/user";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@ -282,7 +519,7 @@ export default {
form: {},
defaultProps: {
children: "children",
label: "name"
label: "name",
},
//
upload: {
@ -297,7 +534,7 @@ export default {
//
headers: getBaseHeader(),
//
url: process.env.VUE_APP_BASE_API + '/admin-api/system/user/import'
url: process.env.VUE_APP_BASE_API + "/admin-api/system/user/import",
},
//
queryParams: {
@ -307,7 +544,7 @@ export default {
mobile: undefined,
status: undefined,
deptId: undefined,
createTime: []
createTime: [],
},
//
columns: [
@ -317,33 +554,34 @@ export default {
{ key: 3, label: `部门`, visible: true },
{ key: 4, label: `手机号码`, visible: true },
{ key: 5, label: `状态`, visible: true },
{ key: 6, label: `创建时间`, visible: true }
{ key: 6, label: `创建时间`, visible: true },
],
//
rules: {
username: [
{ required: true, message: "用户名称不能为空", trigger: "blur" }
{ required: true, message: "用户名称不能为空", trigger: "blur" },
],
nickname: [
{ required: true, message: "用户昵称不能为空", trigger: "blur" }
{ required: true, message: "用户昵称不能为空", trigger: "blur" },
],
password: [
{ required: true, message: "用户密码不能为空", trigger: "blur" }
{ required: true, message: "用户密码不能为空", trigger: "blur" },
],
email: [
{
type: "email",
message: "'请输入正确的邮箱地址",
trigger: ["blur", "change"]
}
trigger: ["blur", "change"],
},
],
mobile: [
{
pattern: /^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/,
pattern:
/^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur"
}
]
trigger: "blur",
},
],
},
//
openRole: false,
@ -359,7 +597,7 @@ export default {
//
deptName(val) {
this.$refs.tree.filter(val);
}
},
},
created() {
this.getList();
@ -372,16 +610,16 @@ export default {
//
handleCommand(command, index, row) {
switch (command) {
case 'handleUpdate':
case "handleUpdate":
this.handleUpdate(row); //
break;
case 'handleDelete':
case "handleDelete":
this.handleDelete(row); //
break;
case 'handleResetPwd':
case "handleResetPwd":
this.handleResetPwd(row);
break;
case 'handleRole':
case "handleRole":
this.handleRole(row);
break;
default:
@ -391,21 +629,21 @@ export default {
/** 查询用户列表 */
getList() {
this.loading = true;
listUser(this.queryParams).then(response => {
listUser(this.queryParams).then((response) => {
this.userList = response.data.list;
this.total = response.data.total;
this.loading = false;
}
);
});
},
/** 查询部门下拉树结构 + 岗位下拉 */
getTreeselect() {
listSimpleDepts().then(response => {
listSimpleDepts().then((response) => {
// deptOptions
this.deptOptions = [];
this.deptOptions.push(...this.handleTree(response.data, "id"));
debugger;
});
listSimplePosts().then(response => {
listSimplePosts().then((response) => {
// postOptions
this.postOptions = [];
this.postOptions.push(...response.data);
@ -424,12 +662,18 @@ export default {
//
handleStatusChange(row) {
let text = row.status === CommonStatusEnum.ENABLE ? "启用" : "停用";
this.$modal.confirm('确认要"' + text + '""' + row.username + '"用户吗?').then(function() {
this.$modal
.confirm('确认要"' + text + '""' + row.username + '"用户吗?')
.then(function () {
return changeUserStatus(row.id, row.status);
}).then(() => {
})
.then(() => {
this.$modal.msgSuccess(text + "成功");
}).catch(function() {
row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE
})
.catch(function () {
row.status =
row.status === CommonStatusEnum.ENABLE
? CommonStatusEnum.DISABLE
: CommonStatusEnum.ENABLE;
});
},
@ -457,7 +701,7 @@ export default {
status: "0",
remark: undefined,
postIds: [],
roleIds: []
roleIds: [],
};
this.resetForm("form");
},
@ -486,7 +730,7 @@ export default {
this.reset();
this.getTreeselect();
const id = row.id;
getUser(id).then(response => {
getUser(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改用户";
@ -497,17 +741,19 @@ export default {
handleResetPwd(row) {
this.$prompt('请输入"' + row.username + '"的新密码', "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消"
}).then(({ value }) => {
resetUserPwd(row.id, value).then(response => {
cancelButtonText: "取消",
})
.then(({ value }) => {
resetUserPwd(row.id, value).then((response) => {
this.$modal.msgSuccess("修改成功,新密码是:" + value);
});
}).catch(() => {});
})
.catch(() => {});
},
/** 分配用户角色操作 */
handleRole(row) {
this.reset();
const id = row.id
const id = row.id;
// form username nickname
this.form.id = id;
this.form.username = row.username;
@ -515,29 +761,29 @@ export default {
//
this.openRole = true;
//
listSimpleRoles().then(response => {
listSimpleRoles().then((response) => {
// roleOptions
this.roleOptions = [];
this.roleOptions.push(...response.data);
});
//
listUserRoles(id).then(response => {
listUserRoles(id).then((response) => {
//
this.form.roleIds = response.data;
})
});
},
/** 提交按钮 */
submitForm: function () {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.id !== undefined) {
updateUser(this.form).then(response => {
updateUser(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addUser(this.form).then(response => {
addUser(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
@ -552,7 +798,7 @@ export default {
assignUserRole({
userId: this.form.id,
roleIds: this.form.roleIds,
}).then(response => {
}).then((response) => {
this.$modal.msgSuccess("分配角色成功");
this.openRole = false;
this.getList();
@ -562,26 +808,34 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除用户编号为"' + ids + '"的数据项?').then(function() {
this.$modal
.confirm('是否确认删除用户编号为"' + ids + '"的数据项?')
.then(function () {
return delUser(ids);
}).then(() => {
})
.then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.$modal.confirm('是否确认导出所有用户数据项?').then(() => {
this.$modal
.confirm("是否确认导出所有用户数据项?")
.then(() => {
//
let params = { ...this.queryParams };
params.pageNo = undefined;
params.pageSize = undefined;
this.exportLoading = true;
return exportUser(params);
}).then(response => {
this.$download.excel(response, '用户数据.xls');
})
.then((response) => {
this.$download.excel(response, "用户数据.xls");
this.exportLoading = false;
}).catch(() => {});
})
.catch(() => {});
},
/** 导入按钮操作 */
handleImport() {
@ -590,8 +844,8 @@ export default {
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
this.$download.excel(response, '用户导入模板.xls');
importTemplate().then((response) => {
this.$download.excel(response, "用户导入模板.xls");
});
},
//
@ -601,7 +855,7 @@ export default {
//
handleFileSuccess(response, file, fileList) {
if (response.code !== 0) {
this.$modal.msgError(response.msg)
this.$modal.msgError(response.msg);
return;
}
this.upload.open = false;
@ -609,17 +863,22 @@ export default {
this.$refs.upload.clearFiles();
//
let data = response.data;
let text = '创建成功数量:' + data.createUsernames.length;
let text = "创建成功数量:" + data.createUsernames.length;
for (const username of data.createUsernames) {
text += '<br />&nbsp;&nbsp;&nbsp;&nbsp;' + username;
text += "<br />&nbsp;&nbsp;&nbsp;&nbsp;" + username;
}
text += '<br />更新成功数量:' + data.updateUsernames.length;
text += "<br />更新成功数量:" + data.updateUsernames.length;
for (const username of data.updateUsernames) {
text += '<br />&nbsp;&nbsp;&nbsp;&nbsp;' + username;
text += "<br />&nbsp;&nbsp;&nbsp;&nbsp;" + username;
}
text += '<br />更新失败数量:' + Object.keys(data.failureUsernames).length;
text +=
"<br />更新失败数量:" + Object.keys(data.failureUsernames).length;
for (const username in data.failureUsernames) {
text += '<br />&nbsp;&nbsp;&nbsp;&nbsp;' + username + '' + data.failureUsernames[username];
text +=
"<br />&nbsp;&nbsp;&nbsp;&nbsp;" +
username +
"" +
data.failureUsernames[username];
}
this.$alert(text, "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
@ -633,9 +892,9 @@ export default {
return {
id: node.id,
label: node.name,
children: node.children
}
}
}
children: node.children,
};
},
},
};
</script>

@ -0,0 +1,994 @@
<template>
<div class="app-container">
<el-row :gutter="20">
<!--部门数据-->
<el-col :span="4" :xs="24">
<div class="head-container">
<el-input
v-model="deptName"
placeholder="请输入部门名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</div>
<div class="head-container">
<el-tree
:data="businessOption"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="tree"
default-expand-all
highlight-current
@node-click="handleNodeClick"
/>
</div>
</el-col>
<el-col :span="20" :xs="24">
<el-tabs v-model="activeTabs" @tab-click="handleClick">
<!--用户数据-->
<el-tab-pane label="仓库列表" name="warehouse">
<!-- 搜索工作栏 -->
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="仓库编号" prop="warehouseCode">
<el-input
v-model="queryParams.warehouseCode"
placeholder="请输入仓库编号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="仓库名称" prop="warehouseName">
<el-input
v-model="queryParams.warehouseName"
placeholder="请输入仓库名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="类型" prop="type">
<el-select
v-model="queryParams.type"
placeholder="请选择类型"
clearable
size="small"
>
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.BUSINESS_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="成立时间" prop="establishDate">
<el-date-picker
v-model="queryParams.establishDate"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['xxjj:business-warehouse:create']"
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['xxjj:business-warehouse:export']"
>导出</el-button
>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<!-- 列表 -->
<el-table v-loading="loading" :data="list">
<el-table-column label="业务id" align="center" prop="id" />
<el-table-column
label="业务线编号"
align="center"
prop="businessCode"
/>
<el-table-column label="业务线名称" align="center" prop="name" />
<el-table-column
label="业务线简称"
align="center"
prop="businessSimple"
/>
<el-table-column
label="业务线LOGO"
align="center"
prop="businessLogo"
>
<template v-slot="scope">
<ImagePreview :src="scope.row.businessLogo" />
</template>
</el-table-column>
<el-table-column label="父id" align="center" prop="parentId" />
<el-table-column label="类型" align="center" prop="type">
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.BUSINESS_TYPE"
:value="scope.row.industry"
/>
</template>
</el-table-column>
<el-table-column
label="业务线/仓库"
align="center"
prop="diffFlag"
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.DIFF_FLAG"
:value="scope.row.diffFlag"
/>
</template>
</el-table-column>
<el-table-column label="所属行业" align="center" prop="industry">
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.DUTY_TYPE"
:value="scope.row.industry"
/>
</template>
</el-table-column>
<el-table-column label="所在城市" align="center" prop="city" />
<el-table-column
label="成立时间"
align="center"
prop="establishDate"
width="180"
>
<template v-slot="scope">
<span>{{ parseTime(scope.row.establishDate) }}</span>
</template>
</el-table-column>
<el-table-column
label="归属人员"
align="center"
prop="belongUserId"
/>
<el-table-column
label="品牌/业务线/事业群名称"
align="center"
prop="brandName"
/>
<el-table-column label="电话" align="center" prop="phone" />
<el-table-column label="传真" align="center" prop="fax" />
<el-table-column label="网址" align="center" prop="url" />
<el-table-column label="介绍" align="center" prop="description" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
width="180"
>
<template v-slot="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template v-slot="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['xxjj:business-warehouse:update']"
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['xxjj:business-warehouse:delete']"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="客户列表" name="customer">
<!-- 搜索工作栏 -->
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="客户名称" prop="customerName">
<el-input
v-model="queryParams.customerName"
placeholder="请输入客户名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="客户类型" prop="customerType">
<el-select
v-model="queryParams.customerType"
placeholder="请选择客户类型"
clearable
size="small"
>
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.CUSTOMER_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="统一结算主体" prop="unifiedSettlement">
<el-input
v-model="queryParams.unifiedSettlement"
placeholder="请输入统一结算主体"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="客户性质" prop="customerNature">
<el-select
v-model="queryParams.customerNature"
placeholder="请选择客户性质"
clearable
size="small"
>
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.CUSTOMER_NATUER)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="合作模式" prop="cooperationMode">
<el-select
v-model="queryParams.cooperationMode"
placeholder="请选择合作模式"
clearable
size="small"
>
<el-option
v-for="dict in this.getDictDatas(
DICT_TYPE.COOPERATION_MODE
)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="隶属业务线" prop="linebusinessId">
<el-input
v-model="queryParams.linebusinessId"
placeholder="请输入隶属业务线"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['xxjj:customer:create']"
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['xxjj:customer:export']"
>导出</el-button
>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
:columns="columns"
></right-toolbar>
</el-row>
<!-- 列表 -->
<el-table
v-loading="loading"
:data="list"
@selection-change="handleSelectionChange"
sortable
border
custom-column
stripe
>
<el-table-column
type="selection"
width="55"
align="center"
></el-table-column>
<el-table-column
label="编号"
align="center"
prop="id"
v-if="columns[0].visible"
/>
<el-table-column
label="客户名称"
align="center"
prop="customerName"
sortable
v-if="columns[1].visible"
/>
<el-table-column
label="客户类型"
align="center"
prop="customerType"
sortable
v-if="columns[2].visible"
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.CUSTOMER_TYPE"
:value="scope.row.customerType"
/>
</template>
</el-table-column>
<el-table-column
label="统一结算主体"
align="center"
prop="unifiedSettlement"
sortable
v-if="columns[3].visible"
/>
<el-table-column
label="客户性质"
align="center"
prop="customerNature"
sortable
v-if="columns[4].visible"
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.CUSTOMER_NATUER"
:value="scope.row.customerNature"
/>
</template>
</el-table-column>
<el-table-column
label="合作模式"
align="center"
prop="cooperationMode"
sortable
v-if="columns[5].visible"
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.COOPERATION_MODE"
:value="scope.row.cooperationMode"
/>
</template>
</el-table-column>
<el-table-column
label="隶属业务线"
align="center"
prop="linebusinessId"
sortable
v-if="columns[6].visible"
/>
<el-table-column
label="状态"
align="center"
prop="status"
sortable
v-if="columns[7].visible"
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.UNIT_LIBRARY_STATUS"
:value="scope.row.status"
/>
</template>
</el-table-column>
<el-table-column
label="归属人员"
align="center"
prop="belongingPeople"
sortable
v-if="columns[8].visible"
/>
<el-table-column
label="创建时间"
align="center"
prop="createTime"
width="180"
v-if="columns[9].visible"
>
<template v-slot="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="更新时间"
align="center"
prop="updateTime"
width="180"
v-if="columns[10].visible"
>
<template v-slot="scope">
<span>{{ parseTime(scope.row.updateTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template v-slot="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['xxjj:customer:update']"
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleopen1close(scope.row)"
>{{ scope.row.status == 0 ? "禁用" : "启用" }}</el-button
>
<el-divider direction="vertical"></el-divider>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['xxjj:customer:delete']"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-col>
</el-row>
<!-- 对话框(添加 / 修改) -->
<el-dialog
:title="title"
:visible.sync="open"
width="500px"
v-dialogDrag
append-to-body
>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="业务线编号" prop="businessCode">
<el-input
v-model="form.businessCode"
placeholder="请输入业务线编号"
/>
</el-form-item>
<el-form-item label="业务线名称" prop="name">
<el-input v-model="form.name" placeholder="请输入业务线名称" />
</el-form-item>
<el-form-item label="业务线简称" prop="businessSimple">
<el-input
v-model="form.businessSimple"
placeholder="请输入业务线简称"
/>
</el-form-item>
<el-form-item label="业务线LOGO">
<imageUpload v-model="form.businessLogo" />
</el-form-item>
<el-form-item label="父id" prop="parentId">
<!-- <el-input v-model="form.parentId" placeholder="请输入父id" /> -->
<treeselect
v-model="form.parentId"
:options="businessOption"
:show-count="true"
:clearable="false"
placeholder="请选择归属部门"
:normalizer="normalizer"
/>
</el-form-item>
<el-form-item label="类型" prop="type">
<el-select v-model="form.type" placeholder="请选择类型">
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.BUSINESS_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="所属行业" prop="industry">
<el-select v-model="form.industry" placeholder="请选择类型">
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.DUTY_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="所在城市" prop="city">
<el-input v-model="form.city" placeholder="请输入所在城市" />
</el-form-item>
<el-form-item label="业务线/仓库" prop="diffFlag">
<el-select v-model="form.diffFlag" placeholder="请选择类型">
<el-option
v-for="dict in this.getDictDatas(DICT_TYPE.DIFF_FLAG)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="成立时间" prop="establishDate">
<el-date-picker
clearable
v-model="form.establishDate"
type="date"
value-format="timestamp"
placeholder="选择成立时间"
/>
</el-form-item>
<el-form-item label="归属人员" prop="belongUserId">
<el-input v-model="form.belongUserId" placeholder="请输入归属人员" />
</el-form-item>
<el-form-item label="品牌/业务线/事业群名称" prop="brandName">
<el-input
v-model="form.brandName"
placeholder="请输入品牌/业务线/事业群名称"
/>
</el-form-item>
<el-form-item label="电话" prop="phone">
<el-input v-model="form.phone" placeholder="请输入电话" />
</el-form-item>
<el-form-item label="传真" prop="fax">
<el-input v-model="form.fax" placeholder="请输入传真" />
</el-form-item>
<el-form-item label="网址" prop="url">
<el-input v-model="form.url" placeholder="请输入网址" />
</el-form-item>
<el-form-item label="介绍">
<editor v-model="form.description" :min-height="192" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
createBusinessWarehouse,
updateBusinessWarehouse,
deleteBusinessWarehouse,
getBusinessWarehouse,
getBusinessWarehousePage,
exportBusinessWarehouseExcel,
} from "@/api/xxjj/businessWarehouse";
import ImageUpload from "@/components/ImageUpload";
import Editor from "@/components/Editor";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import ImagePreview from "@/components/ImagePreview";
import {
createCustomer,
updateCustomer,
deleteCustomer,
getCustomer,
getCustomerPage,
exportCustomerExcel,
} from "@/api/xxjj/customer";
export default {
name: "BusinessWarehouse",
components: {
ImageUpload,
Editor,
Treeselect,
ImagePreview,
},
data() {
return {
//
deptName: undefined,
activeTabs: "warehouse",
// 线
businessOption: undefined,
//
loading: true,
//
exportLoading: false,
//
showSearch: true,
//
total: 0,
// 线/
list: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNo: 1,
pageSize: 10,
businessCode: null,
name: null,
businessSimple: null,
businessLogo: null,
parentId: null,
type: null,
industry: null,
city: null,
establishDate: [],
belongUserId: null,
brandName: null,
phone: null,
fax: null,
url: null,
description: null,
createTime: [],
},
columns: [
{ key: 0, label: `编号`, visible: true },
{ key: 1, label: `客户名称`, visible: true },
{ key: 2, label: `客户类型`, visible: true },
{ key: 3, label: `统一结算主体`, visible: true },
{ key: 4, label: `客户性质`, visible: true },
{ key: 5, label: `合作模式`, visible: true },
{ key: 6, label: `隶属业务线`, visible: true },
{ key: 7, label: `状态`, visible: true },
{ key: 8, label: `归属人员`, visible: true },
{ key: 9, label: `创建时间`, visible: true },
{ key: 10, label: `更新时间`, visible: true },
],
//
form: {},
defaultProps: {
children: "children",
label: "name",
},
//
rules: {
businessCode: [
{ required: true, message: "业务线编号不能为空", trigger: "blur" },
],
name: [
{ required: true, message: "业务线名称不能为空", trigger: "blur" },
],
// businessLogo: [
// { required: true, message: "线LOGO", trigger: "blur" },
// ],
// parentId: [
// { required: true, message: "id", trigger: "blur" },
// ],
// type: [{ required: true, message: "", trigger: "change" }],
// industry: [
// { required: true, message: "", trigger: "blur" },
// ],
// city: [
// { required: true, message: "", trigger: "blur" },
// ],
// establishDate: [
// { required: true, message: "", trigger: "blur" },
// ],
// belongUserId: [
// { required: true, message: "", trigger: "blur" },
// ],
// brandName: [
// {
// required: true,
// message: "/线/",
// trigger: "blur",
// },
// ],
// phone: [{ required: true, message: "", trigger: "blur" }],
diffFlag: [
{ required: true, message: "业务线/仓库不能为空", trigger: "blur" },
],
},
};
},
watch: {
//
deptName(val) {
this.$refs.tree.filter(val);
},
},
created() {
this.getList();
this.getTreeselect();
},
methods: {
//
handleSelectionChange(val) {
this.multipleSelection = val;
},
handleClick(val) {
if (val.name === "warehouse") {
// this.queryParams.affiliatLineId = undefined;
this.queryParams.alarmStock = undefined;
debugger;
} else if (val.name === "customer") {
// this.queryParams.affiliatLineId = 2;
this.queryParams.alarmStock = undefined;
}
this.getList();
},
/** 查询业务线/仓库树状列表 */
getTreeselect() {
getBusinessWarehousePage().then((response) => {
// businessOption
this.businessOption = [];
this.businessOption.push(...this.handleTree(response.data.list, "id"));
debugger;
});
},
/** 查询列表 */
getList() {
debugger;
this.loading = true;
if (this.activeTabs == "warehouse") {
//
getBusinessWarehousePage(this.queryParams).then((response) => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
});
} else if (this.activeTabs == "customer") {
getCustomerPage(this.queryParams).then((response) => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
});
}
},
//
filterNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
//
handleNodeClick(data) {
this.queryParams.parentId = data.id;
this.getList();
},
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
/** 表单重置 */
reset() {
this.form = {
id: undefined,
businessCode: undefined,
name: undefined,
businessSimple: undefined,
businessLogo: undefined,
parentId: undefined,
type: undefined,
industry: undefined,
city: undefined,
establishDate: undefined,
belongUserId: undefined,
brandName: undefined,
phone: undefined,
fax: undefined,
url: undefined,
description: undefined,
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加业务线/仓库";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id;
getBusinessWarehouse(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = "修改业务线/仓库";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (!valid) {
return;
}
//
if (this.form.id != null) {
updateBusinessWarehouse(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
return;
}
//
createBusinessWarehouse(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
});
},
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$modal
.confirm('是否确认删除业务线/仓库编号为"' + id + '"的数据项?')
.then(function () {
return deleteBusinessWarehouse(id);
})
.then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
//
let params = { ...this.queryParams };
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal
.confirm("是否确认导出所有业务线/仓库数据项?")
.then(() => {
this.exportLoading = true;
return exportBusinessWarehouseExcel(params);
})
.then((response) => {
this.$download.excel(response, "业务线/仓库.xls");
this.exportLoading = false;
})
.catch(() => {});
},
//
normalizer(node) {
return {
id: node.id,
label: node.name,
children: node.children,
};
},
},
};
</script>
<style lang="scss">
.app-container {
.el-tag + .el-tag {
margin-left: 10px;
}
}
</style>
Loading…
Cancel
Save