feat:新增LMS 生箔点位库存管理。
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
package cn.code.nl.module.lms.enums;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.common.enums.RpcConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API 相关的枚举
|
||||||
|
*
|
||||||
|
* @author zhouz
|
||||||
|
*/
|
||||||
|
public class ApiConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务名
|
||||||
|
*
|
||||||
|
* 注意,需要保证和 spring.application.name 保持一致
|
||||||
|
*/
|
||||||
|
public static final String NAME = "lms-server";
|
||||||
|
|
||||||
|
public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/lms";
|
||||||
|
|
||||||
|
public static final String VERSION = "1.0.0";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package cn.code.nl.module.lms.enums;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.common.exception.ErrorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dsh
|
||||||
|
* 2026/7/16
|
||||||
|
*/
|
||||||
|
public interface ErrorCodeConstants {
|
||||||
|
|
||||||
|
// ========== 生箔点位库存 ==========
|
||||||
|
ErrorCode RAW_FOIL_POINT_IVT_NOT_EXISTS = new ErrorCode(1, "生箔点位库存不存在");
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package cn.code.nl.module.lms.controller.admin.rawfoilpointivt;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
import jakarta.validation.*;
|
||||||
|
import jakarta.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.common.pojo.PageParam;
|
||||||
|
import cn.code.nl.framework.common.pojo.PageResult;
|
||||||
|
import cn.code.nl.framework.common.pojo.CommonResult;
|
||||||
|
import cn.code.nl.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.code.nl.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.code.nl.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
import cn.code.nl.module.lms.controller.admin.rawfoilpointivt.vo.*;
|
||||||
|
import cn.code.nl.module.lms.dal.dataobject.rawfoilpointivt.RawFoilPointIVTDO;
|
||||||
|
import cn.code.nl.module.lms.service.rawfoilpointivt.RawFoilPointIVTService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 生箔点位库存")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/lms/raw-foil-point-IVT")
|
||||||
|
@Validated
|
||||||
|
public class RawFoilPointIVTController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RawFoilPointIVTService rawFoilPointIVTService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建生箔点位库存")
|
||||||
|
@PreAuthorize("@ss.hasPermission('lms:raw-foil-point-IVT:create')")
|
||||||
|
public CommonResult<Long> createRawFoilPointIVT(@Valid @RequestBody RawFoilPointIVTSaveReqVO createReqVO) {
|
||||||
|
return success(rawFoilPointIVTService.createRawFoilPointIVT(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新生箔点位库存")
|
||||||
|
@PreAuthorize("@ss.hasPermission('lms:raw-foil-point-IVT:update')")
|
||||||
|
public CommonResult<Boolean> updateRawFoilPointIVT(@Valid @RequestBody RawFoilPointIVTSaveReqVO updateReqVO) {
|
||||||
|
rawFoilPointIVTService.updateRawFoilPointIVT(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除生箔点位库存")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('lms:raw-foil-point-IVT:delete')")
|
||||||
|
public CommonResult<Boolean> deleteRawFoilPointIVT(@RequestParam("id") Long id) {
|
||||||
|
rawFoilPointIVTService.deleteRawFoilPointIVT(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete-list")
|
||||||
|
@Parameter(name = "ids", description = "编号", required = true)
|
||||||
|
@Operation(summary = "批量删除生箔点位库存")
|
||||||
|
@PreAuthorize("@ss.hasPermission('lms:raw-foil-point-IVT:delete')")
|
||||||
|
public CommonResult<Boolean> deleteRawFoilPointIVTList(@RequestParam("ids") List<Long> ids) {
|
||||||
|
rawFoilPointIVTService.deleteRawFoilPointIVTListByIds(ids);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得生箔点位库存")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('lms:raw-foil-point-IVT:query')")
|
||||||
|
public CommonResult<RawFoilPointIVTRespVO> getRawFoilPointIVT(@RequestParam("id") Long id) {
|
||||||
|
RawFoilPointIVTDO rawFoilPointIVT = rawFoilPointIVTService.getRawFoilPointIVT(id);
|
||||||
|
return success(BeanUtils.toBean(rawFoilPointIVT, RawFoilPointIVTRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得生箔点位库存分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('lms:raw-foil-point-IVT:query')")
|
||||||
|
public CommonResult<PageResult<RawFoilPointIVTRespVO>> getRawFoilPointIVTPage(@Valid RawFoilPointIVTPageReqVO pageReqVO) {
|
||||||
|
PageResult<RawFoilPointIVTDO> pageResult = rawFoilPointIVTService.getRawFoilPointIVTPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, RawFoilPointIVTRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出生箔点位库存 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('lms:raw-foil-point-IVT:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportRawFoilPointIVTExcel(@Valid RawFoilPointIVTPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<RawFoilPointIVTDO> list = rawFoilPointIVTService.getRawFoilPointIVTPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "生箔点位库存.xls", "数据", RawFoilPointIVTRespVO.class,
|
||||||
|
BeanUtils.toBean(list, RawFoilPointIVTRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package cn.code.nl.module.lms.controller.admin.rawfoilpointivt.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.code.nl.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.code.nl.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 生箔点位库存分页 Request VO")
|
||||||
|
@Data
|
||||||
|
public class RawFoilPointIVTPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "点位编码")
|
||||||
|
private String pointCode;
|
||||||
|
|
||||||
|
@Schema(description = "载具编码")
|
||||||
|
private String vehicleCode;
|
||||||
|
|
||||||
|
@Schema(description = "生产区域")
|
||||||
|
private String productionArea;
|
||||||
|
|
||||||
|
@Schema(description = "位置")
|
||||||
|
private String pointLocation;
|
||||||
|
|
||||||
|
@Schema(description = "外部编码")
|
||||||
|
private String extCode;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用")
|
||||||
|
private String isUsed;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package cn.code.nl.module.lms.controller.admin.rawfoilpointivt.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import cn.idev.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 生箔点位库存 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class RawFoilPointIVTRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "点位标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "31653")
|
||||||
|
@ExcelProperty("点位标识")
|
||||||
|
private Long pointId;
|
||||||
|
|
||||||
|
@Schema(description = "点位编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("点位编码")
|
||||||
|
private String pointCode;
|
||||||
|
|
||||||
|
@Schema(description = "载具编码")
|
||||||
|
@ExcelProperty("载具编码")
|
||||||
|
private String vehicleCode;
|
||||||
|
|
||||||
|
@Schema(description = "生产区域")
|
||||||
|
@ExcelProperty("生产区域")
|
||||||
|
private String productionArea;
|
||||||
|
|
||||||
|
@Schema(description = "位置")
|
||||||
|
@ExcelProperty("位置")
|
||||||
|
private String pointLocation;
|
||||||
|
|
||||||
|
@Schema(description = "外部编码")
|
||||||
|
@ExcelProperty("外部编码")
|
||||||
|
private String extCode;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("是否启用")
|
||||||
|
private String isUsed;
|
||||||
|
|
||||||
|
@Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||||
|
@ExcelProperty("创建人")
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "修改人", example = "张三")
|
||||||
|
@ExcelProperty("修改人")
|
||||||
|
private String updater;
|
||||||
|
|
||||||
|
@Schema(description = "修改时间")
|
||||||
|
@ExcelProperty("修改时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@Schema(description = "是否删除")
|
||||||
|
@ExcelProperty("是否删除")
|
||||||
|
private String deleted;
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package cn.code.nl.module.lms.controller.admin.rawfoilpointivt.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 生箔点位库存新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class RawFoilPointIVTSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "点位标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "31653")
|
||||||
|
private Long pointId;
|
||||||
|
|
||||||
|
@Schema(description = "点位编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "点位编码不能为空")
|
||||||
|
private String pointCode;
|
||||||
|
|
||||||
|
@Schema(description = "载具编码")
|
||||||
|
private String vehicleCode;
|
||||||
|
|
||||||
|
@Schema(description = "生产区域")
|
||||||
|
private String productionArea;
|
||||||
|
|
||||||
|
@Schema(description = "位置")
|
||||||
|
private String pointLocation;
|
||||||
|
|
||||||
|
@Schema(description = "外部编码")
|
||||||
|
private String extCode;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "是否启用不能为空")
|
||||||
|
private String isUsed;
|
||||||
|
|
||||||
|
@Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "修改人", example = "张三")
|
||||||
|
private String updater;
|
||||||
|
|
||||||
|
@Schema(description = "修改时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@Schema(description = "是否删除")
|
||||||
|
private String deleted;
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package cn.code.nl.module.lms.dal.dataobject.rawfoilpointivt;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.code.nl.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生箔点位库存 DO
|
||||||
|
*
|
||||||
|
* @author 诺力管理员
|
||||||
|
*/
|
||||||
|
@TableName("lms_rawfoil_pointivt")
|
||||||
|
@KeySequence("lms_rawfoil_pointivt_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class RawFoilPointIVTDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点位标识
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long pointId;
|
||||||
|
/**
|
||||||
|
* 点位编码
|
||||||
|
*/
|
||||||
|
private String pointCode;
|
||||||
|
/**
|
||||||
|
* 载具编码
|
||||||
|
*/
|
||||||
|
private String vehicleCode;
|
||||||
|
/**
|
||||||
|
* 生产区域
|
||||||
|
*/
|
||||||
|
private String productionArea;
|
||||||
|
/**
|
||||||
|
* 位置
|
||||||
|
*/
|
||||||
|
private String pointLocation;
|
||||||
|
/**
|
||||||
|
* 外部编码
|
||||||
|
*/
|
||||||
|
private String extCode;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
/**
|
||||||
|
* 是否启用
|
||||||
|
*/
|
||||||
|
private String isUsed;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.code.nl.module.lms.dal.mysql.rawfoilpointivt;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.common.pojo.PageResult;
|
||||||
|
import cn.code.nl.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.code.nl.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.code.nl.module.lms.dal.dataobject.rawfoilpointivt.RawFoilPointIVTDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.rawfoilpointivt.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生箔点位库存 Mapper
|
||||||
|
*
|
||||||
|
* @author 诺力管理员
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface RawFoilPointIVTMapper extends BaseMapperX<RawFoilPointIVTDO> {
|
||||||
|
|
||||||
|
default PageResult<RawFoilPointIVTDO> selectPage(RawFoilPointIVTPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<RawFoilPointIVTDO>()
|
||||||
|
.eqIfPresent(RawFoilPointIVTDO::getPointCode, reqVO.getPointCode())
|
||||||
|
.eqIfPresent(RawFoilPointIVTDO::getVehicleCode, reqVO.getVehicleCode())
|
||||||
|
.eqIfPresent(RawFoilPointIVTDO::getProductionArea, reqVO.getProductionArea())
|
||||||
|
.eqIfPresent(RawFoilPointIVTDO::getPointLocation, reqVO.getPointLocation())
|
||||||
|
.eqIfPresent(RawFoilPointIVTDO::getExtCode, reqVO.getExtCode())
|
||||||
|
.eqIfPresent(RawFoilPointIVTDO::getIsUsed, reqVO.getIsUsed())
|
||||||
|
.orderByDesc(RawFoilPointIVTDO::getPointId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package cn.code.nl.module.lms.framwork.security.config;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.security.config.AuthorizeRequestsCustomizer;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lms 模块的 Security 配置
|
||||||
|
*
|
||||||
|
* @author dsh
|
||||||
|
* 2026/7/16
|
||||||
|
*/
|
||||||
|
@Configuration(proxyBeanMethods = false, value = "lmsSecurityConfiguration")
|
||||||
|
public class SecurityConfiguration {
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* 根因确认
|
||||||
|
|
||||||
|
问题出在 NlWebSecurityConfigurerAdapter.java:77-78:
|
||||||
|
|
||||||
|
@Resource // 第77行
|
||||||
|
private List<AuthorizeRequestsCustomizer> authorizeRequestsCustomizers;
|
||||||
|
|
||||||
|
@Resource 在处理 List<T> 泛型注入时的行为与 @Autowired 不同:
|
||||||
|
- @Autowired 能正确按元素类型 T 解析,即使 0 个 Bean 也能注入空集合
|
||||||
|
- @Resource 先按字段名查找,失败后按原始类型回退匹配。由于泛型擦除,类型变成了原始 java.util.List,Spring 找不到类型为 java.util.List 的 Bean,直接报错
|
||||||
|
|
||||||
|
为什么 infra 模块正常? infra 模块的 SecurityConfiguration 定义了 1 个 AuthorizeRequestsCustomizer Bean,@Resource 的非空集合路径能正确处理。而 base 模块有
|
||||||
|
0 个这样的 Bean,触发了空集合路径的 bug。
|
||||||
|
|
||||||
|
修复方式: 为 base 模块创建 SecurityConfiguration(已创建),这是该项目的标准模式(每个模块定义自己的安全配置)。
|
||||||
|
|
||||||
|
现在验证修改:
|
||||||
|
|
||||||
|
Thought for 6s, read 1 file (ctrl+o to expand)
|
||||||
|
|
||||||
|
⏺ 配置已创建。让我验证一下文件结构是否完整:
|
||||||
|
|
||||||
|
Thought for 5s, searched for 1 pattern (ctrl+o to expand)
|
||||||
|
|
||||||
|
⏺ 总结
|
||||||
|
|
||||||
|
问题根因
|
||||||
|
|
||||||
|
NlWebSecurityConfigurerAdapter.java:77-78 中使用了 @Resource 注入 List<AuthorizeRequestsCustomizer>:
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private List<AuthorizeRequestsCustomizer> authorizeRequestsCustomizers;
|
||||||
|
|
||||||
|
@Resource 在处理泛型集合时存在局限性,按字段名查找失败后会按原始类型 java.util.List 回退匹配,导致 Spring 找不到对应 Bean 而报错。@Autowired
|
||||||
|
能正确处理这种情况(包括空集合),但 @Resource 不行。
|
||||||
|
|
||||||
|
修复内容
|
||||||
|
|
||||||
|
创建了 base 模块的 SecurityConfiguration(参考 infra 模块的同等配置):
|
||||||
|
|
||||||
|
nl-module-base/nl-module-base-server/src/main/java/cn/code/nl/module/base/framework/security/config/SecurityConfiguration.java
|
||||||
|
|
||||||
|
这个配置类:
|
||||||
|
1. 定义了一个 AuthorizeRequestsCustomizer Bean,使 NlWebSecurityConfigurerAdapter 中的 List<AuthorizeRequestsCustomizer> 能正确解析
|
||||||
|
1. 定义了一个 AuthorizeRequestsCustomizer Bean,使 NlWebSecurityConfigurerAdapter 中的 List<AuthorizeRequestsCustomizer> 能正确解析
|
||||||
|
|
||||||
|
Thought for 5s, searched for 1 pattern (ctrl+o to expand)
|
||||||
|
⏺ 总结
|
||||||
|
|
||||||
|
问题根因
|
||||||
|
|
||||||
|
NlWebSecurityConfigurerAdapter.java:77-78 中使用了 @Resource 注入
|
||||||
|
List<AuthorizeRequestsCustomizer>:
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private List<AuthorizeRequestsCustomizer> authorizeRequestsCustomizers;
|
||||||
|
|
||||||
|
@Resource 在处理泛型集合时存在局限性,按字段名查找失败后会按原始类型
|
||||||
|
java.util.List 回退匹配,导致 Spring 找不到对应 Bean 而报错。@Autowired
|
||||||
|
能正确处理这种情况(包括空集合),但 @Resource 不行。
|
||||||
|
修复内容
|
||||||
|
|
||||||
|
创建了 base 模块的 SecurityConfiguration(参考 infra 模块的同等配置):
|
||||||
|
|
||||||
|
nl-module-base/nl-module-base-server/src/main/java/cn/code/nl/module/base/fr
|
||||||
|
amework/security/config/SecurityConfiguration.java
|
||||||
|
|
||||||
|
|
||||||
|
nl-module-base/nl-module-base-server/src/main/java/cn/code/nl/module/base/framework/security/config/SecurityConfiguration.java
|
||||||
|
|
||||||
|
这个配置类:
|
||||||
|
1. 定义了一个 AuthorizeRequestsCustomizer Bean,使 NlWebSecurityConfigurerAdapter 中的 List<AuthorizeRequestsCustomizer> 能正确解析
|
||||||
|
2. 配置了 Swagger、Actuator、Druid 等公共路径的免登录访问
|
||||||
|
3. 遵循了项目中每个模块定义各自安全配置的标准模式
|
||||||
|
|
||||||
|
3. 遵循了项目中每个模块定义各自安全配置的标准模式
|
||||||
|
* */
|
||||||
|
@Bean("lmsAuthorizeRequestsCustomizer")
|
||||||
|
public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() {
|
||||||
|
return new AuthorizeRequestsCustomizer() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) {
|
||||||
|
// Swagger 接口文档
|
||||||
|
registry.requestMatchers("/v3/api-docs/**").permitAll()
|
||||||
|
.requestMatchers("/webjars/**").permitAll()
|
||||||
|
.requestMatchers("/swagger-ui").permitAll()
|
||||||
|
.requestMatchers("/swagger-ui/**").permitAll();
|
||||||
|
// Spring Boot Actuator 的安全配置
|
||||||
|
registry.requestMatchers("/actuator").permitAll()
|
||||||
|
.requestMatchers("/actuator/**").permitAll();
|
||||||
|
// Druid 监控
|
||||||
|
registry.requestMatchers("/druid/**").permitAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package cn.code.nl.module.lms.service.rawfoilpointivt;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import jakarta.validation.*;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.rawfoilpointivt.vo.*;
|
||||||
|
import cn.code.nl.module.lms.dal.dataobject.rawfoilpointivt.RawFoilPointIVTDO;
|
||||||
|
import cn.code.nl.framework.common.pojo.PageResult;
|
||||||
|
import cn.code.nl.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生箔点位库存 Service 接口
|
||||||
|
*
|
||||||
|
* @author 诺力管理员
|
||||||
|
*/
|
||||||
|
public interface RawFoilPointIVTService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建生箔点位库存
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createRawFoilPointIVT(@Valid RawFoilPointIVTSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新生箔点位库存
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateRawFoilPointIVT(@Valid RawFoilPointIVTSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除生箔点位库存
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteRawFoilPointIVT(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除生箔点位库存
|
||||||
|
*
|
||||||
|
* @param ids 编号
|
||||||
|
*/
|
||||||
|
void deleteRawFoilPointIVTListByIds(List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得生箔点位库存
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 生箔点位库存
|
||||||
|
*/
|
||||||
|
RawFoilPointIVTDO getRawFoilPointIVT(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得生箔点位库存分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 生箔点位库存分页
|
||||||
|
*/
|
||||||
|
PageResult<RawFoilPointIVTDO> getRawFoilPointIVTPage(RawFoilPointIVTPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package cn.code.nl.module.lms.service.rawfoilpointivt;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.rawfoilpointivt.vo.*;
|
||||||
|
import cn.code.nl.module.lms.dal.dataobject.rawfoilpointivt.RawFoilPointIVTDO;
|
||||||
|
import cn.code.nl.framework.common.pojo.PageResult;
|
||||||
|
import cn.code.nl.framework.common.pojo.PageParam;
|
||||||
|
import cn.code.nl.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.code.nl.module.lms.dal.mysql.rawfoilpointivt.RawFoilPointIVTMapper;
|
||||||
|
|
||||||
|
import static cn.code.nl.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.code.nl.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
import static cn.code.nl.framework.common.util.collection.CollectionUtils.diffList;
|
||||||
|
import static cn.code.nl.module.lms.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生箔点位库存 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 诺力管理员
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class RawFoilPointIVTServiceImpl implements RawFoilPointIVTService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RawFoilPointIVTMapper rawFoilPointIVTMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createRawFoilPointIVT(RawFoilPointIVTSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
RawFoilPointIVTDO rawFoilPointIVT = BeanUtils.toBean(createReqVO, RawFoilPointIVTDO.class);
|
||||||
|
rawFoilPointIVTMapper.insert(rawFoilPointIVT);
|
||||||
|
|
||||||
|
// 返回
|
||||||
|
return rawFoilPointIVT.getPointId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRawFoilPointIVT(RawFoilPointIVTSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateRawFoilPointIVTExists(updateReqVO.getPointId());
|
||||||
|
// 更新
|
||||||
|
RawFoilPointIVTDO updateObj = BeanUtils.toBean(updateReqVO, RawFoilPointIVTDO.class);
|
||||||
|
rawFoilPointIVTMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteRawFoilPointIVT(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateRawFoilPointIVTExists(id);
|
||||||
|
// 删除
|
||||||
|
rawFoilPointIVTMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteRawFoilPointIVTListByIds(List<Long> ids) {
|
||||||
|
// 删除
|
||||||
|
rawFoilPointIVTMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void validateRawFoilPointIVTExists(Long id) {
|
||||||
|
if (rawFoilPointIVTMapper.selectById(id) == null) {
|
||||||
|
throw exception(RAW_FOIL_POINT_IVT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RawFoilPointIVTDO getRawFoilPointIVT(Long id) {
|
||||||
|
return rawFoilPointIVTMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<RawFoilPointIVTDO> getRawFoilPointIVTPage(RawFoilPointIVTPageReqVO pageReqVO) {
|
||||||
|
return rawFoilPointIVTMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.code.nl.module.lms.dal.mysql.rawfoilpointivt.RawFoilPointIVTMapper">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||||
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
|
-->
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
import type { Dayjs } from 'dayjs';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace LmsRawFoilPointIVTApi {
|
||||||
|
/** 生箔点位库存信息 */
|
||||||
|
export interface RawFoilPointIVT {
|
||||||
|
pointId: number; // 点位标识
|
||||||
|
pointCode: string; // 点位编码
|
||||||
|
vehicleCode: string; // 载具编码
|
||||||
|
productionArea: string; // 生产区域
|
||||||
|
pointLocation: string; // 位置
|
||||||
|
extCode: string; // 外部编码
|
||||||
|
remark: string; // 备注
|
||||||
|
isUsed: string; // 是否启用
|
||||||
|
creator: string; // 创建人
|
||||||
|
createTime: string | Dayjs; // 创建时间
|
||||||
|
updater: string; // 修改人
|
||||||
|
updateTime: string | Dayjs; // 修改时间
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询生箔点位库存分页 */
|
||||||
|
export function getRawFoilPointIVTPage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<LmsRawFoilPointIVTApi.RawFoilPointIVT>>(
|
||||||
|
'/lms/raw-foil-point-IVT/page',
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询生箔点位库存详情 */
|
||||||
|
export function getRawFoilPointIVT(id: number) {
|
||||||
|
return requestClient.get<LmsRawFoilPointIVTApi.RawFoilPointIVT>(
|
||||||
|
`/lms/raw-foil-point-IVT/get?id=${id}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增生箔点位库存 */
|
||||||
|
export function createRawFoilPointIVT(data: LmsRawFoilPointIVTApi.RawFoilPointIVT) {
|
||||||
|
return requestClient.post('/lms/raw-foil-point-IVT/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改生箔点位库存 */
|
||||||
|
export function updateRawFoilPointIVT(data: LmsRawFoilPointIVTApi.RawFoilPointIVT) {
|
||||||
|
return requestClient.put('/lms/raw-foil-point-IVT/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除生箔点位库存 */
|
||||||
|
export function deleteRawFoilPointIVT(id: number) {
|
||||||
|
return requestClient.delete(`/lms/raw-foil-point-IVT/delete?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量删除生箔点位库存 */
|
||||||
|
export function deleteRawFoilPointIVTList(ids: number[]) {
|
||||||
|
return requestClient.delete(
|
||||||
|
`/lms/raw-foil-point-IVT/delete-list?ids=${ids.join(',')}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出生箔点位库存 */
|
||||||
|
export function exportRawFoilPointIVT(params: any) {
|
||||||
|
return requestClient.download('/lms/raw-foil-point-IVT/export-excel', { params });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { LmsRawFoilPointIVTApi } from '#/api/lms/rawfoilpointivt';
|
||||||
|
|
||||||
|
import {DICT_TYPE} from "@vben/constants";
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
|
import {z} from "#/adapter/form";
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'pointId',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'pointCode',
|
||||||
|
label: '点位编码',
|
||||||
|
rules: 'required',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入点位编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'vehicleCode',
|
||||||
|
label: '载具编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入载具编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'productionArea',
|
||||||
|
label: '生产区域',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.PRODUCT_AREA),
|
||||||
|
placeholder: '请选择生产区域',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'pointLocation',
|
||||||
|
label: '位置',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入位置',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'extCode',
|
||||||
|
label: '外部编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入外部编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'TextArea',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'isUsed',
|
||||||
|
label: '是否启用',
|
||||||
|
rules: z.string().default('1'),
|
||||||
|
component: 'RadioGroup',
|
||||||
|
componentProps: {
|
||||||
|
options: [{ label: '是', value: '1' }, { label: '否', value: '0' }],
|
||||||
|
buttonStyle: 'solid',
|
||||||
|
optionType: 'button',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'pointCode',
|
||||||
|
label: '点位编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入点位编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'vehicleCode',
|
||||||
|
label: '载具编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入载具编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'productionArea',
|
||||||
|
label: '生产区域',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.PRODUCT_AREA),
|
||||||
|
placeholder: '请选择生产区域',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'pointLocation',
|
||||||
|
label: '位置',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入位置',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'extCode',
|
||||||
|
label: '外部编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入外部编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'isUsed',
|
||||||
|
label: '是否启用',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
options: [
|
||||||
|
{ label: '是', value: '1' },
|
||||||
|
{ label: '否', value: '0' },
|
||||||
|
],
|
||||||
|
placeholder: '请选择是否启用',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<LmsRawFoilPointIVTApi.RawFoilPointIVT>['columns'] {
|
||||||
|
return [
|
||||||
|
{ type: 'checkbox', width: 40 },
|
||||||
|
{
|
||||||
|
field: 'pointCode',
|
||||||
|
title: '点位编码',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'vehicleCode',
|
||||||
|
title: '载具编码',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productionArea',
|
||||||
|
title: '生产区域',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'pointLocation',
|
||||||
|
title: '位置',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'extCode',
|
||||||
|
title: '外部编码',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'isUsed',
|
||||||
|
title: '是否启用',
|
||||||
|
minWidth: 120,
|
||||||
|
formatter: ({ cellValue }: { cellValue: string }) => (cellValue === '1' ? '是' : '否')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'creator',
|
||||||
|
title: '创建人',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
minWidth: 120,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'updater',
|
||||||
|
title: '修改人',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'updateTime',
|
||||||
|
title: '修改时间',
|
||||||
|
minWidth: 120,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 200,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { LmsRawFoilPointIVTApi } from '#/api/lms/rawfoilpointivt';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
import { confirm, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||||
|
|
||||||
|
import { message } from 'antdv-next';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
deleteRawFoilPointIVT,
|
||||||
|
deleteRawFoilPointIVTList,
|
||||||
|
exportRawFoilPointIVT,
|
||||||
|
getRawFoilPointIVTPage,
|
||||||
|
} from '#/api/lms/rawfoilpointivt';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建生箔点位库存 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi.setData(null).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑生箔点位库存 */
|
||||||
|
function handleEdit(row: LmsRawFoilPointIVTApi.RawFoilPointIVT) {
|
||||||
|
formModalApi.setData(row).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除生箔点位库存 */
|
||||||
|
async function handleDelete(row: LmsRawFoilPointIVTApi.RawFoilPointIVT) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.pointId]),
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteRawFoilPointIVT(row.pointId!);
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess', [row.pointId]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量删除生箔点位库存 */
|
||||||
|
async function handleDeleteBatch() {
|
||||||
|
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deletingBatch'),
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteRawFoilPointIVTList(checkedIds.value);
|
||||||
|
checkedIds.value = [];
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkedIds = ref<number[]>([]);
|
||||||
|
function handleRowCheckboxChange({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: LmsRawFoilPointIVTApi.RawFoilPointIVT[];
|
||||||
|
}) {
|
||||||
|
checkedIds.value = records.map((item) => item.pointId!);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportRawFoilPointIVT(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: '生箔点位库存.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getRawFoilPointIVTPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<LmsRawFoilPointIVTApi.RawFoilPointIVT>,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: handleRowCheckboxChange,
|
||||||
|
checkboxChange: handleRowCheckboxChange,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<FormModal @success="handleRefresh" />
|
||||||
|
<Grid table-title="生箔点位库存列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.create', ['生箔点位库存']),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
auth: ['lms:raw-foil-point-IVT:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['lms:raw-foil-point-IVT:export'],
|
||||||
|
onClick: handleExport,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.deleteBatch'),
|
||||||
|
type: 'primary',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['lms:raw-foil-point-IVT:delete'],
|
||||||
|
disabled: isEmpty(checkedIds),
|
||||||
|
onClick: handleDeleteBatch,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['lms:raw-foil-point-IVT:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'link',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['lms:raw-foil-point-IVT:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.pointId]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { LmsRawFoilPointIVTApi } from '#/api/lms/rawfoilpointivt';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { message } from 'antdv-next';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import { createRawFoilPointIVT, getRawFoilPointIVT, updateRawFoilPointIVT } from '#/api/lms/rawfoilpointivt';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<LmsRawFoilPointIVTApi.RawFoilPointIVT>();
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
return formData.value?.pointId
|
||||||
|
? $t('ui.actionTitle.edit', ['生箔点位库存'])
|
||||||
|
: $t('ui.actionTitle.create', ['生箔点位库存']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 80,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: useFormSchema(),
|
||||||
|
showDefaultActions: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data = (await formApi.getValues()) as LmsRawFoilPointIVTApi.RawFoilPointIVT;
|
||||||
|
try {
|
||||||
|
await (formData.value?.pointId ? updateRawFoilPointIVT(data) : createRawFoilPointIVT(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<LmsRawFoilPointIVTApi.RawFoilPointIVT>();
|
||||||
|
if (!data || !data.pointId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getRawFoilPointIVT(data.pointId);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
Reference in New Issue
Block a user