feat: 木箱类型crud
This commit is contained in:
@@ -56,5 +56,6 @@ public interface ErrorCodeConstants {
|
||||
// ========== 子卷包装关系 ==========
|
||||
ErrorCode SUB_PACKAGE_RELATION_NOT_EXISTS = new ErrorCode(300001, "子卷包装关系不存在");
|
||||
|
||||
|
||||
// ========== 木箱类型 ==========
|
||||
ErrorCode BOX_TYPE_NOT_EXISTS = new ErrorCode(400001, "木箱类型不存在");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package cn.code.nl.module.lms.controller.admin.boxtype;
|
||||
|
||||
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.boxtype.vo.*;
|
||||
import cn.code.nl.module.lms.dal.dataobject.boxtype.BoxTypeDO;
|
||||
import cn.code.nl.module.lms.service.boxtype.BoxTypeService;
|
||||
|
||||
@Tag(name = "管理后台 - 木箱类型")
|
||||
@RestController
|
||||
@RequestMapping("/lms/box-type")
|
||||
@Validated
|
||||
public class BoxTypeController {
|
||||
|
||||
@Resource
|
||||
private BoxTypeService boxTypeService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建木箱类型")
|
||||
@PreAuthorize("@ss.hasPermission('lms:box-type:create')")
|
||||
public CommonResult<Long> createBoxType(@Valid @RequestBody BoxTypeSaveReqVO createReqVO) {
|
||||
return success(boxTypeService.createBoxType(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新木箱类型")
|
||||
@PreAuthorize("@ss.hasPermission('lms:box-type:update')")
|
||||
public CommonResult<Boolean> updateBoxType(@Valid @RequestBody BoxTypeSaveReqVO updateReqVO) {
|
||||
boxTypeService.updateBoxType(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除木箱类型")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('lms:box-type:delete')")
|
||||
public CommonResult<Boolean> deleteBoxType(@RequestParam("id") String id) {
|
||||
boxTypeService.deleteBoxType(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除木箱类型")
|
||||
@PreAuthorize("@ss.hasPermission('lms:box-type:delete')")
|
||||
public CommonResult<Boolean> deleteBoxTypeList(@RequestParam("ids") List<String> ids) {
|
||||
boxTypeService.deleteBoxTypeListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得木箱类型")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('lms:box-type:query')")
|
||||
public CommonResult<BoxTypeRespVO> getBoxType(@RequestParam("id") String id) {
|
||||
BoxTypeDO boxType = boxTypeService.getBoxType(id);
|
||||
return success(BeanUtils.toBean(boxType, BoxTypeRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得木箱类型分页")
|
||||
@PreAuthorize("@ss.hasPermission('lms:box-type:query')")
|
||||
public CommonResult<PageResult<BoxTypeRespVO>> getBoxTypePage(@Valid BoxTypePageReqVO pageReqVO) {
|
||||
PageResult<BoxTypeDO> pageResult = boxTypeService.getBoxTypePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, BoxTypeRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出木箱类型 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('lms:box-type:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportBoxTypeExcel(@Valid BoxTypePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<BoxTypeDO> list = boxTypeService.getBoxTypePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "木箱类型.xls", "数据", BoxTypeRespVO.class,
|
||||
BeanUtils.toBean(list, BoxTypeRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.code.nl.module.lms.controller.admin.boxtype.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;
|
||||
|
||||
@Schema(description = "管理后台 - 木箱类型分页 Request VO")
|
||||
@Data
|
||||
public class BoxTypePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "木箱类型", example = "2")
|
||||
private String boxType;
|
||||
|
||||
@Schema(description = "木箱描述", example = "张三")
|
||||
private String boxName;
|
||||
|
||||
@Schema(description = "是否一次捆扎")
|
||||
private Boolean needLashOne;
|
||||
|
||||
@Schema(description = "是否二次捆扎")
|
||||
private Boolean needLashTwo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package cn.code.nl.module.lms.controller.admin.boxtype.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import cn.idev.excel.annotation.*;
|
||||
import cn.code.nl.framework.excel.core.annotations.DictFormat;
|
||||
import cn.code.nl.framework.excel.core.convert.DictConvert;
|
||||
|
||||
@Schema(description = "管理后台 - 木箱类型 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class BoxTypeRespVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "木箱类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("木箱类型")
|
||||
private String boxType;
|
||||
|
||||
@Schema(description = "木箱描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@ExcelProperty("木箱描述")
|
||||
private String boxName;
|
||||
|
||||
@Schema(description = "捆扎模版")
|
||||
@ExcelProperty("捆扎模版")
|
||||
private String lashNum;
|
||||
|
||||
@Schema(description = "一次捆扎次数")
|
||||
@ExcelProperty("一次捆扎次数")
|
||||
private Integer lashNumOne;
|
||||
|
||||
@Schema(description = "二次捆扎次数")
|
||||
@ExcelProperty("二次捆扎次数")
|
||||
private Integer lashNumTwo;
|
||||
|
||||
@Schema(description = "是否一次捆扎")
|
||||
@ExcelProperty(value = "是否一次捆扎", converter = DictConvert.class)
|
||||
@DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Boolean needLashOne;
|
||||
|
||||
@Schema(description = "是否二次捆扎")
|
||||
@ExcelProperty(value = "是否二次捆扎", converter = DictConvert.class)
|
||||
@DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Boolean needLashTwo;
|
||||
|
||||
@Schema(description = "叉车取货宽度")
|
||||
@ExcelProperty("叉车取货宽度")
|
||||
private BigDecimal expendWidth;
|
||||
|
||||
@Schema(description = "木箱结构")
|
||||
@ExcelProperty("木箱结构")
|
||||
private String boxStructure;
|
||||
|
||||
@Schema(description = "干燥剂数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("干燥剂数量")
|
||||
private Integer desiccantNum;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.code.nl.module.lms.controller.admin.boxtype.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 BoxTypeSaveReqVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "木箱类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private String boxType;
|
||||
@Schema(description = "木箱描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private String boxName;
|
||||
|
||||
@Schema(description = "捆扎模版")
|
||||
private String lashNum;
|
||||
|
||||
@Schema(description = "一次捆扎次数")
|
||||
private Integer lashNumOne;
|
||||
|
||||
@Schema(description = "二次捆扎次数")
|
||||
private Integer lashNumTwo;
|
||||
|
||||
@Schema(description = "是否一次捆扎")
|
||||
private Boolean needLashOne;
|
||||
|
||||
@Schema(description = "是否二次捆扎")
|
||||
private Boolean needLashTwo;
|
||||
|
||||
@Schema(description = "叉车取货宽度")
|
||||
private BigDecimal expendWidth;
|
||||
|
||||
@Schema(description = "木箱结构")
|
||||
private String boxStructure;
|
||||
|
||||
@Schema(description = "干燥剂数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "干燥剂数量不能为空")
|
||||
private Integer desiccantNum;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package cn.code.nl.module.lms.dal.dataobject.boxtype;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 木箱类型 DO
|
||||
*
|
||||
* @author 诺力管理员
|
||||
*/
|
||||
@TableName("lms_box_type")
|
||||
@KeySequence("lms_box_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BoxTypeDO {
|
||||
|
||||
/**
|
||||
* 木箱类型id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 木箱类型
|
||||
*/
|
||||
private String boxType;
|
||||
/**
|
||||
* 木箱描述
|
||||
*/
|
||||
private String boxName;
|
||||
/**
|
||||
* 捆扎模版
|
||||
*/
|
||||
private String lashNum;
|
||||
/**
|
||||
* 一次捆扎次数
|
||||
*/
|
||||
private Integer lashNumOne;
|
||||
/**
|
||||
* 二次捆扎次数
|
||||
*/
|
||||
private Integer lashNumTwo;
|
||||
/**
|
||||
* 是否一次捆扎
|
||||
*
|
||||
* 枚举 {@link TODO infra_boolean_string 对应的类}
|
||||
*/
|
||||
private Boolean needLashOne;
|
||||
/**
|
||||
* 是否二次捆扎
|
||||
*
|
||||
* 枚举 {@link TODO infra_boolean_string 对应的类}
|
||||
*/
|
||||
private Boolean needLashTwo;
|
||||
/**
|
||||
* 叉车取货宽度
|
||||
*/
|
||||
private BigDecimal expendWidth;
|
||||
/**
|
||||
* 木箱结构
|
||||
*/
|
||||
private String boxStructure;
|
||||
/**
|
||||
* 干燥剂数量
|
||||
*/
|
||||
private Integer desiccantNum;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.code.nl.module.lms.dal.mysql.boxtype;
|
||||
|
||||
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.boxtype.BoxTypeDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.code.nl.module.lms.controller.admin.boxtype.vo.*;
|
||||
|
||||
/**
|
||||
* 木箱类型 Mapper
|
||||
*
|
||||
* @author 诺力管理员
|
||||
*/
|
||||
@Mapper
|
||||
public interface BoxTypeMapper extends BaseMapperX<BoxTypeDO> {
|
||||
|
||||
default PageResult<BoxTypeDO> selectPage(BoxTypePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BoxTypeDO>()
|
||||
.eqIfPresent(BoxTypeDO::getBoxType, reqVO.getBoxType())
|
||||
.likeIfPresent(BoxTypeDO::getBoxName, reqVO.getBoxName())
|
||||
.eqIfPresent(BoxTypeDO::getNeedLashOne, reqVO.getNeedLashOne())
|
||||
.eqIfPresent(BoxTypeDO::getNeedLashTwo, reqVO.getNeedLashTwo())
|
||||
.orderByDesc(BoxTypeDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package cn.code.nl.module.lms.service.boxtype;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.code.nl.module.lms.controller.admin.boxtype.vo.*;
|
||||
import cn.code.nl.module.lms.dal.dataobject.boxtype.BoxTypeDO;
|
||||
import cn.code.nl.framework.common.pojo.PageResult;
|
||||
import cn.code.nl.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 木箱类型 Service 接口
|
||||
*
|
||||
* @author 诺力管理员
|
||||
*/
|
||||
public interface BoxTypeService {
|
||||
|
||||
/**
|
||||
* 创建木箱类型
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createBoxType(@Valid BoxTypeSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新木箱类型
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateBoxType(@Valid BoxTypeSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除木箱类型
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteBoxType(String id);
|
||||
|
||||
/**
|
||||
* 批量删除木箱类型
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteBoxTypeListByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 获得木箱类型
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 木箱类型
|
||||
*/
|
||||
BoxTypeDO getBoxType(String id);
|
||||
|
||||
/**
|
||||
* 获得木箱类型分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 木箱类型分页
|
||||
*/
|
||||
PageResult<BoxTypeDO> getBoxTypePage(BoxTypePageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package cn.code.nl.module.lms.service.boxtype;
|
||||
|
||||
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.boxtype.vo.*;
|
||||
import cn.code.nl.module.lms.dal.dataobject.boxtype.BoxTypeDO;
|
||||
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.boxtype.BoxTypeMapper;
|
||||
|
||||
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 BoxTypeServiceImpl implements BoxTypeService {
|
||||
|
||||
@Resource
|
||||
private BoxTypeMapper boxTypeMapper;
|
||||
|
||||
@Override
|
||||
public Long createBoxType(BoxTypeSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
BoxTypeDO boxType = BeanUtils.toBean(createReqVO, BoxTypeDO.class);
|
||||
boxTypeMapper.insert(boxType);
|
||||
|
||||
// 返回
|
||||
return boxType.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBoxType(BoxTypeSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateBoxTypeExists(String.valueOf(updateReqVO.getId()));
|
||||
// 更新
|
||||
BoxTypeDO updateObj = BeanUtils.toBean(updateReqVO, BoxTypeDO.class);
|
||||
boxTypeMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBoxType(String id) {
|
||||
// 校验存在
|
||||
validateBoxTypeExists(id);
|
||||
// 删除
|
||||
boxTypeMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBoxTypeListByIds(List<String> ids) {
|
||||
// 删除
|
||||
boxTypeMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
private void validateBoxTypeExists(String id) {
|
||||
if (boxTypeMapper.selectById(id) == null) {
|
||||
throw exception(BOX_TYPE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoxTypeDO getBoxType(String id) {
|
||||
return boxTypeMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BoxTypeDO> getBoxTypePage(BoxTypePageReqVO pageReqVO) {
|
||||
return boxTypeMapper.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.boxtype.BoxTypeMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,64 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace LmsBoxTypeApi {
|
||||
/** 木箱类型信息 */
|
||||
export interface BoxType {
|
||||
id?: number; // id
|
||||
boxType: string; // 木箱类型
|
||||
boxName?: string; // 木箱描述
|
||||
lashNum: string; // 捆扎模版
|
||||
lashNumOne: number; // 一次捆扎次数
|
||||
lashNumTwo: number; // 二次捆扎次数
|
||||
needLashOne: boolean; // 是否一次捆扎
|
||||
needLashTwo: boolean; // 是否二次捆扎
|
||||
expendWidth: number; // 叉车取货宽度
|
||||
boxStructure: string; // 木箱结构
|
||||
desiccantNum?: number; // 干燥剂数量
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询木箱类型分页 */
|
||||
export function getBoxTypePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<LmsBoxTypeApi.BoxType>>(
|
||||
'/lms/box-type/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询木箱类型详情 */
|
||||
export function getBoxType(id: number) {
|
||||
return requestClient.get<LmsBoxTypeApi.BoxType>(
|
||||
`/lms/box-type/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增木箱类型 */
|
||||
export function createBoxType(data: LmsBoxTypeApi.BoxType) {
|
||||
return requestClient.post('/lms/box-type/create', data);
|
||||
}
|
||||
|
||||
/** 修改木箱类型 */
|
||||
export function updateBoxType(data: LmsBoxTypeApi.BoxType) {
|
||||
return requestClient.put('/lms/box-type/update', data);
|
||||
}
|
||||
|
||||
/** 删除木箱类型 */
|
||||
export function deleteBoxType(id: number) {
|
||||
return requestClient.delete(`/lms/box-type/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除木箱类型 */
|
||||
export function deleteBoxTypeList(ids: number[]) {
|
||||
return requestClient.delete(
|
||||
`/lms/box-type/delete-list?ids=${ids.join(',')}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出木箱类型 */
|
||||
export function exportBoxType(params: any) {
|
||||
return requestClient.download('/lms/box-type/export-excel', { params });
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { LmsBoxTypeApi } from '#/api/lms/boxtype';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'boxType',
|
||||
label: '木箱类型',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请选择木箱类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'boxName',
|
||||
label: '木箱描述',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '选择物料后自动带出',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'needLashOne',
|
||||
label: '是否一次捆扎',
|
||||
component: 'RadioGroup',
|
||||
defaultValue: true,
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'lashNumOne',
|
||||
label: '一次捆扎次数',
|
||||
component: 'InputNumber',
|
||||
defaultValue: 1,
|
||||
componentProps: {
|
||||
min: 0,
|
||||
placeholder: '请输入一次捆扎次数',
|
||||
precision: 0,
|
||||
step: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'needLashTwo',
|
||||
label: '是否二次捆扎',
|
||||
component: 'RadioGroup',
|
||||
defaultValue: true,
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'lashNumTwo',
|
||||
label: '二次捆扎次数',
|
||||
component: 'InputNumber',
|
||||
defaultValue: 1,
|
||||
componentProps: {
|
||||
min: 0,
|
||||
placeholder: '请输入二次捆扎次数',
|
||||
precision: 0,
|
||||
step: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'expendWidth',
|
||||
label: '叉车取货宽度',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
placeholder: '请输入叉车取货宽度',
|
||||
step: 0.01,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'lashNum',
|
||||
label: '捆扎模版',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入捆扎模版',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'desiccantNum',
|
||||
label: '干燥剂数量',
|
||||
rules: 'required',
|
||||
component: 'InputNumber',
|
||||
defaultValue: 6,
|
||||
componentProps: {
|
||||
min: 0,
|
||||
placeholder: '请输入干燥剂数量',
|
||||
precision: 0,
|
||||
step: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'boxStructure',
|
||||
label: '木箱结构',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入木箱结构',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'boxType',
|
||||
label: '木箱类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: [],
|
||||
placeholder: '请选择木箱类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'boxName',
|
||||
label: '木箱描述',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入木箱描述',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'needLashOne',
|
||||
label: '是否一次捆扎',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
|
||||
placeholder: '请选择是否一次捆扎',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'needLashTwo',
|
||||
label: '是否二次捆扎',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
|
||||
placeholder: '请选择是否二次捆扎',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<LmsBoxTypeApi.BoxType>['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
field: 'boxType',
|
||||
title: '木箱类型',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'boxName',
|
||||
title: '木箱描述',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'lashNum',
|
||||
title: '捆扎模版',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'desiccantNum',
|
||||
title: '干燥剂数量',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'lashNumOne',
|
||||
title: '一次捆扎次数',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'lashNumTwo',
|
||||
title: '二次捆扎次数',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'needLashOne',
|
||||
title: '是否一次捆扎',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'needLashTwo',
|
||||
title: '是否二次捆扎',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'expendWidth',
|
||||
title: '叉车取货宽度',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'boxStructure',
|
||||
title: '木箱结构',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
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 { LmsBoxTypeApi } from '#/api/lms/boxtype';
|
||||
|
||||
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 {
|
||||
deleteBoxType,
|
||||
deleteBoxTypeList,
|
||||
exportBoxType,
|
||||
getBoxTypePage,
|
||||
} from '#/api/lms/boxtype';
|
||||
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: LmsBoxTypeApi.BoxType) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除木箱类型 */
|
||||
async function handleDelete(row: LmsBoxTypeApi.BoxType) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteBoxType(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 deleteBoxTypeList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
function handleRowCheckboxChange({
|
||||
records,
|
||||
}: {
|
||||
records: LmsBoxTypeApi.BoxType[];
|
||||
}) {
|
||||
checkedIds.value = records.map((item) => item.id!);
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportBoxType(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 getBoxTypePage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<LmsBoxTypeApi.BoxType>,
|
||||
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:box-type:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['lms:box-type:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['lms:box-type:delete'],
|
||||
disabled: isEmpty(checkedIds),
|
||||
onClick: handleDeleteBatch,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['lms:box-type:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['lms:box-type:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,134 @@
|
||||
<script lang="ts" setup>
|
||||
import type { BaseMaterialBaseApi } from '#/api/base/materialbase';
|
||||
import type { LmsBoxTypeApi } from '#/api/lms/boxtype';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createBoxType, getBoxType, updateBoxType } from '#/api/lms/boxtype';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import MaterialSelectModalComponent from '../../../base/materialbase/components/MaterialSelectModal.vue';
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<LmsBoxTypeApi.BoxType>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', ['木箱类型'])
|
||||
: $t('ui.actionTitle.create', ['木箱类型']);
|
||||
});
|
||||
|
||||
/** 物料选择弹窗 */
|
||||
const [MaterialSelectModal, materialSelectModalApi] = useVbenModal({
|
||||
connectedComponent: MaterialSelectModalComponent,
|
||||
});
|
||||
|
||||
/** 打开物料单选弹窗 */
|
||||
function openMaterialSelect() {
|
||||
materialSelectModalApi.setData({ multiple: false }).open();
|
||||
}
|
||||
|
||||
/** 回填木箱类型和木箱描述 */
|
||||
async function handleMaterialSelect(
|
||||
rows: BaseMaterialBaseApi.MaterialBase[],
|
||||
) {
|
||||
const material = rows[0];
|
||||
if (!material) {
|
||||
return;
|
||||
}
|
||||
await formApi.setValues({
|
||||
boxName: material.materialName,
|
||||
boxType: material.materialCode,
|
||||
});
|
||||
}
|
||||
|
||||
const schema = useFormSchema().map((field) => {
|
||||
if (field.fieldName === 'boxType') {
|
||||
return {
|
||||
...field,
|
||||
componentProps: {
|
||||
...field.componentProps,
|
||||
onClick: openMaterialSelect,
|
||||
readonly: true,
|
||||
style: 'cursor: pointer',
|
||||
},
|
||||
};
|
||||
}
|
||||
if (field.fieldName === 'boxName') {
|
||||
return {
|
||||
...field,
|
||||
componentProps: {
|
||||
...field.componentProps,
|
||||
readonly: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
return field;
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-1',
|
||||
labelWidth: 112,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema,
|
||||
showDefaultActions: false,
|
||||
wrapperClass: 'grid-cols-2 gap-x-4',
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as LmsBoxTypeApi.BoxType;
|
||||
try {
|
||||
await (formData.value?.id ? updateBoxType(data) : createBoxType(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<LmsBoxTypeApi.BoxType>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getBoxType(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-1/2">
|
||||
<Form class="mx-4" />
|
||||
<MaterialSelectModal @select="handleMaterialSelect" />
|
||||
</Modal>
|
||||
</template>
|
||||
Reference in New Issue
Block a user