Compare commits
2 Commits
908c58c101
...
d8f645e00a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8f645e00a | ||
|
|
fc7daeebdf |
@ -70,4 +70,8 @@ public interface ErrorCodeConstants {
|
||||
|
||||
ErrorCode CUSTOMER_CODE_DUPLICATE = new ErrorCode(1_001_024, "客户编码不能重复");
|
||||
ErrorCode CUSTOMER_NAME_DUPLICATE = new ErrorCode(1_001_025, "客户名称不能重复");
|
||||
|
||||
/********************质检方案信息*************************/
|
||||
ErrorCode INS_PLAN_SCHEME_NAME_DUPLICATE = new ErrorCode(1_001_026, "质检方案名称不能重复");
|
||||
ErrorCode INS_PLAN_SCHEME_NO_DUPLICATE = new ErrorCode(1_001_027, "质检方案编号不能重复");
|
||||
}
|
||||
|
||||
@ -49,4 +49,5 @@ public class CheckItemPageReqVO extends PageParam {
|
||||
private String printAvgValues;
|
||||
@Schema(description = "编号")
|
||||
private String itemNo;
|
||||
private String keyWord;
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public class InspPlanController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建质检方案表主")
|
||||
@PreAuthorize("@ss.hasPermission('biz:insp-plan:create')")
|
||||
public CommonResult<String> createInspPlan(@Valid @RequestBody InspPlanSaveReqVO createReqVO) {
|
||||
public CommonResult<Integer> createInspPlan(@Valid @RequestBody InspPlanSaveReqVO createReqVO) {
|
||||
return success(inspPlanService.createInspPlan(createReqVO));
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class InspPlanController {
|
||||
@Operation(summary = "删除质检方案表主")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('biz:insp-plan:delete')")
|
||||
public CommonResult<Boolean> deleteInspPlan(@RequestParam("id") String id) {
|
||||
public CommonResult<Boolean> deleteInspPlan(@RequestParam("id") Integer id) {
|
||||
inspPlanService.deleteInspPlan(id);
|
||||
return success(true);
|
||||
}
|
||||
@ -64,7 +64,7 @@ public class InspPlanController {
|
||||
@Operation(summary = "获得质检方案表主")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('biz:insp-plan:query')")
|
||||
public CommonResult<InspPlanRespVO> getInspPlan(@RequestParam("id") String id) {
|
||||
public CommonResult<InspPlanRespVO> getInspPlan(@RequestParam("id") Integer id) {
|
||||
InspPlanDO inspPlan = inspPlanService.getInspPlan(id);
|
||||
return success(BeanUtils.toBean(inspPlan, InspPlanRespVO.class));
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ public class InspPlanRespVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17012")
|
||||
@ExcelProperty("id")
|
||||
private String id;
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "质检方案编号")
|
||||
@ExcelProperty("质检方案编号")
|
||||
|
||||
@ -1,47 +1,51 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.*;
|
||||
|
||||
@Schema(description = "管理后台 - 质检方案表主新增/修改 Request VO")
|
||||
@Data
|
||||
public class InspPlanSaveReqVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17012")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "质检方案编号")
|
||||
private String schemeNo;
|
||||
|
||||
@Schema(description = "质检方案名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@NotEmpty(message = "质检方案名称不能为空")
|
||||
private String schemeName;
|
||||
|
||||
@Schema(description = "描述", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "适用类型,1表示原材料 2表示半成品 3表示成品", example = "2")
|
||||
private Integer schemeType;
|
||||
|
||||
@Schema(description = "分类编码")
|
||||
private String tiemClass;
|
||||
|
||||
@Schema(description = "表单编号")
|
||||
private String formCode;
|
||||
|
||||
@Schema(description = "执行标准")
|
||||
private String execStandard;
|
||||
|
||||
@Schema(description = "检验值数量")
|
||||
private Integer testNum;
|
||||
|
||||
@Schema(description = "打印模板编码")
|
||||
private String printCode;
|
||||
|
||||
@Schema(description = "打印模板名称", example = "张三")
|
||||
private String printName;
|
||||
|
||||
}
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplanitem.vo.InspPlanItemSaveReqVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.*;
|
||||
|
||||
@Schema(description = "管理后台 - 质检方案表主新增/修改 Request VO")
|
||||
@Data
|
||||
public class InspPlanSaveReqVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17012")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "质检方案编号")
|
||||
private String schemeNo;
|
||||
|
||||
@Schema(description = "质检方案名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@NotEmpty(message = "质检方案名称不能为空")
|
||||
private String schemeName;
|
||||
|
||||
@Schema(description = "描述", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "适用类型,1表示原材料 2表示半成品 3表示成品", example = "2")
|
||||
private Integer schemeType;
|
||||
|
||||
@Schema(description = "分类编码")
|
||||
private String tiemClass;
|
||||
|
||||
@Schema(description = "表单编号")
|
||||
private String formCode;
|
||||
|
||||
@Schema(description = "执行标准")
|
||||
private String execStandard;
|
||||
|
||||
@Schema(description = "检验值数量")
|
||||
private Integer testNum;
|
||||
|
||||
@Schema(description = "打印模板编码")
|
||||
private String printCode;
|
||||
|
||||
@Schema(description = "打印模板名称", example = "张三")
|
||||
private String printName;
|
||||
|
||||
@Schema(description = "子表列表")
|
||||
private List<InspPlanItemSaveReqVO> inspPlanItemList;
|
||||
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public class InspPlanItemController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建质检方案子")
|
||||
@PreAuthorize("@ss.hasPermission('tba:insp-plan-item:create')")
|
||||
public CommonResult<String> createInspPlanItem(@Valid @RequestBody InspPlanItemSaveReqVO createReqVO) {
|
||||
public CommonResult<Integer> createInspPlanItem(@Valid @RequestBody InspPlanItemSaveReqVO createReqVO) {
|
||||
return success(inspPlanItemService.createInspPlanItem(createReqVO));
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class InspPlanItemController {
|
||||
@Operation(summary = "删除质检方案子")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('tba:insp-plan-item:delete')")
|
||||
public CommonResult<Boolean> deleteInspPlanItem(@RequestParam("id") String id) {
|
||||
public CommonResult<Boolean> deleteInspPlanItem(@RequestParam("id") Integer id) {
|
||||
inspPlanItemService.deleteInspPlanItem(id);
|
||||
return success(true);
|
||||
}
|
||||
@ -66,7 +66,7 @@ public class InspPlanItemController {
|
||||
@Operation(summary = "获得质检方案子")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('tba:insp-plan-item:query')")
|
||||
public CommonResult<InspPlanItemRespVO> getInspPlanItem(@RequestParam("id") String id) {
|
||||
public CommonResult<InspPlanItemRespVO> getInspPlanItem(@RequestParam("id") Integer id) {
|
||||
InspPlanItemDO inspPlanItem = inspPlanItemService.getInspPlanItem(id);
|
||||
return success(BeanUtils.toBean(inspPlanItem, InspPlanItemRespVO.class));
|
||||
}
|
||||
@ -91,5 +91,11 @@ public class InspPlanItemController {
|
||||
ExcelUtils.write(response, "质检方案子.xls", "数据", InspPlanItemRespVO.class,
|
||||
BeanUtils.toBean(list, InspPlanItemRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/getInspPlanItemByPlanId")
|
||||
@Operation(summary = "获得质检方案子")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('tba:insp-plan-item:query')")
|
||||
public CommonResult<List<InspPlanItemDO>> getInspPlanItemByPlanId(@RequestParam("planId") Integer planId) {
|
||||
return success(inspPlanItemService.getInspPlanItemByPlanId(planId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplanitem.vo;
|
||||
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplanitem.InspPlanItemDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
@ -11,13 +12,13 @@ import java.util.*;
|
||||
public class InspPlanItemSaveReqVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16314")
|
||||
private String id;
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "质检方案id,对应qa_scheme_base中的id列", example = "4222")
|
||||
private String schemeId;
|
||||
private Integer schemeId;
|
||||
|
||||
@Schema(description = "检验项目id,对应qa_check_item_base中的id列", example = "32292")
|
||||
private String itemId;
|
||||
private Integer itemId;
|
||||
|
||||
@Schema(description = "单位")
|
||||
private String unit;
|
||||
@ -48,5 +49,7 @@ public class InspPlanItemSaveReqVO {
|
||||
|
||||
@Schema(description = "模板检测值数量")
|
||||
private Integer printNum;
|
||||
@Schema(description = "明细列表")
|
||||
private List<InspPlanItemDO> inspPlanItemList;
|
||||
|
||||
}
|
||||
|
||||
@ -25,8 +25,7 @@ public class InspPlanDO extends BaseDO {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String id;
|
||||
private Integer id;
|
||||
/**
|
||||
* 质检方案编号
|
||||
*/
|
||||
|
||||
@ -25,12 +25,11 @@ public class InspPlanItemDO extends BaseDO {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String id;
|
||||
private Integer id;
|
||||
/**
|
||||
* 质检方案id,对应qa_scheme_base中的id列
|
||||
*/
|
||||
private String schemeId;
|
||||
private Integer schemeId;
|
||||
/**
|
||||
* 检验项目id,对应qa_check_item_base中的id列
|
||||
*/
|
||||
|
||||
@ -2,10 +2,13 @@ package com.ningxia.yunxi.chemmes.module.biz.dal.mysql.checkitem;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.ningxia.yunxi.chemmes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.checkitem.CheckItemDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplan.InspPlanDO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.checkitem.vo.*;
|
||||
|
||||
@ -47,7 +50,10 @@ public interface CheckItemMapper extends BaseMapperX<CheckItemDO> {
|
||||
.eqIfPresent(CheckItemDO::getTestNum, reqVO.getTestNum())
|
||||
.eqIfPresent(CheckItemDO::getFloatNum, reqVO.getFloatNum())
|
||||
.eqIfPresent(CheckItemDO::getPrintAvgValues, reqVO.getPrintAvgValues())
|
||||
.orderByDesc(CheckItemDO::getCreateTime));
|
||||
.orderByDesc(CheckItemDO::getCreateTime) .and(ObjectUtil.isNotEmpty(reqVO.getKeyWord()), wrapper -> wrapper
|
||||
.like(CheckItemDO::getItemName, reqVO.getKeyWord())
|
||||
.or()
|
||||
.like(CheckItemDO::getItemNo, reqVO.getKeyWord())));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -33,4 +33,26 @@ public interface InspPlanMapper extends BaseMapperX<InspPlanDO> {
|
||||
.like(InspPlanDO::getSchemeNo, keyWord))
|
||||
);
|
||||
}
|
||||
|
||||
default InspPlanDO selectBySchemeName(String schemeName) {
|
||||
return selectOne(new LambdaQueryWrapperX<InspPlanDO>()
|
||||
.eq(InspPlanDO::getSchemeName, schemeName));
|
||||
}
|
||||
|
||||
default InspPlanDO selectBySchemeNameExcludeId(String schemeName, Integer excludeId) {
|
||||
return selectOne(new LambdaQueryWrapperX<InspPlanDO>()
|
||||
.eq(InspPlanDO::getSchemeName, schemeName)
|
||||
.ne(InspPlanDO::getId, excludeId));
|
||||
}
|
||||
|
||||
default InspPlanDO selectBySchemeNo(String schemeNo) {
|
||||
return selectOne(new LambdaQueryWrapperX<InspPlanDO>()
|
||||
.eq(InspPlanDO::getSchemeNo, schemeNo));
|
||||
}
|
||||
|
||||
default InspPlanDO selectBySchemeNoExcludeId(String schemeNo, Integer excludeId) {
|
||||
return selectOne(new LambdaQueryWrapperX<InspPlanDO>()
|
||||
.eq(InspPlanDO::getSchemeNo, schemeNo)
|
||||
.ne(InspPlanDO::getId, excludeId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,8 @@ import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplanitem.vo.Ins
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplanitem.InspPlanItemDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 质检方案子 Mapper
|
||||
*
|
||||
@ -38,4 +40,20 @@ public interface InspPlanItemMapper extends BaseMapperX<InspPlanItemDO> {
|
||||
.eq(InspPlanItemDO::getItemId, id));
|
||||
}
|
||||
|
||||
default List<InspPlanItemDO> getInspPlanItemByPlanId(Integer planId){
|
||||
return selectList(new LambdaQueryWrapperX<InspPlanItemDO>()
|
||||
.eq(InspPlanItemDO::getSchemeId, planId)
|
||||
.orderByAsc(InspPlanItemDO::getSeqNo));
|
||||
}
|
||||
|
||||
default InspPlanItemDO selectBySchemeIdAndItemId(Integer schemeId, Integer itemId) {
|
||||
return selectOne(new LambdaQueryWrapperX<InspPlanItemDO>()
|
||||
.eq(InspPlanItemDO::getSchemeId, schemeId)
|
||||
.eq(InspPlanItemDO::getItemId, itemId));
|
||||
}
|
||||
|
||||
default int deleteBySchemeId(Integer schemeId) {
|
||||
return delete(new LambdaQueryWrapperX<InspPlanItemDO>()
|
||||
.eq(InspPlanItemDO::getSchemeId, schemeId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ public interface TechProcMapper extends BaseMapperX<TechProcDO> {
|
||||
default Long selectByTechProcCount(String techProc, Integer id){
|
||||
return selectCount(new MPJLambdaWrapper<TechProcDO>()
|
||||
.eq(TechProcDO::getTechProc, techProc)
|
||||
.eq(TechProcDO::getId, id)
|
||||
.ne(ObjectUtil.isNotEmpty(id),TechProcDO::getId, id)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ public interface InspPlanService {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
String createInspPlan(@Valid InspPlanSaveReqVO createReqVO);
|
||||
Integer createInspPlan(@Valid InspPlanSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新质检方案表主
|
||||
@ -35,7 +35,7 @@ public interface InspPlanService {
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteInspPlan(String id);
|
||||
void deleteInspPlan(Integer id);
|
||||
|
||||
/**
|
||||
* 获得质检方案表主
|
||||
@ -43,7 +43,7 @@ public interface InspPlanService {
|
||||
* @param id 编号
|
||||
* @return 质检方案表主
|
||||
*/
|
||||
InspPlanDO getInspPlan(String id);
|
||||
InspPlanDO getInspPlan(Integer id);
|
||||
|
||||
/**
|
||||
* 获得质检方案表主分页
|
||||
|
||||
@ -1,16 +1,28 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.service.inspplan;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.InspPlanPageReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplan.vo.InspPlanSaveReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplanitem.vo.InspPlanItemSaveReqVO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplan.InspPlanDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplanitem.InspPlanItemDO;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.inspplan.InspPlanMapper;
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.inspplanitem.InspPlanItemMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.ningxia.yunxi.chemmes.module.biz.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 质检方案表主 Service 实现类
|
||||
@ -24,40 +36,106 @@ public class InspPlanServiceImpl implements InspPlanService {
|
||||
@Resource
|
||||
private InspPlanMapper inspPlanMapper;
|
||||
|
||||
@Resource
|
||||
private InspPlanItemMapper inspPlanItemMapper;
|
||||
|
||||
@Override
|
||||
public String createInspPlan(InspPlanSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer createInspPlan(InspPlanSaveReqVO createReqVO) {
|
||||
// 校验方案名称不能重复
|
||||
if (inspPlanMapper.selectBySchemeName(createReqVO.getSchemeName()) != null) {
|
||||
throw exception(INS_PLAN_SCHEME_NAME_DUPLICATE);
|
||||
}
|
||||
// 校验方案编号不能重复
|
||||
if (createReqVO.getSchemeNo() != null && inspPlanMapper.selectBySchemeNo(createReqVO.getSchemeNo()) != null) {
|
||||
throw exception(INS_PLAN_SCHEME_NO_DUPLICATE);
|
||||
}
|
||||
// 插入主表
|
||||
InspPlanDO inspPlan = BeanUtils.toBean(createReqVO, InspPlanDO.class);
|
||||
inspPlanMapper.insert(inspPlan);
|
||||
|
||||
// 处理子表
|
||||
saveInspPlanItemList(inspPlan.getId(), createReqVO.getInspPlanItemList());
|
||||
|
||||
// 返回
|
||||
return inspPlan.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateInspPlan(InspPlanSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateInspPlanExists(updateReqVO.getId());
|
||||
// 更新
|
||||
// 校验方案名称不能重复(排除自身)
|
||||
if (inspPlanMapper.selectBySchemeNameExcludeId(updateReqVO.getSchemeName(), updateReqVO.getId()) != null) {
|
||||
throw exception(INS_PLAN_SCHEME_NAME_DUPLICATE);
|
||||
}
|
||||
// 校验方案编号不能重复(排除自身)
|
||||
if (updateReqVO.getSchemeNo() != null && inspPlanMapper.selectBySchemeNoExcludeId(updateReqVO.getSchemeNo(), updateReqVO.getId()) != null) {
|
||||
throw exception(INS_PLAN_SCHEME_NO_DUPLICATE);
|
||||
}
|
||||
// 更新主表
|
||||
InspPlanDO updateObj = BeanUtils.toBean(updateReqVO, InspPlanDO.class);
|
||||
inspPlanMapper.updateById(updateObj);
|
||||
|
||||
// 处理子表
|
||||
saveInspPlanItemList(updateReqVO.getId(), updateReqVO.getInspPlanItemList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteInspPlan(String id) {
|
||||
// 校验存在
|
||||
validateInspPlanExists(id);
|
||||
// 删除
|
||||
inspPlanMapper.deleteById(id);
|
||||
}
|
||||
/**
|
||||
* 保存子表列表
|
||||
*/
|
||||
private void saveInspPlanItemList(Integer schemeId, List<InspPlanItemSaveReqVO> itemList) {
|
||||
if (CollUtil.isEmpty(itemList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
private void validateInspPlanExists(String id) {
|
||||
if (inspPlanMapper.selectById(id) == null) {
|
||||
// throw exception(INSP_PLAN_NOT_EXISTS);
|
||||
// 处理子表:如果子表数据没有 id 但有相同的 schemeId + itemId,则复用已有的 id
|
||||
List<InspPlanItemSaveReqVO> collect = itemList.stream()
|
||||
.filter(model -> ObjectUtil.isEmpty(model.getId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
boolean updated = false;
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
for (InspPlanItemSaveReqVO model : collect) {
|
||||
// 查询是否已存在相同的 schemeId + itemId
|
||||
InspPlanItemDO existItem = inspPlanItemMapper.selectBySchemeIdAndItemId(schemeId, model.getItemId());
|
||||
if (existItem != null) {
|
||||
model.setId(existItem.getId());
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除该方案下所有旧的子表数据
|
||||
inspPlanItemMapper.deleteBySchemeId(schemeId);
|
||||
|
||||
// 重新插入/更新子表数据
|
||||
for (InspPlanItemSaveReqVO item : itemList) {
|
||||
InspPlanItemDO inspPlanItem = BeanUtils.toBean(item, InspPlanItemDO.class);
|
||||
inspPlanItem.setSchemeId(schemeId);
|
||||
inspPlanItemMapper.insertOrUpdate(inspPlanItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspPlanDO getInspPlan(String id) {
|
||||
public void deleteInspPlan(Integer id) {
|
||||
// 校验存在
|
||||
validateInspPlanExists(id);
|
||||
// 删除子表
|
||||
inspPlanItemMapper.deleteBySchemeId(id);
|
||||
// 删除主表
|
||||
inspPlanMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateInspPlanExists(Integer id) {
|
||||
if (inspPlanMapper.selectById(id) == null) {
|
||||
throw exception("数据不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspPlanDO getInspPlan(Integer id) {
|
||||
return inspPlanMapper.selectById(id);
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import com.ningxia.yunxi.chemmes.module.biz.controller.admin.inspplanitem.vo.Ins
|
||||
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.inspplanitem.InspPlanItemDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 质检方案子 Service 接口
|
||||
@ -20,7 +21,7 @@ public interface InspPlanItemService {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
String createInspPlanItem(@Valid InspPlanItemSaveReqVO createReqVO);
|
||||
Integer createInspPlanItem(@Valid InspPlanItemSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新质检方案子
|
||||
@ -34,7 +35,7 @@ public interface InspPlanItemService {
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteInspPlanItem(String id);
|
||||
void deleteInspPlanItem(Integer id);
|
||||
|
||||
/**
|
||||
* 获得质检方案子
|
||||
@ -42,7 +43,7 @@ public interface InspPlanItemService {
|
||||
* @param id 编号
|
||||
* @return 质检方案子
|
||||
*/
|
||||
InspPlanItemDO getInspPlanItem(String id);
|
||||
InspPlanItemDO getInspPlanItem(Integer id);
|
||||
|
||||
/**
|
||||
* 获得质检方案子分页
|
||||
@ -52,4 +53,5 @@ public interface InspPlanItemService {
|
||||
*/
|
||||
PageResult<InspPlanItemDO> getInspPlanItemPage(InspPlanItemPageReqVO pageReqVO);
|
||||
|
||||
List<InspPlanItemDO> getInspPlanItemByPlanId(Integer planId);
|
||||
}
|
||||
|
||||
@ -10,6 +10,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 质检方案子 Service 实现类
|
||||
@ -24,7 +27,7 @@ public class InspPlanItemServiceImpl implements InspPlanItemService {
|
||||
private InspPlanItemMapper inspPlanItemMapper;
|
||||
|
||||
@Override
|
||||
public String createInspPlanItem(InspPlanItemSaveReqVO createReqVO) {
|
||||
public Integer createInspPlanItem(InspPlanItemSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
InspPlanItemDO inspPlanItem = BeanUtils.toBean(createReqVO, InspPlanItemDO.class);
|
||||
inspPlanItemMapper.insert(inspPlanItem);
|
||||
@ -42,21 +45,21 @@ public class InspPlanItemServiceImpl implements InspPlanItemService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteInspPlanItem(String id) {
|
||||
public void deleteInspPlanItem(Integer id) {
|
||||
// 校验存在
|
||||
validateInspPlanItemExists(id);
|
||||
// 删除
|
||||
inspPlanItemMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateInspPlanItemExists(String id) {
|
||||
private void validateInspPlanItemExists(Integer id) {
|
||||
if (inspPlanItemMapper.selectById(id) == null) {
|
||||
// throw exception(INSP_PLAN_ITEM_NOT_EXISTS);
|
||||
throw exception("数据不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspPlanItemDO getInspPlanItem(String id) {
|
||||
public InspPlanItemDO getInspPlanItem(Integer id) {
|
||||
return inspPlanItemMapper.selectById(id);
|
||||
}
|
||||
|
||||
@ -65,4 +68,9 @@ public class InspPlanItemServiceImpl implements InspPlanItemService {
|
||||
return inspPlanItemMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InspPlanItemDO> getInspPlanItemByPlanId(Integer planId) {
|
||||
return inspPlanItemMapper.getInspPlanItemByPlanId(planId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,47 +1,52 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
export interface InspPlanItemVO {
|
||||
id: string
|
||||
schemeId: string
|
||||
itemId: string
|
||||
unit: string
|
||||
standardValue: string
|
||||
upperLimit: string
|
||||
lowerLimit: string
|
||||
remark: string
|
||||
itemName: string
|
||||
seqNo: number
|
||||
printMergeYn: string
|
||||
printItem: string
|
||||
printNum: number
|
||||
}
|
||||
|
||||
// 查询质检方案子分页
|
||||
export const getInspPlanItemPage = async (params) => {
|
||||
return await request.get({ url: `/tba/insp-plan-item/page`, params })
|
||||
}
|
||||
|
||||
// 查询质检方案子详情
|
||||
export const getInspPlanItem = async (id: number) => {
|
||||
return await request.get({ url: `/tba/insp-plan-item/get?id=` + id })
|
||||
}
|
||||
|
||||
// 新增质检方案子
|
||||
export const createInspPlanItem = async (data: InspPlanItemVO) => {
|
||||
return await request.post({ url: `/tba/insp-plan-item/create`, data })
|
||||
}
|
||||
|
||||
// 修改质检方案子
|
||||
export const updateInspPlanItem = async (data: InspPlanItemVO) => {
|
||||
return await request.put({ url: `/tba/insp-plan-item/update`, data })
|
||||
}
|
||||
|
||||
// 删除质检方案子
|
||||
export const deleteInspPlanItem = async (id: number) => {
|
||||
return await request.delete({ url: `/tba/insp-plan-item/delete?id=` + id })
|
||||
}
|
||||
|
||||
// 导出质检方案子 Excel
|
||||
export const exportInspPlanItem = async (params) => {
|
||||
return await request.download({ url: `/tba/insp-plan-item/export-excel`, params })
|
||||
}
|
||||
import request from '@/config/axios'
|
||||
|
||||
|
||||
|
||||
export interface InspPlanItemVO {
|
||||
id: string
|
||||
schemeId: string
|
||||
itemId: string
|
||||
unit: string
|
||||
standardValue: string
|
||||
upperLimit: string
|
||||
lowerLimit: string
|
||||
remark: string
|
||||
itemName: string
|
||||
seqNo: number
|
||||
printMergeYn: string
|
||||
printItem: string
|
||||
printNum: number
|
||||
}
|
||||
|
||||
// 查询质检方案子分页
|
||||
export const getInspPlanItemPage = async (params) => {
|
||||
return await request.get({ url: `/tba/insp-plan-item/page`, params })
|
||||
}
|
||||
|
||||
// 查询质检方案子详情
|
||||
export const getInspPlanItem = async (id: number) => {
|
||||
return await request.get({ url: `/tba/insp-plan-item/get?id=` + id })
|
||||
}
|
||||
|
||||
// 新增质检方案子
|
||||
export const createInspPlanItem = async (data: InspPlanItemVO) => {
|
||||
return await request.post({ url: `/tba/insp-plan-item/create`, data })
|
||||
}
|
||||
|
||||
// 修改质检方案子
|
||||
export const updateInspPlanItem = async (data: InspPlanItemVO) => {
|
||||
return await request.put({ url: `/tba/insp-plan-item/update`, data })
|
||||
}
|
||||
|
||||
// 删除质检方案子
|
||||
export const deleteInspPlanItem = async (id: number) => {
|
||||
return await request.delete({ url: `/tba/insp-plan-item/delete?id=` + id })
|
||||
}
|
||||
|
||||
// 导出质检方案子 Excel
|
||||
export const exportInspPlanItem = async (params) => {
|
||||
return await request.download({ url: `/tba/insp-plan-item/export-excel`, params })
|
||||
}
|
||||
export const getInspPlanItemByPlanId = async (id: number) => {
|
||||
return await request.get({ url: `/tba/insp-plan-item/getInspPlanItemByPlanId?planId=` + id })
|
||||
}
|
||||
|
||||
@ -239,6 +239,7 @@ export enum DICT_TYPE {
|
||||
TEST_VALUE_TYPE='test_value_type', // 检验值类型
|
||||
RAW_MATERIALS_TYPE='raw_materials_type', // 原材料大类
|
||||
FINISHED_PRODUCT_TYPE='finished_product_type', // 成品大类
|
||||
CLASSIFICATION_CODE='classification_code',// 质检方案分类编码
|
||||
TEMPLATE_CODE='template_code', // 模板编码
|
||||
ORDER_TYPE='order_type', // 销售订单类型
|
||||
ORDER_STATUS='order_status', // 销售订单状态
|
||||
|
||||
@ -13,19 +13,19 @@
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="编号" prop="itemNo">
|
||||
<el-input v-model="formData.itemNo" placeholder="请输入检验项编号" class="!w-240px"/>
|
||||
<el-input v-model="formData.itemNo" placeholder="请输入检验项编号" class="!w-240px" clearable/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="名称" prop="itemName">
|
||||
<el-input v-model="formData.itemName" placeholder="请输入名称" class="!w-240px"/>
|
||||
<el-input v-model="formData.itemName" placeholder="请输入名称" class="!w-240px" clearable/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="性质" prop="nature">
|
||||
<el-radio-group v-model="formData.nature">
|
||||
<el-radio-group v-model="formData.nature" >
|
||||
<el-radio
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.NATURE)"
|
||||
:key="dict.value"
|
||||
@ -38,14 +38,14 @@
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="单位" prop="unitName">
|
||||
<el-input v-model="formData.unitName" placeholder="请输入单位" class="!w-240px"/>
|
||||
<el-input v-model="formData.unitName" placeholder="请输入单位" class="!w-240px" clearable/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="检验值类型" prop="itemValueType">
|
||||
<el-select v-model="formData.itemValueType" placeholder="请选择检验值类型" @change="handleItemValueTypeChange">
|
||||
<el-select v-model="formData.itemValueType" placeholder="请选择检验值类型" @change="handleItemValueTypeChange" clearable>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.TEST_VALUE_TYPE)"
|
||||
:key="dict.value"
|
||||
@ -57,7 +57,7 @@
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="适用类型" prop="itemType">
|
||||
<el-select v-model="formData.itemType" placeholder="请选择适用类型" @change="handleItemTypeChange">
|
||||
<el-select v-model="formData.itemType" placeholder="请选择适用类型" @change="handleItemTypeChange" clearable>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.MAT_TYPE)"
|
||||
:key="dict.value"
|
||||
@ -71,12 +71,12 @@
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="检验值数量" prop="testNum">
|
||||
<el-input v-model="formData.testNum" placeholder="请输入检验值数量" class="!w-240px"/>
|
||||
<el-input v-model="formData.testNum" placeholder="请输入检验值数量" class="!w-240px" clearable/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="绑定值" prop="itemContent">
|
||||
<el-input v-model="formData.itemContent" class="!w-240px" />
|
||||
<el-input v-model="formData.itemContent" class="!w-240px" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -96,14 +96,14 @@
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="小数位数" prop="floatNum">
|
||||
<el-input v-model="formData.floatNum" placeholder="请输入小数位数" class="!w-240px" />
|
||||
<el-input v-model="formData.floatNum" placeholder="请输入小数位数" class="!w-240px" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="检验大类" prop="itemClass">
|
||||
<el-select v-model="formData.itemClass" placeholder="请选择检验大类" v-if="formData.itemType=='3'">
|
||||
<el-select v-model="formData.itemClass" placeholder="请选择检验大类" v-if="formData.itemType=='3'" clearable>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.FINISHED_PRODUCT_TYPE)"
|
||||
:key="dict.value"
|
||||
@ -111,7 +111,7 @@
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-select v-model="formData.itemClass" placeholder="请选择检验大类" v-if="formData.itemType=='1'">
|
||||
<el-select v-model="formData.itemClass" placeholder="请选择检验大类" v-if="formData.itemType=='1'" clearable>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.RAW_MATERIALS_TYPE)"
|
||||
:key="dict.value"
|
||||
@ -119,21 +119,21 @@
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-select v-model="formData.itemClass" placeholder="请选择检验大类" v-if="formData.itemType=='2'||!formData.itemType" disabled/>
|
||||
<el-select v-model="formData.itemClass" placeholder="请选择检验大类" v-if="formData.itemType=='2'||!formData.itemType" disabled clearable/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="检验方法" prop="checkMethod">
|
||||
<el-input type="textarea" :rows="4" v-model="formData.checkMethod" placeholder="请输入检验方法"/>
|
||||
<el-input type="textarea" :rows="4" v-model="formData.checkMethod" placeholder="请输入检验方法" clearable/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input type="textarea" :rows="4" v-model="formData.remark" placeholder="请输入备注"/>
|
||||
<el-input type="textarea" :rows="4" v-model="formData.remark" placeholder="请输入备注" clearable/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -147,7 +147,7 @@
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {getStrDictOptions, DICT_TYPE, getIntDictOptions} from '@/utils/dict'
|
||||
import {getStrDictOptions, DICT_TYPE,} from '@/utils/dict'
|
||||
import * as CheckItemApi from '@/api/biz/checkitem'
|
||||
|
||||
const {t} = useI18n() // 国际化
|
||||
|
||||
124
mes-ui/mes-ui-admin-vue3/src/views/biz/inspplan/CheckItem.vue
Normal file
124
mes-ui/mes-ui-admin-vue3/src/views/biz/inspplan/CheckItem.vue
Normal file
@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="800px">
|
||||
<el-form :model="queryParams" inline label-width="80px">
|
||||
<el-form-item label="检索条件">
|
||||
<el-input v-model="queryParams.keyWord" placeholder="请输入编号或者名称" clearable class="!w-200px" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="getList">搜索</el-button>
|
||||
<el-button @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table ref="tableRef" v-loading="loading" :data="CheckItemList" :show-overflow-tooltip="true" class="mt-15px" row-key="id" @row-click="handleRowClick" @row-dblclick="handleRowDblClick" @selection-change="handleSelectionChange" border>
|
||||
<el-table-column type="selection" width="55"/>
|
||||
<el-table-column label="序号" width="60px" align="center" type="index" />
|
||||
<el-table-column label="编号" align="center" prop="itemNo" />
|
||||
<el-table-column label="名称" align="center" prop="itemName" />
|
||||
<el-table-column label="性质" align="center" prop="nature" >
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.NATURE" :value="scope.row.nature" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" align="center" prop="unitName" />
|
||||
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; padding: 10px 0;">
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
<div style="display: flex; gap: 10px;">
|
||||
<el-button @click="confirmSelection" type="primary">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, nextTick } from 'vue'
|
||||
import {DICT_TYPE} from "@/utils/dict";
|
||||
import * as CheckItemApi from "@/api/biz/checkitem";
|
||||
|
||||
const message = useMessage()
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('选择检验标准')
|
||||
const loading = ref(false)
|
||||
const total = ref(0)
|
||||
const tableRef = ref()
|
||||
let isRestoring = false
|
||||
const CheckItemList = ref([])
|
||||
const selectedCheckItems = ref<any[]>([])
|
||||
const selectedIds = ref<string[]>([])
|
||||
|
||||
const queryParams = reactive({
|
||||
keyWord: undefined,
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
itemType: '',
|
||||
})
|
||||
|
||||
const emit = defineEmits(['confirm'])
|
||||
|
||||
const open = (params?: { schemeType?: number; selectedIds?: number[] }) => {
|
||||
dialogVisible.value = true
|
||||
selectedCheckItems.value = []
|
||||
selectedIds.value = params?.selectedIds ? params.selectedIds.map(String) : []
|
||||
queryParams.itemType = params?.schemeType ?? ''
|
||||
getList()
|
||||
}
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await CheckItemApi.getCheckItemPage(queryParams)
|
||||
CheckItemList.value = data.list
|
||||
total.value = data.total
|
||||
// 恢复已选项
|
||||
isRestoring = true
|
||||
nextTick(() => {
|
||||
tableRef.value?.clearSelection()
|
||||
CheckItemList.value.forEach((row: any) => {
|
||||
if (selectedIds.value.includes(String(row.id))) {
|
||||
tableRef.value?.toggleRowSelection(row, true)
|
||||
}
|
||||
})
|
||||
isRestoring = false
|
||||
})
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const resetQuery = () => {
|
||||
queryParams.keyWord = undefined
|
||||
getList()
|
||||
}
|
||||
|
||||
const handleSelectionChange = (rows: any[]) => {
|
||||
if (isRestoring) return
|
||||
selectedCheckItems.value = rows
|
||||
selectedIds.value = rows.map((item: any) => String(item.id))
|
||||
}
|
||||
|
||||
const handleRowClick = (row: any) => {
|
||||
tableRef.value?.toggleRowSelection(row)
|
||||
}
|
||||
|
||||
const handleRowDblClick = (row: any) => {
|
||||
const isSelected = selectedIds.value.includes(String(row.id))
|
||||
if (!isSelected) {
|
||||
tableRef.value?.toggleRowSelection(row, true)
|
||||
}
|
||||
}
|
||||
|
||||
const confirmSelection = () => {
|
||||
emit('confirm', selectedCheckItems.value)
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
@ -1,67 +1,247 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" @close="cancel" width="1500px">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
label-width="120px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="质检方案编号" prop="schemeNo">
|
||||
<el-input v-model="formData.schemeNo" placeholder="请输入质检方案编号" />
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="编号" prop="schemeNo">
|
||||
<el-input v-model="formData.schemeNo" placeholder="请输入编号" clearable/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="名称" prop="schemeName">
|
||||
<el-input v-model="formData.schemeName" placeholder="请输入名称" clearable/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="适用类型" prop="schemeType">
|
||||
<el-select v-model="formData.schemeType" clearable class="!w-1/1"
|
||||
placeholder="请选择适用类型" @change="formData.tiemClass = undefined">
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.MAT_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="产品大类" prop="tiemClass">
|
||||
<el-select v-model="formData.tiemClass" v-if="formData.schemeType==1" clearable class="!w-1/1"
|
||||
placeholder="请选择产品大类">
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.CLASSIFICATION_CODE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-select v-model="formData.tiemClass" placeholder="请选择产品大类" v-if="formData.schemeType!=1" disabled class="!w-1/1"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="表单编号" prop="formCode">
|
||||
<el-input v-model="formData.formCode" placeholder="请输入表单编号" clearable/>
|
||||
</el-form-item>
|
||||
<el-form-item label="质检方案名称" prop="schemeName">
|
||||
<el-input v-model="formData.schemeName" placeholder="请输入质检方案名称" />
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="执行标准" prop="execStandard">
|
||||
<el-input v-model="formData.execStandard" placeholder="请输入执行标准" clearable/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="检验值数量" prop="testNum">
|
||||
<el-input v-model="formData.testNum" placeholder="请输入检验值数量" clearable/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="描述" prop="remark">
|
||||
<el-input v-model="formData.remark" placeholder="请输入描述" />
|
||||
<el-input v-model="formData.remark" placeholder="请输入描述" clearable/>
|
||||
</el-form-item>
|
||||
<el-form-item label="适用类型,1表示原材料 2表示半成品 3表示成品" prop="schemeType">
|
||||
<el-select v-model="formData.schemeType" placeholder="请选择适用类型,1表示原材料 2表示半成品 3表示成品">
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="15">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="模板编码" prop="printCode" >
|
||||
<el-select v-model="formData.printCode" clearable class="!w-1/1"
|
||||
placeholder="请选择模板编码">
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.MAT_TYPE)"
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.TEMPLATE_CODE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类编码" prop="tiemClass">
|
||||
<el-input v-model="formData.tiemClass" placeholder="请输入分类编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="表单编号" prop="formCode">
|
||||
<el-input v-model="formData.formCode" placeholder="请输入表单编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="执行标准" prop="execStandard">
|
||||
<el-input v-model="formData.execStandard" placeholder="请输入执行标准" />
|
||||
</el-form-item>
|
||||
<el-form-item label="检验值数量" prop="testNum">
|
||||
<el-input v-model="formData.testNum" placeholder="请输入检验值数量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="打印模板编码" prop="printCode">
|
||||
<el-input v-model="formData.printCode" placeholder="请输入打印模板编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="打印模板名称" prop="printName">
|
||||
<el-input v-model="formData.printName" placeholder="请输入打印模板名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-card class="hl-card-info">
|
||||
<template #header>
|
||||
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">质检方案明细</span>
|
||||
<el-button type="primary" size="large" @click="openCheckItem" style="margin-left: 20px">新增</el-button>
|
||||
|
||||
</template>
|
||||
<el-row>
|
||||
<el-col>
|
||||
<el-card class="hl-incard">
|
||||
<el-form ref="OrderYsDetailSubFormRef" :model="formData.inspPlanItemList" label-width="0" >
|
||||
<el-table :data="formData.inspPlanItemList" class="hl-table" >
|
||||
<el-table-column type="index" label="序号" align="center" min-width="60" fixed />
|
||||
<el-table-column label="检验项目" prop="itemName" width="250" align="center">
|
||||
<template #default="scope">
|
||||
{{scope.row.itemName}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="单位" width="120">
|
||||
<template #default="scope">
|
||||
|
||||
<el-input v-model="scope.row.unit" placeholder="请输入单位" clearable/>
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="标准值" width="150">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.standardValue" placeholder="请输入标准值" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="上限值" width="150">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.upperLimit" placeholder="请输入上限值" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="下限值" width="150">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.lowerLimit" placeholder="请输入下限值" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="打印是否合并" width="150">
|
||||
<template #default="scope">
|
||||
<el-select
|
||||
v-model="scope.row.printMergeYn"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.SYSTEM_IS_CELL)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="备注" width="200">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.remark" placeholder="请输入备注" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="打印是否传送标准" width="180">
|
||||
<template #default="scope">
|
||||
<el-select
|
||||
v-model="scope.row.printItem"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.SYSTEM_IS_CELL)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="模板检测值数量" width="180">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.printNum" placeholder="请输入模板检测值数量" clearable/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="展示顺序" prop="seqNo" align="center" width="150" >
|
||||
<template #default="scope">
|
||||
<el-input-number
|
||||
v-model="scope.row.seqNo"
|
||||
placeholder="请输入展示顺序"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
class="!w-1/1"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="操作" align="center" width="120" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button link type="danger" size="small" @click.prevent="onDeleteItem(scope.$index)" >
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
|
||||
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
<CheckItem ref="checkItemRef" @confirm="confirmCheckItem" />
|
||||
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import {getIntDictOptions, DICT_TYPE, getStrDictOptions} from '@/utils/dict'
|
||||
import * as InspPlanApi from '@/api/biz/inspplan'
|
||||
import * as InspPlanItemApi from '@/api/biz/inspplanitem'
|
||||
import CheckItem from "./CheckItem.vue";
|
||||
import {ref} from "vue";
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const {t} = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
const checkItemRef = ref() // 检验项目选择弹窗引用
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
interface InspPlanItem {
|
||||
itemId?: number
|
||||
itemName?: string
|
||||
unit?: string
|
||||
standardValue?: string
|
||||
upperLimit?: string
|
||||
lowerLimit?: string
|
||||
printMergeYn?: string
|
||||
remark?: string
|
||||
printItem?: string
|
||||
printNum?: string
|
||||
seqNo?: number
|
||||
}
|
||||
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
schemeNo: undefined,
|
||||
@ -74,12 +254,51 @@ const formData = ref({
|
||||
testNum: undefined,
|
||||
printCode: undefined,
|
||||
printName: undefined,
|
||||
inspPlanItemList: [] as InspPlanItem[],
|
||||
})
|
||||
const formRules = reactive({
|
||||
schemeName: [{ required: true, message: '质检方案名称不能为空', trigger: 'blur' }],
|
||||
schemeNo: [{required: true, message: '编号不能为空', trigger: 'blur'}],
|
||||
schemeName: [{required: true, message: '名称不能为空', trigger: 'blur'}],
|
||||
schemeType: [{required: true, message: '适用类型不能为空', trigger: 'change'}],
|
||||
testNum: [{required: true, message: '检验值数量不能为空', trigger: 'blur'}],
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
const cancel = async () => {
|
||||
dialogVisible.value = false
|
||||
emit('success')
|
||||
}
|
||||
/** 打开质检方案选择弹窗 */
|
||||
const openCheckItem = () => {
|
||||
if (!formData.value.schemeType) {
|
||||
message.warning('请先选择适用类型')
|
||||
return
|
||||
}
|
||||
const selectedIds = formData.value.inspPlanItemList
|
||||
.filter((item: any) => item.itemId)
|
||||
.map((item: any) => item.itemId)
|
||||
checkItemRef.value.open({
|
||||
schemeType: formData.value.schemeType,
|
||||
selectedIds,
|
||||
})
|
||||
}
|
||||
|
||||
/** 确认选择检验标准 */
|
||||
const confirmCheckItem = async (checkItems: any[]) => {
|
||||
if (!checkItems || checkItems.length === 0) return
|
||||
checkItems.forEach((item: any) => {
|
||||
// 避免重复添加
|
||||
const exists = formData.value.inspPlanItemList.some(
|
||||
(existing: any) => existing.itemId === item.id
|
||||
)
|
||||
if (!exists) {
|
||||
formData.value.inspPlanItemList.push({
|
||||
itemId: item.id,
|
||||
itemName: item.itemName,
|
||||
unit: item.unitName,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
@ -91,16 +310,38 @@ const open = async (type: string, id?: number) => {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await InspPlanApi.getInspPlan(id)
|
||||
formData.value.inspPlanItemList = await InspPlanItemApi.getInspPlanItemByPlanId(id)
|
||||
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
defineExpose({open}) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验展示顺序是否为空
|
||||
const hasEmptySeqNo = formData.value.inspPlanItemList.some((item) => item.seqNo == null || item.seqNo === ('' as unknown as number))
|
||||
if (hasEmptySeqNo) {
|
||||
message.warning('展示顺序不能为空,请输入')
|
||||
return
|
||||
}
|
||||
// 校验展示顺序是否为数字
|
||||
const hasInvalidSeqNo = formData.value.inspPlanItemList.some((item) => item.seqNo != null && typeof item.seqNo !== 'number')
|
||||
if (hasInvalidSeqNo) {
|
||||
message.warning('展示顺序必须为数字,请确认')
|
||||
return
|
||||
}
|
||||
// 校验展示顺序是否重复
|
||||
const seqNos = formData.value.inspPlanItemList
|
||||
.map((item) => item.seqNo)
|
||||
.filter((seqNo) => seqNo != null)
|
||||
if (new Set(seqNos).size !== seqNos.length) {
|
||||
message.warning('展示顺序不能重复,请确认')
|
||||
return
|
||||
}
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
@ -122,6 +363,11 @@ const submitForm = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除子项操作 */
|
||||
const onDeleteItem = async (index) => {
|
||||
formData.value.inspPlanItemList.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
@ -136,7 +382,8 @@ const resetForm = () => {
|
||||
testNum: undefined,
|
||||
printCode: undefined,
|
||||
printName: undefined,
|
||||
inspPlanItemList: [] as InspPlanItem[],
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@ -6,21 +6,21 @@
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item label="质检方案名称" prop="schemeName">
|
||||
<el-form-item label="名称" prop="schemeName">
|
||||
<el-input
|
||||
v-model="queryParams.schemeName"
|
||||
placeholder="请输入质检方案名称"
|
||||
placeholder="请输入名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="适用类型,1表示原材料 2表示半成品 3表示成品" prop="schemeType">
|
||||
<el-form-item label="适用类型" prop="schemeType">
|
||||
<el-select
|
||||
v-model="queryParams.schemeType"
|
||||
placeholder="请选择适用类型,1表示原材料 2表示半成品 3表示成品"
|
||||
placeholder="请选择适用类型"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
@ -39,55 +39,38 @@
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['biz:insp-plan:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['biz:insp-plan:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
<el-table-column label="id" align="center" prop="id" />
|
||||
<el-table-column label="质检方案编号" align="center" prop="schemeNo" />
|
||||
<el-table-column label="质检方案名称" align="center" prop="schemeName" />
|
||||
<el-table-column label="描述" align="center" prop="remark" />
|
||||
<el-table-column label="适用类型,1表示原材料 2表示半成品 3表示成品" align="center" prop="schemeType">
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" border>
|
||||
<el-table-column type="index" label="序号" align="center" min-width="60" />
|
||||
<el-table-column label="名称" align="center" prop="schemeName" />
|
||||
<el-table-column label="适用类型" align="center" prop="schemeType">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.MAT_TYPE" :value="scope.row.schemeType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
/>
|
||||
<el-table-column label="分类编码" align="center" prop="tiemClass" />
|
||||
<el-table-column label="产品大类" align="center" prop="tiemClass" >
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.CLASSIFICATION_CODE" :value="scope.row.tiemClass" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="表单编号" align="center" prop="formCode" />
|
||||
<el-table-column label="执行标准" align="center" prop="execStandard" />
|
||||
<el-table-column label="检验值数量" align="center" prop="testNum" />
|
||||
<el-table-column label="打印模板编码" align="center" prop="printCode" />
|
||||
<el-table-column label="打印模板名称" align="center" prop="printName" />
|
||||
<el-table-column label="描述" align="center" prop="remark" />
|
||||
<el-table-column label="编号" align="center" prop="schemeNo" />
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['biz:insp-plan:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
@ -95,7 +78,6 @@
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['biz:insp-plan:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
@ -117,8 +99,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
|
||||
import * as InspPlanApi from '@/api/biz/inspplan'
|
||||
import InspPlanForm from './InspPlanForm.vue'
|
||||
|
||||
@ -127,7 +108,7 @@ defineOptions({ name: 'InspPlan' })
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const loading = ref(false) // 列表的加载中
|
||||
const list = ref([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
@ -137,7 +118,6 @@ const queryParams = reactive({
|
||||
schemeType: undefined,
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
@ -182,23 +162,10 @@ const handleDelete = async (id: number) => {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await InspPlanApi.exportInspPlan(queryParams)
|
||||
download.excel(data, '质检方案表主.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
// getList()
|
||||
})
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@ -196,6 +196,14 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验序列号是否重复
|
||||
const seqNos = formData.value.shiftConfigList
|
||||
.map((item) => item.seqNo)
|
||||
.filter((seqNo) => seqNo != null)
|
||||
if (new Set(seqNos).size !== seqNos.length) {
|
||||
message.warning('序列号不能重复,请确认')
|
||||
return
|
||||
}
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
|
||||
@ -6,70 +6,60 @@
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="80px">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="6">
|
||||
<el-form-item label="排班年月">
|
||||
<el-date-picker
|
||||
v-model="queryParams.years"
|
||||
value-format="YYYY-MM"
|
||||
type="month"
|
||||
placeholder="请选择排班年月"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
<div style="display: flex; flex-wrap: nowrap; align-items: flex-start;">
|
||||
<el-form-item label="排班年月">
|
||||
<el-date-picker
|
||||
v-model="queryParams.years"
|
||||
value-format="YYYY-MM"
|
||||
type="month"
|
||||
placeholder="请选择排班年月"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div style="display: flex; flex-wrap: nowrap; align-items: flex-start;">
|
||||
<el-form-item label="倒班类型">
|
||||
<el-select
|
||||
v-model="queryParams.chgClassType"
|
||||
placeholder="请选择倒班类型"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.SHIFT_WORK_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="6">
|
||||
<el-form-item label="倒班类型">
|
||||
<el-select
|
||||
v-model="queryParams.chgClassType"
|
||||
placeholder="请选择倒班类型"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.SHIFT_WORK_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="开始日期">
|
||||
<el-date-picker
|
||||
v-model="queryParams.bgnDtime"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="date"
|
||||
placeholder="请选择开始日期"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
:disabled-date="disabledDate"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="success"
|
||||
@click="handleGenerate"
|
||||
:loading="generatedLoading"
|
||||
:disabled="generatedLoading"
|
||||
>
|
||||
生成排班结果
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="开始日期">
|
||||
<el-date-picker
|
||||
v-model="queryParams.bgnDtime"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="date"
|
||||
placeholder="请选择开始日期"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
:disabled-date="disabledDate"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="success"
|
||||
@click="handleGenerate"
|
||||
:loading="generatedLoading"
|
||||
:disabled="generatedLoading"
|
||||
>
|
||||
生成排班结果
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
|
||||
@ -19,13 +19,13 @@
|
||||
/>
|
||||
</el-select> </el-form-item>
|
||||
<el-form-item label="库区编码" prop="storeAreCd">
|
||||
<el-input v-model="formData.storeAreCd" placeholder="请输入库区编码" class="!w-240px" :disabled="formData.id"/>
|
||||
<el-input v-model="formData.storeAreCd" placeholder="请输入库区编码" clearable class="!w-240px" :disabled="formData.id"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="库区名称" prop="storeAreaName">
|
||||
<el-input v-model="formData.storeAreaName" placeholder="请输入库区名称" class="!w-240px"/>
|
||||
<el-input v-model="formData.storeAreaName" placeholder="请输入库区名称" clearable class="!w-240px"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="enabledStatus">
|
||||
<el-select v-model="formData.enabledStatus" placeholder="请选择状态">
|
||||
<el-select v-model="formData.enabledStatus" placeholder="请选择状态" clearable>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_STATUS)"
|
||||
:key="dict.value"
|
||||
@ -35,7 +35,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input type='textarea' :rows="4" v-model="formData.remark" placeholder="请输入备注" />
|
||||
<el-input type='textarea' :rows="4" v-model="formData.remark" placeholder="请输入备注" clearable/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="仓库类型" prop="storeType">
|
||||
<el-select v-model="formData.storeType" placeholder="请选择仓库类型">
|
||||
<el-select v-model="formData.storeType" placeholder="请选择仓库类型" clearable>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.WAREHOUSE_TYPE)"
|
||||
:key="dict.value"
|
||||
@ -19,15 +19,15 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="仓储编码" prop="storeHouseCd">
|
||||
<el-input v-model="formData.storeHouseCd" placeholder="请输入仓储编码" class="!w-240px" :disabled="formData.id"/>
|
||||
<el-input v-model="formData.storeHouseCd" placeholder="请输入仓储编码" clearable class="!w-240px" :disabled="formData.id"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="仓储名称" prop="storeHouseName">
|
||||
<el-input v-model="formData.storeHouseName" placeholder="请输入仓储名称" class="!w-240px" />
|
||||
<el-input v-model="formData.storeHouseName" placeholder="请输入仓储名称" class="!w-240px" clearable/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="状态" prop="enabledStatus">
|
||||
<el-select v-model="formData.enabledStatus" placeholder="请选择状态">
|
||||
<el-select v-model="formData.enabledStatus" placeholder="请选择状态" clearable>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_STATUS)"
|
||||
:key="dict.value"
|
||||
@ -37,7 +37,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input type="textarea" :rows="4" v-model="formData.remark" placeholder="请输入备注" />
|
||||
<el-input type="textarea" :rows="4" v-model="formData.remark" placeholder="请输入备注" clearable/>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
|
||||
@ -9,10 +9,10 @@
|
||||
|
||||
>
|
||||
<el-form-item label="工艺流程" prop="techProc">
|
||||
<el-input v-model="techProcDisplay" placeholder="请输入工艺流程" />
|
||||
<el-input v-model="techProcDisplay" placeholder="请输入工艺流程" clearable disabled/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="enabledStatus">
|
||||
<el-select v-model="formData.enabledStatus" placeholder="请选择状态">
|
||||
<el-select v-model="formData.enabledStatus" placeholder="请选择状态" clearable>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_STATUS)"
|
||||
:key="dict.value"
|
||||
@ -22,7 +22,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input type="textarea" :rows="4" v-model="formData.remark" placeholder="请输入备注" />
|
||||
<el-input type="textarea" :rows="4" v-model="formData.remark" placeholder="请输入备注" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-card class="hl-card-info">
|
||||
@ -127,21 +127,26 @@ const convertCodeToName = (codeStr: string | undefined) => {
|
||||
})
|
||||
return names.join(PROC_SEPARATOR)
|
||||
}
|
||||
/** 工序选择变化处理 - 按列表顺序排列 */
|
||||
/** 工序选择变化处理 - 按选择顺序排列 */
|
||||
const handleProcSelectionChange = (rows: ProcApi.ProcVO[]) => {
|
||||
selectedProcs.value = rows
|
||||
// 获取选中的编码集合
|
||||
const selectedCodes = new Set(rows.map(item => item.procCd))
|
||||
// 按列表顺序过滤选中的工序
|
||||
const sortedSelected = procList.value.filter(item => selectedCodes.has(item.procCd))
|
||||
// 显示用:工序名称拼接(按列表顺序)
|
||||
techProcDisplay.value = sortedSelected.map(item => item.procName).join(PROC_SEPARATOR)
|
||||
// 存储用:工序编码拼接(按列表顺序)
|
||||
formData.value.techProc = sortedSelected.map(item => item.procCd).join(PROC_SEPARATOR)
|
||||
// 保存选中的工序编码列表(按列表顺序)
|
||||
formData.value.procList = sortedSelected.map(item => item.procCd)
|
||||
const newCodes = new Set(rows.map(item => item.procCd))
|
||||
const oldCodes = new Set(selectedProcs.value.map(item => item.procCd))
|
||||
// 找出新增的工序(在 rows 中但不在 selectedProcs 中),追加到末尾
|
||||
for (const row of rows) {
|
||||
if (!oldCodes.has(row.procCd)) {
|
||||
selectedProcs.value.push(row)
|
||||
}
|
||||
}
|
||||
// 找出移除的工序(在 selectedProcs 中但不在 rows 中),从原位置删除
|
||||
selectedProcs.value = selectedProcs.value.filter(item => newCodes.has(item.procCd))
|
||||
// 显示用:工序名称拼接(按选择顺序)
|
||||
techProcDisplay.value = selectedProcs.value.map(item => item.procName).join(PROC_SEPARATOR)
|
||||
// 存储用:工序编码拼接(按选择顺序)
|
||||
formData.value.techProc = selectedProcs.value.map(item => item.procCd).join(PROC_SEPARATOR)
|
||||
// 保存选中的工序编码列表(按选择顺序)
|
||||
formData.value.procList = selectedProcs.value.map(item => item.procCd)
|
||||
}
|
||||
/** 设置表格选中行 */
|
||||
/** 设置表格选中行 - 按传入顺序排列 */
|
||||
const setSelectedRows = (procCodes) => {
|
||||
if (!procCodes || !procTable.value || procList.value.length === 0) {
|
||||
return
|
||||
@ -159,10 +164,12 @@ const setSelectedRows = (procCodes) => {
|
||||
procTable.value.clearSelection()
|
||||
if (codes.length > 0) {
|
||||
const codeSet = new Set(codes.map(c => String(c)))
|
||||
const rows = procList.value.filter(item => codeSet.has(String(item.procCd)))
|
||||
selectedProcs.value = rows
|
||||
// 按 codes 原始顺序筛选,并作为选中顺序
|
||||
selectedProcs.value = codes
|
||||
.map(c => procList.value.find(item => String(item.procCd) === String(c)))
|
||||
.filter(Boolean) as ProcApi.ProcVO[]
|
||||
nextTick(() => {
|
||||
rows.forEach(row => {
|
||||
selectedProcs.value.forEach(row => {
|
||||
procTable.value.toggleRowSelection(row, true)
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user