feat(eqmainconfig): 添加设备点检保养配置功能
This commit is contained in:
parent
01c4d749f1
commit
b0343c7dd6
@ -0,0 +1,11 @@
|
|||||||
|
package jnpf.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigItemEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备点检/保养配置子表 Mapper
|
||||||
|
*/
|
||||||
|
public interface EqMainConfigItemMapper extends BaseMapper<EqMainConfigItemEntity> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package jnpf.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备点检/保养配置 Mapper
|
||||||
|
*/
|
||||||
|
public interface EqMainConfigMapper extends BaseMapper<EqMainConfigEntity> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package jnpf.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigItemEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备点检/保养配置子表 Service
|
||||||
|
*/
|
||||||
|
public interface EqMainConfigItemService extends IService<EqMainConfigItemEntity> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
package jnpf.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigEntity;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigForm;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigPagination;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备点检/保养配置 Service
|
||||||
|
*/
|
||||||
|
public interface EqMainConfigService extends IService<EqMainConfigEntity> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表查询
|
||||||
|
* @param pagination 分页参数
|
||||||
|
* @return 列表数据
|
||||||
|
*/
|
||||||
|
List<EqMainConfigEntity> getList(EqMainConfigPagination pagination);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情查询(包含子表)
|
||||||
|
* @param id 主键
|
||||||
|
* @return 实体对象
|
||||||
|
*/
|
||||||
|
EqMainConfigEntity getInfo(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
* @param entity 实体对象
|
||||||
|
*/
|
||||||
|
void create(EqMainConfigEntity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
* @param id 主键
|
||||||
|
* @param entity 实体对象
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean update(Integer id, EqMainConfigEntity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
* @param entity 实体对象
|
||||||
|
*/
|
||||||
|
void delete(EqMainConfigEntity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证表单
|
||||||
|
* @param form 表单对象
|
||||||
|
* @param i 0新增-1修改
|
||||||
|
* @return 错误信息
|
||||||
|
*/
|
||||||
|
String checkForm(EqMainConfigForm form, int i);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存或更新(包含子表)
|
||||||
|
* @param form 表单对象
|
||||||
|
* @param id 主键
|
||||||
|
* @param isSave 是否新增
|
||||||
|
* @throws Exception 异常
|
||||||
|
*/
|
||||||
|
void saveOrUpdate(EqMainConfigForm form, Integer id, boolean isSave) throws Exception;
|
||||||
|
}
|
||||||
@ -0,0 +1,119 @@
|
|||||||
|
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.eqmain.EqMainConfigEntity;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigForm;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigItemEntity;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigPagination;
|
||||||
|
import jnpf.service.EqMainConfigItemService;
|
||||||
|
import jnpf.service.EqMainConfigService;
|
||||||
|
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 = "EqMainConfig")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/example/eqmainconfig")
|
||||||
|
public class EqMainConfigController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EqMainConfigService eqMainConfigService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EqMainConfigItemService eqMainConfigItemService;
|
||||||
|
|
||||||
|
@Operation(summary = "获取配置列表")
|
||||||
|
@PostMapping("/getList")
|
||||||
|
public ActionResult getList(@RequestBody EqMainConfigPagination pagination) {
|
||||||
|
List<EqMainConfigEntity> list = eqMainConfigService.getList(pagination);
|
||||||
|
List<Map<String, Object>> realList = list.stream()
|
||||||
|
.map(JsonUtil::entityToMap)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
PageListVO vo = new PageListVO();
|
||||||
|
vo.setList(realList);
|
||||||
|
PaginationVO page = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||||
|
vo.setPagination(page);
|
||||||
|
return ActionResult.success(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取配置详情(含子表)")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public ActionResult info(@PathVariable("id") Integer id) {
|
||||||
|
EqMainConfigEntity entity = eqMainConfigService.getInfo(id);
|
||||||
|
if (entity != null) {
|
||||||
|
Map<String, Object> result = JsonUtil.entityToMap(entity);
|
||||||
|
|
||||||
|
List<EqMainConfigItemEntity> itemList = eqMainConfigItemService.lambdaQuery()
|
||||||
|
.eq(EqMainConfigItemEntity::getEqMainId, id)
|
||||||
|
.orderByAsc(EqMainConfigItemEntity::getSeqNo)
|
||||||
|
.list();
|
||||||
|
result.put("itemList", itemList.stream()
|
||||||
|
.map(JsonUtil::entityToMap)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
|
return ActionResult.success(result);
|
||||||
|
}
|
||||||
|
return ActionResult.fail("数据不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新建配置")
|
||||||
|
@PostMapping
|
||||||
|
public ActionResult create(@RequestBody @Valid EqMainConfigForm form) {
|
||||||
|
String errorMsg = eqMainConfigService.checkForm(form, 0);
|
||||||
|
if (StringUtil.isNotEmpty(errorMsg)) {
|
||||||
|
return ActionResult.fail(errorMsg);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
eqMainConfigService.saveOrUpdate(form, null, true);
|
||||||
|
return ActionResult.success("新建成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ActionResult.fail("新建数据失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新配置")
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public ActionResult update(@PathVariable("id") Integer id, @RequestBody @Valid EqMainConfigForm form) {
|
||||||
|
form.setId(id);
|
||||||
|
String errorMsg = eqMainConfigService.checkForm(form, 1);
|
||||||
|
if (StringUtil.isNotEmpty(errorMsg)) {
|
||||||
|
return ActionResult.fail(errorMsg);
|
||||||
|
}
|
||||||
|
EqMainConfigEntity entity = eqMainConfigService.getInfo(id);
|
||||||
|
if (entity != null) {
|
||||||
|
try {
|
||||||
|
eqMainConfigService.saveOrUpdate(form, 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") Integer id) {
|
||||||
|
EqMainConfigEntity entity = eqMainConfigService.getInfo(id);
|
||||||
|
if (entity != null) {
|
||||||
|
eqMainConfigService.delete(entity);
|
||||||
|
return ActionResult.success("删除成功");
|
||||||
|
}
|
||||||
|
return ActionResult.fail("删除失败,数据不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
package jnpf.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import jnpf.mapper.EqMainConfigItemMapper;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigItemEntity;
|
||||||
|
import jnpf.service.EqMainConfigItemService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备点检/保养配置子表 ServiceImpl
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class EqMainConfigItemServiceImpl extends ServiceImpl<EqMainConfigItemMapper, EqMainConfigItemEntity> implements EqMainConfigItemService {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,159 @@
|
|||||||
|
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.EqMainConfigMapper;
|
||||||
|
import jnpf.model.eqmain.*;
|
||||||
|
import jnpf.service.EqMainConfigItemService;
|
||||||
|
import jnpf.service.EqMainConfigService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备点检/保养配置 ServiceImpl
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class EqMainConfigServiceImpl extends ServiceImpl<EqMainConfigMapper, EqMainConfigEntity> implements EqMainConfigService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EqMainConfigItemService eqMainConfigItemService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EqMainConfigEntity> getList(EqMainConfigPagination pagination) {
|
||||||
|
LambdaQueryWrapper<EqMainConfigEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(pagination.getEqCode())) {
|
||||||
|
wrapper.like(EqMainConfigEntity::getEqCode, pagination.getEqCode());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(pagination.getEqName())) {
|
||||||
|
wrapper.like(EqMainConfigEntity::getEqName, pagination.getEqName());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(pagination.getMainName())) {
|
||||||
|
wrapper.like(EqMainConfigEntity::getMainName, pagination.getMainName());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(pagination.getMainType())) {
|
||||||
|
wrapper.eq(EqMainConfigEntity::getMainType, pagination.getMainType());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(pagination.getDeptId())) {
|
||||||
|
wrapper.eq(EqMainConfigEntity::getDeptId, pagination.getDeptId());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(pagination.getUserId())) {
|
||||||
|
wrapper.eq(EqMainConfigEntity::getUserId, pagination.getUserId());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(pagination.getEnabledStatus())) {
|
||||||
|
wrapper.eq(EqMainConfigEntity::getEnabledStatus, pagination.getEnabledStatus());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(pagination.getKeyword())) {
|
||||||
|
String keyword = pagination.getKeyword();
|
||||||
|
wrapper.and(w -> w.like(EqMainConfigEntity::getEqCode, keyword)
|
||||||
|
.or()
|
||||||
|
.like(EqMainConfigEntity::getEqName, keyword)
|
||||||
|
.or()
|
||||||
|
.like(EqMainConfigEntity::getMainName, keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.eq(EqMainConfigEntity::getDeleteMark, 0);
|
||||||
|
wrapper.orderByDesc(EqMainConfigEntity::getId);
|
||||||
|
|
||||||
|
if ("0".equals(pagination.getDataType())) {
|
||||||
|
Page<EqMainConfigEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||||
|
IPage<EqMainConfigEntity> configIPage = this.page(page, wrapper);
|
||||||
|
pagination.setData(configIPage.getRecords(), configIPage.getTotal());
|
||||||
|
return configIPage.getRecords();
|
||||||
|
} else {
|
||||||
|
return this.list(wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EqMainConfigEntity getInfo(Integer id) {
|
||||||
|
QueryWrapper<EqMainConfigEntity> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.lambda().eq(EqMainConfigEntity::getId, id);
|
||||||
|
return this.getOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void create(EqMainConfigEntity entity) {
|
||||||
|
this.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(Integer id, EqMainConfigEntity entity) {
|
||||||
|
return this.updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(EqMainConfigEntity entity) {
|
||||||
|
if (entity != null) {
|
||||||
|
this.removeById(entity.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String checkForm(EqMainConfigForm form, int i) {
|
||||||
|
boolean isUp = ObjectUtil.isNotEmpty(form.getId());
|
||||||
|
String countRecover = "";
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(form.getEqCode())) {
|
||||||
|
LambdaQueryWrapper<EqMainConfigEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(EqMainConfigEntity::getEqCode, form.getEqCode());
|
||||||
|
wrapper.eq(EqMainConfigEntity::getMainType, form.getMainType());
|
||||||
|
if (isUp) {
|
||||||
|
wrapper.ne(EqMainConfigEntity::getId, form.getId());
|
||||||
|
}
|
||||||
|
long count = this.count(wrapper);
|
||||||
|
if (count > 0) {
|
||||||
|
countRecover += "该设备、类型已存在保养配置,请确认!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return countRecover;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void saveOrUpdate(EqMainConfigForm form, Integer id, boolean isSave) throws Exception {
|
||||||
|
EqMainConfigEntity entity = getInfo(id);
|
||||||
|
if (entity == null) {
|
||||||
|
entity = new EqMainConfigEntity();
|
||||||
|
}
|
||||||
|
BeanUtils.copyProperties(form, entity);
|
||||||
|
|
||||||
|
if (isSave) {
|
||||||
|
this.save(entity);
|
||||||
|
} else {
|
||||||
|
this.updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer mainId = entity.getId();
|
||||||
|
|
||||||
|
List<EqMainConfigItemEntity> newItemList = new ArrayList<>();
|
||||||
|
if (form.getItemList() != null && !form.getItemList().isEmpty()) {
|
||||||
|
for (int i = 0; i < form.getItemList().size(); i++) {
|
||||||
|
EqMainConfigItemForm itemForm = form.getItemList().get(i);
|
||||||
|
EqMainConfigItemEntity itemEntity = new EqMainConfigItemEntity();
|
||||||
|
BeanUtils.copyProperties(itemForm, itemEntity);
|
||||||
|
itemEntity.setEqMainId(mainId);
|
||||||
|
newItemList.add(itemEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<EqMainConfigItemEntity> deleteWrapper = new LambdaQueryWrapper<>();
|
||||||
|
deleteWrapper.eq(EqMainConfigItemEntity::getEqMainId, mainId);
|
||||||
|
eqMainConfigItemService.remove(deleteWrapper);
|
||||||
|
|
||||||
|
if (!newItemList.isEmpty()) {
|
||||||
|
eqMainConfigItemService.saveBatch(newItemList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,120 @@
|
|||||||
|
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.eqmain.EqMainConfigEntity;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigForm;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigItemEntity;
|
||||||
|
import jnpf.model.eqmain.EqMainConfigPagination;
|
||||||
|
import jnpf.service.EqMainConfigItemService;
|
||||||
|
import jnpf.service.EqMainConfigService;
|
||||||
|
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 = "EqMainConfig")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/example/eqmainconfig")
|
||||||
|
public class EqMainConfigController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EqMainConfigService eqMainConfigService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EqMainConfigItemService eqMainConfigItemService;
|
||||||
|
|
||||||
|
@Operation(summary = "获取配置列表")
|
||||||
|
@PostMapping("/getList")
|
||||||
|
public ActionResult getList(@RequestBody EqMainConfigPagination pagination) {
|
||||||
|
List<EqMainConfigEntity> list = eqMainConfigService.getList(pagination);
|
||||||
|
List<Map<String, Object>> realList = list.stream()
|
||||||
|
.map(JsonUtil::entityToMap)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
PageListVO vo = new PageListVO();
|
||||||
|
vo.setList(realList);
|
||||||
|
PaginationVO page = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||||
|
vo.setPagination(page);
|
||||||
|
return ActionResult.success(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取配置详情(含子表)")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public ActionResult info(@PathVariable("id") Integer id) {
|
||||||
|
EqMainConfigEntity entity = eqMainConfigService.getInfo(id);
|
||||||
|
if (entity != null) {
|
||||||
|
Map<String, Object> result = JsonUtil.entityToMap(entity);
|
||||||
|
|
||||||
|
List<EqMainConfigItemEntity> itemList = eqMainConfigItemService.lambdaQuery()
|
||||||
|
.eq(EqMainConfigItemEntity::getEqMainId, id)
|
||||||
|
.orderByAsc(EqMainConfigItemEntity::getSeqNo)
|
||||||
|
.list();
|
||||||
|
result.put("itemList", itemList.stream()
|
||||||
|
.map(JsonUtil::entityToMap)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
|
return ActionResult.success(result);
|
||||||
|
}
|
||||||
|
return ActionResult.fail("数据不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新建配置")
|
||||||
|
@PostMapping
|
||||||
|
public ActionResult create(@RequestBody @Valid EqMainConfigForm form) {
|
||||||
|
String errorMsg = eqMainConfigService.checkForm(form, 0);
|
||||||
|
if (StringUtil.isNotEmpty(errorMsg)) {
|
||||||
|
return ActionResult.fail(errorMsg);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
eqMainConfigService.saveOrUpdate(form, null, true);
|
||||||
|
return ActionResult.success("新建成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ActionResult.fail("新建数据失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新配置")
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public ActionResult update(@PathVariable("id") Integer id, @RequestBody @Valid EqMainConfigForm form) {
|
||||||
|
form.setId(id);
|
||||||
|
String errorMsg = eqMainConfigService.checkForm(form, 1);
|
||||||
|
if (StringUtil.isNotEmpty(errorMsg)) {
|
||||||
|
return ActionResult.fail(errorMsg);
|
||||||
|
}
|
||||||
|
EqMainConfigEntity entity = eqMainConfigService.getInfo(id);
|
||||||
|
if (entity != null) {
|
||||||
|
try {
|
||||||
|
eqMainConfigService.saveOrUpdate(form, 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") Integer id) {
|
||||||
|
EqMainConfigEntity entity = eqMainConfigService.getInfo(id);
|
||||||
|
if (entity != null) {
|
||||||
|
eqMainConfigService.delete(entity);
|
||||||
|
return ActionResult.success("删除成功");
|
||||||
|
}
|
||||||
|
return ActionResult.fail("删除失败,数据不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
package jnpf.model.eqmain;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备点检/保养配置主表
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("tba_eq_main_config")
|
||||||
|
public class EqMainConfigEntity {
|
||||||
|
|
||||||
|
@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(value = "enabled_status", updateStrategy = FieldStrategy.IGNORED)
|
||||||
|
private Integer enabledStatus;
|
||||||
|
|
||||||
|
@TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED)
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@TableField("eq_id")
|
||||||
|
private Integer eqId;
|
||||||
|
|
||||||
|
@TableField("eq_code")
|
||||||
|
private String eqCode;
|
||||||
|
|
||||||
|
@TableField("eq_name")
|
||||||
|
private String eqName;
|
||||||
|
|
||||||
|
@TableField("main_name")
|
||||||
|
private String mainName;
|
||||||
|
|
||||||
|
@TableField("main_type")
|
||||||
|
private String mainType;
|
||||||
|
|
||||||
|
@TableField("cycle_unit")
|
||||||
|
private String cycleUnit;
|
||||||
|
|
||||||
|
@TableField("plan_start_dtime")
|
||||||
|
private Date planStartDtime;
|
||||||
|
|
||||||
|
@TableField("dept_id")
|
||||||
|
private String deptId;
|
||||||
|
|
||||||
|
@TableField("dept_name")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
@TableField("user_id")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
@TableField("user_name")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@TableField("main_post")
|
||||||
|
private String mainPost;
|
||||||
|
}
|
||||||
@ -0,0 +1,75 @@
|
|||||||
|
|
||||||
|
package jnpf.model.eqmain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备点检/保养配置 Form
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EqMainConfigForm {
|
||||||
|
|
||||||
|
@Schema(description = "主键")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@NotBlank(message = "设备编码不能为空")
|
||||||
|
@Schema(description = "设备编码")
|
||||||
|
private String eqCode;
|
||||||
|
|
||||||
|
@NotBlank(message = "设备名称不能为空")
|
||||||
|
@Schema(description = "设备名称")
|
||||||
|
private String eqName;
|
||||||
|
|
||||||
|
@Schema(description = "设备id")
|
||||||
|
private Integer eqId;
|
||||||
|
|
||||||
|
@NotBlank(message = "方案名称不能为空")
|
||||||
|
@Schema(description = "方案名称")
|
||||||
|
private String mainName;
|
||||||
|
|
||||||
|
@Schema(description = "类型(1 点检 2 保养 3润滑)")
|
||||||
|
private String mainType;
|
||||||
|
|
||||||
|
@Schema(description = "周期(1 班 2 日 3 月 4 季度 5 年 )")
|
||||||
|
private String cycleUnit;
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||||
|
@Schema(description = "下次执行时间")
|
||||||
|
private Date planStartDtime;
|
||||||
|
|
||||||
|
@Schema(description = "责任部门id")
|
||||||
|
private String deptId;
|
||||||
|
|
||||||
|
@Schema(description = "责任部门名称")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
@Schema(description = "责任人id")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
@Schema(description = "责任人")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "负责岗位")
|
||||||
|
private String mainPost;
|
||||||
|
|
||||||
|
@Schema(description = "状态(1启用 2未启用)")
|
||||||
|
private Integer enabledStatus;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "流程ID")
|
||||||
|
private String flowId;
|
||||||
|
|
||||||
|
@Schema(description = "流程任务ID")
|
||||||
|
private String flowTaskId;
|
||||||
|
|
||||||
|
@Schema(description = "子表数据")
|
||||||
|
private List<EqMainConfigItemForm> itemList;
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
package jnpf.model.eqmain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备点检/保养配置子表
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("tba_eq_main_config_item")
|
||||||
|
public class EqMainConfigItemEntity {
|
||||||
|
|
||||||
|
@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(value = "enabled_status", updateStrategy = FieldStrategy.IGNORED)
|
||||||
|
private Integer enabledStatus;
|
||||||
|
|
||||||
|
@TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED)
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@TableField("eq_main_id")
|
||||||
|
private Integer eqMainId;
|
||||||
|
|
||||||
|
@TableField("item_name")
|
||||||
|
private String itemName;
|
||||||
|
|
||||||
|
@TableField("check_part")
|
||||||
|
private String checkPart;
|
||||||
|
|
||||||
|
@TableField("check_method")
|
||||||
|
private String checkMethod;
|
||||||
|
|
||||||
|
@TableField("qualified_stand")
|
||||||
|
private String qualifiedStand;
|
||||||
|
|
||||||
|
@TableField("check_tool")
|
||||||
|
private String checkTool;
|
||||||
|
|
||||||
|
@TableField("seq_no")
|
||||||
|
private Integer seqNo;
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package jnpf.model.eqmain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备点检/保养配置子表 Form
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EqMainConfigItemForm {
|
||||||
|
|
||||||
|
@Schema(description = "主键")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Schema(description = "主表id")
|
||||||
|
private Integer eqMainId;
|
||||||
|
|
||||||
|
@Schema(description = "保养项目")
|
||||||
|
private String itemName;
|
||||||
|
|
||||||
|
@Schema(description = "检查/保养部位")
|
||||||
|
private String checkPart;
|
||||||
|
|
||||||
|
@Schema(description = "检查/保养方法")
|
||||||
|
private String checkMethod;
|
||||||
|
|
||||||
|
@Schema(description = "标准/要求")
|
||||||
|
private String qualifiedStand;
|
||||||
|
|
||||||
|
@Schema(description = "所需工具")
|
||||||
|
private String checkTool;
|
||||||
|
|
||||||
|
@Schema(description = "项目序号")
|
||||||
|
private Integer seqNo;
|
||||||
|
|
||||||
|
@Schema(description = "状态(1启用 2未启用)")
|
||||||
|
private Integer enabledStatus;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package jnpf.model.eqmain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jnpf.base.Pagination;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备点检/保养配置 Pagination
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EqMainConfigPagination extends Pagination {
|
||||||
|
|
||||||
|
@Schema(description = "数据类型")
|
||||||
|
private String dataType;
|
||||||
|
|
||||||
|
@Schema(description = "设备编码")
|
||||||
|
private String eqCode;
|
||||||
|
|
||||||
|
@Schema(description = "设备名称")
|
||||||
|
private String eqName;
|
||||||
|
|
||||||
|
@Schema(description = "方案名称")
|
||||||
|
private String mainName;
|
||||||
|
|
||||||
|
@Schema(description = "类型(1 点检 2 保养 3润滑)")
|
||||||
|
private String mainType;
|
||||||
|
|
||||||
|
@Schema(description = "责任部门id")
|
||||||
|
private Integer deptId;
|
||||||
|
|
||||||
|
@Schema(description = "责任人id")
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
@Schema(description = "状态(1启用 2未启用)")
|
||||||
|
private Integer enabledStatus;
|
||||||
|
|
||||||
|
@Schema(description = "关键词")
|
||||||
|
private String keyword;
|
||||||
|
}
|
||||||
@ -59,9 +59,9 @@ public class MachineForm {
|
|||||||
private String flowTaskId;
|
private String flowTaskId;
|
||||||
|
|
||||||
@Schema(description = "所属产线id")
|
@Schema(description = "所属产线id")
|
||||||
private Long belgLineId;
|
private String belgLineId;
|
||||||
|
|
||||||
@Schema(description = "所属工序id")
|
@Schema(description = "所属工序id")
|
||||||
private Long belgProcId;
|
private String belgProcId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,10 @@ export const dictMaps = {
|
|||||||
enabledStatus: { '1': '启用', '2': '未启用' },
|
enabledStatus: { '1': '启用', '2': '未启用' },
|
||||||
// 订单类型
|
// 订单类型
|
||||||
ordType: { '1': '备库订单', '2': '销售订单' },
|
ordType: { '1': '备库订单', '2': '销售订单' },
|
||||||
|
// 设备维护类型
|
||||||
|
mainType: { '1': '点检', '2': '保养', '3': '润滑' },
|
||||||
|
// 周期单位
|
||||||
|
cycleUnit: { '1': '班', '2': '日', '3': '月', '4': '季度', '5': '年' },
|
||||||
};
|
};
|
||||||
|
|
||||||
// 根据映射自动生成下拉选项(使用id和fullName字段)
|
// 根据映射自动生成下拉选项(使用id和fullName字段)
|
||||||
@ -36,5 +40,7 @@ export function getLabel(type, value) {
|
|||||||
export const paramTypeOptions = dictOptions.paramType;
|
export const paramTypeOptions = dictOptions.paramType;
|
||||||
export const enabledStatusOptions = dictOptions.enabledStatus;
|
export const enabledStatusOptions = dictOptions.enabledStatus;
|
||||||
export const ordTypeOptions = dictOptions.ordType;
|
export const ordTypeOptions = dictOptions.ordType;
|
||||||
|
export const mainTypeOptions = dictOptions.mainType;
|
||||||
|
export const cycleUnitOptions = dictOptions.cycleUnit;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,68 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
import { getDataInterfaceRes } from '@/api/systemData/dataInterface'
|
||||||
|
|
||||||
|
// 获取设备列表
|
||||||
|
export function getEquipmentList(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/example/equipment/getList',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取配置列表
|
||||||
|
export function getEqMainConfigList(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/example/eqmainconfig/getList',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取配置详情
|
||||||
|
export function getEqMainConfigInfo(id) {
|
||||||
|
return request({
|
||||||
|
url: `/api/example/eqmainconfig/${id}`,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新建配置
|
||||||
|
export function createEqMainConfig(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/example/eqmainconfig',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新配置
|
||||||
|
export function updateEqMainConfig(id, data) {
|
||||||
|
return request({
|
||||||
|
url: `/api/example/eqmainconfig/${id}`,
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除配置
|
||||||
|
export function deleteEqMainConfig(id) {
|
||||||
|
return request({
|
||||||
|
url: `/api/example/eqmainconfig/${id}`,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取部门列表(使用数据接口)
|
||||||
|
export function getDeptList() {
|
||||||
|
return getDataInterfaceRes('811583643129479301')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取人员列表(通过部门ID)
|
||||||
|
export function getUserList(deptId) {
|
||||||
|
return request({
|
||||||
|
url: `/api/example/exampleOrder/getByDeptId/${deptId}`,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,173 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
:title="'详情'"
|
||||||
|
:visible.sync="dialogVisible"
|
||||||
|
width="1200px"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
@close="handleClose"
|
||||||
|
>
|
||||||
|
<el-form :model="dataForm" size="small" label-width="100px" label-position="right">
|
||||||
|
<template v-if="!loading">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="设备名称">
|
||||||
|
<el-input :value="dataForm.eqName" disabled style="width: 100%;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="设备编码">
|
||||||
|
<el-input :value="dataForm.eqCode" disabled style="width: 100%;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="方案名称">
|
||||||
|
<el-input :value="dataForm.mainName" disabled style="width: 100%;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="维护类型">
|
||||||
|
<el-input :value="getMainTypeLabel(dataForm.mainType)" disabled style="width: 100%;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="周期单位">
|
||||||
|
<el-input :value="getCycleUnitLabel(dataForm.cycleUnit)" disabled style="width: 100%;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="下次执行时间">
|
||||||
|
<el-input :value="formatDate(dataForm.planStartDtime)" disabled style="width: 100%;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="责任部门">
|
||||||
|
<el-input :value="dataForm.deptName" disabled style="width: 100%;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="责任人">
|
||||||
|
<el-input :value="dataForm.userName" disabled style="width: 100%;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="负责岗位">
|
||||||
|
<el-input :value="dataForm.mainPost" disabled style="width: 100%;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="启用状态">
|
||||||
|
<el-input :value="getEnabledStatusLabel(dataForm.enabledStatus)" disabled style="width: 100%;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="16">
|
||||||
|
<el-form-item label="备注">
|
||||||
|
<el-input :value="dataForm.remark" disabled style="width: 100%;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<div style="margin-bottom: 10px; display: flex; align-items: center;">
|
||||||
|
<span style="font-weight: bold;">项目信息</span>
|
||||||
|
</div>
|
||||||
|
<el-table :data="dataForm.itemList" border style="width: 100%;" size="small">
|
||||||
|
<el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
|
||||||
|
<el-table-column label="保养项目" prop="itemName" align="center"></el-table-column>
|
||||||
|
<el-table-column label="检查/保养部位" prop="checkPart" align="center"></el-table-column>
|
||||||
|
<el-table-column label="检查/保养方法" prop="checkMethod" align="center"></el-table-column>
|
||||||
|
<el-table-column label="标准/要求" prop="qualifiedStand" align="center"></el-table-column>
|
||||||
|
<el-table-column label="所需工具" prop="checkTool" align="center"></el-table-column>
|
||||||
|
<el-table-column label="项目序号" prop="seqNo" align="center"></el-table-column>
|
||||||
|
<el-table-column label="备注" prop="remark" align="center"></el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="handleClose">关 闭</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {getEqMainConfigInfo} from "./api";
|
||||||
|
import {getLabel} from "../common/dict";
|
||||||
|
import jnpf from "@/utils/jnpf";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "EqmainconfigDetail",
|
||||||
|
components: {},
|
||||||
|
props: [],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
loading: false,
|
||||||
|
jnpf: jnpf,
|
||||||
|
dataForm: {
|
||||||
|
id: '',
|
||||||
|
eqId: undefined,
|
||||||
|
eqCode: undefined,
|
||||||
|
eqName: undefined,
|
||||||
|
mainName: undefined,
|
||||||
|
mainType: undefined,
|
||||||
|
cycleUnit: undefined,
|
||||||
|
planStartDtime: undefined,
|
||||||
|
deptId: undefined,
|
||||||
|
deptName: undefined,
|
||||||
|
userId: undefined,
|
||||||
|
userName: undefined,
|
||||||
|
mainPost: undefined,
|
||||||
|
enabledStatus: "1",
|
||||||
|
remark: undefined,
|
||||||
|
itemList: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
init(id) {
|
||||||
|
this.dialogVisible = true
|
||||||
|
this.loading = true
|
||||||
|
getEqMainConfigInfo(id).then((res) => {
|
||||||
|
const data = res.data
|
||||||
|
this.dataForm = {
|
||||||
|
...data,
|
||||||
|
enabledStatus: String(data.enabledStatus || '1'),
|
||||||
|
itemList: data.itemList || []
|
||||||
|
}
|
||||||
|
this.loading = false
|
||||||
|
}).catch(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getMainTypeLabel(value) {
|
||||||
|
return getLabel('mainType', value)
|
||||||
|
},
|
||||||
|
getCycleUnitLabel(value) {
|
||||||
|
return getLabel('cycleUnit', value)
|
||||||
|
},
|
||||||
|
getEnabledStatusLabel(value) {
|
||||||
|
return getLabel('enabledStatus', value)
|
||||||
|
},
|
||||||
|
formatDate(timestamp) {
|
||||||
|
if (!timestamp) return ''
|
||||||
|
const date = new Date(timestamp)
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||||
|
const day = String(date.getDate()).padStart(2, '0')
|
||||||
|
const hours = String(date.getHours()).padStart(2, '0')
|
||||||
|
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||||
|
return `${year}-${month}-${day} ${hours}:${minutes}`
|
||||||
|
},
|
||||||
|
handleClose() {
|
||||||
|
this.dialogVisible = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
467
jnpf-java-boot/jnpf-web/src/views/example/eqmainconfig/form.vue
Normal file
467
jnpf-java-boot/jnpf-web/src/views/example/eqmainconfig/form.vue
Normal file
@ -0,0 +1,467 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-dialog
|
||||||
|
:title="!dataForm.id ? '新建' : '编辑'"
|
||||||
|
:visible.sync="dialogVisible"
|
||||||
|
width="1200px"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
@close="handleClose"
|
||||||
|
>
|
||||||
|
<el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="120px" label-position="right">
|
||||||
|
<template v-if="!loading">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="设备名称" prop="eqCode">
|
||||||
|
<el-input v-model="dataForm.eqName" placeholder="请选择设备" clearable readonly :disabled="!!dataForm.id" @click.native="selectEquipment">
|
||||||
|
<i slot="suffix" class="el-input__icon el-icon-search" style="cursor: pointer;"></i>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="类型" prop="mainType">
|
||||||
|
<JnpfSelect v-model="dataForm.mainType" placeholder="请选择类型" :options="mainTypeOptions" :disabled="!!dataForm.id" :props="mainTypeProps" clearable :style="{ width: '100%' }">
|
||||||
|
</JnpfSelect>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="方案名称" prop="mainName">
|
||||||
|
<JnpfInput v-model="dataForm.mainName" placeholder="请输入方案名称" clearable>
|
||||||
|
</JnpfInput>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="周期" prop="cycleUnit">
|
||||||
|
<JnpfSelect v-model="dataForm.cycleUnit" placeholder="请选择周期单位" :options="cycleUnitOptions" :props="cycleUnitProps" clearable :style="{ width: '100%' }">
|
||||||
|
</JnpfSelect>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="下次执行时间" prop="planStartDtime">
|
||||||
|
<JnpfDatePicker v-model="dataForm.planStartDtime"
|
||||||
|
placeholder="请选择下次执行时间"
|
||||||
|
clearable
|
||||||
|
:style='{ "width": "100%" }'
|
||||||
|
format="yyyy-MM-dd HH:mm"
|
||||||
|
type="datetime">
|
||||||
|
</JnpfDatePicker>
|
||||||
|
</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" :style="{ width: '100%' }">
|
||||||
|
</JnpfSelect>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="责任部门" prop="deptId">
|
||||||
|
<el-select v-model="dataForm.deptId" placeholder="请选择责任部门" clearable ref="deptSelect"
|
||||||
|
:style="{ width: '100%' }" @clear="deptIdLabel = ''">
|
||||||
|
<el-option :value="dataForm.deptId" :label="deptIdLabel" style="height: auto; padding: 0;">
|
||||||
|
<el-tree
|
||||||
|
:data="deptOptions"
|
||||||
|
:props="{ children: 'children', label: 'name' }"
|
||||||
|
@node-click="handleDeptSelect"
|
||||||
|
node-key="id"
|
||||||
|
default-expand-all
|
||||||
|
:expand-on-click-node="true">
|
||||||
|
</el-tree>
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="责任人" prop="userId">
|
||||||
|
<JnpfSelect v-model="dataForm.userId" placeholder="请选择责任人" filterable clearable
|
||||||
|
:style="{ width: '100%' }" :options="userIdOptions"
|
||||||
|
:props="userIdProps" @change="handleUserChange">
|
||||||
|
</JnpfSelect>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="负责岗位" prop="mainPost">
|
||||||
|
<JnpfInput v-model="dataForm.mainPost" placeholder="请输入负责岗位" clearable>
|
||||||
|
</JnpfInput>
|
||||||
|
</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="请输入备注" :autoSize="{ minRows: 2, maxRows: 2 }" type="textarea">
|
||||||
|
</JnpfTextarea>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<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="addItem" style="margin-left: 10px;">新增</el-button>
|
||||||
|
</div>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-table :data="dataForm.itemList" border :show-header="true" style="width: 100%; table-layout: auto;">
|
||||||
|
<el-table-column type="index" label="序号" width="60" align="center"/>
|
||||||
|
<el-table-column prop="itemName" label="*保养项目" min-width="150" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<JnpfInput v-model="scope.row.itemName" clearable>
|
||||||
|
</JnpfInput>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="checkPart" label="*检查/保养部位" min-width="150" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<JnpfInput v-model="scope.row.checkPart" clearable>
|
||||||
|
</JnpfInput>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="checkMethod" label="*检查/保养方法" min-width="150" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<JnpfInput v-model="scope.row.checkMethod" clearable>
|
||||||
|
</JnpfInput>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="qualifiedStand" label="标准/要求" min-width="150" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<JnpfInput v-model="scope.row.qualifiedStand" clearable>
|
||||||
|
</JnpfInput>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="checkTool" label="所需工具" min-width="120" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<JnpfInput v-model="scope.row.checkTool" clearable>
|
||||||
|
</JnpfInput>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="seqNo" label="*项目序号" width="100" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<JnpfInput v-model="scope.row.seqNo" type="number" :step="1">
|
||||||
|
</JnpfInput>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="remark" label="备注" min-width="200" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<JnpfInput v-model="scope.row.remark" clearable>
|
||||||
|
</JnpfInput>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="80" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="text" class="JNPF-table-delBtn" @click="deleteItem(scope.$index)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
</el-dialog>
|
||||||
|
<EquipmentSelect v-if="equipmentSelectVisible" :visible.sync="equipmentSelectVisible" @select="handleEquipmentSelect"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {createEqMainConfig, deleteEqMainConfig, getDeptList, getEqMainConfigInfo, getUserList, updateEqMainConfig} from './api'
|
||||||
|
import EquipmentSelect from '../equipment/select.vue'
|
||||||
|
import {enabledStatusOptions, dictProps, mainTypeOptions, cycleUnitOptions} from '../common/dict'
|
||||||
|
import { getLabel } from '../equipment/equipment'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
EquipmentSelect
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
loading: false,
|
||||||
|
btnLoading: false,
|
||||||
|
equipmentSelectVisible: false,
|
||||||
|
dataForm: {
|
||||||
|
id: '',
|
||||||
|
eqId: undefined,
|
||||||
|
eqCode: undefined,
|
||||||
|
eqName: undefined,
|
||||||
|
mainName: undefined,
|
||||||
|
mainType: undefined,
|
||||||
|
cycleUnit: undefined,
|
||||||
|
planStartDtime: undefined,
|
||||||
|
deptId: undefined,
|
||||||
|
deptName: undefined,
|
||||||
|
userId: undefined,
|
||||||
|
userName: undefined,
|
||||||
|
mainPost: undefined,
|
||||||
|
enabledStatus: "1",
|
||||||
|
remark: undefined,
|
||||||
|
itemList: []
|
||||||
|
},
|
||||||
|
dataRule: {
|
||||||
|
eqCode: [
|
||||||
|
{required: true, message: '请选择设备', trigger: 'change'},
|
||||||
|
],
|
||||||
|
mainName: [
|
||||||
|
{required: true, message: '请输入方案名称', trigger: 'blur'},
|
||||||
|
],
|
||||||
|
mainType: [
|
||||||
|
{required: true, message: '请选择类型', trigger: 'change'},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
deptOptions: [],
|
||||||
|
userIdOptions: [],
|
||||||
|
userIdProps: { 'label': 'realName', 'value': 'id' },
|
||||||
|
deptIdLabel: '',
|
||||||
|
mainTypeOptions: mainTypeOptions,
|
||||||
|
mainTypeProps: dictProps,
|
||||||
|
cycleUnitOptions: cycleUnitOptions,
|
||||||
|
cycleUnitProps: dictProps,
|
||||||
|
enabledStatusOptions: enabledStatusOptions,
|
||||||
|
enabledStatusProps: dictProps
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
init(id) {
|
||||||
|
this.dialogVisible = true
|
||||||
|
this.loading = true
|
||||||
|
// 重置表单数据
|
||||||
|
this.resetForm()
|
||||||
|
this.dataForm.id = id || ''
|
||||||
|
this.loadDeptList().then(() => {
|
||||||
|
if (id) {
|
||||||
|
this.getInfo()
|
||||||
|
} else {
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
resetForm() {
|
||||||
|
this.dataForm = {
|
||||||
|
id: '',
|
||||||
|
eqId: undefined,
|
||||||
|
eqCode: undefined,
|
||||||
|
eqName: undefined,
|
||||||
|
mainName: undefined,
|
||||||
|
mainType: undefined,
|
||||||
|
cycleUnit: undefined,
|
||||||
|
planStartDtime: undefined,
|
||||||
|
deptId: undefined,
|
||||||
|
deptName: undefined,
|
||||||
|
userId: undefined,
|
||||||
|
userName: undefined,
|
||||||
|
mainPost: undefined,
|
||||||
|
enabledStatus: "1",
|
||||||
|
remark: undefined,
|
||||||
|
itemList: []
|
||||||
|
}
|
||||||
|
this.deptIdLabel = ''
|
||||||
|
this.userIdOptions = []
|
||||||
|
},
|
||||||
|
getInfo() {
|
||||||
|
getEqMainConfigInfo(this.dataForm.id).then((res) => {
|
||||||
|
const data = res.data
|
||||||
|
// 逐个赋值,保持响应式
|
||||||
|
Object.keys(data).forEach(key => {
|
||||||
|
if (key !== 'itemList') {
|
||||||
|
if (key === 'enabledStatus') {
|
||||||
|
this.dataForm[key] = String(data[key])
|
||||||
|
} else {
|
||||||
|
this.dataForm[key] = data[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 处理 itemList,保持响应式数组
|
||||||
|
if (data.itemList && Array.isArray(data.itemList)) {
|
||||||
|
this.dataForm.itemList = [...data.itemList]
|
||||||
|
} else {
|
||||||
|
this.dataForm.itemList = []
|
||||||
|
}
|
||||||
|
// 设置责任部门名称
|
||||||
|
if (this.dataForm.deptId) {
|
||||||
|
this.deptIdLabel = this.findDeptNameById(this.dataForm.deptId, this.deptOptions)
|
||||||
|
// 加载该部门下的用户
|
||||||
|
getUserList(this.dataForm.deptId).then((res) => {
|
||||||
|
this.userIdOptions = res.data || []
|
||||||
|
// 设置责任人名称
|
||||||
|
if (this.dataForm.userId) {
|
||||||
|
const user = this.userIdOptions.find(item => String(item.id) === String(this.dataForm.userId))
|
||||||
|
if (user) {
|
||||||
|
this.dataForm.userName = user.realName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.loading = false
|
||||||
|
}).catch(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
loadDeptList() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
getDeptList().then((res) => {
|
||||||
|
let data = res.data || []
|
||||||
|
this.deptOptions = this.buildTree(data)
|
||||||
|
resolve()
|
||||||
|
}).catch(() => {
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
buildTree(list) {
|
||||||
|
if (!list || !list.length) return []
|
||||||
|
const tree = []
|
||||||
|
const map = {}
|
||||||
|
list.forEach(item => {
|
||||||
|
map[item.id] = { ...item, children: [] }
|
||||||
|
})
|
||||||
|
list.forEach(item => {
|
||||||
|
if (item.parentId && map[item.parentId]) {
|
||||||
|
map[item.parentId].children.push(map[item.id])
|
||||||
|
} else {
|
||||||
|
tree.push(map[item.id])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return tree
|
||||||
|
},
|
||||||
|
handleDeptSelect(data) {
|
||||||
|
this.dataForm.deptId = String(data.id)
|
||||||
|
this.deptIdLabel = data.name
|
||||||
|
this.dataForm.deptName = data.name
|
||||||
|
if (this.$refs.deptSelect) {
|
||||||
|
this.$refs.deptSelect.visible = false
|
||||||
|
}
|
||||||
|
// 加载该部门下的用户
|
||||||
|
this.userIdOptions = []
|
||||||
|
this.dataForm.userId = undefined
|
||||||
|
this.dataForm.userName = undefined
|
||||||
|
if (data.id) {
|
||||||
|
getUserList(data.id).then((res) => {
|
||||||
|
this.userIdOptions = res.data || []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleUserChange(val) {
|
||||||
|
this.dataForm.userId = val
|
||||||
|
const user = this.userIdOptions.find(item => String(item.id) === String(val))
|
||||||
|
if (user) {
|
||||||
|
this.dataForm.userName = user.realName
|
||||||
|
} else {
|
||||||
|
this.dataForm.userName = undefined
|
||||||
|
}
|
||||||
|
},
|
||||||
|
findDeptNameById(id, tree) {
|
||||||
|
for (const item of tree) {
|
||||||
|
if (String(item.id) === String(id)) {
|
||||||
|
return item.name
|
||||||
|
}
|
||||||
|
if (item.children && item.children.length > 0) {
|
||||||
|
const found = this.findDeptNameById(id, item.children)
|
||||||
|
if (found) {
|
||||||
|
return found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
},
|
||||||
|
selectEquipment() {
|
||||||
|
this.equipmentSelectVisible = true
|
||||||
|
},
|
||||||
|
handleEquipmentSelect(data) {
|
||||||
|
this.dataForm.eqId = data.eqId
|
||||||
|
this.dataForm.eqCode = data.eqCode
|
||||||
|
this.dataForm.eqName = data.eqName
|
||||||
|
this.equipmentSelectVisible = false
|
||||||
|
},
|
||||||
|
addItem() {
|
||||||
|
this.dataForm.itemList = [...this.dataForm.itemList, {
|
||||||
|
id: '',
|
||||||
|
itemName: undefined,
|
||||||
|
checkPart: undefined,
|
||||||
|
checkMethod: undefined,
|
||||||
|
qualifiedStand: undefined,
|
||||||
|
checkTool: undefined,
|
||||||
|
seqNo: undefined,
|
||||||
|
enabledStatus: 1,
|
||||||
|
remark: undefined
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
deleteItem(index) {
|
||||||
|
this.dataForm.itemList = this.dataForm.itemList.filter((_, i) => i !== index)
|
||||||
|
},
|
||||||
|
dataFormSubmit() {
|
||||||
|
// 验证表格行数据
|
||||||
|
if (!this.validateItemList()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.$refs.formRef.validate((valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.btnLoading = true
|
||||||
|
if (this.dataForm.id) {
|
||||||
|
updateEqMainConfig(this.dataForm.id, this.dataForm).then(() => {
|
||||||
|
this.$message.success('修改成功')
|
||||||
|
this.dialogVisible = false
|
||||||
|
this.btnLoading = false
|
||||||
|
this.$emit('refresh')
|
||||||
|
}).catch(() => {
|
||||||
|
this.btnLoading = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
createEqMainConfig(this.dataForm).then(() => {
|
||||||
|
this.$message.success('新增成功')
|
||||||
|
this.dialogVisible = false
|
||||||
|
this.btnLoading = false
|
||||||
|
this.$emit('refresh')
|
||||||
|
}).catch(() => {
|
||||||
|
this.btnLoading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
validateItemList() {
|
||||||
|
// 检查非空
|
||||||
|
for (let i = 0; i < this.dataForm.itemList.length; i++) {
|
||||||
|
const item = this.dataForm.itemList[i]
|
||||||
|
if (!item.itemName || item.itemName.trim() === '') {
|
||||||
|
this.$message.warning(`第${i + 1}行保养项目不能为空`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!item.checkPart || item.checkPart.trim() === '') {
|
||||||
|
this.$message.warning(`第${i + 1}行检查/保养部位不能为空`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!item.checkMethod || item.checkMethod.trim() === '') {
|
||||||
|
this.$message.warning(`第${i + 1}行检查/保养方法不能为空`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!item.seqNo && item.seqNo !== 0) {
|
||||||
|
this.$message.warning(`第${i + 1}行项目序号不能为空`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 检查保养项目重复
|
||||||
|
const itemNameMap = {}
|
||||||
|
for (let i = 0; i < this.dataForm.itemList.length; i++) {
|
||||||
|
const itemName = this.dataForm.itemList[i].itemName.trim()
|
||||||
|
if (itemNameMap[itemName]) {
|
||||||
|
this.$message.warning('保养项目存在重复数据,请确认!')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
itemNameMap[itemName] = true
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
handleClose() {
|
||||||
|
this.dialogVisible = false
|
||||||
|
this.$emit('refresh',true)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// 由父组件调用 init() 方法初始化,不自动显示弹窗
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
219
jnpf-java-boot/jnpf-web/src/views/example/eqmainconfig/index.vue
Normal file
219
jnpf-java-boot/jnpf-web/src/views/example/eqmainconfig/index.vue
Normal file
@ -0,0 +1,219 @@
|
|||||||
|
<template>
|
||||||
|
<div class="JNPF-common-layout eq-main-config-data">
|
||||||
|
<div class="JNPF-common-layout-center">
|
||||||
|
<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.eqCode" placeholder="请输入设备编码" clearable></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="设备名称">
|
||||||
|
<el-input v-model="query.eqName" placeholder="请输入设备名称" clearable></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="类型">
|
||||||
|
<JnpfSelect v-model="query.mainType" placeholder="请选择类型" :options="mainTypeOptions" :props="mainTypeProps" clearable></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"
|
||||||
|
@selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="50" align="center"/>
|
||||||
|
<el-table-column prop="eqCode" label="设备编码" align="center" min-width="120"/>
|
||||||
|
<el-table-column prop="eqName" label="设备名称" align="center" min-width="120"/>
|
||||||
|
<el-table-column prop="mainName" label="方案名称" align="center" min-width="180"/>
|
||||||
|
<el-table-column prop="mainType" label="类型" align="center" min-width="80">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ getMainTypeLabel(scope.row.mainType) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="cycleUnit" label="周期单位" align="center" min-width="80">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ getCycleUnitLabel(scope.row.cycleUnit) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="deptName" label="责任部门" align="center" min-width="100"/>
|
||||||
|
<el-table-column prop="userName" label="责任人" align="center" min-width="80"/>
|
||||||
|
<el-table-column prop="mainPost" label="负责岗位" align="center" min-width="100"/>
|
||||||
|
<el-table-column prop="planStartDtime" label="下次执行时间" align="center" min-width="150" :formatter="jnpf.tableDateFormat1"/>
|
||||||
|
<el-table-column prop="enabledStatus" label="启用状态" align="center" min-width="80">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag :type="scope.row.enabledStatus == 1 ? 'success' : 'info'" size="small">
|
||||||
|
{{ getLabel('enabledStatus', scope.row.enabledStatus) }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="remark" label="备注" align="center" min-width="150" show-overflow-tooltip/>
|
||||||
|
<el-table-column label="操作" fixed="right" align="center" width="200">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="text" @click="addOrUpdateHandle(scope.row)">编辑</el-button>
|
||||||
|
<el-button type="text" @click="detailHandle(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"/>
|
||||||
|
<EqmainconfigDetail ref="detail"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {deleteEqMainConfig, getEqMainConfigList} from "./api";
|
||||||
|
import JNPFForm from "./form";
|
||||||
|
import EqmainconfigDetail from "./detail";
|
||||||
|
import jnpf from "@/utils/jnpf";
|
||||||
|
import {enabledStatusOptions, dictProps, getLabel, mainTypeOptions} from '../common/dict';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "eqmainconfig",
|
||||||
|
components: {
|
||||||
|
JNPFForm,
|
||||||
|
EqmainconfigDetail,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
query: {
|
||||||
|
eqCode: undefined,
|
||||||
|
eqName: undefined,
|
||||||
|
mainName: undefined,
|
||||||
|
mainType: undefined,
|
||||||
|
enabledStatus: undefined,
|
||||||
|
},
|
||||||
|
list: [],
|
||||||
|
listLoading: false,
|
||||||
|
multipleSelection: [],
|
||||||
|
total: 0,
|
||||||
|
listQuery: {
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
sort: "",
|
||||||
|
sidx: "",
|
||||||
|
},
|
||||||
|
formVisible: false,
|
||||||
|
detailVisible: false,
|
||||||
|
enabledStatusOptions: enabledStatusOptions,
|
||||||
|
enabledStatusProps: dictProps,
|
||||||
|
mainTypeOptions: mainTypeOptions,
|
||||||
|
mainTypeProps: dictProps,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
jnpf() {
|
||||||
|
return jnpf
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.initData();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData() {
|
||||||
|
this.listLoading = true;
|
||||||
|
let _query = {
|
||||||
|
...this.listQuery,
|
||||||
|
...this.query,
|
||||||
|
dataType: 0,
|
||||||
|
};
|
||||||
|
Object.keys(_query).forEach(key => {
|
||||||
|
if (_query[key] === undefined || _query[key] === null || _query[key] === '') {
|
||||||
|
delete _query[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
getEqMainConfigList(_query).then((res) => {
|
||||||
|
console.log('response:', res);
|
||||||
|
console.log('list length:', res.data.list.length);
|
||||||
|
this.list = res.data.list || [];
|
||||||
|
this.total = res.data.pagination.total;
|
||||||
|
this.listLoading = false;
|
||||||
|
}).catch(() => {
|
||||||
|
this.listLoading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
search() {
|
||||||
|
this.listQuery.currentPage = 1;
|
||||||
|
this.initData();
|
||||||
|
},
|
||||||
|
reset() {
|
||||||
|
this.query = {
|
||||||
|
eqCode: undefined,
|
||||||
|
eqName: undefined,
|
||||||
|
mainName: undefined,
|
||||||
|
mainType: undefined,
|
||||||
|
enabledStatus: undefined,
|
||||||
|
};
|
||||||
|
this.search();
|
||||||
|
},
|
||||||
|
handleSelectionChange(val) {
|
||||||
|
this.multipleSelection = val;
|
||||||
|
},
|
||||||
|
detailHandle(row) {
|
||||||
|
this.$refs.detail.init(row.id);
|
||||||
|
},
|
||||||
|
addOrUpdateHandle(row) {
|
||||||
|
this.formVisible = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.JNPFForm.init(row ? row.id : '');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDel(row) {
|
||||||
|
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
deleteEqMainConfig(row.id).then((res) => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '删除成功!'
|
||||||
|
});
|
||||||
|
this.initData();
|
||||||
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
});
|
||||||
|
},
|
||||||
|
refresh() {
|
||||||
|
this.initData();
|
||||||
|
},
|
||||||
|
getLabel(type, value) {
|
||||||
|
return getLabel(type, value);
|
||||||
|
},
|
||||||
|
getMainTypeLabel(value) {
|
||||||
|
return this.getLabel('mainType', value);
|
||||||
|
},
|
||||||
|
getCycleUnitLabel(value) {
|
||||||
|
return this.getLabel('cycleUnit', value);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
||||||
153
jnpf-java-boot/jnpf-web/src/views/example/equipment/select.vue
Normal file
153
jnpf-java-boot/jnpf-web/src/views/example/equipment/select.vue
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog title="选择设备" :visible.sync="visible" width="1000px" append-to-body>
|
||||||
|
<el-form :model="query" inline>
|
||||||
|
<el-form-item label="关键词">
|
||||||
|
<el-input v-model="query.keyword" placeholder="请输入设备编码或名称" clearable style="width: 200px;"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="search()">查询</el-button>
|
||||||
|
<el-button @click="reset()">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<el-table :data="list" v-loading="loading" @row-click="handleRowClick" @row-dblclick="handleRowDblClick" highlight-current-row ref="table">
|
||||||
|
<el-table-column width="60" align="center" label="单选框">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span style="display: inline-block; width: 18px; overflow: hidden;">
|
||||||
|
<el-radio :label="scope.row.id" v-model="selectedId"></el-radio>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column type="index" width="50" align="center" label="序号"></el-table-column>
|
||||||
|
<el-table-column prop="eqCode" label="设备编码" align="center"/>
|
||||||
|
<el-table-column prop="eqName" label="设备名称" align="center"/>
|
||||||
|
<el-table-column prop="eqType" label="设备类型" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ getEquipmentTypeLabel(scope.row.eqType) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="deptName" label="责任部门" align="center"/>
|
||||||
|
</el-table>
|
||||||
|
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize"
|
||||||
|
@pagination="initData" style="margin-top: 10px;"/>
|
||||||
|
<div class="dialog-footer" style="text-align: right; padding-top: 10px;">
|
||||||
|
<el-button type="primary" @click="confirm()">保存</el-button>
|
||||||
|
<el-button @click="handleClose()">取消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {getEquipmentList, getLabel} from "./equipment";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "equipmentSelect",
|
||||||
|
props: {
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
query: {
|
||||||
|
keyword: '',
|
||||||
|
enabledStatus: 1
|
||||||
|
},
|
||||||
|
list: [],
|
||||||
|
loading: false,
|
||||||
|
total: 0,
|
||||||
|
listQuery: {
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
sort: "",
|
||||||
|
sidx: ""
|
||||||
|
},
|
||||||
|
selectedRow: null,
|
||||||
|
selectedId: null
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
visible(val) {
|
||||||
|
if (val) {
|
||||||
|
this.initData();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectedId(val) {
|
||||||
|
if (val !== null) {
|
||||||
|
this.selectedRow = this.list.find(item => item.id === val);
|
||||||
|
} else {
|
||||||
|
this.selectedRow = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData() {
|
||||||
|
this.loading = true;
|
||||||
|
let _query = {
|
||||||
|
...this.listQuery,
|
||||||
|
...this.query,
|
||||||
|
dataType: 0
|
||||||
|
};
|
||||||
|
Object.keys(_query).forEach(key => {
|
||||||
|
if (_query[key] === undefined || _query[key] === null || _query[key] === '') {
|
||||||
|
delete _query[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log('equipment select query:', _query);
|
||||||
|
getEquipmentList(_query).then(res => {
|
||||||
|
console.log('equipment select response:', res);
|
||||||
|
this.list = res.data.list;
|
||||||
|
this.total = res.data.pagination ? res.data.pagination.total : res.data.total;
|
||||||
|
this.loading = false;
|
||||||
|
}).catch(err => {
|
||||||
|
console.log('equipment select error:', err);
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
search() {
|
||||||
|
this.listQuery.currentPage = 1;
|
||||||
|
this.selectedId = null;
|
||||||
|
this.selectedRow = null;
|
||||||
|
this.initData();
|
||||||
|
},
|
||||||
|
reset() {
|
||||||
|
this.query = {keyword: '', enabledStatus: 1};
|
||||||
|
this.selectedId = null;
|
||||||
|
this.selectedRow = null;
|
||||||
|
this.search();
|
||||||
|
},
|
||||||
|
getEquipmentTypeLabel(value) {
|
||||||
|
return getLabel('eqType', value);
|
||||||
|
},
|
||||||
|
handleRowClick(row) {
|
||||||
|
this.selectedId = row.id;
|
||||||
|
},
|
||||||
|
handleRowDblClick(row) {
|
||||||
|
this.selectedId = row.id;
|
||||||
|
this.selectedRow = row;
|
||||||
|
this.confirm();
|
||||||
|
},
|
||||||
|
confirm() {
|
||||||
|
if (!this.selectedRow) {
|
||||||
|
this.$message.warning('请选择设备');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$emit('select', {
|
||||||
|
id: this.selectedRow.id,
|
||||||
|
eqId: this.selectedRow.id,
|
||||||
|
eqCode: this.selectedRow.eqCode,
|
||||||
|
eqName: this.selectedRow.eqName
|
||||||
|
});
|
||||||
|
this.handleClose();
|
||||||
|
},
|
||||||
|
handleClose() {
|
||||||
|
this.$emit('update:visible', false);
|
||||||
|
this.selectedRow = null;
|
||||||
|
this.selectedId = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
||||||
Loading…
Reference in New Issue
Block a user