Merge branch 'feature/mall_product' of http://117.33.142.185:3000/zenghuapei/cyywl_server into feature/mall_product
commit
fd0627c470
|
@ -13,6 +13,9 @@ public interface ErrorCodeConstants {
|
|||
ErrorCode USER_NOT_EXISTS = new ErrorCode(1004001000, "用户不存在");
|
||||
ErrorCode USER_PASSWORD_FAILED = new ErrorCode(1004001001, "密码校验失败");
|
||||
ErrorCode PROMOTER_NOT_EXISTS = new ErrorCode(1004001002, "推广员不存在");
|
||||
|
||||
ErrorCode PROMOTER_EXISTS = new ErrorCode(1004001003, "推广员存在");
|
||||
ErrorCode PROMOTER_IMPORT_LIST_IS_EMPTY = new ErrorCode(1002003004, "导入推广员数据不能为空!");
|
||||
// ========== AUTH 模块 1004003000 ==========
|
||||
ErrorCode AUTH_LOGIN_BAD_CREDENTIALS = new ErrorCode(1004003000, "登录失败,账号密码不正确");
|
||||
ErrorCode AUTH_LOGIN_USER_DISABLED = new ErrorCode(1004003001, "登录失败,账号被禁用");
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package cn.iocoder.yudao.module.member.controller.admin.promoter;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.module.system.enums.common.SexEnum;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -27,6 +30,7 @@ import cn.iocoder.yudao.module.member.controller.admin.promoter.vo.*;
|
|||
import cn.iocoder.yudao.module.member.dal.dataobject.promoter.PromoterDO;
|
||||
import cn.iocoder.yudao.module.member.convert.promoter.PromoterConvert;
|
||||
import cn.iocoder.yudao.module.member.service.promoter.PromoterService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Tag(name = "管理后台 - 推广员")
|
||||
@RestController
|
||||
|
@ -98,5 +102,27 @@ public class PromoterController {
|
|||
List<PromoterExcelVO> datas = PromoterConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "推广员.xls", "数据", PromoterExcelVO.class, datas);
|
||||
}
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获得导入推广员模板")
|
||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||
// 手动创建导出 demo
|
||||
List<PromoterImportExcelVO> list = Arrays.asList(
|
||||
PromoterImportExcelVO.builder().nickName("yunai").orgName("创盈云网络>重庆总公司>研发部门").mobile("15601691300").build()
|
||||
);
|
||||
|
||||
// 输出
|
||||
ExcelUtils.write(response, "推广员导入模板.xls", "推广员列表", PromoterImportExcelVO.class, list);
|
||||
}
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入推广员")
|
||||
@Parameters({
|
||||
@Parameter(name = "file", description = "Excel 文件", required = true),
|
||||
@Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
|
||||
})
|
||||
// @PreAuthorize("@ss.hasPermission('system:user:import')")
|
||||
public CommonResult<PromoterImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
|
||||
List<PromoterImportExcelVO> list = ExcelUtils.read(file, PromoterImportExcelVO.class);
|
||||
return success(promoterService.importUserList(list, updateSupport));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package cn.iocoder.yudao.module.member.controller.admin.promoter.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* 推广员 Excel VO
|
||||
*
|
||||
* @author 创盈云
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = false)
|
||||
public class PromoterImportExcelVO {
|
||||
|
||||
@ExcelProperty("手机号码")
|
||||
@Mobile
|
||||
@NotEmpty(message = "手机号码不能为空")
|
||||
private String mobile;
|
||||
@ExcelProperty("组织全称")
|
||||
@NotEmpty(message = "组织全称不能为空")
|
||||
private String orgName;
|
||||
|
||||
@ExcelProperty("姓名")
|
||||
@NotEmpty(message = "姓名不能为空")
|
||||
private String nickName;
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package cn.iocoder.yudao.module.member.controller.admin.promoter.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Schema(description = "管理后台 - 推广员导入 Response VO")
|
||||
@Data
|
||||
@Builder
|
||||
public class PromoterImportRespVO {
|
||||
|
||||
@Schema(description = "导入成功的推广员数组", required = true)
|
||||
private List<String> createUsernames;
|
||||
|
||||
@Schema(description = "更新成功的推广员数组", required = true)
|
||||
private List<String> updateUsernames;
|
||||
|
||||
@Schema(description = "导入失败的推广员", required = true)
|
||||
private Map<String, String> failureUsernames;
|
||||
|
||||
}
|
|
@ -32,7 +32,7 @@ public class PromoterDO implements Serializable {
|
|||
/**
|
||||
* 组织id
|
||||
*/
|
||||
private String orgId;
|
||||
private Long orgId;
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
|
|
|
@ -67,4 +67,13 @@ public interface PromoterService {
|
|||
*/
|
||||
List<PromoterDO> getPromoterList(PromoterExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 批量导入推广员列表
|
||||
*
|
||||
* @param importUsers 批量导入推广员列表
|
||||
* @param isUpdateSupport 是否支持更新
|
||||
* @return 导入结果
|
||||
*/
|
||||
PromoterImportRespVO importUserList(List<PromoterImportExcelVO> importUsers, boolean isUpdateSupport);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
package cn.iocoder.yudao.module.member.service.promoter;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -18,6 +27,9 @@ import cn.iocoder.yudao.module.member.dal.mysql.promoter.PromoterMapper;
|
|||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_IMPORT_LIST_IS_EMPTY;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_USERNAME_EXISTS;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
|
||||
/**
|
||||
* 推广员 Service 实现类
|
||||
|
@ -30,10 +42,14 @@ public class PromoterServiceImpl implements PromoterService {
|
|||
|
||||
@Resource
|
||||
private PromoterMapper promoterMapper;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
@Resource
|
||||
private Validator validator;
|
||||
@Resource
|
||||
private MemberUserService memberUserService;
|
||||
|
||||
@Resource
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
@Override
|
||||
public Long createPromoter(PromoterCreateReqVO createReqVO) {
|
||||
|
@ -45,11 +61,16 @@ public class PromoterServiceImpl implements PromoterService {
|
|||
memberUserDO.setNickname(createReqVO.getNickName());
|
||||
memberUserDO.setMobile(createReqVO.getMobile());
|
||||
memberUserDO.setStatus(createReqVO.getStatus());
|
||||
memberUserDO.setPassword(createReqVO.getMobile().substring(createReqVO.getMobile().length()-6));
|
||||
memberUserService.createUserIfAbsent(createReqVO.getMobile(),createReqVO.getNickName(),getClientIP());
|
||||
}
|
||||
// 插入
|
||||
PromoterDO promoter = PromoterConvert.INSTANCE.convert(createReqVO);
|
||||
promoter.setTenantId(SecurityFrameworkUtils.getLoginUser().getTenantId());
|
||||
Long count = promoterMapper.selectCount(Wrappers.lambdaQuery(PromoterDO.class).eq(PromoterDO::getUserId,memberUserDO.getId()));
|
||||
if(count>0){
|
||||
throw new ServiceException(PROMOTER_EXISTS);
|
||||
}
|
||||
promoter.setUserId(memberUserDO.getId());
|
||||
promoterMapper.insert(promoter);
|
||||
// 返回
|
||||
|
@ -99,4 +120,68 @@ public class PromoterServiceImpl implements PromoterService {
|
|||
return promoterMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导入推广员列表
|
||||
*
|
||||
* @param importUsers 批量导入推广员列表
|
||||
* @param isUpdateSupport 是否支持更新
|
||||
* @return 导入结果
|
||||
*/
|
||||
@Override
|
||||
public PromoterImportRespVO importUserList(List<PromoterImportExcelVO> importUsers, boolean isUpdateSupport) {
|
||||
if (CollUtil.isEmpty(importUsers)) {
|
||||
throw exception(PROMOTER_IMPORT_LIST_IS_EMPTY);
|
||||
}
|
||||
PromoterImportRespVO respVO = PromoterImportRespVO.builder().createUsernames(new ArrayList<>())
|
||||
.updateUsernames(new ArrayList<>()).failureUsernames(new LinkedHashMap<>()).build();
|
||||
List<DeptRespDTO> deptRespDTOList = deptApi.getDeptList();
|
||||
Map<String,DeptRespDTO> nameList = deptRespDTOList.stream().collect(toMap(DeptRespDTO::getParentOrganizationName, value -> value,(value1,value2)->value1));
|
||||
importUsers.forEach(importUser -> {
|
||||
try {
|
||||
ValidationUtils.validate(validator,importUser);
|
||||
} catch (ServiceException ex) {
|
||||
respVO.getFailureUsernames().put(importUser.getNickName(), ex.getMessage());
|
||||
return;
|
||||
}
|
||||
//判断手机号是否注册
|
||||
MemberUserDO memberUserDO = memberUserService.getUserByMobile(importUser.getMobile());
|
||||
if(memberUserDO==null){
|
||||
//创建用户
|
||||
memberUserDO = new MemberUserDO();
|
||||
memberUserDO.setNickname(importUser.getNickName());
|
||||
memberUserDO.setMobile(importUser.getMobile());
|
||||
memberUserDO.setPassword(importUser.getMobile().substring(importUser.getMobile().length()-6));
|
||||
memberUserDO.setStatus(1);
|
||||
memberUserService.createUserIfAbsent(importUser.getMobile(),importUser.getNickName(),getClientIP());
|
||||
}
|
||||
// 插入
|
||||
PromoterDO promoter = new PromoterDO();
|
||||
promoter.setTenantId(SecurityFrameworkUtils.getLoginUser().getTenantId());
|
||||
promoter.setUserId(memberUserDO.getId());
|
||||
Long count = promoterMapper.selectCount(Wrappers.lambdaQuery(PromoterDO.class).eq(PromoterDO::getUserId,memberUserDO.getId()));
|
||||
if(count>0){
|
||||
respVO.getFailureUsernames().put(importUser.getNickName(), "已经是推广员");
|
||||
return;
|
||||
}
|
||||
DeptRespDTO deptRespDTO = nameList.get(importUser.getOrgName());
|
||||
if(deptRespDTO==null){
|
||||
respVO.getFailureUsernames().put(importUser.getNickName(), "组织不存在");
|
||||
return;
|
||||
}
|
||||
promoter.setOrgId(deptRespDTO.getId());
|
||||
promoterMapper.insert(promoter);
|
||||
respVO.getCreateUsernames().add(importUser.getNickName());
|
||||
return;
|
||||
});
|
||||
return respVO;
|
||||
}
|
||||
/**
|
||||
* 对密码进行加密
|
||||
*
|
||||
* @param password 密码
|
||||
* @return 加密后的密码
|
||||
*/
|
||||
private String encodePassword(String password) {
|
||||
return passwordEncoder.encode(password);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,14 @@ public interface DeptApi {
|
|||
*/
|
||||
List<DeptRespDTO> getDeptList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得部门信息数组
|
||||
*
|
||||
* @param ids 部门编号数组
|
||||
* @return 部门信息数组
|
||||
*/
|
||||
List<DeptRespDTO> getDeptList();
|
||||
|
||||
/**
|
||||
* 校验部门们是否有效。如下情况,视为无效:
|
||||
* 1. 部门编号不存在
|
||||
|
|
|
@ -34,4 +34,14 @@ public class DeptRespDTO {
|
|||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 父级组织链
|
||||
*/
|
||||
private String parentOrganizationIds;
|
||||
|
||||
/**
|
||||
* 父级组织链名称
|
||||
*/
|
||||
private String parentOrganizationName;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cn.iocoder.yudao.module.system.api.dept;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
|
||||
import cn.iocoder.yudao.module.system.convert.dept.DeptConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
|
@ -32,7 +33,11 @@ public class DeptApiImpl implements DeptApi {
|
|||
List<DeptDO> depts = deptService.getDeptList(ids);
|
||||
return DeptConvert.INSTANCE.convertList03(depts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptRespDTO> getDeptList() {
|
||||
List<DeptDO> depts = deptService.getDeptList(new DeptListReqVO());
|
||||
return DeptConvert.INSTANCE.convertList03(depts);
|
||||
}
|
||||
@Override
|
||||
public void validateDeptList(Collection<Long> ids) {
|
||||
deptService.validateDeptList(ids);
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -24,11 +26,24 @@ public class TenantPageReqVO extends PageParam {
|
|||
private String contactName;
|
||||
|
||||
@Schema(description = "联系手机", example = "15601691300")
|
||||
@Mobile
|
||||
private String contactMobile;
|
||||
|
||||
@Schema(description = "租户状态(0正常 1停用)", example = "1")
|
||||
private Integer status;
|
||||
/**
|
||||
* 销售负责人
|
||||
*/
|
||||
@Schema(description = "销售负责人", example = "https://www.iocoder.cn")
|
||||
@Length( max = 10, message = "销售负责人长度为 {max}位")
|
||||
private String saleContactName;
|
||||
|
||||
/**
|
||||
* 销售负责人联系电话
|
||||
*/
|
||||
@Schema(description = "销售负责人联系电话", example = "https://www.iocoder.cn")
|
||||
@Mobile
|
||||
private String saleContactMobile;
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime[] createTime;
|
||||
|
|
|
@ -23,6 +23,8 @@ public interface TenantMapper extends BaseMapperX<TenantDO> {
|
|||
.likeIfPresent(TenantDO::getName, reqVO.getName())
|
||||
.likeIfPresent(TenantDO::getContactName, reqVO.getContactName())
|
||||
.likeIfPresent(TenantDO::getContactMobile, reqVO.getContactMobile())
|
||||
.likeIfPresent(TenantDO::getSaleContactName, reqVO.getSaleContactName())
|
||||
.likeIfPresent(TenantDO::getSaleContactMobile, reqVO.getSaleContactMobile())
|
||||
.eqIfPresent(TenantDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(TenantDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(TenantDO::getId));
|
||||
|
|
|
@ -5,7 +5,7 @@ ENV = 'development'
|
|||
VUE_APP_TITLE = 创盈商户管理系统
|
||||
|
||||
# 芋道管理系统/开发环境
|
||||
VUE_APP_BASE_API = 'http://192.168.1.147:48080'
|
||||
VUE_APP_BASE_API = 'http://192.168.2.71:48080'
|
||||
|
||||
# 路由懒加载
|
||||
VUE_CLI_BABEL_TRANSPILE_MODULES = true
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 创建推广员
|
||||
export function createPromoter(data) {
|
||||
return request({
|
||||
url: '/member/promoter/create',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新推广员
|
||||
export function updatePromoter(data) {
|
||||
return request({
|
||||
url: '/member/promoter/update',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除推广员
|
||||
export function deletePromoter(id) {
|
||||
return request({
|
||||
url: '/member/promoter/delete?id=' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 获得推广员
|
||||
export function getPromoter(id) {
|
||||
return request({
|
||||
url: '/member/promoter/get?id=' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 获得推广员分页
|
||||
export function getPromoterPage(query) {
|
||||
return request({
|
||||
url: '/member/promoter/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 导出推广员 Excel
|
||||
export function exportPromoterExcel(query) {
|
||||
return request({
|
||||
url: '/member/promoter/export-excel',
|
||||
method: 'get',
|
||||
params: query,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
// 下载用户导入模板
|
||||
export function importTemplate() {
|
||||
return request({
|
||||
url: '/member/promoter/get-import-template',
|
||||
method: 'get',
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
|
@ -0,0 +1,289 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="组织id" prop="orgId">
|
||||
<el-input v-model="queryParams.orgId" placeholder="请输入组织id" clearable @keyup.enter.native="handleQuery"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="会员id" prop="userId">
|
||||
<el-input v-model="queryParams.userId" placeholder="请输入会员id" clearable @keyup.enter.native="handleQuery"/>
|
||||
</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="['member:promoter: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-col>
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"-->
|
||||
<!-- v-hasPermi="['member:promoter: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="编号" align="center" prop="id" />
|
||||
<el-table-column label="组织id" align="center" prop="orgId" />
|
||||
<el-table-column label="会员id" align="center" prop="userId" />
|
||||
<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="['member:promoter:update']">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['member:promoter:delete']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页组件 -->
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"/>
|
||||
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<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="组织id" prop="orgId">
|
||||
<el-input v-model="form.orgId" placeholder="请输入组织id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="会员id" prop="userId">
|
||||
<el-input v-model="form.userId" placeholder="请输入会员id" />
|
||||
</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>
|
||||
<!-- 用户导入对话框 -->
|
||||
<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" /> 是否更新已经存在的用户数据-->
|
||||
<!-- </div>-->
|
||||
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||
<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">
|
||||
<el-button type="primary" @click="submitFileForm">确 定</el-button>
|
||||
<el-button @click="upload.open = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { createPromoter, updatePromoter, deletePromoter, getPromoter, getPromoterPage, importTemplate,exportPromoterExcel } from "@/api/member/promoter";
|
||||
import {getBaseHeader} from "@/utils/request";
|
||||
export default {
|
||||
name: "Promoter",
|
||||
components: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 导出遮罩层
|
||||
exportLoading: false,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 推广员列表
|
||||
list: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 用户导入参数
|
||||
upload: {
|
||||
// 是否显示弹出层(用户导入)
|
||||
open: false,
|
||||
// 弹出层标题(用户导入)
|
||||
title: "推广员导入",
|
||||
// 是否禁用上传
|
||||
isUploading: false,
|
||||
// 是否更新已经存在的用户数据
|
||||
updateSupport: 0,
|
||||
// 设置上传的请求头部
|
||||
headers: getBaseHeader(),
|
||||
// 上传的地址
|
||||
url: process.env.VUE_APP_BASE_API + '/admin-api/member/promoter/import'
|
||||
},
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
orgId: null,
|
||||
userId: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
orgId: [{ required: true, message: "组织id不能为空", trigger: "blur" }],
|
||||
userId: [{ required: true, message: "会员id不能为空", trigger: "blur" }],
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
// 执行查询
|
||||
getPromoterPage(this.queryParams).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 取消按钮 */
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
/** 表单重置 */
|
||||
reset() {
|
||||
this.form = {
|
||||
id: undefined,
|
||||
orgId: undefined,
|
||||
userId: 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;
|
||||
getPromoter(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) {
|
||||
updatePromoter(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
createPromoter(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 deletePromoter(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 exportPromoterExcel(params);
|
||||
}).then(response => {
|
||||
this.$download.excel(response, '推广员.xls');
|
||||
this.exportLoading = false;
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导入按钮操作 */
|
||||
handleImport() {
|
||||
this.upload.title = "推广员导入";
|
||||
this.upload.open = true;
|
||||
},
|
||||
/** 下载模板操作 */
|
||||
importTemplate() {
|
||||
importTemplate().then(response => {
|
||||
this.$download.excel(response, '推广员导入模板.xls');
|
||||
});
|
||||
},
|
||||
// 文件上传中处理
|
||||
handleFileUploadProgress(event, file, fileList) {
|
||||
this.upload.isUploading = true;
|
||||
},
|
||||
// 文件上传成功处理
|
||||
handleFileSuccess(response, file, fileList) {
|
||||
if (response.code !== 0) {
|
||||
this.$modal.msgError(response.msg)
|
||||
return;
|
||||
}
|
||||
this.upload.open = false;
|
||||
this.upload.isUploading = false;
|
||||
this.$refs.upload.clearFiles();
|
||||
// 拼接提示语
|
||||
let data = response.data;
|
||||
let text = '创建成功数量:' + data.createUsernames.length;
|
||||
for (const username of data.createUsernames) {
|
||||
text += '<br /> ' + username;
|
||||
}
|
||||
text += '<br />创建失败数量:' + Object.keys(data.failureUsernames).length;
|
||||
for (const username in data.failureUsernames) {
|
||||
text += '<br /> ' + username + ':' + data.failureUsernames[username];
|
||||
}
|
||||
this.$alert(text, "导入结果", { dangerouslyUseHTMLString: true });
|
||||
this.getList();
|
||||
},
|
||||
// 提交上传文件
|
||||
submitFileForm() {
|
||||
this.$refs.upload.submit();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue