parent
df77236902
commit
4e7007cc04
35 changed files with 2653 additions and 68 deletions
@ -0,0 +1,336 @@ |
||||
package org.jeecg.modules.demo.expproject.controller; |
||||
|
||||
import java.io.UnsupportedEncodingException; |
||||
import java.io.IOException; |
||||
import java.net.URLDecoder; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
import org.aspectj.apache.bcel.classfile.Module; |
||||
import org.jeecg.modules.demo.expert.entity.Expert; |
||||
import org.jeecg.modules.demo.expert.service.IExpertService; |
||||
import org.jeecg.modules.system.entity.SysUser; |
||||
import org.jeecg.modules.system.service.ISysUserService; |
||||
import org.jeecgframework.poi.excel.ExcelImportUtil; |
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
||||
import org.jeecgframework.poi.excel.entity.ExportParams; |
||||
import org.jeecgframework.poi.excel.entity.ImportParams; |
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
||||
import org.jeecg.common.system.vo.LoginUser; |
||||
import org.apache.shiro.SecurityUtils; |
||||
import org.jeecg.common.api.vo.Result; |
||||
import org.jeecg.common.system.query.QueryGenerator; |
||||
import org.jeecg.common.system.query.QueryRuleEnum; |
||||
import org.jeecg.common.util.oConvertUtils; |
||||
import org.jeecg.modules.demo.expproject.entity.Expandpro; |
||||
import org.jeecg.modules.demo.expproject.entity.Expproject; |
||||
import org.jeecg.modules.demo.expproject.vo.ExpprojectPage; |
||||
import org.jeecg.modules.demo.expproject.service.IExpprojectService; |
||||
import org.jeecg.modules.demo.expproject.service.IExpandproService; |
||||
import org.springframework.beans.BeanUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.servlet.ModelAndView; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
import org.springframework.web.multipart.MultipartHttpServletRequest; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import com.alibaba.fastjson.JSON; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.jeecg.common.aspect.annotation.AutoLog; |
||||
|
||||
|
||||
/** |
||||
* @Description: 专家项目表 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2024-10-23 |
||||
* @Version: V1.0 |
||||
*/ |
||||
@Api(tags="专家项目表") |
||||
@RestController |
||||
@RequestMapping("/expproject/expproject") |
||||
@Slf4j |
||||
public class ExpprojectController { |
||||
@Autowired |
||||
private IExpprojectService expprojectService; |
||||
@Autowired |
||||
private IExpandproService expandproService; |
||||
@Autowired |
||||
private IExpertService expertService; |
||||
@Autowired |
||||
private ISysUserService sysUserService; |
||||
|
||||
/** |
||||
* 分页列表查询 |
||||
* |
||||
* @param expproject |
||||
* @param pageNo |
||||
* @param pageSize |
||||
* @param req |
||||
* @return |
||||
*/ |
||||
//@AutoLog(value = "专家项目表-分页列表查询")
|
||||
@ApiOperation(value="专家项目表-分页列表查询", notes="专家项目表-分页列表查询") |
||||
@GetMapping(value = "/list") |
||||
public Result<IPage<Expproject>> queryPageList(Expproject expproject, |
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
||||
HttpServletRequest req) { |
||||
QueryWrapper<Expproject> queryWrapper = QueryGenerator.initQueryWrapper(expproject, req.getParameterMap()); |
||||
Page<Expproject> page = new Page<Expproject>(pageNo, pageSize); |
||||
IPage<Expproject> pageList = expprojectService.page(page, queryWrapper); |
||||
return Result.OK(pageList); |
||||
} |
||||
|
||||
/** |
||||
* 添加 |
||||
* |
||||
* @param expprojectPage |
||||
* @return |
||||
*/ |
||||
@AutoLog(value = "专家项目表-添加") |
||||
@ApiOperation(value="专家项目表-添加", notes="专家项目表-添加") |
||||
@PostMapping(value = "/add") |
||||
public Result<String> add(@RequestBody ExpprojectPage expprojectPage) { |
||||
Expproject expproject = new Expproject(); |
||||
BeanUtils.copyProperties(expprojectPage, expproject); |
||||
if (expproject.getNeedexp()>=expprojectPage.getExpandproList().size()) { |
||||
expprojectService.saveMain(expproject, expprojectPage.getExpandproList()); |
||||
return Result.OK("添加成功!"); |
||||
}else { |
||||
return Result.error("确定项目专家数量"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 编辑 |
||||
* |
||||
* @param expprojectPage |
||||
* @return |
||||
*/ |
||||
@AutoLog(value = "专家项目表-编辑") |
||||
@ApiOperation(value="专家项目表-编辑", notes="专家项目表-编辑") |
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
||||
public Result<String> edit(@RequestBody ExpprojectPage expprojectPage) { |
||||
Expproject expproject = new Expproject(); |
||||
BeanUtils.copyProperties(expprojectPage, expproject); |
||||
Expproject expprojectEntity = expprojectService.getById(expproject.getId()); |
||||
if(expprojectEntity==null) { |
||||
return Result.error("未找到对应数据"); |
||||
} |
||||
if (expproject.getNeedexp()>=expprojectPage.getExpandproList().size()) { |
||||
expprojectService.updateMain(expproject, expprojectPage.getExpandproList()); |
||||
return Result.OK("编辑成功!"); |
||||
}else { |
||||
return Result.error("确定项目专家数量"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 通过id删除 |
||||
* |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
@AutoLog(value = "专家项目表-通过id删除") |
||||
@ApiOperation(value="专家项目表-通过id删除", notes="专家项目表-通过id删除") |
||||
@DeleteMapping(value = "/delete") |
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
||||
expprojectService.delMain(id); |
||||
return Result.OK("删除成功!"); |
||||
} |
||||
|
||||
/** |
||||
* 批量删除 |
||||
* |
||||
* @param ids |
||||
* @return |
||||
*/ |
||||
@AutoLog(value = "专家项目表-批量删除") |
||||
@ApiOperation(value="专家项目表-批量删除", notes="专家项目表-批量删除") |
||||
@DeleteMapping(value = "/deleteBatch") |
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
||||
this.expprojectService.delBatchMain(Arrays.asList(ids.split(","))); |
||||
return Result.OK("批量删除成功!"); |
||||
} |
||||
|
||||
/** |
||||
* 通过id查询 |
||||
* |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
//@AutoLog(value = "专家项目表-通过id查询")
|
||||
@ApiOperation(value="专家项目表-通过id查询", notes="专家项目表-通过id查询") |
||||
@GetMapping(value = "/queryById") |
||||
public Result<Expproject> queryById(@RequestParam(name="id",required=true) String id) { |
||||
Expproject expproject = expprojectService.getById(id); |
||||
if(expproject==null) { |
||||
return Result.error("未找到对应数据"); |
||||
} |
||||
return Result.OK(expproject); |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* 随机生成专家 |
||||
* |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
//@AutoLog(value = "专家项目表-随机生成专家")
|
||||
@ApiOperation(value="专家项目表-随机生成专家", notes="专家项目表-随机生成专家") |
||||
@GetMapping(value = "/createexpawait") |
||||
public Result<String> createexpawait(@RequestParam(name="id",required=true) String id) { |
||||
String str = ""; |
||||
Expproject expproject = expprojectService.getById(id); |
||||
int intce = expproject.getNeedexp(); |
||||
List<Expandpro> expandproList = expandproService.query().eq("expprojectid",id).list(); |
||||
if (expandproList.size()==intce ){ |
||||
str="此项目专家已经足够"; |
||||
} else if (expandproList.size()<intce){ |
||||
int a = intce-expandproList.size(); |
||||
List<String> usernamelist = expandproService.getusernamelist(); |
||||
Collections.shuffle(usernamelist); |
||||
List<String> randomUsers = getRandomUsers(usernamelist, a); |
||||
Expandpro expandpro =new Expandpro(); |
||||
List<Expert> expertList = expertService.query().in("seusername",randomUsers).list(); |
||||
for (int i=0;i<expertList.size();i++){ |
||||
expandpro.setExpid(expertList.get(i).getSeusername()); |
||||
expandpro.setExpprojectid(id); |
||||
expandpro.setSsdep(expandproService.getdepid(expertList.get(i).getSeusername())); |
||||
expandpro.setExptype(expertList.get(i).getDirectioncal()); |
||||
expandpro.setPhone(expertList.get(i).getPhone()); |
||||
expandpro.setEmil(expertList.get(i).getEmails()); |
||||
expandproService.save(expandpro); |
||||
} |
||||
str="生成完成"; |
||||
} |
||||
|
||||
return Result.OK(str); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 通过id查询 |
||||
* |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
//@AutoLog(value = "评审专家通过主表ID查询")
|
||||
@ApiOperation(value="评审专家主表ID查询", notes="评审专家-通主表ID查询") |
||||
@GetMapping(value = "/queryExpandproByMainId") |
||||
public Result<List<Expandpro>> queryExpandproListByMainId(@RequestParam(name="id",required=true) String id) { |
||||
List<Expandpro> expandproList = expandproService.selectByMainId(id); |
||||
return Result.OK(expandproList); |
||||
} |
||||
|
||||
/** |
||||
* 导出excel |
||||
* |
||||
* @param request |
||||
* @param expproject |
||||
*/ |
||||
|
||||
@RequestMapping(value = "/exportXls") |
||||
public ModelAndView exportXls(HttpServletRequest request, Expproject expproject) { |
||||
// Step.1 组装查询条件查询数据
|
||||
QueryWrapper<Expproject> queryWrapper = QueryGenerator.initQueryWrapper(expproject, request.getParameterMap()); |
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
||||
|
||||
//配置选中数据查询条件
|
||||
String selections = request.getParameter("selections"); |
||||
if(oConvertUtils.isNotEmpty(selections)) { |
||||
List<String> selectionList = Arrays.asList(selections.split(",")); |
||||
queryWrapper.in("id",selectionList); |
||||
} |
||||
//Step.2 获取导出数据
|
||||
List<Expproject> expprojectList = expprojectService.list(queryWrapper); |
||||
|
||||
// Step.3 组装pageList
|
||||
List<ExpprojectPage> pageList = new ArrayList<ExpprojectPage>(); |
||||
for (Expproject main : expprojectList) { |
||||
ExpprojectPage vo = new ExpprojectPage(); |
||||
BeanUtils.copyProperties(main, vo); |
||||
List<Expandpro> expandproList = expandproService.selectByMainId(main.getId()); |
||||
vo.setExpandproList(expandproList); |
||||
pageList.add(vo); |
||||
} |
||||
|
||||
// Step.4 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "专家项目表列表"); |
||||
mv.addObject(NormalExcelConstants.CLASS, ExpprojectPage.class); |
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("专家项目表数据", "导出人:"+sysUser.getRealname(), "专家项目表")); |
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList); |
||||
return mv; |
||||
} |
||||
|
||||
/** |
||||
* 通过excel导入数据 |
||||
* |
||||
* @param request |
||||
* @param response |
||||
* @return |
||||
*/ |
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); |
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
||||
// 获取上传文件对象
|
||||
MultipartFile file = entity.getValue(); |
||||
ImportParams params = new ImportParams(); |
||||
params.setTitleRows(2); |
||||
params.setHeadRows(1); |
||||
params.setNeedSave(true); |
||||
try { |
||||
List<ExpprojectPage> list = ExcelImportUtil.importExcel(file.getInputStream(), ExpprojectPage.class, params); |
||||
for (ExpprojectPage page : list) { |
||||
Expproject po = new Expproject(); |
||||
BeanUtils.copyProperties(page, po); |
||||
expprojectService.saveMain(po, page.getExpandproList()); |
||||
} |
||||
return Result.OK("文件导入成功!数据行数:" + list.size()); |
||||
} catch (Exception e) { |
||||
log.error(e.getMessage(),e); |
||||
return Result.error("文件导入失败:"+e.getMessage()); |
||||
} finally { |
||||
try { |
||||
file.getInputStream().close(); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
return Result.OK("文件导入失败!"); |
||||
} |
||||
|
||||
|
||||
|
||||
public static List<String> getRandomUsers(List<String> userlist, int numberOfUsers) { |
||||
List<String> result = new ArrayList<>(); |
||||
Random random = new Random(); |
||||
int listSize = userlist.size(); |
||||
|
||||
// 如果想要选择的用户数量超过了列表中的用户数量,就循环选择直到达到所需数量
|
||||
// 注意:这将允许结果中有重复的用户
|
||||
for (int i = 0; i < numberOfUsers; i++) { |
||||
int index = random.nextInt(listSize); // 生成一个0到listSize-1之间的随机索引
|
||||
result.add(userlist.get(index)); // 将随机选择的用户添加到结果列表中
|
||||
} |
||||
|
||||
// 如果需要,可以对结果列表进行打乱(虽然在这个特定情况下可能不是必需的)
|
||||
// Collections.shuffle(result);
|
||||
|
||||
return result; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,81 @@ |
||||
package org.jeecg.modules.demo.expproject.entity; |
||||
|
||||
import java.io.Serializable; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
import org.jeecg.common.constant.ProvinceCityArea; |
||||
import org.jeecg.common.util.SpringContextUtils; |
||||
import lombok.Data; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import org.jeecgframework.poi.excel.annotation.Excel; |
||||
import java.util.Date; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import java.io.UnsupportedEncodingException; |
||||
|
||||
/** |
||||
* @Description: 评审专家 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2024-10-23 |
||||
* @Version: V1.0 |
||||
*/ |
||||
@ApiModel(value="expandpro对象", description="评审专家") |
||||
@Data |
||||
@TableName("expandpro") |
||||
public class Expandpro implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/**主键*/ |
||||
@TableId(type = IdType.ASSIGN_ID) |
||||
@ApiModelProperty(value = "主键") |
||||
private String id; |
||||
/**创建人*/ |
||||
@ApiModelProperty(value = "创建人") |
||||
private String createBy; |
||||
/**创建日期*/ |
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
||||
@ApiModelProperty(value = "创建日期") |
||||
private Date createTime; |
||||
/**更新人*/ |
||||
@ApiModelProperty(value = "更新人") |
||||
private String updateBy; |
||||
/**更新日期*/ |
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
||||
@ApiModelProperty(value = "更新日期") |
||||
private Date updateTime; |
||||
/**所属部门*/ |
||||
@ApiModelProperty(value = "所属部门") |
||||
private String sysOrgCode; |
||||
/**专家id*/ |
||||
@Excel(name = "专家id", width = 15) |
||||
@ApiModelProperty(value = "专家id") |
||||
private String expid; |
||||
/**外键id*/ |
||||
@ApiModelProperty(value = "外键id") |
||||
private String expprojectid; |
||||
/**专家名称*/ |
||||
@Excel(name = "专家名称", width = 15) |
||||
@ApiModelProperty(value = "专家名称") |
||||
private String expname; |
||||
/**所属领域*/ |
||||
@Excel(name = "所属领域", width = 15) |
||||
@ApiModelProperty(value = "所属领域") |
||||
private String exptype; |
||||
/**所属单位*/ |
||||
@Excel(name = "所属单位", width = 15, dictTable = "sys_depart", dicText = "depart_name", dicCode = "id") |
||||
@ApiModelProperty(value = "所属单位") |
||||
private String ssdep; |
||||
/**专家电话*/ |
||||
@Excel(name = "专家电话", width = 15) |
||||
@ApiModelProperty(value = "专家电话") |
||||
private String phone; |
||||
/**专家邮箱*/ |
||||
@Excel(name = "专家邮箱", width = 15) |
||||
@ApiModelProperty(value = "专家邮箱") |
||||
private String emil; |
||||
} |
@ -0,0 +1,76 @@ |
||||
package org.jeecg.modules.demo.expproject.entity; |
||||
|
||||
import java.io.Serializable; |
||||
import java.io.UnsupportedEncodingException; |
||||
import java.util.Date; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
import org.jeecg.common.constant.ProvinceCityArea; |
||||
import org.jeecg.common.util.SpringContextUtils; |
||||
import lombok.Data; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import org.jeecgframework.poi.excel.annotation.Excel; |
||||
import org.jeecg.common.aspect.annotation.Dict; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
|
||||
/** |
||||
* @Description: 专家项目表 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2024-10-23 |
||||
* @Version: V1.0 |
||||
*/ |
||||
@ApiModel(value="expproject对象", description="专家项目表") |
||||
@Data |
||||
@TableName("expproject") |
||||
public class Expproject implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/**主键*/ |
||||
@TableId(type = IdType.ASSIGN_ID) |
||||
@ApiModelProperty(value = "主键") |
||||
private String id; |
||||
/**创建人*/ |
||||
@ApiModelProperty(value = "创建人") |
||||
private String createBy; |
||||
/**创建日期*/ |
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
||||
@ApiModelProperty(value = "创建日期") |
||||
private Date createTime; |
||||
/**更新人*/ |
||||
@ApiModelProperty(value = "更新人") |
||||
private String updateBy; |
||||
/**更新日期*/ |
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
||||
@ApiModelProperty(value = "更新日期") |
||||
private Date updateTime; |
||||
/**所属部门*/ |
||||
@ApiModelProperty(value = "所属部门") |
||||
private String sysOrgCode; |
||||
/**项目名称*/ |
||||
@Excel(name = "项目名称", width = 15) |
||||
@ApiModelProperty(value = "项目名称") |
||||
private String proname; |
||||
/**专家类型*/ |
||||
@Excel(name = "专家类型", width = 15, dictTable = "discipline_fieid", dicText = "name", dicCode = "id") |
||||
@Dict(dictTable = "discipline_fieid", dicText = "name", dicCode = "id") |
||||
@ApiModelProperty(value = "专家类型") |
||||
private String exptype; |
||||
/**需要专家个数*/ |
||||
@Excel(name = "需要专家个数", width = 15) |
||||
@ApiModelProperty(value = "需要专家个数") |
||||
private Integer needexp; |
||||
/**简介*/ |
||||
@Excel(name = "简介", width = 15) |
||||
@ApiModelProperty(value = "简介") |
||||
private String proinfo; |
||||
/**附件*/ |
||||
@Excel(name = "附件", width = 15) |
||||
@ApiModelProperty(value = "附件") |
||||
private String profile; |
||||
} |
@ -0,0 +1,39 @@ |
||||
package org.jeecg.modules.demo.expproject.mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.apache.ibatis.annotations.Select; |
||||
import org.jeecg.modules.demo.expproject.entity.Expandpro; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
/** |
||||
* @Description: 评审专家 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2024-10-23 |
||||
* @Version: V1.0 |
||||
*/ |
||||
public interface ExpandproMapper extends BaseMapper<Expandpro> { |
||||
|
||||
/** |
||||
* 通过主表id删除子表数据 |
||||
* |
||||
* @param mainId 主表id |
||||
* @return boolean |
||||
*/ |
||||
public boolean deleteByMainId(@Param("mainId") String mainId); |
||||
|
||||
/** |
||||
* 通过主表id查询子表数据 |
||||
* |
||||
* @param mainId 主表id |
||||
* @return List<Expandpro> |
||||
*/ |
||||
public List<Expandpro> selectByMainId(@Param("mainId") String mainId); |
||||
|
||||
@Select("select seusername from expert WHERE expsture='N' AND isdone='Y' AND adminopen='2' AND compopen='2'") |
||||
List<String> getusernamelist(); |
||||
|
||||
@Select("SELECT dep_id FROM expert AS expe LEFT JOIN sys_user AS sysu ON sysu.username = expe.seusername LEFT JOIN sys_user_depart AS sysud ON sysu.id =sysud.user_id WHERE expe.seusername =#{seusername} ") |
||||
String getdepid(String seusername); |
||||
} |
@ -0,0 +1,17 @@ |
||||
package org.jeecg.modules.demo.expproject.mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.jeecg.modules.demo.expproject.entity.Expproject; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
/** |
||||
* @Description: 专家项目表 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2024-10-23 |
||||
* @Version: V1.0 |
||||
*/ |
||||
public interface ExpprojectMapper extends BaseMapper<Expproject> { |
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
<?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="org.jeecg.modules.demo.expproject.mapper.ExpandproMapper"> |
||||
|
||||
<delete id="deleteByMainId" parameterType="java.lang.String"> |
||||
DELETE |
||||
FROM expandpro |
||||
WHERE |
||||
expprojectid = #{mainId} </delete> |
||||
|
||||
<select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.demo.expproject.entity.Expandpro"> |
||||
SELECT * |
||||
FROM expandpro |
||||
WHERE |
||||
expprojectid = #{mainId} </select> |
||||
</mapper> |
@ -0,0 +1,5 @@ |
||||
<?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="org.jeecg.modules.demo.expproject.mapper.ExpprojectMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,26 @@ |
||||
package org.jeecg.modules.demo.expproject.service; |
||||
|
||||
import org.jeecg.modules.demo.expproject.entity.Expandpro; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Description: 评审专家 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2024-10-23 |
||||
* @Version: V1.0 |
||||
*/ |
||||
public interface IExpandproService extends IService<Expandpro> { |
||||
|
||||
/** |
||||
* 通过主表id查询子表数据 |
||||
* |
||||
* @param mainId 主表id |
||||
* @return List<Expandpro> |
||||
*/ |
||||
public List<Expandpro> selectByMainId(String mainId); |
||||
|
||||
List<String> getusernamelist(); |
||||
|
||||
String getdepid(String seusername); |
||||
} |
@ -0,0 +1,48 @@ |
||||
package org.jeecg.modules.demo.expproject.service; |
||||
|
||||
import org.jeecg.modules.demo.expproject.entity.Expandpro; |
||||
import org.jeecg.modules.demo.expproject.entity.Expproject; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import java.io.Serializable; |
||||
import java.util.Collection; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Description: 专家项目表 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2024-10-23 |
||||
* @Version: V1.0 |
||||
*/ |
||||
public interface IExpprojectService extends IService<Expproject> { |
||||
|
||||
/** |
||||
* 添加一对多 |
||||
* |
||||
* @param expproject |
||||
* @param expandproList |
||||
*/ |
||||
public void saveMain(Expproject expproject,List<Expandpro> expandproList) ; |
||||
|
||||
/** |
||||
* 修改一对多 |
||||
* |
||||
* @param expproject |
||||
* @param expandproList |
||||
*/ |
||||
public void updateMain(Expproject expproject,List<Expandpro> expandproList); |
||||
|
||||
/** |
||||
* 删除一对多 |
||||
* |
||||
* @param id |
||||
*/ |
||||
public void delMain (String id); |
||||
|
||||
/** |
||||
* 批量删除一对多 |
||||
* |
||||
* @param idList |
||||
*/ |
||||
public void delBatchMain (Collection<? extends Serializable> idList); |
||||
|
||||
} |
@ -0,0 +1,37 @@ |
||||
package org.jeecg.modules.demo.expproject.service.impl; |
||||
|
||||
import org.jeecg.modules.demo.expproject.entity.Expandpro; |
||||
import org.jeecg.modules.demo.expproject.mapper.ExpandproMapper; |
||||
import org.jeecg.modules.demo.expproject.service.IExpandproService; |
||||
import org.springframework.stereotype.Service; |
||||
import java.util.List; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
||||
/** |
||||
* @Description: 评审专家 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2024-10-23 |
||||
* @Version: V1.0 |
||||
*/ |
||||
@Service |
||||
public class ExpandproServiceImpl extends ServiceImpl<ExpandproMapper, Expandpro> implements IExpandproService { |
||||
|
||||
@Autowired |
||||
private ExpandproMapper expandproMapper; |
||||
|
||||
@Override |
||||
public List<Expandpro> selectByMainId(String mainId) { |
||||
return expandproMapper.selectByMainId(mainId); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getusernamelist() { |
||||
return expandproMapper.getusernamelist(); |
||||
} |
||||
|
||||
@Override |
||||
public String getdepid(String seusername) { |
||||
return expandproMapper.getdepid(seusername); |
||||
} |
||||
} |
@ -0,0 +1,77 @@ |
||||
package org.jeecg.modules.demo.expproject.service.impl; |
||||
|
||||
import org.jeecg.modules.demo.expproject.entity.Expproject; |
||||
import org.jeecg.modules.demo.expproject.entity.Expandpro; |
||||
import org.jeecg.modules.demo.expproject.mapper.ExpandproMapper; |
||||
import org.jeecg.modules.demo.expproject.mapper.ExpprojectMapper; |
||||
import org.jeecg.modules.demo.expproject.service.IExpprojectService; |
||||
import org.springframework.stereotype.Service; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
import java.util.Collection; |
||||
|
||||
/** |
||||
* @Description: 专家项目表 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2024-10-23 |
||||
* @Version: V1.0 |
||||
*/ |
||||
@Service |
||||
public class ExpprojectServiceImpl extends ServiceImpl<ExpprojectMapper, Expproject> implements IExpprojectService { |
||||
|
||||
@Autowired |
||||
private ExpprojectMapper expprojectMapper; |
||||
@Autowired |
||||
private ExpandproMapper expandproMapper; |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void saveMain(Expproject expproject, List<Expandpro> expandproList) { |
||||
expprojectMapper.insert(expproject); |
||||
if(expandproList!=null && expandproList.size()>0) { |
||||
for(Expandpro entity:expandproList) { |
||||
//外键设置
|
||||
entity.setExpprojectid(expproject.getId()); |
||||
expandproMapper.insert(entity); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void updateMain(Expproject expproject,List<Expandpro> expandproList) { |
||||
expprojectMapper.updateById(expproject); |
||||
|
||||
//1.先删除子表数据
|
||||
expandproMapper.deleteByMainId(expproject.getId()); |
||||
|
||||
//2.子表数据重新插入
|
||||
if(expandproList!=null && expandproList.size()>0) { |
||||
for(Expandpro entity:expandproList) { |
||||
//外键设置
|
||||
entity.setExpprojectid(expproject.getId()); |
||||
expandproMapper.insert(entity); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void delMain(String id) { |
||||
expandproMapper.deleteByMainId(id); |
||||
expprojectMapper.deleteById(id); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public void delBatchMain(Collection<? extends Serializable> idList) { |
||||
for(Serializable id:idList) { |
||||
expandproMapper.deleteByMainId(id.toString()); |
||||
expprojectMapper.deleteById(id); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,77 @@ |
||||
package org.jeecg.modules.demo.expproject.vo; |
||||
|
||||
import java.util.List; |
||||
import org.jeecg.modules.demo.expproject.entity.Expproject; |
||||
import org.jeecg.modules.demo.expproject.entity.Expandpro; |
||||
import lombok.Data; |
||||
import org.jeecgframework.poi.excel.annotation.Excel; |
||||
import org.jeecgframework.poi.excel.annotation.ExcelEntity; |
||||
import org.jeecgframework.poi.excel.annotation.ExcelCollection; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import java.util.Date; |
||||
import org.jeecg.common.aspect.annotation.Dict; |
||||
import org.jeecg.common.constant.ProvinceCityArea; |
||||
import org.jeecg.common.util.SpringContextUtils; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
|
||||
/** |
||||
* @Description: 专家项目表 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2024-10-23 |
||||
* @Version: V1.0 |
||||
*/ |
||||
@Data |
||||
@ApiModel(value="expprojectPage对象", description="专家项目表") |
||||
public class ExpprojectPage { |
||||
|
||||
/**主键*/ |
||||
@ApiModelProperty(value = "主键") |
||||
private String id; |
||||
/**创建人*/ |
||||
@ApiModelProperty(value = "创建人") |
||||
private String createBy; |
||||
/**创建日期*/ |
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
||||
@ApiModelProperty(value = "创建日期") |
||||
private Date createTime; |
||||
/**更新人*/ |
||||
@ApiModelProperty(value = "更新人") |
||||
private String updateBy; |
||||
/**更新日期*/ |
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
||||
@ApiModelProperty(value = "更新日期") |
||||
private Date updateTime; |
||||
/**所属部门*/ |
||||
@ApiModelProperty(value = "所属部门") |
||||
private String sysOrgCode; |
||||
/**项目名称*/ |
||||
@Excel(name = "项目名称", width = 15) |
||||
@ApiModelProperty(value = "项目名称") |
||||
private String proname; |
||||
/**专家类型*/ |
||||
@Excel(name = "专家类型", width = 15, dictTable = "discipline_fieid", dicText = "name", dicCode = "id") |
||||
@Dict(dictTable = "discipline_fieid", dicText = "name", dicCode = "id") |
||||
@ApiModelProperty(value = "专家类型") |
||||
private String exptype; |
||||
/**需要专家个数*/ |
||||
@Excel(name = "需要专家个数", width = 15) |
||||
@ApiModelProperty(value = "需要专家个数") |
||||
private Integer needexp; |
||||
/**简介*/ |
||||
@Excel(name = "简介", width = 15) |
||||
@ApiModelProperty(value = "简介") |
||||
private String proinfo; |
||||
/**附件*/ |
||||
@Excel(name = "附件", width = 15) |
||||
@ApiModelProperty(value = "附件") |
||||
private String profile; |
||||
|
||||
@ExcelCollection(name="评审专家") |
||||
@ApiModelProperty(value = "评审专家") |
||||
private List<Expandpro> expandproList; |
||||
|
||||
} |
@ -0,0 +1,87 @@ |
||||
import {defHttp} from '/@/utils/http/axios'; |
||||
import { useMessage } from "/@/hooks/web/useMessage"; |
||||
|
||||
const { createConfirm } = useMessage(); |
||||
|
||||
enum Api { |
||||
list = '/expproject/expproject/list', |
||||
save='/expproject/expproject/add', |
||||
edit='/expproject/expproject/edit', |
||||
deleteOne = '/expproject/expproject/delete', |
||||
deleteBatch = '/expproject/expproject/deleteBatch', |
||||
importExcel = '/expproject/expproject/importExcel', |
||||
exportXls = '/expproject/expproject/exportXls', |
||||
queryDataById = '/expproject/expproject/queryById', |
||||
expandproList = '/expproject/expproject/queryExpandproByMainId', |
||||
createexpawaitup= '/expproject/expproject/createexpawait', |
||||
} |
||||
/** |
||||
* 导出api |
||||
* @param params |
||||
*/ |
||||
export const getExportUrl = Api.exportXls; |
||||
|
||||
/** |
||||
* 导入api |
||||
*/ |
||||
export const getImportUrl = Api.importExcel; |
||||
|
||||
/** |
||||
* 查询子表数据 |
||||
* @param params |
||||
*/ |
||||
export const queryExpandproListByMainId = (id) => defHttp.get({url: Api.expandproList, params:{ id }}); |
||||
|
||||
/** |
||||
* 列表接口 |
||||
* @param params |
||||
*/ |
||||
export const list = (params) => |
||||
defHttp.get({url: Api.list, params}); |
||||
|
||||
/** |
||||
* 随机生成专家接口 |
||||
* @param params |
||||
*/ |
||||
export const createexpawait = (params) => defHttp.get({url: Api.createexpawaitup, params}); |
||||
|
||||
/** |
||||
* 删除单个 |
||||
*/ |
||||
export const deleteOne = (params,handleSuccess) => { |
||||
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { |
||||
handleSuccess(); |
||||
}); |
||||
} |
||||
/** |
||||
* 批量删除 |
||||
* @param params |
||||
*/ |
||||
export const batchDelete = (params, handleSuccess) => { |
||||
createConfirm({ |
||||
iconType: 'warning', |
||||
title: '确认删除', |
||||
content: '是否删除选中数据', |
||||
okText: '确认', |
||||
cancelText: '取消', |
||||
onOk: () => { |
||||
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { |
||||
handleSuccess(); |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
/** |
||||
* 保存或者更新 |
||||
* @param params |
||||
*/ |
||||
export const saveOrUpdate = (params, isUpdate) => { |
||||
let url = isUpdate ? Api.edit : Api.save; |
||||
return defHttp.post({url: url, params}); |
||||
} |
||||
|
||||
/** |
||||
* 根据id查询数据 |
||||
* @param params |
||||
*/ |
||||
export const queryDataById = (id) => defHttp.get({url: Api.queryDataById, params:{ id }}); |
@ -0,0 +1,105 @@ |
||||
import {BasicColumn} from '/@/components/Table'; |
||||
import {FormSchema} from '/@/components/Table'; |
||||
import { rules} from '/@/utils/helper/validator'; |
||||
import { render } from '/@/utils/common/renderUtils'; |
||||
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types' |
||||
import { getWeekMonthQuarterYear } from '/@/utils'; |
||||
//列表数据 |
||||
export const columns: BasicColumn[] = [ |
||||
{ |
||||
title: '专家类型', |
||||
align:"center", |
||||
dataIndex: 'exptype_dictText' |
||||
}, |
||||
{ |
||||
title: '需要专家个数', |
||||
align:"center", |
||||
dataIndex: 'needexp' |
||||
}, |
||||
{ |
||||
title: '简介', |
||||
align:"center", |
||||
dataIndex: 'proinfo' |
||||
}, |
||||
{ |
||||
title: '附件', |
||||
align:"center", |
||||
dataIndex: 'profile', |
||||
}, |
||||
]; |
||||
|
||||
//子表表格配置 |
||||
export const expandproColumns: JVxeColumn[] = [ |
||||
{ |
||||
title: '专家名称', |
||||
key: 'expname', |
||||
type: JVxeTypes.popup, |
||||
popupCode:"findexp", |
||||
fieldConfig: [ |
||||
{ source: 'id', target: 'expid' }, |
||||
{ source: 'realname', target: 'expname' }, |
||||
{ source: 'directioncal', target: 'exptype' }, |
||||
{ source: 'depid', target: 'ssdep' }, |
||||
{ source: 'phone', target: 'phone' }, |
||||
{ source: 'email', target: 'emil' }, |
||||
], |
||||
|
||||
width:"200px", |
||||
placeholder: '请输入${title}', |
||||
defaultValue:'', |
||||
}, |
||||
{ |
||||
title: '所属领域', |
||||
key: 'exptype', |
||||
type: JVxeTypes.input, |
||||
disabled:true, |
||||
width:"200px", |
||||
placeholder: '请输入${title}', |
||||
defaultValue:'', |
||||
}, |
||||
{ |
||||
title: '所属单位', |
||||
key: 'ssdep', |
||||
type: JVxeTypes.selectSearch, |
||||
dictCode:"sys_depart,depart_name,id", |
||||
width:"200px", |
||||
placeholder: '请输入${title}', |
||||
defaultValue:'', |
||||
}, |
||||
{ |
||||
title: '专家电话', |
||||
key: 'phone', |
||||
type: JVxeTypes.input, |
||||
width:"200px", |
||||
placeholder: '请输入${title}', |
||||
defaultValue:'', |
||||
}, |
||||
{ |
||||
title: '专家邮箱', |
||||
key: 'emil', |
||||
type: JVxeTypes.input, |
||||
width:"200px", |
||||
placeholder: '请输入${title}', |
||||
defaultValue:'', |
||||
}, |
||||
] |
||||
|
||||
// 高级查询数据 |
||||
export const superQuerySchema = { |
||||
exptype: {title: '专家类型',order: 1,view: 'sel_search', type: 'string',dictTable: "discipline_fieid", dictCode: 'id', dictText: 'name',}, |
||||
needexp: {title: '需要专家个数',order: 2,view: 'number', type: 'number',}, |
||||
proinfo: {title: '简介',order: 3,view: 'text', type: 'string',}, |
||||
profile: {title: '附件',order: 4,view: 'file', type: 'string',}, |
||||
//子表高级查询 |
||||
expandpro: { |
||||
title: '评审专家', |
||||
view: 'table', |
||||
fields: { |
||||
expname: {title: '专家名称',order: 1,view: 'popup', type: 'string',code: 'findexp', orgFields: 'realname', destFields: 'expname', popupMulti: false,}, |
||||
exptype: {title: '所属领域',order: 2,view: 'text', type: 'string',}, |
||||
ssdep: {title: '所属单位',order: 3,view: 'sel_search', type: 'string',dictTable: "sys_depart", dictCode: 'id', dictText: 'depart_name',}, |
||||
phone: {title: '专家电话',order: 4,view: 'text', type: 'string',}, |
||||
emil: {title: '专家邮箱',order: 5,view: 'text', type: 'string',}, |
||||
} |
||||
}, |
||||
}; |
@ -0,0 +1,277 @@ |
||||
<template> |
||||
<div class="p-2"> |
||||
<!--查询区域--> |
||||
<div class="jeecg-basic-table-form-container"> |
||||
<a-form ref="formRef" @keyup.enter.native="reload" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol"> |
||||
<a-row :gutter="24"> |
||||
<a-col :lg="6"> |
||||
<a-form-item name="proname"> |
||||
<template #label><span title="项目名称">项目名称</span></template> |
||||
<a-input placeholder="请输入项目名称" v-model:value="queryParam.proname" allow-clear ></a-input> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :lg="6"> |
||||
<a-form-item name="exptype"> |
||||
<template #label><span title="专家类型">专家类型</span></template> |
||||
<j-search-select placeholder="请选择专家类型" v-model:value="queryParam.exptype" dict="discipline_fieid,name,id" allow-clear /> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :xl="6" :lg="7" :md="8" :sm="24"> |
||||
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons"> |
||||
<a-col :lg="6"> |
||||
<a-button type="primary" preIcon="ant-design:search-outlined" @click="reload">查询</a-button> |
||||
<a-button preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button> |
||||
<a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px"> |
||||
{{ toggleSearchStatus ? '收起' : '展开' }} |
||||
<Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" /> |
||||
</a> |
||||
</a-col> |
||||
</span> |
||||
</a-col> |
||||
</a-row> |
||||
</a-form> |
||||
</div> |
||||
<!--引用表格--> |
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection"> |
||||
<!--插槽:table标题--> |
||||
<template #tableTitle> |
||||
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> |
||||
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> |
||||
<j-upload-button type="primary" v-auth="'expproject:expproject:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> |
||||
<a-dropdown v-if="selectedRowKeys.length > 0"> |
||||
<template #overlay> |
||||
<a-menu> |
||||
<a-menu-item key="1" @click="batchHandleDelete"> |
||||
<Icon icon="ant-design:delete-outlined"></Icon> |
||||
删除 |
||||
</a-menu-item> |
||||
</a-menu> |
||||
</template> |
||||
<a-button >批量操作 |
||||
<Icon icon="mdi:chevron-down"></Icon> |
||||
</a-button> |
||||
</a-dropdown> |
||||
<!-- 高级查询 --> |
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" /> |
||||
</template> |
||||
<!--操作栏--> |
||||
<template #action="{ record }"> |
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/> |
||||
</template> |
||||
<!--字段回显插槽--> |
||||
<template v-slot:bodyCell="{ column, record, index, text }"> |
||||
<template v-if="column.dataIndex==='profile'"> |
||||
<!--文件字段回显插槽--> |
||||
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span> |
||||
<a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button> |
||||
</template> |
||||
</template> |
||||
</BasicTable> |
||||
<!-- 表单区域 --> |
||||
<ExpprojectModal @register="registerModal" @success="handleSuccess"></ExpprojectModal> |
||||
</div> |
||||
</template> |
||||
|
||||
<script lang="ts" name="expproject-expproject" setup> |
||||
import {ref, reactive, computed, unref} from 'vue'; |
||||
import {BasicTable, useTable, TableAction} from '/@/components/Table'; |
||||
import { useListPage } from '/@/hooks/system/useListPage' |
||||
import {useModal} from '/@/components/Modal'; |
||||
import ExpprojectModal from './components/ExpprojectModal.vue' |
||||
import {columns, superQuerySchema} from './Expproject.data'; |
||||
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl,createexpawait} from './Expproject.api'; |
||||
import {downloadFile} from '/@/utils/common/renderUtils'; |
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue'; |
||||
import JSelectMultiple from '/@/components/Form/src/jeecg/components/JSelectMultiple.vue'; |
||||
import JSearchSelect from '/@/components/Form/src/jeecg/components/JSearchSelect.vue'; |
||||
import { useUserStore } from '/@/store/modules/user'; |
||||
const formRef = ref(); |
||||
const queryParam = reactive<any>({}); |
||||
const checkedKeys = ref<Array<string | number>>([]); |
||||
//注册model |
||||
const [registerModal, {openModal}] = useModal(); |
||||
const userStore = useUserStore(); |
||||
//注册table数据 |
||||
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({ |
||||
tableProps:{ |
||||
title: '专家项目表', |
||||
api: list, |
||||
columns, |
||||
canResize:false, |
||||
useSearchForm: false, |
||||
actionColumn: { |
||||
width: 120, |
||||
fixed:'right' |
||||
}, |
||||
beforeFetch: async (params) => { |
||||
return Object.assign(params, queryParam); |
||||
}, |
||||
}, |
||||
exportConfig: { |
||||
name:"专家项目表", |
||||
url: getExportUrl, |
||||
params: queryParam, |
||||
}, |
||||
importConfig: { |
||||
url: getImportUrl, |
||||
success: handleSuccess |
||||
}, |
||||
}) |
||||
|
||||
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext |
||||
|
||||
// 高级查询配置 |
||||
const superQueryConfig = reactive(superQuerySchema); |
||||
|
||||
/** |
||||
* 高级查询事件 |
||||
*/ |
||||
function handleSuperQuery(params) { |
||||
Object.keys(params).map((k) => { |
||||
queryParam[k] = params[k]; |
||||
}); |
||||
reload(); |
||||
} |
||||
|
||||
/** |
||||
* 新增事件 |
||||
*/ |
||||
function handleAdd() { |
||||
openModal(true, { |
||||
isUpdate: false, |
||||
showFooter: true, |
||||
}); |
||||
} |
||||
/** |
||||
* 编辑事件 |
||||
*/ |
||||
function handleEdit(record: Recordable) { |
||||
openModal(true, { |
||||
record, |
||||
isUpdate: true, |
||||
showFooter: true, |
||||
}); |
||||
} |
||||
/** |
||||
* 详情 |
||||
*/ |
||||
function handleDetail(record: Recordable) { |
||||
openModal(true, { |
||||
record, |
||||
isUpdate: true, |
||||
showFooter: false, |
||||
}); |
||||
} |
||||
/** |
||||
* 删除事件 |
||||
*/ |
||||
async function handleDelete(record) { |
||||
await deleteOne({id: record.id}, handleSuccess); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 随机生成专家 |
||||
*/ |
||||
async function createexp(record) { |
||||
await createexpawait({id: record.id}, handleSuccess); |
||||
} |
||||
/** |
||||
* 批量删除事件 |
||||
*/ |
||||
async function batchHandleDelete() { |
||||
await batchDelete({ids: selectedRowKeys.value},handleSuccess); |
||||
} |
||||
/** |
||||
* 成功回调 |
||||
*/ |
||||
function handleSuccess() { |
||||
(selectedRowKeys.value = []) && reload(); |
||||
} |
||||
/** |
||||
* 操作栏 |
||||
*/ |
||||
function getTableAction(record){ |
||||
return [ |
||||
{ |
||||
label: '编辑', |
||||
onClick: handleEdit.bind(null, record), |
||||
} |
||||
] |
||||
} |
||||
/** |
||||
* 下拉操作栏 |
||||
*/ |
||||
function getDropDownAction(record){ |
||||
return [ |
||||
{ |
||||
label: '详情', |
||||
onClick: handleDetail.bind(null, record), |
||||
}, { |
||||
label: '删除', |
||||
popConfirm: { |
||||
title: '是否确认删除', |
||||
confirm: handleDelete.bind(null, record), |
||||
placement: 'topLeft' |
||||
}, |
||||
}, { |
||||
label: '生成专家', |
||||
popConfirm: { |
||||
title: '是否随机生成专家', |
||||
confirm: createexp.bind(null, record), |
||||
placement: 'topLeft' |
||||
}, |
||||
} |
||||
] |
||||
} |
||||
|
||||
|
||||
|
||||
/* ----------------------以下为原生查询需要添加的-------------------------- */ |
||||
const toggleSearchStatus = ref<boolean>(false); |
||||
const labelCol = reactive({ |
||||
xs:24, |
||||
sm:4, |
||||
xl:6, |
||||
xxl:4 |
||||
}); |
||||
const wrapperCol = reactive({ |
||||
xs: 24, |
||||
sm: 20, |
||||
}); |
||||
/** |
||||
* 重置 |
||||
*/ |
||||
function searchReset() { |
||||
formRef.value.resetFields(); |
||||
selectedRowKeys.value = []; |
||||
//刷新数据 |
||||
reload(); |
||||
} |
||||
|
||||
</script> |
||||
<style lang="less" scoped> |
||||
.jeecg-basic-table-form-container { |
||||
padding: 0; |
||||
.table-page-search-submitButtons { |
||||
display: block; |
||||
margin-bottom: 24px; |
||||
white-space: nowrap; |
||||
} |
||||
.query-group-cust{ |
||||
min-width: 100px !important; |
||||
} |
||||
.query-group-split-cust{ |
||||
width: 30px; |
||||
display: inline-block; |
||||
text-align: center |
||||
} |
||||
.ant-form-item:not(.ant-form-item-with-help){ |
||||
margin-bottom: 16px; |
||||
height: 32px; |
||||
} |
||||
:deep(.ant-picker),:deep(.ant-input-number){ |
||||
width: 100%; |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,26 @@ |
||||
-- 注意:该页面对应的前台目录为views/expproject文件夹下 |
||||
-- 如果你想更改到其他目录,请修改sql中component字段对应的值 |
||||
|
||||
|
||||
INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external) |
||||
VALUES ('202410230508460320', NULL, '专家项目表', '/expproject/expprojectList', 'expproject/ExpprojectList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2024-10-23 17:08:32', NULL, NULL, 0); |
||||
|
||||
-- 权限控制sql |
||||
-- 新增 |
||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
||||
VALUES ('202410230508460321', '202410230508460320', '添加专家项目表', NULL, NULL, 0, NULL, NULL, 2, 'expproject:expproject:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2024-10-23 17:08:32', NULL, NULL, 0, 0, '1', 0); |
||||
-- 编辑 |
||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
||||
VALUES ('202410230508460322', '202410230508460320', '编辑专家项目表', NULL, NULL, 0, NULL, NULL, 2, 'expproject:expproject:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2024-10-23 17:08:32', NULL, NULL, 0, 0, '1', 0); |
||||
-- 删除 |
||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
||||
VALUES ('202410230508460323', '202410230508460320', '删除专家项目表', NULL, NULL, 0, NULL, NULL, 2, 'expproject:expproject:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2024-10-23 17:08:32', NULL, NULL, 0, 0, '1', 0); |
||||
-- 批量删除 |
||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
||||
VALUES ('202410230508460324', '202410230508460320', '批量删除专家项目表', NULL, NULL, 0, NULL, NULL, 2, 'expproject:expproject:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2024-10-23 17:08:32', NULL, NULL, 0, 0, '1', 0); |
||||
-- 导出excel |
||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
||||
VALUES ('202410230508460325', '202410230508460320', '导出excel_专家项目表', NULL, NULL, 0, NULL, NULL, 2, 'expproject:expproject:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2024-10-23 17:08:32', NULL, NULL, 0, 0, '1', 0); |
||||
-- 导入excel |
||||
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) |
||||
VALUES ('202410230508460326', '202410230508460320', '导入excel_专家项目表', NULL, NULL, 0, NULL, NULL, 2, 'expproject:expproject:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2024-10-23 17:08:32', NULL, NULL, 0, 0, '1', 0); |
@ -0,0 +1,227 @@ |
||||
<template> |
||||
<a-spin :spinning="loading"> |
||||
<JFormContainer :disabled="disabled"> |
||||
<template #detail> |
||||
<a-form v-bind="formItemLayout" name="ExpprojectForm" ref="formRef"> |
||||
<a-row> |
||||
<a-col :span="24"> |
||||
<a-form-item label="项目名称" v-bind="validateInfos.proname" id="ExpprojectForm-proname" name="proname"> |
||||
<a-input v-model:value="formData.proname" placeholder="请输入项目名称" allow-clear ></a-input> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="24"> |
||||
<a-form-item label="专家类型" v-bind="validateInfos.exptype" id="ExpprojectForm-exptype" name="exptype"> |
||||
<j-search-select v-model:value="formData.exptype" dict="discipline_fieid,name,id" allow-clear /> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="24"> |
||||
<a-form-item label="需要专家个数" v-bind="validateInfos.needexp" id="ExpprojectForm-needexp" name="needexp"> |
||||
<a-input-number v-model:value="formData.needexp" placeholder="请输入需要专家个数" style="width: 100%" /> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="24"> |
||||
<a-form-item label="简介" v-bind="validateInfos.proinfo" id="ExpprojectForm-proinfo" name="proinfo"> |
||||
<a-textarea v-model:value="formData.proinfo" :rows="4" placeholder="请输入简介" /> |
||||
</a-form-item> |
||||
</a-col> |
||||
<a-col :span="24"> |
||||
<a-form-item label="附件" v-bind="validateInfos.profile" id="ExpprojectForm-profile" name="profile"> |
||||
<j-upload v-model:value="formData.profile" ></j-upload> |
||||
</a-form-item> |
||||
</a-col> |
||||
</a-row> |
||||
</a-form> |
||||
</template> |
||||
</JFormContainer> |
||||
|
||||
<!-- 子表单区域 --> |
||||
<a-tabs v-model:activeKey="activeKey" animated> |
||||
<a-tab-pane tab="评审专家" key="expandpro" :forceRender="true"> |
||||
<j-vxe-table |
||||
:keep-source="true" |
||||
resizable |
||||
ref="expandproTableRef" |
||||
:loading="expandproTable.loading" |
||||
:columns="expandproTable.columns" |
||||
:dataSource="expandproTable.dataSource" |
||||
:height="340" |
||||
:disabled="disabled" |
||||
:rowNumber="true" |
||||
:rowSelection="true" |
||||
:toolbar="true"/> |
||||
</a-tab-pane> |
||||
</a-tabs> |
||||
</a-spin> |
||||
</template> |
||||
|
||||
<script lang="ts"> |
||||
import { defineComponent, ref, reactive, computed, toRaw, onMounted } from 'vue'; |
||||
import { defHttp } from '/@/utils/http/axios'; |
||||
import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods'; |
||||
import { queryExpandproListByMainId, queryDataById, saveOrUpdate } from '../Expproject.api'; |
||||
import { JVxeTable } from '/@/components/jeecg/JVxeTable'; |
||||
import {expandproColumns} from '../Expproject.data'; |
||||
import JSearchSelect from '/@/components/Form/src/jeecg/components/JSearchSelect.vue'; |
||||
import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue'; |
||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue'; |
||||
import { Form } from 'ant-design-vue'; |
||||
const useForm = Form.useForm; |
||||
|
||||
export default defineComponent({ |
||||
name: "ExpprojectForm", |
||||
components:{ |
||||
JSearchSelect, |
||||
JUpload, |
||||
JVxeTable, |
||||
JFormContainer, |
||||
}, |
||||
props:{ |
||||
formDisabled:{ |
||||
type: Boolean, |
||||
default: false |
||||
}, |
||||
formData: { type: Object, default: ()=>{} }, |
||||
formBpm: { type: Boolean, default: true } |
||||
}, |
||||
emits:['success'], |
||||
setup(props, {emit}) { |
||||
const loading = ref(false); |
||||
const formRef = ref(); |
||||
const expandproTableRef = ref(); |
||||
const expandproTable = reactive<Record<string, any>>({ |
||||
loading: false, |
||||
columns: expandproColumns, |
||||
dataSource: [] |
||||
}); |
||||
const activeKey = ref('expandpro'); |
||||
const formData = reactive<Record<string, any>>({ |
||||
id: '', |
||||
proname: '', |
||||
exptype: '', |
||||
needexp: 0, |
||||
proinfo: '', |
||||
profile: '', |
||||
}); |
||||
|
||||
//表单验证 |
||||
const validatorRules = reactive({ |
||||
needexp: [{ required: false}, { pattern: /^-?\d+$/, message: '请输入整数!'},], |
||||
}); |
||||
const {resetFields, validate, validateInfos} = useForm(formData, validatorRules, {immediate: false}); |
||||
const dbData = {}; |
||||
const formItemLayout = { |
||||
labelCol: {xs: {span: 24}, sm: {span: 5}}, |
||||
wrapperCol: {xs: {span: 24}, sm: {span: 16}}, |
||||
}; |
||||
|
||||
// 表单禁用 |
||||
const disabled = computed(()=>{ |
||||
if(props.formBpm === true){ |
||||
if(props.formData.disabled === false){ |
||||
return false; |
||||
}else{ |
||||
return true; |
||||
} |
||||
} |
||||
return props.formDisabled; |
||||
}); |
||||
|
||||
|
||||
|
||||
function add() { |
||||
resetFields(); |
||||
expandproTable.dataSource = []; |
||||
} |
||||
|
||||
async function edit(row) { |
||||
//主表数据 |
||||
await queryMainData(row.id); |
||||
//子表数据 |
||||
const expandproDataList = await queryExpandproListByMainId(row['id']); |
||||
expandproTable.dataSource = [...expandproDataList]; |
||||
} |
||||
|
||||
async function queryMainData(id) { |
||||
const row = await queryDataById(id); |
||||
resetFields(); |
||||
const tmpData = {}; |
||||
Object.keys(formData).forEach((key) => { |
||||
if(row.hasOwnProperty(key)){ |
||||
tmpData[key] = row[key] |
||||
} |
||||
}) |
||||
//赋值 |
||||
Object.assign(formData,tmpData); |
||||
} |
||||
|
||||
const {getSubFormAndTableData, transformData} = useValidateAntFormAndTable(activeKey, { |
||||
'expandpro': expandproTableRef, |
||||
}); |
||||
|
||||
async function getFormData() { |
||||
try { |
||||
// 触发表单验证 |
||||
await validate(); |
||||
} catch ({ errorFields }) { |
||||
if (errorFields) { |
||||
const firstField = errorFields[0]; |
||||
if (firstField) { |
||||
formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' }); |
||||
} |
||||
} |
||||
return Promise.reject(errorFields); |
||||
} |
||||
return transformData(toRaw(formData)) |
||||
} |
||||
|
||||
async function submitForm() { |
||||
const mainData = await getFormData(); |
||||
const subData = await getSubFormAndTableData(); |
||||
const values = Object.assign({}, dbData, mainData, subData); |
||||
console.log('表单提交数据', values) |
||||
const isUpdate = values.id ? true : false |
||||
await saveOrUpdate(values, isUpdate); |
||||
//关闭弹窗 |
||||
emit('success'); |
||||
} |
||||
|
||||
function setFieldsValue(values) { |
||||
if(values){ |
||||
Object.keys(values).map(k=>{ |
||||
formData[k] = values[k]; |
||||
}); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 值改变事件触发-树控件回调 |
||||
* @param key |
||||
* @param value |
||||
*/ |
||||
function handleFormChange(key, value) { |
||||
formData[key] = value; |
||||
} |
||||
|
||||
|
||||
return { |
||||
expandproTableRef, |
||||
expandproTable, |
||||
validatorRules, |
||||
validateInfos, |
||||
activeKey, |
||||
loading, |
||||
formData, |
||||
setFieldsValue, |
||||
handleFormChange, |
||||
formItemLayout, |
||||
disabled, |
||||
getFormData, |
||||
submitForm, |
||||
add, |
||||
edit, |
||||
formRef, |
||||
} |
||||
} |
||||
}); |
||||
</script> |
||||
<style lang="less" scoped></style> |
@ -0,0 +1,67 @@ |
||||
<template> |
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" :width="800" @ok="handleSubmit"> |
||||
<expproject-form ref="formComponent" :formDisabled="formDisabled" :formBpm="false" @success="submitSuccess"></expproject-form> |
||||
</BasicModal> |
||||
</template> |
||||
|
||||
<script lang="ts"> |
||||
import { ref, unref } from 'vue'; |
||||
import { BasicModal, useModalInner } from '/@/components/Modal'; |
||||
import ExpprojectForm from './ExpprojectForm.vue'; |
||||
|
||||
export default { |
||||
name: "TestCgMainVxeModal", |
||||
components:{ |
||||
BasicModal, |
||||
ExpprojectForm |
||||
}, |
||||
emits:['register','success'], |
||||
setup(_p, {emit}){ |
||||
const formComponent = ref() |
||||
const isUpdate = ref(true); |
||||
const formDisabled = ref(false); |
||||
const title = ref('') |
||||
|
||||
//表单赋值 |
||||
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
||||
setModalProps({confirmLoading: false,showCancelBtn:data?.showFooter,showOkBtn:data?.showFooter}); |
||||
isUpdate.value = !!data?.isUpdate; |
||||
formDisabled.value = !data?.showFooter; |
||||
title.value = data?.isUpdate ? (unref(formDisabled) ? '详情' : '编辑') : '新增'; |
||||
if (unref(isUpdate)) { |
||||
formComponent.value.edit(data.record) |
||||
}else{ |
||||
formComponent.value.add() |
||||
} |
||||
}); |
||||
|
||||
function handleSubmit() { |
||||
formComponent.value.submitForm(); |
||||
} |
||||
|
||||
function submitSuccess(){ |
||||
emit('success'); |
||||
closeModal(); |
||||
} |
||||
|
||||
return { |
||||
registerModal, |
||||
title, |
||||
formComponent, |
||||
formDisabled, |
||||
handleSubmit, |
||||
submitSuccess |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
<style lang="less" scoped> |
||||
/** 时间和数字输入框样式 */ |
||||
:deep(.ant-input-number) { |
||||
width: 100%; |
||||
} |
||||
|
||||
:deep(.ant-calendar-picker) { |
||||
width: 100%; |
||||
} |
||||
</style> |
@ -0,0 +1,353 @@ |
||||
<template> |
||||
<div class="aui-content"> |
||||
<div class="aui-container"> |
||||
<div class="aui-form"> |
||||
<div class="aui-image"> |
||||
<div class="aui-image-text"> |
||||
<img :src="jeecgAdTextImg" alt="" /> |
||||
</div> |
||||
</div> |
||||
<div class="aui-formBox"> |
||||
<div class="aui-formWell"> |
||||
<a-form ref="formRef" :model="formData"> |
||||
<div class="aui-flex aui-form-nav aui-clear-left" style="padding-bottom: 21px"> |
||||
<div class="aui-flex-box activeNav on">{{t('sys.login.registerButtonexp')}}</div> |
||||
</div> |
||||
<div class="aui-form-box"> |
||||
<div class="aui-account aui-account-line"> |
||||
<a-form-item> |
||||
<div class="aui-input-line"> |
||||
<Icon class="aui-icon" icon="ant-design:user-outlined" /> |
||||
<a-input class="fix-auto-fill" type="text" :placeholder="t('用户名')" v-model:value="formData.seusername" /> |
||||
</div> |
||||
</a-form-item> |
||||
<a-form-item> |
||||
<div class="aui-input-line"> |
||||
<Icon class="aui-icon" icon="ant-design:lock-outlined" /> |
||||
<a-input |
||||
class="fix-auto-fill" |
||||
:type="pwdIndex === 'close' ? 'password' : 'text'" |
||||
:placeholder="t('sys.login.passwordPlaceholder')" |
||||
v-model:value="formData.psd" |
||||
/> |
||||
<div class="aui-eye"> |
||||
<img :src="eyeKImg" alt="开启" v-if="pwdIndex === 'open'" @click="pwdClick('close')" /> |
||||
<img :src="eyeGImg" alt="关闭" v-else-if="pwdIndex === 'close'" @click="pwdClick('open')" /> |
||||
</div> |
||||
</div> |
||||
</a-form-item> |
||||
<a-form-item> |
||||
<div class="aui-input-line"> |
||||
<Icon class="aui-icon" icon="ant-design:lock-outlined" /> |
||||
<a-input |
||||
class="fix-auto-fill" |
||||
:type="confirmPwdIndex === 'close' ? 'password' : 'text'" |
||||
:placeholder="t('sys.login.confirmPassword')" |
||||
v-model:value="formData.sepsd" |
||||
/> |
||||
<div class="aui-eye"> |
||||
<img :src="eyeKImg" alt="开启" v-if="confirmPwdIndex === 'open'" @click="confirmPwdClick('close')" /> |
||||
<img :src="eyeGImg" alt="关闭" v-else-if="confirmPwdIndex === 'close'" @click="confirmPwdClick('open')" /> |
||||
</div> |
||||
</div> |
||||
</a-form-item> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a-form-item> |
||||
<div class="aui-input-line"> |
||||
<Icon class="aui-icon" icon="ant-design:user-outlined" /> |
||||
<a-input class="fix-auto-fill" type="text" :placeholder="t('真实姓名')" v-model:value="formData.realname" /> |
||||
</div> |
||||
</a-form-item> |
||||
<a-form-item> |
||||
<div class="aui-input-line"> |
||||
<Icon class="aui-icon" icon="ant-design:mobile-outlined" /> |
||||
<a-input class="fix-auto-fill" type="text" :placeholder="t('工号')" v-model:value="formData.workon" /> |
||||
</div> |
||||
</a-form-item> |
||||
|
||||
<a-form-item> |
||||
<div class="aui-input-line"> |
||||
<JSelectDept :placeholder="t('sys.login.selectorgPlaceholder')" v-model:value="formData.ssdep" :multiple="false" /> |
||||
</div> |
||||
</a-form-item> |
||||
<a-form-item> |
||||
<div class="aui-input-line"> |
||||
<Icon class="aui-icon" icon="ant-design:user-outlined"/> |
||||
<a-input class="fix-auto-fill" type="text" :placeholder="t('电话')" v-model:value="formData.phone" /> |
||||
</div> |
||||
</a-form-item> |
||||
|
||||
<a-form-item> |
||||
<div class="aui-input-line"> |
||||
<Icon class="aui-icon" icon="ant-design:mobile-outlined" /> |
||||
<a-input class="fix-auto-fill" type="text" :placeholder="t('邮箱')" v-model:value="formData.emails" /> |
||||
</div> |
||||
</a-form-item> |
||||
|
||||
|
||||
<div class="aui-inputClear"> |
||||
<i class="icon icon-code"></i> |
||||
<a-form-item> |
||||
<a-input class="fix-auto-fill" type="text" :placeholder="t('sys.login.smsPlaceholder')" v-model:value="formData.smscode" /> |
||||
</a-form-item> |
||||
<div class="aui-code"> |
||||
<img v-if="randCodeData.requestCodeSuccess" :src="randCodeData.randCodeImage" @click="handleChangeCheckCode" /> |
||||
<img v-else style="margin-top: 2px; max-width: initial" :src="codeImg" @click="handleChangeCheckCode" /> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="aui-formButton"> |
||||
<div class="aui-flex"> |
||||
<a class="aui-link-login aui-flex-box" @click="registerHandleClick"> {{ t('sys.login.registerButton') }}</a> |
||||
</div> |
||||
<div class="aui-flex"> |
||||
<a class="aui-linek-code aui-flex-box" @click="goBackHandleClick">{{ t('sys.login.backSignIn') }}</a> |
||||
</div> |
||||
</div> |
||||
</a-form> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
|
||||
<script lang="ts" setup name="mini-register"> |
||||
|
||||
import { ref, reactive, unref, toRaw,onMounted } from 'vue'; |
||||
import { getCaptcha, registerFaren, getCodeInfo } from '/@/api/sys/user'; |
||||
import { SmsEnum } from '/@/views/sys/login/useLogin'; |
||||
import { useMessage } from '/@/hooks/web/useMessage'; |
||||
import logoImg from '/@/assets/loginmini/icon/jeecg_logo.png'; |
||||
import jeecgAdTextImg from '/@/assets/loginmini/icon/jeecg_ad_text.png'; |
||||
import eyeKImg from '/@/assets/loginmini/icon/icon-eye-k.png'; |
||||
import eyeGImg from '/@/assets/loginmini/icon/icon-eye-g.png'; |
||||
import JSelectDept from '/@/components/Form/src/jeecg/components/JSelectDept.vue'; |
||||
import { useI18n } from '/@/hooks/web/useI18n'; |
||||
import codeImg from '/@/assets/images/checkcode.png'; |
||||
|
||||
const { t } = useI18n(); |
||||
const { notification, createErrorModal, createMessage } = useMessage(); |
||||
const emit = defineEmits(['go-back', 'success', 'register']); |
||||
const formRef = ref(); |
||||
const formData = reactive<any>({ |
||||
id: '', |
||||
seusername: '', |
||||
psd: '', |
||||
sepsd: '', |
||||
realname: '', |
||||
workon: '', |
||||
sex: '', |
||||
ssdep: '', |
||||
topPic: '', |
||||
phone: '', |
||||
emails: '', |
||||
colleges: '', |
||||
major: '', |
||||
directioncal: '', |
||||
research: '', |
||||
educationcal: '', |
||||
expinfo: '', |
||||
compopen: '', |
||||
adminopen: '', |
||||
}); |
||||
|
||||
// 选择部门 |
||||
//是否显示获取验证码 |
||||
const showInterval = ref<boolean>(true); |
||||
//60s |
||||
const timeRuning = ref<number>(60); |
||||
//定时器 |
||||
const timer = ref<any>(null); |
||||
//密码眼睛打开关闭 |
||||
const pwdIndex = ref<string>('close'); |
||||
//确认密码眼睛打开关闭 |
||||
const confirmPwdIndex = ref<string>('close'); |
||||
|
||||
/** |
||||
* 返回 |
||||
*/ |
||||
function goBackHandleClick() { |
||||
emit('go-back'); |
||||
initForm(); |
||||
} |
||||
// 验证码 |
||||
const randCodeData = reactive<any>({ |
||||
randCodeImage: '', |
||||
requestCodeSuccess: false, |
||||
checkKey: null, |
||||
}); |
||||
function handleChangeCheckCode() { |
||||
formData.inputCode = ''; |
||||
|
||||
randCodeData.checkKey = 1629428467008; |
||||
getCodeInfo(randCodeData.checkKey).then((res) => { |
||||
randCodeData.randCodeImage = res; |
||||
randCodeData.requestCodeSuccess = true; |
||||
}); |
||||
} |
||||
/** |
||||
* 获取手机验证码 |
||||
*/ |
||||
async function getLoginCode() { |
||||
if (!formData.mobile) { |
||||
createMessage.warn(t('sys.login.mobilePlaceholder')); |
||||
return; |
||||
} |
||||
const result = await getCaptcha({ mobile: formData.mobile, smsmode: SmsEnum.REGISTER }); |
||||
if (result) { |
||||
const TIME_COUNT = 60; |
||||
if (!unref(timer)) { |
||||
timeRuning.value = TIME_COUNT; |
||||
showInterval.value = false; |
||||
timer.value = setInterval(() => { |
||||
if (unref(timeRuning) > 0 && unref(timeRuning) <= TIME_COUNT) { |
||||
timeRuning.value = timeRuning.value - 1; |
||||
} else { |
||||
showInterval.value = true; |
||||
clearInterval(unref(timer)); |
||||
timer.value = null; |
||||
} |
||||
}, 1000); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function registerHandleClick() { |
||||
if (!formData.seusername) { |
||||
createMessage.warn(t('请输入用户名')); |
||||
return; |
||||
} |
||||
if (!formData.realname) { |
||||
createMessage.warn(t('请输入真实姓名')); |
||||
return; |
||||
} |
||||
if (!formData.workon) { |
||||
createMessage.warn(t('请输入工号')); |
||||
return; |
||||
} |
||||
if (!formData.sex) { |
||||
createMessage.warn(t('请输入性别')); |
||||
return; |
||||
} |
||||
if (!formData.ssdep) { |
||||
createMessage.warn(t('sys.login.selectorgPlaceholder')); |
||||
return; |
||||
} |
||||
if (!formData.phone) { |
||||
createMessage.warn(t('请输入电话')); |
||||
return; |
||||
} |
||||
if (!formData.emails) { |
||||
createMessage.warn(t('请输入邮箱')); |
||||
return; |
||||
} |
||||
if (!formData.password) { |
||||
createMessage.warn(t('sys.login.passwordPlaceholder')); |
||||
return; |
||||
} |
||||
registerAccount(); |
||||
} |
||||
|
||||
/** |
||||
* 注册账号 |
||||
*/ |
||||
async function registerAccount() { |
||||
try { |
||||
const resultInfo = await registerFaren( |
||||
toRaw({ |
||||
// workno: formData.workno, |
||||
username: formData.username, |
||||
departmentid: formData.department, |
||||
realname: formData.realname, |
||||
password: formData.password, |
||||
phone: formData.mobile, |
||||
smscode: formData.smscode, |
||||
checkKey: randCodeData.checkKey, |
||||
idNo: formData.idNo, |
||||
certificateCode: formData.certificateCode, |
||||
orgName: formData.orgName, |
||||
}) |
||||
); |
||||
if (resultInfo && resultInfo.data.success) { |
||||
notification.success({ |
||||
description: resultInfo.data.message || t('sys.api.registerMsg'), |
||||
duration: 3, |
||||
}); |
||||
emit('success', { username: formData.username, password: formData.password }); |
||||
initForm(); |
||||
} else { |
||||
notification.warning({ |
||||
message: t('sys.api.errorTip'), |
||||
description: resultInfo.data.message || t('sys.api.networkExceptionMsg'), |
||||
duration: 3, |
||||
}); |
||||
} |
||||
} catch (error) { |
||||
notification.error({ |
||||
message: t('sys.api.errorTip'), |
||||
description: error.message || t('sys.api.networkExceptionMsg'), |
||||
duration: 3, |
||||
}); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 初始化表单 |
||||
*/ |
||||
function initForm() { |
||||
Object.assign(formData, { workno: '', username: '', mobile: '', realname: '', department: '', smscode: '', password: '', |
||||
confirmPassword: '', |
||||
idNo: '', |
||||
certificateCode: '', |
||||
orgName: '', |
||||
}); |
||||
if (!unref(timer)) { |
||||
showInterval.value = true; |
||||
clearInterval(unref(timer)); |
||||
timer.value = null; |
||||
} |
||||
formRef.value.resetFields(); |
||||
} |
||||
|
||||
/** |
||||
* 密码打开或关闭 |
||||
* @param value |
||||
*/ |
||||
function pwdClick(value) { |
||||
pwdIndex.value = value; |
||||
} |
||||
|
||||
/** |
||||
* 确认密码打开或关闭 |
||||
* @param value |
||||
*/ |
||||
function confirmPwdClick(value) { |
||||
confirmPwdIndex.value = value; |
||||
} |
||||
onMounted(() => { |
||||
//加载验证码 |
||||
handleChangeCheckCode(); |
||||
}); |
||||
defineExpose({ |
||||
initForm, |
||||
}); |
||||
</script> |
||||
|
||||
<style lang="less" scoped> |
||||
@import '/@/assets/loginmini/style/home.less'; |
||||
@import '/@/assets/loginmini/style/base.less'; |
||||
.aui-input-line .aui-icon { |
||||
position: absolute; |
||||
z-index: 2; |
||||
top: 10px; |
||||
left: 10px; |
||||
font-size: 20px !important; |
||||
} |
||||
</style> |
Loading…
Reference in new issue