feat:代码初始化

This commit is contained in:
2026-07-10 13:17:35 +08:00
parent eefb056fea
commit 812dd50f66
20 changed files with 1744 additions and 895 deletions

View File

@@ -45,6 +45,19 @@ spring:
- Path=/app-api/system/**
filters:
- RewritePath=/app-api/system/v3/api-docs, /v3/api-docs
## lms-server 服务
- id: lms-admin-api # 路由的编号
uri: grayLb://lms-server
predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
- Path=/admin-api/lms/**
filters:
- RewritePath=/admin-api/lms/v3/api-docs, /v3/api-docs # 配置,保证转发到 /v3/api-docs
- id: lms-app-api # 路由的编号
uri: grayLb://lms-server
predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
- Path=/app-api/lms/**
filters:
- RewritePath=/app-api/lms/v3/api-docs, /v3/api-docs
## infra-server 服务
- id: infra-admin-api # 路由的编号
uri: grayLb://infra-server
@@ -233,6 +246,9 @@ knife4j:
gateway:
enabled: true
routes:
- name: lms-server
service-name: lms-server
url: /admin-api/lms/v3/api-docs
- name: system-server
service-name: system-server
url: /admin-api/system/v3/api-docs

View File

@@ -134,4 +134,4 @@ spring:
# 芋道配置项,设置当前项目所有自定义的配置
nl:
demo: true # 开启演示模式
demo: false # 开启演示模式

View File

@@ -0,0 +1,23 @@
package cn.code.nl.module.lms.enums;
import cn.code.nl.framework.common.enums.RpcConstants;
/**
* API 相关的枚举
*
* @author liyongde
*/
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";
}

View File

@@ -0,0 +1,12 @@
package cn.code.nl.module.lms.enums;
import cn.code.nl.framework.common.exception.ErrorCode;
/**
*
* @Author: liyongde
* @Date: 2026/7/10 10:12
*/
public interface ErrorCodeConstants {
ErrorCode PDM_RAW_FOIL_WORK_ORDER_NOT_EXISTS = new ErrorCode(100001, "生箔工序工单不存在");
}

View File

@@ -0,0 +1,104 @@
package cn.code.nl.module.lms.controller.admin.pdmrawfoilworkorder;
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.pdmrawfoilworkorder.vo.*;
import cn.code.nl.module.lms.dal.dataobject.pdmrawfoilworkorder.PdmRawFoilWorkOrderDO;
import cn.code.nl.module.lms.service.pdmrawfoilworkorder.PdmRawFoilWorkOrderService;
@Tag(name = "管理后台 - 生箔工序工单")
@RestController
@RequestMapping("/lms/pdm-raw-foil-work-order")
@Validated
public class PdmRawFoilWorkOrderController {
@Resource
private PdmRawFoilWorkOrderService pdmRawFoilWorkOrderService;
@PostMapping("/create")
@Operation(summary = "创建生箔工序工单")
@PreAuthorize("@ss.hasPermission('lms:pdm-raw-foil-work-order:create')")
public CommonResult<Long> createPdmRawFoilWorkOrder(@Valid @RequestBody PdmRawFoilWorkOrderSaveReqVO createReqVO) {
return success(pdmRawFoilWorkOrderService.createPdmRawFoilWorkOrder(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新生箔工序工单")
@PreAuthorize("@ss.hasPermission('lms:pdm-raw-foil-work-order:update')")
public CommonResult<Boolean> updatePdmRawFoilWorkOrder(@Valid @RequestBody PdmRawFoilWorkOrderSaveReqVO updateReqVO) {
pdmRawFoilWorkOrderService.updatePdmRawFoilWorkOrder(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除生箔工序工单")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('lms:pdm-raw-foil-work-order:delete')")
public CommonResult<Boolean> deletePdmRawFoilWorkOrder(@RequestParam("id") Long id) {
pdmRawFoilWorkOrderService.deletePdmRawFoilWorkOrder(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除生箔工序工单")
@PreAuthorize("@ss.hasPermission('lms:pdm-raw-foil-work-order:delete')")
public CommonResult<Boolean> deletePdmRawFoilWorkOrderList(@RequestParam("ids") List<Long> ids) {
pdmRawFoilWorkOrderService.deletePdmRawFoilWorkOrderListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得生箔工序工单")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('lms:pdm-raw-foil-work-order:query')")
public CommonResult<PdmRawFoilWorkOrderRespVO> getPdmRawFoilWorkOrder(@RequestParam("id") Long id) {
PdmRawFoilWorkOrderDO pdmRawFoilWorkOrder = pdmRawFoilWorkOrderService.getPdmRawFoilWorkOrder(id);
return success(BeanUtils.toBean(pdmRawFoilWorkOrder, PdmRawFoilWorkOrderRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得生箔工序工单分页")
@PreAuthorize("@ss.hasPermission('lms:pdm-raw-foil-work-order:query')")
public CommonResult<PageResult<PdmRawFoilWorkOrderRespVO>> getPdmRawFoilWorkOrderPage(@Valid PdmRawFoilWorkOrderPageReqVO pageReqVO) {
PageResult<PdmRawFoilWorkOrderDO> pageResult = pdmRawFoilWorkOrderService.getPdmRawFoilWorkOrderPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, PdmRawFoilWorkOrderRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出生箔工序工单 Excel")
@PreAuthorize("@ss.hasPermission('lms:pdm-raw-foil-work-order:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportPdmRawFoilWorkOrderExcel(@Valid PdmRawFoilWorkOrderPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PdmRawFoilWorkOrderDO> list = pdmRawFoilWorkOrderService.getPdmRawFoilWorkOrderPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "生箔工序工单.xls", "数据", PdmRawFoilWorkOrderRespVO.class,
BeanUtils.toBean(list, PdmRawFoilWorkOrderRespVO.class));
}
}

View File

@@ -0,0 +1,90 @@
package cn.code.nl.module.lms.controller.admin.pdmrawfoilworkorder.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.code.nl.framework.common.pojo.PageParam;
import java.math.BigDecimal;
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 PdmRawFoilWorkOrderPageReqVO extends PageParam {
@Schema(description = "母卷号", example = "芋艿")
private String containerName;
@Schema(description = "机台编码", example = "赵六")
private String resourceName;
@Schema(description = "生产工单", example = "王五")
private String mfgOrderName;
@Schema(description = "产品编码")
private String productCode;
@Schema(description = "产品名称", example = "随便")
private String description;
@Schema(description = "理论长度")
private BigDecimal theoryHeight;
@Schema(description = "设备生产速度")
private BigDecimal eqpVelocity;
@Schema(description = "上卷开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private String[] upCoilerDate;
@Schema(description = "是否重新更新")
private String isReloadSend;
@Schema(description = "重量")
private BigDecimal productinQty;
@Schema(description = "开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private String[] realstartTime;
@Schema(description = "结束时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private String[] realendTime;
@Schema(description = "状态", example = "1")
private String status;
@Schema(description = "完成方式", example = "2")
private String finishType;
@Schema(description = "车号")
private String agvno;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "生产区域")
private String productArea;
@Schema(description = "点位编码")
private String pointCode;
@Schema(description = "请求烘烤")
private String isBaking;
@Schema(description = "请求入半成品库")
private String isInstor;
@Schema(description = "收卷辊")
private String windRoll;
@Schema(description = "类型", example = "2")
private String orderType;
}

View File

@@ -0,0 +1,108 @@
package cn.code.nl.module.lms.controller.admin.pdmrawfoilworkorder.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import cn.idev.excel.annotation.*;
@Schema(description = "管理后台 - 生箔工序工单 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PdmRawFoilWorkOrderRespVO {
@Schema(description = "母卷号", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@ExcelProperty("母卷号")
private String containerName;
@Schema(description = "机台编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@ExcelProperty("机台编码")
private String resourceName;
@Schema(description = "生产工单", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("生产工单")
private String mfgOrderName;
@Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("产品编码")
private String productCode;
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
@ExcelProperty("产品名称")
private String description;
@Schema(description = "理论长度", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("理论长度")
private BigDecimal theoryHeight;
@Schema(description = "设备生产速度", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("设备生产速度")
private BigDecimal eqpVelocity;
@Schema(description = "上卷开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("上卷开始时间")
private String upCoilerDate;
@Schema(description = "是否重新更新", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("是否重新更新")
private String isReloadSend;
@Schema(description = "重量")
@ExcelProperty("重量")
private BigDecimal productinQty;
@Schema(description = "开始时间")
@ExcelProperty("开始时间")
private String realstartTime;
@Schema(description = "结束时间")
@ExcelProperty("结束时间")
private String realendTime;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("状态")
private String status;
@Schema(description = "完成方式", example = "2")
@ExcelProperty("完成方式")
private String finishType;
@Schema(description = "车号")
@ExcelProperty("车号")
private String agvno;
@Schema(description = "备注", example = "随便")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "生产区域")
@ExcelProperty("生产区域")
private String productArea;
@Schema(description = "点位编码")
@ExcelProperty("点位编码")
private String pointCode;
@Schema(description = "请求烘烤")
@ExcelProperty("请求烘烤")
private String isBaking;
@Schema(description = "请求入半成品库")
@ExcelProperty("请求入半成品库")
private String isInstor;
@Schema(description = "收卷辊")
@ExcelProperty("收卷辊")
private String windRoll;
@Schema(description = "类型", example = "2")
@ExcelProperty("类型")
private String orderType;
}

View File

@@ -0,0 +1,91 @@
package cn.code.nl.module.lms.controller.admin.pdmrawfoilworkorder.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 生箔工序工单新增/修改 Request VO")
@Data
public class PdmRawFoilWorkOrderSaveReqVO {
private Long workorderId;
@Schema(description = "母卷号", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotEmpty(message = "母卷号不能为空")
private String containerName;
@Schema(description = "机台编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@NotEmpty(message = "机台编码不能为空")
private String resourceName;
@Schema(description = "生产工单", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "生产工单不能为空")
private String mfgOrderName;
@Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "产品编码不能为空")
private String productCode;
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
@NotEmpty(message = "产品名称不能为空")
private String description;
@Schema(description = "理论长度", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "理论长度不能为空")
private BigDecimal theoryHeight;
@Schema(description = "设备生产速度", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "设备生产速度不能为空")
private BigDecimal eqpVelocity;
@Schema(description = "上卷开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "上卷开始时间不能为空")
private String upCoilerDate;
@Schema(description = "是否重新更新", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "是否重新更新不能为空")
private String isReloadSend;
@Schema(description = "重量")
private BigDecimal productinQty;
@Schema(description = "开始时间")
private String realstartTime;
@Schema(description = "结束时间")
private String realendTime;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotEmpty(message = "状态不能为空")
private String status;
@Schema(description = "完成方式", example = "2")
private String finishType;
@Schema(description = "车号")
private String agvno;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "生产区域")
private String productArea;
@Schema(description = "点位编码")
private String pointCode;
@Schema(description = "请求烘烤")
private String isBaking;
@Schema(description = "请求入半成品库")
private String isInstor;
@Schema(description = "收卷辊")
private String windRoll;
@Schema(description = "类型", example = "2")
private String orderType;
}

View File

@@ -0,0 +1,123 @@
package cn.code.nl.module.lms.dal.dataobject.pdmrawfoilworkorder;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigDecimal;
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_pdm_rawfoilworkorder")
@KeySequence("lms_pdm_rawfoilworkorder_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PdmRawFoilWorkOrderDO extends BaseDO {
/**
* 工单标识
*/
@TableId
private Long workorderId;
/**
* 母卷号
*/
private String containerName;
/**
* 机台编码
*/
private String resourceName;
/**
* 生产工单
*/
private String mfgOrderName;
/**
* 产品编码
*/
private String productCode;
/**
* 产品名称
*/
private String description;
/**
* 理论长度
*/
private BigDecimal theoryHeight;
/**
* 设备生产速度
*/
private BigDecimal eqpVelocity;
/**
* 上卷开始时间
*/
private String upCoilerDate;
/**
* 是否重新更新
*/
private String isReloadSend;
/**
* 重量
*/
private BigDecimal productinQty;
/**
* 开始时间
*/
private String realstartTime;
/**
* 结束时间
*/
private String realendTime;
/**
* 状态
*/
private String status;
/**
* 完成方式
*/
private String finishType;
/**
* 车号
*/
private String agvno;
/**
* 备注
*/
private String remark;
/**
* 生产区域
*/
private String productArea;
/**
* 点位编码
*/
private String pointCode;
/**
* 请求烘烤
*/
private String isBaking;
/**
* 请求入半成品库
*/
private String isInstor;
/**
* 收卷辊
*/
private String windRoll;
/**
* 类型
*/
private String orderType;
}

View File

@@ -0,0 +1,48 @@
package cn.code.nl.module.lms.dal.mysql.pdmrawfoilworkorder;
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.pdmrawfoilworkorder.PdmRawFoilWorkOrderDO;
import org.apache.ibatis.annotations.Mapper;
import cn.code.nl.module.lms.controller.admin.pdmrawfoilworkorder.vo.*;
/**
* 生箔工序工单 Mapper
*
* @author 诺力管理员
*/
@Mapper
public interface PdmRawFoilWorkOrderMapper extends BaseMapperX<PdmRawFoilWorkOrderDO> {
default PageResult<PdmRawFoilWorkOrderDO> selectPage(PdmRawFoilWorkOrderPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PdmRawFoilWorkOrderDO>()
.likeIfPresent(PdmRawFoilWorkOrderDO::getContainerName, reqVO.getContainerName())
.likeIfPresent(PdmRawFoilWorkOrderDO::getResourceName, reqVO.getResourceName())
.likeIfPresent(PdmRawFoilWorkOrderDO::getMfgOrderName, reqVO.getMfgOrderName())
.eqIfPresent(PdmRawFoilWorkOrderDO::getProductCode, reqVO.getProductCode())
.eqIfPresent(PdmRawFoilWorkOrderDO::getDescription, reqVO.getDescription())
.eqIfPresent(PdmRawFoilWorkOrderDO::getTheoryHeight, reqVO.getTheoryHeight())
.eqIfPresent(PdmRawFoilWorkOrderDO::getEqpVelocity, reqVO.getEqpVelocity())
.betweenIfPresent(PdmRawFoilWorkOrderDO::getUpCoilerDate, reqVO.getUpCoilerDate())
.eqIfPresent(PdmRawFoilWorkOrderDO::getIsReloadSend, reqVO.getIsReloadSend())
.eqIfPresent(PdmRawFoilWorkOrderDO::getProductinQty, reqVO.getProductinQty())
.betweenIfPresent(PdmRawFoilWorkOrderDO::getRealstartTime, reqVO.getRealstartTime())
.betweenIfPresent(PdmRawFoilWorkOrderDO::getRealendTime, reqVO.getRealendTime())
.eqIfPresent(PdmRawFoilWorkOrderDO::getStatus, reqVO.getStatus())
.eqIfPresent(PdmRawFoilWorkOrderDO::getFinishType, reqVO.getFinishType())
.eqIfPresent(PdmRawFoilWorkOrderDO::getAgvno, reqVO.getAgvno())
.eqIfPresent(PdmRawFoilWorkOrderDO::getRemark, reqVO.getRemark())
.betweenIfPresent(PdmRawFoilWorkOrderDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PdmRawFoilWorkOrderDO::getProductArea, reqVO.getProductArea())
.eqIfPresent(PdmRawFoilWorkOrderDO::getPointCode, reqVO.getPointCode())
.eqIfPresent(PdmRawFoilWorkOrderDO::getIsBaking, reqVO.getIsBaking())
.eqIfPresent(PdmRawFoilWorkOrderDO::getIsInstor, reqVO.getIsInstor())
.eqIfPresent(PdmRawFoilWorkOrderDO::getWindRoll, reqVO.getWindRoll())
.eqIfPresent(PdmRawFoilWorkOrderDO::getOrderType, reqVO.getOrderType())
.orderByDesc(PdmRawFoilWorkOrderDO::getWorkorderId));
}
}

View File

@@ -0,0 +1,41 @@
package cn.code.nl.module.lms.framework.security.config;
import cn.code.nl.framework.security.config.AuthorizeRequestsCustomizer;
import cn.code.nl.module.lms.enums.ApiConstants;
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 liyongde
*/
@Configuration(proxyBeanMethods = false, value = "lmsSecurityConfiguration")
public class SecurityConfiguration {
@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();
// RPC 服务的安全配置
registry.requestMatchers(ApiConstants.PREFIX + "/**").permitAll();
}
};
}
}

View File

@@ -0,0 +1,62 @@
package cn.code.nl.module.lms.service.pdmrawfoilworkorder;
import java.util.*;
import jakarta.validation.*;
import cn.code.nl.module.lms.controller.admin.pdmrawfoilworkorder.vo.*;
import cn.code.nl.module.lms.dal.dataobject.pdmrawfoilworkorder.PdmRawFoilWorkOrderDO;
import cn.code.nl.framework.common.pojo.PageResult;
import cn.code.nl.framework.common.pojo.PageParam;
/**
* 生箔工序工单 Service 接口
*
* @author 诺力管理员
*/
public interface PdmRawFoilWorkOrderService {
/**
* 创建生箔工序工单
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createPdmRawFoilWorkOrder(@Valid PdmRawFoilWorkOrderSaveReqVO createReqVO);
/**
* 更新生箔工序工单
*
* @param updateReqVO 更新信息
*/
void updatePdmRawFoilWorkOrder(@Valid PdmRawFoilWorkOrderSaveReqVO updateReqVO);
/**
* 删除生箔工序工单
*
* @param id 编号
*/
void deletePdmRawFoilWorkOrder(Long id);
/**
* 批量删除生箔工序工单
*
* @param ids 编号
*/
void deletePdmRawFoilWorkOrderListByIds(List<Long> ids);
/**
* 获得生箔工序工单
*
* @param id 编号
* @return 生箔工序工单
*/
PdmRawFoilWorkOrderDO getPdmRawFoilWorkOrder(Long id);
/**
* 获得生箔工序工单分页
*
* @param pageReqVO 分页查询
* @return 生箔工序工单分页
*/
PageResult<PdmRawFoilWorkOrderDO> getPdmRawFoilWorkOrderPage(PdmRawFoilWorkOrderPageReqVO pageReqVO);
}

View File

@@ -0,0 +1,80 @@
package cn.code.nl.module.lms.service.pdmrawfoilworkorder;
import cn.code.nl.framework.common.pojo.PageResult;
import cn.code.nl.framework.common.util.object.BeanUtils;
import cn.code.nl.module.lms.controller.admin.pdmrawfoilworkorder.vo.PdmRawFoilWorkOrderPageReqVO;
import cn.code.nl.module.lms.controller.admin.pdmrawfoilworkorder.vo.PdmRawFoilWorkOrderSaveReqVO;
import cn.code.nl.module.lms.dal.dataobject.pdmrawfoilworkorder.PdmRawFoilWorkOrderDO;
import cn.code.nl.module.lms.dal.mysql.pdmrawfoilworkorder.PdmRawFoilWorkOrderMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import static cn.code.nl.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.code.nl.module.lms.enums.ErrorCodeConstants.PDM_RAW_FOIL_WORK_ORDER_NOT_EXISTS;
/**
* 生箔工序工单 Service 实现类
*
* @author 诺力管理员
*/
@Service
@Validated
public class PdmRawFoilWorkOrderServiceImpl implements PdmRawFoilWorkOrderService {
@Resource
private PdmRawFoilWorkOrderMapper pdmRawFoilWorkOrderMapper;
@Override
public Long createPdmRawFoilWorkOrder(PdmRawFoilWorkOrderSaveReqVO createReqVO) {
// 插入
PdmRawFoilWorkOrderDO pdmRawFoilWorkOrder = BeanUtils.toBean(createReqVO, PdmRawFoilWorkOrderDO.class);
pdmRawFoilWorkOrderMapper.insert(pdmRawFoilWorkOrder);
// 返回
return pdmRawFoilWorkOrder.getWorkorderId();
}
@Override
public void updatePdmRawFoilWorkOrder(PdmRawFoilWorkOrderSaveReqVO updateReqVO) {
// 校验存在
validatePdmRawFoilWorkOrderExists(updateReqVO.getWorkorderId());
// 更新
PdmRawFoilWorkOrderDO updateObj = BeanUtils.toBean(updateReqVO, PdmRawFoilWorkOrderDO.class);
pdmRawFoilWorkOrderMapper.updateById(updateObj);
}
@Override
public void deletePdmRawFoilWorkOrder(Long id) {
// 校验存在
validatePdmRawFoilWorkOrderExists(id);
// 删除
pdmRawFoilWorkOrderMapper.deleteById(id);
}
@Override
public void deletePdmRawFoilWorkOrderListByIds(List<Long> ids) {
// 删除
pdmRawFoilWorkOrderMapper.deleteByIds(ids);
}
private void validatePdmRawFoilWorkOrderExists(Long id) {
if (pdmRawFoilWorkOrderMapper.selectById(id) == null) {
throw exception(PDM_RAW_FOIL_WORK_ORDER_NOT_EXISTS);
}
}
@Override
public PdmRawFoilWorkOrderDO getPdmRawFoilWorkOrder(Long id) {
return pdmRawFoilWorkOrderMapper.selectById(id);
}
@Override
public PageResult<PdmRawFoilWorkOrderDO> getPdmRawFoilWorkOrderPage(PdmRawFoilWorkOrderPageReqVO pageReqVO) {
return pdmRawFoilWorkOrderMapper.selectPage(pageReqVO);
}
}

View File

@@ -36,7 +36,7 @@ spring:
time-to-live: 1h # 设置过期时间为 1 小时
server:
port: 48081
port: 48083
logging:
file:

View File

@@ -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.pdmrawfoilworkorder.PdmRawFoilWorkOrderMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@@ -0,0 +1,76 @@
import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';
import { requestClient } from '#/api/request';
export namespace LmsPdmRawFoilWorkOrderApi {
/** 生箔工序工单信息 */
export interface PdmRawFoilWorkOrder {
containerName?: string; // 母卷号
resourceName?: string; // 机台编码
mfgOrderName?: string; // 生产工单
productCode?: string; // 产品编码
description?: string; // 产品名称
theoryHeight?: number; // 理论长度
eqpVelocity?: number; // 设备生产速度
upCoilerDate?: string; // 上卷开始时间
isReloadSend?: string; // 是否重新更新
productinQty: number; // 重量
realstartTime: string; // 开始时间
realendTime: string; // 结束时间
status?: string; // 状态
finishType: string; // 完成方式
agvno: string; // 车号
remark: string; // 备注
productArea: string; // 生产区域
pointCode: string; // 点位编码
isBaking: string; // 请求烘烤
isInstor: string; // 请求入半成品库
windRoll: string; // 收卷辊
orderType: string; // 类型
}
}
/** 查询生箔工序工单分页 */
export function getPdmRawFoilWorkOrderPage(params: PageParam) {
return requestClient.get<PageResult<LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder>>(
'/lms/pdm-raw-foil-work-order/page',
{ params },
);
}
/** 查询生箔工序工单详情 */
export function getPdmRawFoilWorkOrder(id: number) {
return requestClient.get<LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder>(
`/lms/pdm-raw-foil-work-order/get?id=${id}`,
);
}
/** 新增生箔工序工单 */
export function createPdmRawFoilWorkOrder(data: LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder) {
return requestClient.post('/lms/pdm-raw-foil-work-order/create', data);
}
/** 修改生箔工序工单 */
export function updatePdmRawFoilWorkOrder(data: LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder) {
return requestClient.put('/lms/pdm-raw-foil-work-order/update', data);
}
/** 删除生箔工序工单 */
export function deletePdmRawFoilWorkOrder(id: number) {
return requestClient.delete(`/lms/pdm-raw-foil-work-order/delete?id=${id}`);
}
/** 批量删除生箔工序工单 */
export function deletePdmRawFoilWorkOrderList(ids: number[]) {
return requestClient.delete(
`/lms/pdm-raw-foil-work-order/delete-list?ids=${ids.join(',')}`,
);
}
/** 导出生箔工序工单 */
export function exportPdmRawFoilWorkOrder(params: any) {
return requestClient.download('/lms/pdm-raw-foil-work-order/export-excel', { params });
}

View File

@@ -0,0 +1,560 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { LmsPdmRawFoilWorkOrderApi } from '#/api/lms/pdmrawfoilworkorder';
import { getDictOptions } from '@vben/hooks';
import { getRangePickerDefaultProps } from '#/utils';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'id',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'containerName',
label: '母卷号',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入母卷号',
},
},
{
fieldName: 'resourceName',
label: '机台编码',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入机台编码',
},
},
{
fieldName: 'mfgOrderName',
label: '生产工单',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入生产工单',
},
},
{
fieldName: 'productCode',
label: '产品编码',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入产品编码',
},
},
{
fieldName: 'description',
label: '产品名称',
rules: 'required',
component: 'RichTextarea',
},
{
fieldName: 'theoryHeight',
label: '理论长度',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入理论长度',
},
},
{
fieldName: 'eqpVelocity',
label: '设备生产速度',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入设备生产速度',
},
},
{
fieldName: 'upCoilerDate',
label: '上卷开始时间',
rules: 'required',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'x',
},
},
{
fieldName: 'isReloadSend',
label: '是否重新更新',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入是否重新更新',
},
},
{
fieldName: 'productinQty',
label: '重量',
component: 'Input',
componentProps: {
placeholder: '请输入重量',
},
},
{
fieldName: 'realstartTime',
label: '开始时间',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'x',
},
},
{
fieldName: 'realendTime',
label: '结束时间',
component: 'DatePicker',
componentProps: {
showTime: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'x',
},
},
{
fieldName: 'status',
label: '状态',
rules: 'required',
component: 'RadioGroup',
componentProps: {
options: [],
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'finishType',
label: '完成方式',
component: 'Select',
componentProps: {
options: [],
placeholder: '请选择完成方式',
},
},
{
fieldName: 'agvno',
label: '车号',
component: 'Input',
componentProps: {
placeholder: '请输入车号',
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Input',
componentProps: {
placeholder: '请输入备注',
},
},
{
fieldName: 'productArea',
label: '生产区域',
component: 'Input',
componentProps: {
placeholder: '请输入生产区域',
},
},
{
fieldName: 'pointCode',
label: '点位编码',
component: 'Input',
componentProps: {
placeholder: '请输入点位编码',
},
},
{
fieldName: 'isBaking',
label: '请求烘烤',
component: 'Input',
componentProps: {
placeholder: '请输入请求烘烤',
},
},
{
fieldName: 'isInstor',
label: '请求入半成品库',
component: 'Input',
componentProps: {
placeholder: '请输入请求入半成品库',
},
},
{
fieldName: 'windRoll',
label: '收卷辊',
component: 'Input',
componentProps: {
placeholder: '请输入收卷辊',
},
},
{
fieldName: 'orderType',
label: '类型',
component: 'Select',
componentProps: {
options: [],
placeholder: '请选择类型',
},
},
];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'containerName',
label: '母卷号',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入母卷号',
},
},
{
fieldName: 'resourceName',
label: '机台编码',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入机台编码',
},
},
{
fieldName: 'mfgOrderName',
label: '生产工单',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入生产工单',
},
},
{
fieldName: 'productCode',
label: '产品编码',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入产品编码',
},
},
{
fieldName: 'description',
label: '产品名称',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入产品名称',
},
},
{
fieldName: 'theoryHeight',
label: '理论长度',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入理论长度',
},
},
{
fieldName: 'eqpVelocity',
label: '设备生产速度',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入设备生产速度',
},
},
{
fieldName: 'upCoilerDate',
label: '上卷开始时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
},
},
{
fieldName: 'isReloadSend',
label: '是否重新更新',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入是否重新更新',
},
},
{
fieldName: 'productinQty',
label: '重量',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入重量',
},
},
{
fieldName: 'realstartTime',
label: '开始时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
},
},
{
fieldName: 'realendTime',
label: '结束时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
},
},
{
fieldName: 'status',
label: '状态',
component: 'Select',
componentProps: {
allowClear: true,
options: [],
placeholder: '请选择状态',
},
},
{
fieldName: 'finishType',
label: '完成方式',
component: 'Select',
componentProps: {
allowClear: true,
options: [],
placeholder: '请选择完成方式',
},
},
{
fieldName: 'agvno',
label: '车号',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入车号',
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入备注',
},
},
{
fieldName: 'createTime',
label: '创建时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
},
},
{
fieldName: 'productArea',
label: '生产区域',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入生产区域',
},
},
{
fieldName: 'pointCode',
label: '点位编码',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入点位编码',
},
},
{
fieldName: 'isBaking',
label: '请求烘烤',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入请求烘烤',
},
},
{
fieldName: 'isInstor',
label: '请求入半成品库',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入请求入半成品库',
},
},
{
fieldName: 'windRoll',
label: '收卷辊',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入收卷辊',
},
},
{
fieldName: 'orderType',
label: '类型',
component: 'Select',
componentProps: {
allowClear: true,
options: [],
placeholder: '请选择类型',
},
},
];
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder>['columns'] {
return [
{ type: 'checkbox', width: 40 },
{
field: 'containerName',
title: '母卷号',
minWidth: 120,
},
{
field: 'resourceName',
title: '机台编码',
minWidth: 120,
},
{
field: 'mfgOrderName',
title: '生产工单',
minWidth: 120,
},
{
field: 'productCode',
title: '产品编码',
minWidth: 120,
},
{
field: 'description',
title: '产品名称',
minWidth: 120,
},
{
field: 'theoryHeight',
title: '理论长度',
minWidth: 120,
},
{
field: 'eqpVelocity',
title: '设备生产速度',
minWidth: 120,
},
{
field: 'upCoilerDate',
title: '上卷开始时间',
minWidth: 120,
},
{
field: 'isReloadSend',
title: '是否重新更新',
minWidth: 120,
},
{
field: 'productinQty',
title: '重量',
minWidth: 120,
},
{
field: 'realstartTime',
title: '开始时间',
minWidth: 120,
},
{
field: 'realendTime',
title: '结束时间',
minWidth: 120,
},
{
field: 'status',
title: '状态',
minWidth: 120,
},
{
field: 'finishType',
title: '完成方式',
minWidth: 120,
},
{
field: 'agvno',
title: '车号',
minWidth: 120,
},
{
field: 'remark',
title: '备注',
minWidth: 120,
},
{
field: 'createTime',
title: '创建时间',
minWidth: 120,
formatter: 'formatDateTime',
},
{
field: 'productArea',
title: '生产区域',
minWidth: 120,
},
{
field: 'pointCode',
title: '点位编码',
minWidth: 120,
},
{
field: 'isBaking',
title: '请求烘烤',
minWidth: 120,
},
{
field: 'isInstor',
title: '请求入半成品库',
minWidth: 120,
},
{
field: 'windRoll',
title: '收卷辊',
minWidth: 120,
},
{
field: 'orderType',
title: '类型',
minWidth: 120,
},
{
title: '操作',
width: 200,
fixed: 'right',
slots: { default: 'actions' },
},
];
}

View File

@@ -0,0 +1,186 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { LmsPdmRawFoilWorkOrderApi } from '#/api/lms/pdmrawfoilworkorder';
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 {
deletePdmRawFoilWorkOrder,
deletePdmRawFoilWorkOrderList,
exportPdmRawFoilWorkOrder,
getPdmRawFoilWorkOrderPage,
} from '#/api/lms/pdmrawfoilworkorder';
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: LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder) {
formModalApi.setData(row).open();
}
/** 删除生箔工序工单 */
async function handleDelete(row: LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.id]),
duration: 0,
});
try {
await deletePdmRawFoilWorkOrder(row.id!);
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
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 deletePdmRawFoilWorkOrderList(checkedIds.value);
checkedIds.value = [];
message.success($t('ui.actionMessage.deleteSuccess'));
handleRefresh();
} finally {
hideLoading();
}
}
const checkedIds = ref<number[]>([]);
function handleRowCheckboxChange({
records,
}: {
records: LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder[];
}) {
checkedIds.value = records.map((item) => item.id!);
}
/** 导出表格 */
async function handleExport() {
const data = await exportPdmRawFoilWorkOrder(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 getPdmRawFoilWorkOrderPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder>,
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:pdm-raw-foil-work-order:create'],
onClick: handleCreate,
},
{
label: $t('ui.actionTitle.export'),
type: 'primary',
icon: ACTION_ICON.DOWNLOAD,
auth: ['lms:pdm-raw-foil-work-order:export'],
onClick: handleExport,
},
{
label: $t('ui.actionTitle.deleteBatch'),
type: 'primary',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['lms:pdm-raw-foil-work-order:delete'],
disabled: isEmpty(checkedIds),
onClick: handleDeleteBatch,
},
]"
/>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['lms:pdm-raw-foil-work-order:update'],
onClick: handleEdit.bind(null, row),
},
{
label: $t('common.delete'),
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['lms:pdm-raw-foil-work-order:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,82 @@
<script lang="ts" setup>
import type { LmsPdmRawFoilWorkOrderApi } from '#/api/lms/pdmrawfoilworkorder';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { message } from 'antdv-next';
import { useVbenForm } from '#/adapter/form';
import { createPdmRawFoilWorkOrder, getPdmRawFoilWorkOrder, updatePdmRawFoilWorkOrder } from '#/api/lms/pdmrawfoilworkorder';
import { $t } from '#/locales';
import { useFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder>();
const getTitle = computed(() => {
return formData.value?.id
? $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 LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder;
try {
await (formData.value?.id ? updatePdmRawFoilWorkOrder(data) : createPdmRawFoilWorkOrder(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<LmsPdmRawFoilWorkOrderApi.PdmRawFoilWorkOrder>();
if (!data || !data.id) {
return;
}
modalApi.lock();
try {
formData.value = await getPdmRawFoilWorkOrder(data.id);
// 设置到 values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal :title="getTitle">
<Form class="mx-4" />
</Modal>
</template>

File diff suppressed because it is too large Load Diff