feat(example): 新增用户机台班组配置功能模块
This commit is contained in:
parent
0f7cf4f068
commit
e3259786f4
@ -0,0 +1,8 @@
|
||||
package jnpf.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import jnpf.model.machine.UserMachineDetailEntity;
|
||||
|
||||
public interface UserMachineDetailMapper extends BaseMapper<UserMachineDetailEntity> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
package jnpf.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import jnpf.model.machine.UserMachineEntity;
|
||||
|
||||
public interface UserMachineMapper extends BaseMapper<UserMachineEntity> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package jnpf.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jnpf.model.machine.UserMachineDetailEntity;
|
||||
import jnpf.model.usermachinedetail.UserMachineDetailForm;
|
||||
import jnpf.model.usermachinedetail.UserMachineDetailPagination;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserMachineDetailService extends IService<UserMachineDetailEntity> {
|
||||
|
||||
List<UserMachineDetailEntity> getList(UserMachineDetailPagination userMachineDetailPagination);
|
||||
|
||||
UserMachineDetailEntity getInfo(String id);
|
||||
|
||||
void delete(UserMachineDetailEntity entity);
|
||||
|
||||
void create(UserMachineDetailEntity entity);
|
||||
|
||||
boolean update(String id, UserMachineDetailEntity entity);
|
||||
|
||||
String checkForm(UserMachineDetailForm form, int i);
|
||||
|
||||
void saveOrUpdate(UserMachineDetailForm userMachineDetailForm, String id, boolean isSave) throws Exception;
|
||||
|
||||
List<UserMachineDetailEntity> getListByUserMachId(Integer userMachId);
|
||||
|
||||
void deleteByUserMachId(Integer userMachId);
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package jnpf.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jnpf.model.machine.UserMachineEntity;
|
||||
import jnpf.model.usermachine.UserMachineForm;
|
||||
import jnpf.model.usermachine.UserMachinePagination;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserMachineService extends IService<UserMachineEntity> {
|
||||
|
||||
List<UserMachineEntity> getList(UserMachinePagination userMachinePagination);
|
||||
|
||||
UserMachineEntity getInfo(String id);
|
||||
|
||||
void delete(UserMachineEntity entity);
|
||||
|
||||
void create(UserMachineEntity entity);
|
||||
|
||||
boolean update(String id, UserMachineEntity entity);
|
||||
|
||||
String checkForm(UserMachineForm form, int i);
|
||||
|
||||
void saveOrUpdate(UserMachineForm userMachineForm, String id, boolean isSave) throws Exception;
|
||||
|
||||
List<UserMachineEntity> getSelectList();
|
||||
}
|
||||
@ -65,6 +65,10 @@ public class MachineServiceImpl extends ServiceImpl<MachineMapper, MachineEntity
|
||||
if (ObjectUtil.isNotEmpty(machinePagination.getBelgProcId())) {
|
||||
machineWrapper.eq(MachineEntity::getBelgProcId, machinePagination.getBelgProcId());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(machinePagination.getSelectKey())) {
|
||||
machineWrapper.like(MachineEntity::getMachineCd, machinePagination.getSelectKey()).or()
|
||||
.like(MachineEntity::getMachineName, machinePagination.getSelectKey());
|
||||
}
|
||||
machineWrapper.eq(MachineEntity::getDeleteMark, 0);
|
||||
machineWrapper.orderByDesc(MachineEntity::getCreatorTime);
|
||||
if ("0".equals(machinePagination.getDataType())) {
|
||||
|
||||
@ -0,0 +1,147 @@
|
||||
package jnpf.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jnpf.mapper.UserMachineDetailMapper;
|
||||
import jnpf.model.machine.UserMachineDetailEntity;
|
||||
import jnpf.model.usermachinedetail.UserMachineDetailForm;
|
||||
import jnpf.model.usermachinedetail.UserMachineDetailPagination;
|
||||
import jnpf.permission.entity.UserEntity;
|
||||
import jnpf.permission.service.UserService;
|
||||
import jnpf.service.UserMachineDetailService;
|
||||
import jnpf.util.UserProvider;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserMachineDetailServiceImpl extends ServiceImpl<UserMachineDetailMapper, UserMachineDetailEntity> implements UserMachineDetailService {
|
||||
|
||||
@Resource
|
||||
private UserProvider userProvider;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public List<UserMachineDetailEntity> getList(UserMachineDetailPagination userMachineDetailPagination) {
|
||||
LambdaQueryWrapper<UserMachineDetailEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if (ObjectUtil.isNotEmpty(userMachineDetailPagination.getUserMachId())) {
|
||||
wrapper.eq(UserMachineDetailEntity::getUserMachId, userMachineDetailPagination.getUserMachId());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(userMachineDetailPagination.getMachineCd())) {
|
||||
wrapper.like(UserMachineDetailEntity::getMachineCd, userMachineDetailPagination.getMachineCd());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(userMachineDetailPagination.getMachineName())) {
|
||||
wrapper.like(UserMachineDetailEntity::getMachineName, userMachineDetailPagination.getMachineName());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(userMachineDetailPagination.getEnabledStatus())) {
|
||||
wrapper.eq(UserMachineDetailEntity::getEnabledStatus, userMachineDetailPagination.getEnabledStatus());
|
||||
}
|
||||
|
||||
wrapper.eq(UserMachineDetailEntity::getDeleteMark, 0);
|
||||
wrapper.orderByDesc(UserMachineDetailEntity::getId);
|
||||
|
||||
if ("0".equals(userMachineDetailPagination.getDataType())) {
|
||||
Page<UserMachineDetailEntity> page = new Page<>(userMachineDetailPagination.getCurrentPage(), userMachineDetailPagination.getPageSize());
|
||||
IPage<UserMachineDetailEntity> result = this.page(page, wrapper);
|
||||
return userMachineDetailPagination.setData(result.getRecords(), result.getTotal());
|
||||
} else {
|
||||
return this.list(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserMachineDetailEntity getInfo(String id) {
|
||||
QueryWrapper<UserMachineDetailEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserMachineDetailEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(UserMachineDetailEntity entity) {
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, UserMachineDetailEntity entity) {
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(UserMachineDetailEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkForm(UserMachineDetailForm form, int i) {
|
||||
String countRecover = "";
|
||||
|
||||
if (ObjectUtil.isEmpty(form.getUserMachId())) {
|
||||
return "主表ID不能为空";
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(form.getMachineId())) {
|
||||
return "机台不能为空";
|
||||
}
|
||||
|
||||
return countRecover;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveOrUpdate(UserMachineDetailForm userMachineDetailForm, String id, boolean isSave) throws Exception {
|
||||
if (isSave) {
|
||||
UserMachineDetailEntity entity = new UserMachineDetailEntity();
|
||||
BeanUtils.copyProperties(userMachineDetailForm, entity);
|
||||
entity.setId(null);
|
||||
this.save(entity);
|
||||
} else {
|
||||
UserMachineDetailEntity entity = getInfo(id);
|
||||
if (entity == null) {
|
||||
throw new Exception("数据不存在");
|
||||
}
|
||||
BeanUtils.copyProperties(userMachineDetailForm, entity);
|
||||
this.updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserMachineDetailEntity> getListByUserMachId(Integer userMachId) {
|
||||
LambdaQueryWrapper<UserMachineDetailEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserMachineDetailEntity::getUserMachId, userMachId);
|
||||
wrapper.eq(UserMachineDetailEntity::getDeleteMark, 0);
|
||||
wrapper.eq(UserMachineDetailEntity::getEnabledStatus, 1);
|
||||
wrapper.orderByAsc(UserMachineDetailEntity::getMachineCd);
|
||||
List<UserMachineDetailEntity> list = this.list(wrapper);
|
||||
// 查询用户信息
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
list.forEach(item -> {
|
||||
UserEntity userEntity = userService.getById(item.getCreatorUserId());
|
||||
if (userEntity != null) {
|
||||
item.setCreateUserName(userEntity.getRealName());
|
||||
}
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteByUserMachId(Integer userMachId) {
|
||||
LambdaQueryWrapper<UserMachineDetailEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserMachineDetailEntity::getUserMachId, userMachId);
|
||||
this.remove(wrapper);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,151 @@
|
||||
package jnpf.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jnpf.mapper.UserMachineMapper;
|
||||
import jnpf.model.machine.UserMachineDetailEntity;
|
||||
import jnpf.model.machine.UserMachineEntity;
|
||||
import jnpf.model.usermachine.UserMachineForm;
|
||||
import jnpf.model.usermachine.UserMachinePagination;
|
||||
import jnpf.model.usermachinedetail.UserMachineDetailForm;
|
||||
import jnpf.service.UserMachineDetailService;
|
||||
import jnpf.service.UserMachineService;
|
||||
import jnpf.util.UserProvider;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class UserMachineServiceImpl extends ServiceImpl<UserMachineMapper, UserMachineEntity> implements UserMachineService {
|
||||
|
||||
@Resource
|
||||
private UserProvider userProvider;
|
||||
|
||||
@Resource
|
||||
private UserMachineDetailService userMachineDetailService;
|
||||
|
||||
@Override
|
||||
public List<UserMachineEntity> getList(UserMachinePagination userMachinePagination) {
|
||||
LambdaQueryWrapper<UserMachineEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if (ObjectUtil.isNotEmpty(userMachinePagination.getUserName())) {
|
||||
wrapper.like(UserMachineEntity::getUserName, userMachinePagination.getUserName());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(userMachinePagination.getUserNo())) {
|
||||
wrapper.like(UserMachineEntity::getUserNo, userMachinePagination.getUserNo());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(userMachinePagination.getClassGroup())) {
|
||||
wrapper.eq(UserMachineEntity::getClassGroup, userMachinePagination.getClassGroup());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(userMachinePagination.getEnabledStatus())) {
|
||||
wrapper.eq(UserMachineEntity::getEnabledStatus, userMachinePagination.getEnabledStatus());
|
||||
}
|
||||
|
||||
wrapper.eq(UserMachineEntity::getDeleteMark, 0);
|
||||
wrapper.orderByDesc(UserMachineEntity::getId);
|
||||
|
||||
if ("0".equals(userMachinePagination.getDataType())) {
|
||||
Page<UserMachineEntity> page = new Page<>(userMachinePagination.getCurrentPage(), userMachinePagination.getPageSize());
|
||||
IPage<UserMachineEntity> result = this.page(page, wrapper);
|
||||
return userMachinePagination.setData(result.getRecords(), result.getTotal());
|
||||
} else {
|
||||
return this.list(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserMachineEntity getInfo(String id) {
|
||||
QueryWrapper<UserMachineEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserMachineEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(UserMachineEntity entity) {
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, UserMachineEntity entity) {
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(UserMachineEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkForm(UserMachineForm form, int i) {
|
||||
if (ObjectUtil.isEmpty(form.getUserId())) {
|
||||
return "人员不能为空";
|
||||
}
|
||||
if (ObjectUtil.isEmpty(form.getClassGroup())) {
|
||||
return "班组不能为空";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveOrUpdate(UserMachineForm userMachineForm, String id, boolean isSave) throws Exception {
|
||||
UserMachineEntity entity;
|
||||
if (isSave) {
|
||||
entity = new UserMachineEntity();
|
||||
BeanUtils.copyProperties(userMachineForm, entity);
|
||||
entity.setId(null);
|
||||
this.save(entity);
|
||||
} else {
|
||||
entity = getInfo(id);
|
||||
if (entity == null) {
|
||||
throw new Exception("数据不存在");
|
||||
}
|
||||
BeanUtils.copyProperties(userMachineForm, entity);
|
||||
this.updateById(entity);
|
||||
}
|
||||
|
||||
saveMachineDetails(entity.getId(), userMachineForm.getMachineList());
|
||||
}
|
||||
|
||||
private void saveMachineDetails(Integer userMachId, List<UserMachineDetailForm> machineList) {
|
||||
if (ObjectUtil.isEmpty(machineList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
userMachineDetailService.deleteByUserMachId(userMachId);
|
||||
|
||||
List<UserMachineDetailEntity> detailEntities = machineList.stream()
|
||||
.map(form -> {
|
||||
UserMachineDetailEntity detailEntity = new UserMachineDetailEntity();
|
||||
detailEntity.setUserMachId(userMachId);
|
||||
detailEntity.setMachineCd(form.getMachineCd());
|
||||
detailEntity.setMachineId(form.getMachineId());
|
||||
detailEntity.setMachineName(form.getMachineName());
|
||||
detailEntity.setEnabledStatus(1);
|
||||
return detailEntity;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
userMachineDetailService.saveBatch(detailEntities);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<UserMachineEntity> getSelectList() {
|
||||
LambdaQueryWrapper<UserMachineEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserMachineEntity::getDeleteMark, 0);
|
||||
wrapper.eq(UserMachineEntity::getEnabledStatus, 1);
|
||||
wrapper.orderByAsc(UserMachineEntity::getUserName);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
}
|
||||
@ -10,10 +10,10 @@ import jnpf.model.machine.MachineEntity;
|
||||
import jnpf.model.machine.MachineForm;
|
||||
import jnpf.model.machine.MachinePagination;
|
||||
import jnpf.model.proline.ProLineEntity;
|
||||
import jnpf.permission.entity.UserEntity;
|
||||
import jnpf.permission.service.UserService;
|
||||
import jnpf.service.MachineService;
|
||||
import jnpf.service.ProLineService;
|
||||
import jnpf.service.ProcService;
|
||||
import jnpf.util.JsonUtil;
|
||||
import jnpf.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -26,7 +26,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 机台主数据 控制类
|
||||
*
|
||||
*/
|
||||
@Tag(name = "机台主数据", description = "Machine")
|
||||
@RestController
|
||||
@ -39,9 +38,13 @@ public class MachineController {
|
||||
@Autowired
|
||||
private ProLineService proLineService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param machinePagination 分页查询对象
|
||||
* @return 列表结果集
|
||||
*/
|
||||
@ -49,6 +52,13 @@ public class MachineController {
|
||||
@PostMapping("/getList")
|
||||
public ActionResult getList(@RequestBody MachinePagination machinePagination) {
|
||||
List<MachineEntity> list = machineService.getList(machinePagination);
|
||||
// 查询用户信息
|
||||
list.forEach(item -> {
|
||||
UserEntity userEntity = userService.getById(item.getCreatorUserId());
|
||||
if (userEntity != null) {
|
||||
item.setCreateUserName(userEntity.getRealName());
|
||||
}
|
||||
});
|
||||
List<Map<String, Object>> realList = list.stream()
|
||||
.map(JsonUtil::entityToMap)
|
||||
.collect(Collectors.toList());
|
||||
@ -63,6 +73,7 @@ public class MachineController {
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 详情结果集
|
||||
*/
|
||||
@ -78,6 +89,7 @@ public class MachineController {
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*
|
||||
* @param machineForm 表单对象
|
||||
* @return 新建结果
|
||||
*/
|
||||
@ -98,7 +110,8 @@ public class MachineController {
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param id 主键
|
||||
*
|
||||
* @param id 主键
|
||||
* @param machineForm 表单对象
|
||||
* @return 编辑结果
|
||||
*/
|
||||
@ -125,6 +138,7 @@ public class MachineController {
|
||||
|
||||
/**
|
||||
* 获取产线下拉列表
|
||||
*
|
||||
* @return 产线列表
|
||||
*/
|
||||
@Operation(summary = "获取产线下拉列表")
|
||||
@ -140,5 +154,4 @@ public class MachineController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,126 @@
|
||||
package jnpf.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jnpf.base.ActionResult;
|
||||
import jnpf.base.vo.PageListVO;
|
||||
import jnpf.base.vo.PaginationVO;
|
||||
import jnpf.model.machine.UserMachineDetailEntity;
|
||||
import jnpf.model.machine.UserMachineEntity;
|
||||
import jnpf.model.usermachine.UserMachineForm;
|
||||
import jnpf.model.usermachine.UserMachinePagination;
|
||||
import jnpf.permission.entity.UserEntity;
|
||||
import jnpf.permission.service.UserService;
|
||||
import jnpf.service.UserMachineDetailService;
|
||||
import jnpf.service.UserMachineService;
|
||||
import jnpf.util.JsonUtil;
|
||||
import jnpf.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Tag(name = "人员机台班组配置", description = "UserMachine")
|
||||
@RestController
|
||||
@RequestMapping("/api/example/userMachine")
|
||||
public class UserMachineController {
|
||||
|
||||
@Autowired
|
||||
private UserMachineService userMachineService;
|
||||
|
||||
@Autowired
|
||||
private UserMachineDetailService userMachineDetailService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Operation(summary = "获取人员机台班组列表")
|
||||
@PostMapping("/getList")
|
||||
public ActionResult getList(@RequestBody UserMachinePagination userMachinePagination) {
|
||||
List<UserMachineEntity> list = userMachineService.getList(userMachinePagination);
|
||||
// 循环查询创建人
|
||||
list.forEach(item -> {
|
||||
UserEntity userEntity = userService.getById(item.getCreatorUserId());
|
||||
if (userEntity != null) {
|
||||
item.setCreateUserName(userEntity.getRealName());
|
||||
}
|
||||
});
|
||||
List<Map<String, Object>> realList = list.stream()
|
||||
.map(JsonUtil::entityToMap)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
PageListVO vo = new PageListVO();
|
||||
vo.setList(realList);
|
||||
PaginationVO page = JsonUtil.getJsonToBean(userMachinePagination, PaginationVO.class);
|
||||
vo.setPagination(page);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取人员机台班组详情")
|
||||
@GetMapping("/{id}")
|
||||
public ActionResult info(@PathVariable("id") String id) {
|
||||
UserMachineEntity entity = userMachineService.getInfo(id);
|
||||
// 查询机台
|
||||
List<UserMachineDetailEntity> detailEntities = userMachineDetailService.getListByUserMachId(entity.getId());
|
||||
entity.setMachineList(detailEntities);
|
||||
if (entity != null) {
|
||||
return ActionResult.success(JsonUtil.entityToMap(entity));
|
||||
}
|
||||
return ActionResult.fail("数据不存在");
|
||||
}
|
||||
|
||||
@Operation(summary = "新建人员机台班组配置")
|
||||
@PostMapping
|
||||
public ActionResult create(@RequestBody @Valid UserMachineForm userMachineForm) {
|
||||
String b = userMachineService.checkForm(userMachineForm, 0);
|
||||
if (StringUtil.isNotEmpty(b)) {
|
||||
return ActionResult.fail(b);
|
||||
}
|
||||
try {
|
||||
userMachineService.saveOrUpdate(userMachineForm, "", true);
|
||||
return ActionResult.success("新建成功");
|
||||
} catch (Exception e) {
|
||||
return ActionResult.fail("新建数据失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "更新人员机台班组配置")
|
||||
@PutMapping("/{id}")
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid UserMachineForm userMachineForm) {
|
||||
userMachineForm.setId(Integer.parseInt(id));
|
||||
String b = userMachineService.checkForm(userMachineForm, 1);
|
||||
if (StringUtil.isNotEmpty(b)) {
|
||||
return ActionResult.fail(b);
|
||||
}
|
||||
UserMachineEntity entity = userMachineService.getInfo(id);
|
||||
if (entity != null) {
|
||||
try {
|
||||
userMachineService.saveOrUpdate(userMachineForm, id, false);
|
||||
return ActionResult.success("更新成功");
|
||||
} catch (Exception e) {
|
||||
return ActionResult.fail("更新数据失败:" + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
return ActionResult.fail("更新失败,数据不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "删除人员机台班组配置")
|
||||
@DeleteMapping("/{id}")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
UserMachineEntity entity = userMachineService.getInfo(id);
|
||||
if (entity != null) {
|
||||
try {
|
||||
userMachineService.delete(entity);
|
||||
return ActionResult.success("删除成功");
|
||||
} catch (Exception e) {
|
||||
return ActionResult.fail("删除失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
return ActionResult.fail("删除失败,数据不存在");
|
||||
}
|
||||
|
||||
}
|
||||
@ -51,4 +51,7 @@ public class MachineEntity {
|
||||
@TableField(exist = false)
|
||||
private String belgProcName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String createUserName;
|
||||
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ import lombok.Data;
|
||||
@Data
|
||||
public class MachinePagination extends Pagination {
|
||||
/** 查询key */
|
||||
private String[] selectKey;
|
||||
private String selectKey;
|
||||
/** json */
|
||||
private String json;
|
||||
/** 数据类型 0-当前页,1-全部数据 */
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
package jnpf.model.machine;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("tba_user_machine_detail")
|
||||
public class UserMachineDetailEntity {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@TableField(value = "f_creator_user_id", fill = FieldFill.INSERT)
|
||||
private String creatorUserId;
|
||||
|
||||
@TableField(value = "f_creator_time", fill = FieldFill.INSERT)
|
||||
private Date creatorTime;
|
||||
|
||||
@TableField(value = "f_last_modify_user_id", fill = FieldFill.INSERT_UPDATE)
|
||||
private String lastModifyUserId;
|
||||
|
||||
@TableField(value = "f_last_modify_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private Date lastModifyTime;
|
||||
|
||||
@TableField(value = "f_delete_user_id", fill = FieldFill.UPDATE)
|
||||
private String deleteUserId;
|
||||
|
||||
@TableField(value = "f_delete_time", fill = FieldFill.UPDATE)
|
||||
private Date deleteTime;
|
||||
|
||||
@TableField(value = "f_delete_mark", updateStrategy = FieldStrategy.IGNORED)
|
||||
private Integer deleteMark;
|
||||
|
||||
@TableField(value = "f_flow_id")
|
||||
private String flowId;
|
||||
|
||||
@TableField(value = "f_flow_task_id")
|
||||
private String flowTaskId;
|
||||
|
||||
@TableField("enabled_status")
|
||||
private Integer enabledStatus;
|
||||
|
||||
@TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED)
|
||||
private String remark;
|
||||
|
||||
@TableField("user_mach_id")
|
||||
private Integer userMachId;
|
||||
|
||||
@TableField("machine_cd")
|
||||
private String machineCd;
|
||||
|
||||
@TableField("machine_name")
|
||||
private String machineName;
|
||||
|
||||
@TableField("machine_id")
|
||||
private Integer machineId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String createUserName;
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package jnpf.model.usermachinedetail;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class UserMachineDetailForm {
|
||||
|
||||
@Schema(description = "主键")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "状态(1启用 2 未启用)")
|
||||
private Integer enabledStatus;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "主表id")
|
||||
private Integer userMachId;
|
||||
|
||||
@Schema(description = "机台编码")
|
||||
private String machineCd;
|
||||
|
||||
@Schema(description = "机台名称")
|
||||
private String machineName;
|
||||
|
||||
@Schema(description = "机台id")
|
||||
private Integer machineId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date creatorTime;
|
||||
|
||||
@Schema(description = "创建用户ID")
|
||||
private String creatorUserId;
|
||||
|
||||
@Schema(description = "最后修改时间")
|
||||
private Date lastModifyTime;
|
||||
|
||||
@Schema(description = "最后修改用户ID")
|
||||
private String lastModifyUserId;
|
||||
|
||||
@Schema(description = "删除时间")
|
||||
private Date deleteTime;
|
||||
|
||||
@Schema(description = "删除用户ID")
|
||||
private String deleteUserId;
|
||||
|
||||
@Schema(description = "删除标记")
|
||||
private Integer deleteMark;
|
||||
|
||||
@Schema(description = "流程ID")
|
||||
private String flowId;
|
||||
|
||||
@Schema(description = "流程任务ID")
|
||||
private String flowTaskId;
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package jnpf.model.usermachinedetail;
|
||||
|
||||
import jnpf.base.Pagination;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserMachineDetailPagination extends Pagination {
|
||||
private String[] selectKey;
|
||||
private String json;
|
||||
private String dataType;
|
||||
private String superQueryJson;
|
||||
private String moduleId;
|
||||
private String menuId;
|
||||
|
||||
@Schema(description = "主表id")
|
||||
private Integer userMachId;
|
||||
|
||||
@Schema(description = "机台编码")
|
||||
private String machineCd;
|
||||
|
||||
@Schema(description = "机台名称")
|
||||
private String machineName;
|
||||
|
||||
@Schema(description = "状态(1启用 2 未启用)")
|
||||
private Integer enabledStatus;
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
package jnpf.model.machine;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("tba_user_machine")
|
||||
public class UserMachineEntity {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@TableField(value = "f_creator_user_id", fill = FieldFill.INSERT)
|
||||
private String creatorUserId;
|
||||
|
||||
@TableField(value = "f_creator_time", fill = FieldFill.INSERT)
|
||||
private Date creatorTime;
|
||||
|
||||
@TableField(value = "f_last_modify_user_id", fill = FieldFill.INSERT_UPDATE)
|
||||
private String lastModifyUserId;
|
||||
|
||||
@TableField(value = "f_last_modify_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private Date lastModifyTime;
|
||||
|
||||
@TableField(value = "f_delete_user_id", fill = FieldFill.UPDATE)
|
||||
private String deleteUserId;
|
||||
|
||||
@TableField(value = "f_delete_time", fill = FieldFill.UPDATE)
|
||||
private Date deleteTime;
|
||||
|
||||
@TableField(value = "f_delete_mark", updateStrategy = FieldStrategy.IGNORED)
|
||||
private Integer deleteMark;
|
||||
|
||||
@TableField(value = "f_flow_id")
|
||||
private String flowId;
|
||||
|
||||
@TableField(value = "f_flow_task_id")
|
||||
private String flowTaskId;
|
||||
|
||||
@TableField("enabled_status")
|
||||
private Integer enabledStatus;
|
||||
|
||||
@TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED)
|
||||
private String remark;
|
||||
|
||||
@TableField("user_id")
|
||||
private String userId;
|
||||
|
||||
@TableField("user_name")
|
||||
private String userName;
|
||||
|
||||
@TableField("user_no")
|
||||
private String userNo;
|
||||
|
||||
@TableField("class_group")
|
||||
private String classGroup;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String createUserName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<UserMachineDetailEntity> machineList;
|
||||
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package jnpf.model.usermachine;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UserMachineForm {
|
||||
|
||||
@Schema(description = "主键")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "状态(1启用 2 未启用)")
|
||||
private Integer enabledStatus;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "人员id")
|
||||
private String userId;
|
||||
|
||||
@Schema(description = "人员名称")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "人员账号")
|
||||
private String userNo;
|
||||
|
||||
@Schema(description = "班组(甲 乙 丙 丁)")
|
||||
private String classGroup;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date creatorTime;
|
||||
|
||||
@Schema(description = "创建用户ID")
|
||||
private String creatorUserId;
|
||||
|
||||
@Schema(description = "最后修改时间")
|
||||
private Date lastModifyTime;
|
||||
|
||||
@Schema(description = "最后修改用户ID")
|
||||
private String lastModifyUserId;
|
||||
|
||||
@Schema(description = "删除时间")
|
||||
private Date deleteTime;
|
||||
|
||||
@Schema(description = "删除用户ID")
|
||||
private String deleteUserId;
|
||||
|
||||
@Schema(description = "删除标记")
|
||||
private Integer deleteMark;
|
||||
|
||||
@Schema(description = "流程ID")
|
||||
private String flowId;
|
||||
|
||||
@Schema(description = "流程任务ID")
|
||||
private String flowTaskId;
|
||||
|
||||
|
||||
List<jnpf.model.usermachinedetail.UserMachineDetailForm> machineList;
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package jnpf.model.usermachine;
|
||||
|
||||
import jnpf.base.Pagination;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserMachinePagination extends Pagination {
|
||||
private String[] selectKey;
|
||||
private String json;
|
||||
private String dataType;
|
||||
private String superQueryJson;
|
||||
private String moduleId;
|
||||
private String menuId;
|
||||
|
||||
@Schema(description = "人员名称")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "人员账号")
|
||||
private String userNo;
|
||||
|
||||
@Schema(description = "班组")
|
||||
private String classGroup;
|
||||
|
||||
@Schema(description = "状态(1启用 2 未启用)")
|
||||
private Integer enabledStatus;
|
||||
}
|
||||
@ -1,41 +1,46 @@
|
||||
package jnpf.permission.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.xuyanwu.spring.file.storage.FileInfo;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import jnpf.base.Pagination;
|
||||
import jnpf.base.UserInfo;
|
||||
import jnpf.base.entity.DictionaryDataEntity;
|
||||
import jnpf.base.service.DictionaryDataService;
|
||||
import jnpf.base.service.SuperServiceImpl;
|
||||
import jnpf.base.vo.DownloadVO;
|
||||
import jnpf.config.ConfigValueUtil;
|
||||
import jnpf.constant.JnpfConst;
|
||||
import jnpf.constant.PermissionConst;
|
||||
import jnpf.consts.AuthConsts;
|
||||
import jnpf.database.source.DbBase;
|
||||
import jnpf.database.util.DataSourceUtil;
|
||||
import jnpf.exception.DataException;
|
||||
import jnpf.message.util.OnlineUserModel;
|
||||
import jnpf.message.util.OnlineUserProvider;
|
||||
import jnpf.permission.model.user.UserIdListVo;
|
||||
import jnpf.permission.model.user.vo.*;
|
||||
import jnpf.database.source.DbBase;
|
||||
import jnpf.database.util.DataSourceUtil;
|
||||
import jnpf.permission.entity.*;
|
||||
import jnpf.permission.mapper.UserMapper;
|
||||
import jnpf.permission.model.user.UserIdListVo;
|
||||
import jnpf.permission.model.user.mod.UserConditionModel;
|
||||
import jnpf.permission.model.user.mod.UserImportModel;
|
||||
import jnpf.permission.model.user.page.PaginationUser;
|
||||
import jnpf.util.ExcelUtil;
|
||||
import jnpf.permission.model.user.vo.UserByRoleVO;
|
||||
import jnpf.permission.model.user.vo.UserExportExceptionVO;
|
||||
import jnpf.permission.model.user.vo.UserExportVO;
|
||||
import jnpf.permission.model.user.vo.UserImportVO;
|
||||
import jnpf.permission.service.*;
|
||||
import jnpf.util.*;
|
||||
import lombok.Cleanup;
|
||||
@ -43,17 +48,13 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import jnpf.base.UserInfo;
|
||||
import jnpf.permission.model.user.mod.UserConditionModel;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static jnpf.consts.AuthConsts.TOKEN_PREFIX;
|
||||
|
||||
@ -2173,4 +2174,13 @@ public class UserServiceImpl extends SuperServiceImpl<UserMapper, UserEntity> im
|
||||
return (currentFinded == 1)?userInfo.getUserId():"";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserEntity> getUserSelect(String keyword) {
|
||||
LambdaQueryWrapper<UserEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(StringUtil.isNotEmpty(keyword), UserEntity::getRealName, keyword);
|
||||
// queryWrapper.or().like(StringUtil.isNotEmpty(keyword), UserEntity::getRealName, keyword);
|
||||
queryWrapper.isNull(UserEntity::getDeleteMark);
|
||||
queryWrapper.eq(UserEntity::getEnabledMark, 1);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +1,27 @@
|
||||
package jnpf.permission.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import jnpf.base.controller.SuperController;
|
||||
import cn.xuyanwu.spring.file.storage.FileInfo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jnpf.annotation.UserPermission;
|
||||
import jnpf.base.ActionResult;
|
||||
import jnpf.base.Page;
|
||||
import jnpf.base.Pagination;
|
||||
import jnpf.base.UserInfo;
|
||||
import jnpf.base.controller.SuperController;
|
||||
import jnpf.base.vo.DownloadVO;
|
||||
import jnpf.base.vo.ListVO;
|
||||
import jnpf.base.vo.PageListVO;
|
||||
import jnpf.base.vo.PaginationVO;
|
||||
import jnpf.config.ConfigValueUtil;
|
||||
import jnpf.constant.MsgCode;
|
||||
import jnpf.constant.PermissionConst;
|
||||
import jnpf.engine.service.FlowTaskService;
|
||||
import jnpf.exception.DataException;
|
||||
import jnpf.exception.ImportException;
|
||||
import jnpf.message.service.SynThirdDingTalkService;
|
||||
import jnpf.message.service.SynThirdQyService;
|
||||
@ -32,15 +38,9 @@ import jnpf.permission.model.user.page.PageUser;
|
||||
import jnpf.permission.model.user.page.PaginationUser;
|
||||
import jnpf.permission.model.user.vo.*;
|
||||
import jnpf.permission.rest.PullUserUtil;
|
||||
import jnpf.permission.service.*;
|
||||
import jnpf.permission.util.PermissionUtil;
|
||||
import jnpf.util.*;
|
||||
import jnpf.base.ActionResult;
|
||||
import jnpf.base.vo.PageListVO;
|
||||
import jnpf.base.Pagination;
|
||||
import jnpf.base.vo.PaginationVO;
|
||||
import jnpf.base.vo.ListVO;
|
||||
import jnpf.exception.DataException;
|
||||
import jnpf.permission.service.*;
|
||||
import jnpf.util.treeutil.SumTree;
|
||||
import jnpf.util.treeutil.newtreeutil.TreeDotUtils;
|
||||
import lombok.Cleanup;
|
||||
@ -1467,5 +1467,22 @@ public class UserController extends SuperController<UserService, UserEntity> {
|
||||
flowWorkListVO.setPermission(jsonToList);
|
||||
return ActionResult.success(flowWorkListVO);
|
||||
}
|
||||
//获取用户下拉框,根据用户名称或者者用户模糊查询
|
||||
@Operation(summary = "获取用户下拉框")
|
||||
@SaCheckPermission("permission.user")
|
||||
@GetMapping("/getUserSelect")
|
||||
public ActionResult getUserSelect(String keyword) {
|
||||
List<UserEntity> list = userService.getUserSelect(keyword);
|
||||
List<Map<String, Object>> result = list.stream()
|
||||
.map(entity -> {
|
||||
Map<String, Object> map = new HashMap<>(3);
|
||||
map.put("id", entity.getId());
|
||||
map.put("name", entity.getRealName());
|
||||
map.put("account", entity.getAccount());
|
||||
return map;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return ActionResult.success(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -398,4 +398,6 @@ public interface UserService extends SuperService<UserEntity> {
|
||||
List<UserIdListVo> selectedByIds(List<String> ids);
|
||||
|
||||
List<UserEntity> getUserByName(String saleManName);
|
||||
|
||||
List<UserEntity> getUserSelect(String keyword);
|
||||
}
|
||||
|
||||
242
jnpf-java-boot/jnpf-web/src/views/example/usermachine/form.vue
Normal file
242
jnpf-java-boot/jnpf-web/src/views/example/usermachine/form.vue
Normal file
@ -0,0 +1,242 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="!dataForm.id ? '新建' : '编辑'"
|
||||
:visible.sync="dialogVisible"
|
||||
width="900px"
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="60px" label-position="right">
|
||||
<template v-if="!loading">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="人员" prop="userId">
|
||||
<UserSelect
|
||||
v-model="dataForm.userId"
|
||||
@change="handleUserChange"
|
||||
placeholder="请选择人员"
|
||||
:disabled="!!dataForm.id"
|
||||
></UserSelect>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="班组" prop="classGroup">
|
||||
<JnpfSelect v-model="dataForm.classGroup" placeholder="请选择班组" :options="classGroupOptions"
|
||||
:props="classGroupProps" clearable :style="{ width: '100%' }">
|
||||
</JnpfSelect>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="状态" prop="enabledStatus">
|
||||
<JnpfSelect v-model="dataForm.enabledStatus" placeholder="请选择状态" :options="enabledStatusOptions"
|
||||
:props="enabledStatusProps" clearable :style="{ width: '100%' }">
|
||||
</JnpfSelect>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<JnpfTextarea v-model="dataForm.remark" placeholder="请输入备注" :style="{ width: '100%' }" :autoSize="{ minRows: 3, maxRows: 3 }" type="textarea">
|
||||
</JnpfTextarea>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 机台信息列表 -->
|
||||
<el-row :gutter="20" style="margin-top: 20px; border-top: 1px solid #eee; padding-top: 20px;">
|
||||
<el-col :span="24">
|
||||
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
||||
<span style="font-weight: bold;">机台信息</span>
|
||||
<el-button type="primary" size="small" icon="el-icon-plus" @click="addMachineHandle" style="margin-left: 10px;">新增</el-button>
|
||||
</div>
|
||||
<div style="max-height: 360px; overflow-y: auto;">
|
||||
<el-table
|
||||
:data="dataForm.machineList"
|
||||
:border="true"
|
||||
:style="{ width: '100%' }"
|
||||
:max-height="340"
|
||||
>
|
||||
<el-table-column type="index" label="序号" align="center" width="60"/>
|
||||
<el-table-column prop="machineCd" label="机台编码" align="center"/>
|
||||
<el-table-column prop="machineName" label="机台名称" align="center"/>
|
||||
<el-table-column prop="createUserName" label="创建人" align="center"/>
|
||||
<el-table-column prop="creatorTime" label="创建时间" align="center" :formatter="jnpf.tableDateFormat1"/>
|
||||
<el-table-column label="操作" align="center" width="80">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="small" @click="removeMachine(scope.row)" style="color: #f56c6c;">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading">确 定</el-button>
|
||||
<el-button @click="handleClose">取 消</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 机台选择弹窗 -->
|
||||
<machineList
|
||||
:dialog-visible.sync="machineFormVisible"
|
||||
title="选择机台"
|
||||
:selected-machine-ids="selectedMachineIds"
|
||||
@confirm="handleMachineConfirm"
|
||||
/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from "@/utils/request";
|
||||
import UserSelect from '../common/UserSelect';
|
||||
import machineList from './machineList.vue';
|
||||
import jnpf from "@/utils/jnpf";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
UserSelect,
|
||||
machineList,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
loading: false,
|
||||
btnLoading: false,
|
||||
formRef: 'formRef',
|
||||
dataForm: {
|
||||
id: '',
|
||||
userId: undefined,
|
||||
userName: "",
|
||||
userNo: "",
|
||||
classGroup: undefined,
|
||||
enabledStatus: 1,
|
||||
remark: undefined,
|
||||
machineList: [],
|
||||
},
|
||||
machineFormVisible: false,
|
||||
dataRule: {
|
||||
userId: [
|
||||
{ required: true, message: "请选择人员", trigger: "change" },
|
||||
],
|
||||
classGroup: [
|
||||
{ required: true, message: "请选择班组", trigger: "change" },
|
||||
],
|
||||
enabledStatus: [
|
||||
{ required: true, message: "请选择状态", trigger: "change" },
|
||||
],
|
||||
},
|
||||
classGroupOptions: [
|
||||
{ fullName: "甲", id: "甲" },
|
||||
{ fullName: "乙", id: "乙" },
|
||||
{ fullName: "丙", id: "丙" },
|
||||
{ fullName: "丁", id: "丁" },
|
||||
],
|
||||
classGroupProps: { label: "fullName", value: "id" },
|
||||
enabledStatusOptions: [
|
||||
{ fullName: "启用", id: 1 },
|
||||
{ fullName: "未启用", id: 2 },
|
||||
],
|
||||
enabledStatusProps: { label: "fullName", value: "id" },
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
jnpf() {
|
||||
return jnpf;
|
||||
},
|
||||
// 获取已选中的机台ID列表
|
||||
selectedMachineIds() {
|
||||
return this.dataForm.machineList.map(item => item.machineId || item.id);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.id = id || '';
|
||||
this.dialogVisible = true;
|
||||
this.loading = true;
|
||||
|
||||
// 新增时直接显示页面
|
||||
if (!this.dataForm.id) {
|
||||
if (this.$refs.formRef) {
|
||||
this.$refs.formRef.clearValidate();
|
||||
}
|
||||
this.loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 编辑时加载数据
|
||||
request({
|
||||
url: `/api/example/userMachine/${this.dataForm.id}`,
|
||||
method: "get",
|
||||
}).then((res) => {
|
||||
this.dataForm = { ...this.dataForm, ...res.data };
|
||||
this.loading = false;
|
||||
}).catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
handleUserChange(user) {
|
||||
if (user) {
|
||||
this.dataForm.userId = user.id;
|
||||
this.dataForm.userName = user.name || user.fullName;
|
||||
this.dataForm.userNo = user.account;
|
||||
} else {
|
||||
this.dataForm.userId = undefined;
|
||||
this.dataForm.userName = "";
|
||||
this.dataForm.userNo = "";
|
||||
}
|
||||
},
|
||||
dataFormSubmit() {
|
||||
this.$refs.formRef.validate((valid) => {
|
||||
if (valid) {
|
||||
this.btnLoading = true;
|
||||
const url = this.dataForm.id
|
||||
? `/api/example/userMachine/${this.dataForm.id}`
|
||||
: `/api/example/userMachine`;
|
||||
const method = this.dataForm.id ? "put" : "post";
|
||||
request({
|
||||
url: url,
|
||||
method: method,
|
||||
data: this.dataForm,
|
||||
})
|
||||
.then((res) => {
|
||||
this.$message({
|
||||
message: res.msg || "操作成功",
|
||||
type: "success",
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.btnLoading = false;
|
||||
this.dialogVisible = false;
|
||||
this.$emit("refresh", true);
|
||||
},
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.btnLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
handleClose() {
|
||||
this.dialogVisible = false;
|
||||
this.$emit("refresh", true);
|
||||
},
|
||||
// 打开机台选择弹窗
|
||||
addMachineHandle() {
|
||||
this.machineFormVisible = true;
|
||||
},
|
||||
// 删除机台
|
||||
removeMachine(row) {
|
||||
const index = this.dataForm.machineList.findIndex(item => item.machineId === row.machineId || item.id === row.id);
|
||||
if (index > -1) {
|
||||
this.dataForm.machineList.splice(index, 1);
|
||||
}
|
||||
},
|
||||
// 处理机台选择结果
|
||||
handleMachineConfirm(selectedMachines) {
|
||||
this.dataForm.machineList = selectedMachines;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
212
jnpf-java-boot/jnpf-web/src/views/example/usermachine/index.vue
Normal file
212
jnpf-java-boot/jnpf-web/src/views/example/usermachine/index.vue
Normal file
@ -0,0 +1,212 @@
|
||||
<template>
|
||||
<div class="JNPF-common-layout usermachine_data">
|
||||
<div class="JNPF-common-layout-center">
|
||||
|
||||
<!-- 机台选择弹窗组件(用于form.vue) -->
|
||||
<machineList
|
||||
:dialogVisible.sync="machineDialogVisible"
|
||||
:userName="currentUserName"
|
||||
:userMachineId="currentUserMachineId"
|
||||
></machineList>
|
||||
|
||||
<!-- 机台详情弹窗组件(用于显示用户机台列表) -->
|
||||
<machineDetail
|
||||
:dialogVisible.sync="machineDetailVisible"
|
||||
:userName="currentUserName"
|
||||
:userMachineId="currentUserMachineId"
|
||||
></machineDetail>
|
||||
|
||||
<el-row class="JNPF-common-search-box" :gutter="14">
|
||||
<el-form @submit.native.prevent>
|
||||
<!-- <el-col :span="6">
|
||||
<el-form-item label="人员名称">
|
||||
<el-input v-model="query.userName" placeholder="请输入" clearable></el-input>
|
||||
</el-form-item>
|
||||
</el-col> -->
|
||||
<el-col :span="6">
|
||||
<el-form-item label="人员编码">
|
||||
<el-input v-model="query.userNo" placeholder="请输入" clearable></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="班组">
|
||||
<JnpfSelect v-model="query.classGroup" placeholder="请选择" clearable :options="classGroupOptions"
|
||||
:props="classGroupProps">
|
||||
</JnpfSelect>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="状态">
|
||||
<JnpfSelect v-model="query.enabledStatus" placeholder="请选择" clearable :options="enabledStatusOptions"
|
||||
:props="enabledStatusProps">
|
||||
</JnpfSelect>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item class="btn">
|
||||
<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
|
||||
<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<div class="JNPF-common-layout-main JNPF-flex-main">
|
||||
<div class="JNPF-common-head">
|
||||
<div>
|
||||
<el-button type="primary" icon="icon-ym icon-ym-btn-add" @click="addOrUpdateHandle()">新建</el-button>
|
||||
</div>
|
||||
<div class="JNPF-common-head-right"></div>
|
||||
</div>
|
||||
<JNPF-table v-loading="listLoading" :data="list" @row-click="showMachineList">
|
||||
<el-table-column prop="userName" label="人员名称" align="center"/>
|
||||
<el-table-column prop="userNo" label="人员编码" align="center"/>
|
||||
<el-table-column prop="classGroup" label="所属班组" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ getClassGroupName(scope.row.classGroup) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="enabledStatus" label="启用状态" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="scope.row.enabledStatus == 1 ? 'success' : 'info'" size="small">
|
||||
{{ scope.row.enabledStatus == 1 ? '启用' : '未启用' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" align="center"/>
|
||||
<el-table-column prop="createUserName" label="创建人" align="center"/>
|
||||
<el-table-column prop="creatorTime" label="创建时间" align="center" :formatter="jnpf.tableDateFormat1"/>
|
||||
<el-table-column label="操作" fixed="right" align="center" width="100">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click.stop="addOrUpdateHandle(scope.row)">编辑</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</JNPF-table>
|
||||
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize"
|
||||
@pagination="initData" />
|
||||
</div>
|
||||
</div>
|
||||
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from "@/utils/request";
|
||||
import { mapGetters } from "vuex";
|
||||
import JNPFForm from "./form.vue";
|
||||
import machineList from "./machineList.vue";
|
||||
import machineDetail from "./machineDetail.vue";
|
||||
import jnpf from "@/utils/jnpf";
|
||||
|
||||
export default {
|
||||
name: "usermachine",
|
||||
components: {
|
||||
JNPFForm,
|
||||
machineList,
|
||||
machineDetail,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
query: {
|
||||
userName: undefined,
|
||||
userNo: undefined,
|
||||
classGroup: undefined,
|
||||
enabledStatus: undefined,
|
||||
},
|
||||
list: [],
|
||||
listLoading: false,
|
||||
total: 0,
|
||||
listQuery: {
|
||||
currentPage: 1,
|
||||
pageSize: 20,
|
||||
sort: "desc",
|
||||
sidx: "",
|
||||
},
|
||||
formVisible: false,
|
||||
classGroupOptions: [
|
||||
{ fullName: "甲", id: "甲" },
|
||||
{ fullName: "乙", id: "乙" },
|
||||
{ fullName: "丙", id: "丙" },
|
||||
{ fullName: "丁", id: "丁" },
|
||||
],
|
||||
classGroupProps: { label: "fullName", value: "id" },
|
||||
enabledStatusOptions: [
|
||||
{ fullName: "启用", id: 1 },
|
||||
{ fullName: "未启用", id: 2 },
|
||||
],
|
||||
enabledStatusProps: { label: "fullName", value: "id" },
|
||||
// 机台选择弹窗(用于form.vue)
|
||||
machineDialogVisible: false,
|
||||
// 机台详情弹窗(用于显示用户机台列表)
|
||||
machineDetailVisible: false,
|
||||
currentUserName: "",
|
||||
currentUserMachineId: "",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
jnpf() {
|
||||
return jnpf;
|
||||
},
|
||||
...mapGetters(["userInfo"]),
|
||||
menuId() {
|
||||
return this.$route.meta.modelId || "";
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.initData();
|
||||
},
|
||||
methods: {
|
||||
getClassGroupName(group) {
|
||||
const option = this.classGroupOptions.find(item => item.id === group);
|
||||
return option ? option.fullName : group;
|
||||
},
|
||||
initData() {
|
||||
this.listLoading = true;
|
||||
let _query = {
|
||||
...this.listQuery,
|
||||
...this.query,
|
||||
dataType: 0,
|
||||
};
|
||||
request({
|
||||
url: `/api/example/userMachine/getList`,
|
||||
method: "post",
|
||||
data: _query,
|
||||
}).then((res) => {
|
||||
this.list = res.data.list || [];
|
||||
this.total = res.data.pagination.total;
|
||||
this.listLoading = false;
|
||||
});
|
||||
},
|
||||
addOrUpdateHandle(row) {
|
||||
let id = row ? row.id : "";
|
||||
this.formVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.JNPFForm.init(id);
|
||||
});
|
||||
},
|
||||
search() {
|
||||
this.listQuery.currentPage = 1;
|
||||
this.listQuery.pageSize = 20;
|
||||
this.initData();
|
||||
},
|
||||
refresh(isRefresh) {
|
||||
this.formVisible = false;
|
||||
if (isRefresh) this.search();
|
||||
},
|
||||
reset() {
|
||||
this.query = {
|
||||
userName: undefined,
|
||||
userNo: undefined,
|
||||
classGroup: undefined,
|
||||
enabledStatus: undefined,
|
||||
};
|
||||
this.search();
|
||||
},
|
||||
// 查看用户所属机台
|
||||
showMachineList(row) {
|
||||
this.currentUserName = row.userName;
|
||||
this.currentUserMachineId = row.id;
|
||||
this.machineDetailVisible = true;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user