parent
07a0553e03
commit
d4ee54b27b
@ -0,0 +1,10 @@
|
||||
{
|
||||
"systemParams": "win32-x64-93",
|
||||
"modulesFolders": [],
|
||||
"flags": [],
|
||||
"linkedModules": [],
|
||||
"topLevelPatterns": [],
|
||||
"lockfileEntries": {},
|
||||
"files": [],
|
||||
"artifacts": {}
|
||||
}
|
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 3.1 MiB |
After Width: | Height: | Size: 4.0 MiB |
After Width: | Height: | Size: 78 KiB |
@ -0,0 +1,4 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunxi</artifactId>
|
||||
<groupId>com.yunxi.scm</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunxi-module-demo</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
demo 模块,主要实现 XXX、YYY、ZZZ 等功能。
|
||||
</description>
|
||||
<modules>
|
||||
<module>yunxi-module-demo-api</module>
|
||||
<module>yunxi-module-demo-biz</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
@ -0,0 +1,18 @@
|
||||
package com.yunxi.scm.module.demo.enums;
|
||||
|
||||
/**
|
||||
* System 字典类型的枚举类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface DictTypeConstants {
|
||||
|
||||
String USER_TYPE = "user_type"; // 用户类型
|
||||
String COMMON_STATUS = "common_status"; // 系统状态
|
||||
|
||||
String MATERIAL_STATUS = "material_status"; // 物料状态
|
||||
|
||||
// ========== SYSTEM 模块 ==========
|
||||
String TRADE_ORDER_TYPE = "trade_order_type"; // 订单交易类型
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunxi-module-demo</artifactId>
|
||||
<groupId>com.yunxi.scm</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<artifactId>yunxi-module-demo-biz</artifactId>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
demo 模块,主要实现 XXX、YYY、ZZZ 等功能。
|
||||
</description>
|
||||
|
||||
<!-- 新增依赖,这里引入的都是比较常用的业务组件、技术组件 -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunxi.scm</groupId>
|
||||
<artifactId>yunxi-module-demo-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<dependency>
|
||||
<groupId>com.yunxi.scm</groupId>
|
||||
<artifactId>yunxi-spring-boot-starter-biz-operatelog</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.yunxi.scm</groupId>
|
||||
<artifactId>yunxi-spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.yunxi.scm</groupId>
|
||||
<artifactId>yunxi-spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- DB 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.yunxi.scm</groupId>
|
||||
<artifactId>yunxi-spring-boot-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test 测试相关 -->
|
||||
<dependency>
|
||||
<groupId>com.yunxi.scm</groupId>
|
||||
<artifactId>yunxi-spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Excel 相关 -->
|
||||
<dependency>
|
||||
<groupId>com.yunxi.scm</groupId>
|
||||
<artifactId>yunxi-spring-boot-starter-excel</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,28 @@
|
||||
package com.yunxi.scm.module.demo.controller.admin;
|
||||
|
||||
import com.yunxi.scm.framework.common.pojo.CommonResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
|
||||
import static com.yunxi.scm.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - Test")
|
||||
@RestController
|
||||
@RequestMapping("/demo/test")
|
||||
@Validated
|
||||
public class DemoTestController {
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获取 test 信息")
|
||||
@PermitAll // 无需认证即可访问
|
||||
public CommonResult<String> get() {
|
||||
return success("无需认证即可访问的后台接口");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package com.yunxi.scm.module.demo.controller.admin.material;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.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 javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||
import com.yunxi.scm.framework.common.pojo.CommonResult;
|
||||
import static com.yunxi.scm.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import com.yunxi.scm.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.yunxi.scm.framework.operatelog.core.annotations.OperateLog;
|
||||
import static com.yunxi.scm.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import com.yunxi.scm.module.demo.controller.admin.material.vo.*;
|
||||
import com.yunxi.scm.module.demo.dal.dataobject.material.MaterialDO;
|
||||
import com.yunxi.scm.module.demo.convert.material.MaterialConvert;
|
||||
import com.yunxi.scm.module.demo.service.material.MaterialService;
|
||||
|
||||
@Tag(name = "管理后台 - 物料管理")
|
||||
@RestController
|
||||
@RequestMapping("/demo/material")
|
||||
@Validated
|
||||
public class MaterialController {
|
||||
|
||||
@Resource
|
||||
private MaterialService materialService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建物料管理")
|
||||
@PreAuthorize("@ss.hasPermission('demo:material:create')")
|
||||
public CommonResult<Long> createMaterial(@Valid @RequestBody MaterialCreateReqVO createReqVO) {
|
||||
return success(materialService.createMaterial(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新物料管理")
|
||||
@PreAuthorize("@ss.hasPermission('demo:material:update')")
|
||||
public CommonResult<Boolean> updateMaterial(@Valid @RequestBody MaterialUpdateReqVO updateReqVO) {
|
||||
materialService.updateMaterial(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除物料管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('demo:material:delete')")
|
||||
public CommonResult<Boolean> deleteMaterial(@RequestParam("id") Long id) {
|
||||
materialService.deleteMaterial(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得物料管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('demo:material:query')")
|
||||
public CommonResult<MaterialRespVO> getMaterial(@RequestParam("id") Long id) {
|
||||
MaterialDO material = materialService.getMaterial(id);
|
||||
return success(MaterialConvert.INSTANCE.convert(material));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得物料管理列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('demo:material:query')")
|
||||
public CommonResult<List<MaterialRespVO>> getMaterialList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<MaterialDO> list = materialService.getMaterialList(ids);
|
||||
return success(MaterialConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得物料管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('demo:material:query')")
|
||||
public CommonResult<PageResult<MaterialRespVO>> getMaterialPage(@Valid MaterialPageReqVO pageVO) {
|
||||
PageResult<MaterialDO> pageResult = materialService.getMaterialPage(pageVO);
|
||||
return success(MaterialConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出物料管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('demo:material:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportMaterialExcel(@Valid MaterialExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<MaterialDO> list = materialService.getMaterialList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<MaterialExcelVO> datas = MaterialConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "物料管理.xls", "数据", MaterialExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.yunxi.scm.module.demo.controller.admin.material.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 物料管理创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class MaterialCreateReqVO extends MaterialBaseVO {
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.yunxi.scm.module.demo.controller.admin.material.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.yunxi.scm.framework.excel.core.annotations.DictFormat;
|
||||
import com.yunxi.scm.framework.excel.core.convert.DictConvert;
|
||||
import com.yunxi.scm.module.demo.enums.DictTypeConstants;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 物料管理 Excel VO
|
||||
*
|
||||
* @author ccongli
|
||||
*/
|
||||
@Data
|
||||
public class MaterialExcelVO {
|
||||
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.MATERIAL_STATUS)
|
||||
private Byte status;
|
||||
|
||||
@ExcelProperty("类型")
|
||||
@DictFormat(DictTypeConstants.TRADE_ORDER_TYPE)
|
||||
private Byte type;
|
||||
|
||||
@ExcelProperty("分类")
|
||||
@DictFormat(DictTypeConstants.TRADE_ORDER_TYPE)
|
||||
private List<Integer> category;
|
||||
|
||||
@ExcelProperty("图片")
|
||||
private String imgurl;
|
||||
|
||||
@ExcelProperty("库存数量")
|
||||
private Integer stock;
|
||||
|
||||
@ExcelProperty("单价")
|
||||
private BigDecimal price;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.yunxi.scm.module.demo.controller.admin.material.vo;
|
||||
|
||||
import com.yunxi.scm.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static com.yunxi.scm.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 物料管理分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class MaterialPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "名称", example = "李四")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "状态", example = "1")
|
||||
private Byte status;
|
||||
|
||||
@Schema(description = "类型", example = "2")
|
||||
private Byte type;
|
||||
|
||||
@Schema(description = "分类", example = "[1,2]")
|
||||
private List<Integer> category;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.yunxi.scm.module.demo.controller.admin.material.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 物料管理 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class MaterialRespVO extends MaterialBaseVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14541")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.yunxi.scm.module.demo.controller.admin.material.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 物料管理更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class MaterialUpdateReqVO extends MaterialBaseVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14541")
|
||||
@NotNull(message = "ID不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.yunxi.scm.module.demo.controller.app;
|
||||
|
||||
import com.yunxi.scm.framework.common.pojo.CommonResult;
|
||||
import com.yunxi.scm.framework.security.core.annotations.PreAuthenticated;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static com.yunxi.scm.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 App - Test")
|
||||
@RestController
|
||||
@RequestMapping("/demo/test")
|
||||
@Validated
|
||||
public class AppDemoTestController {
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获取 test 信息")
|
||||
@PreAuthenticated // 认证后可访问
|
||||
public CommonResult<String> get() {
|
||||
return success("需认证后才能访问的app接口");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.yunxi.scm.module.demo.convert.material;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import com.yunxi.scm.module.demo.controller.admin.material.vo.*;
|
||||
import com.yunxi.scm.module.demo.dal.dataobject.material.MaterialDO;
|
||||
|
||||
/**
|
||||
* 物料管理 Convert
|
||||
*
|
||||
* @author ccongli
|
||||
*/
|
||||
@Mapper
|
||||
public interface MaterialConvert {
|
||||
|
||||
MaterialConvert INSTANCE = Mappers.getMapper(MaterialConvert.class);
|
||||
|
||||
MaterialDO convert(MaterialCreateReqVO bean);
|
||||
|
||||
MaterialDO convert(MaterialUpdateReqVO bean);
|
||||
|
||||
MaterialRespVO convert(MaterialDO bean);
|
||||
|
||||
List<MaterialRespVO> convertList(List<MaterialDO> list);
|
||||
|
||||
PageResult<MaterialRespVO> convertPage(PageResult<MaterialDO> page);
|
||||
|
||||
List<MaterialExcelVO> convertList02(List<MaterialDO> list);
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.yunxi.scm.module.demo.dal.dataobject.material;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunxi.scm.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.yunxi.scm.framework.mybatis.core.type.IntegerListTypeHandler;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 物料管理 DO
|
||||
*
|
||||
* @author ccongli
|
||||
*/
|
||||
@TableName(value = "demo_material",autoResultMap = true)
|
||||
@KeySequence("demo_material_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MaterialDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link TODO material_status 对应的类}
|
||||
*/
|
||||
private Byte status;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Byte type;
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
// @TableField(typeHandler = JacksonTypeHandler.class)
|
||||
@TableField(typeHandler = IntegerListTypeHandler.class)
|
||||
private List<Integer> category;
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
private String imgurl;
|
||||
/**
|
||||
* 库存数量
|
||||
*/
|
||||
private Integer stock;
|
||||
/**
|
||||
* 单价
|
||||
*/
|
||||
private BigDecimal price;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.yunxi.scm.module.demo.dal.mysql.material;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||
import com.yunxi.scm.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.yunxi.scm.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.yunxi.scm.module.demo.dal.dataobject.material.MaterialDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.yunxi.scm.module.demo.controller.admin.material.vo.*;
|
||||
|
||||
/**
|
||||
* 物料管理 Mapper
|
||||
*
|
||||
* @author ccongli
|
||||
*/
|
||||
@Mapper
|
||||
public interface MaterialMapper extends BaseMapperX<MaterialDO> {
|
||||
|
||||
default PageResult<MaterialDO> selectPage(MaterialPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialDO>()
|
||||
.likeIfPresent(MaterialDO::getName, reqVO.getName())
|
||||
.eqIfPresent(MaterialDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(MaterialDO::getType, reqVO.getType())
|
||||
.eqIfPresent(MaterialDO::getCategory, reqVO.getCategory())
|
||||
.betweenIfPresent(MaterialDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(MaterialDO::getId));
|
||||
}
|
||||
|
||||
default List<MaterialDO> selectList(MaterialExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<MaterialDO>()
|
||||
.likeIfPresent(MaterialDO::getName, reqVO.getName())
|
||||
.eqIfPresent(MaterialDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(MaterialDO::getType, reqVO.getType())
|
||||
.eqIfPresent(MaterialDO::getCategory, reqVO.getCategory())
|
||||
.betweenIfPresent(MaterialDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(MaterialDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.yunxi.scm.module.demo.service.material;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import com.yunxi.scm.module.demo.controller.admin.material.vo.*;
|
||||
import com.yunxi.scm.module.demo.dal.dataobject.material.MaterialDO;
|
||||
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 物料管理 Service 接口
|
||||
*
|
||||
* @author ccongli
|
||||
*/
|
||||
public interface MaterialService {
|
||||
|
||||
/**
|
||||
* 创建物料管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createMaterial(@Valid MaterialCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新物料管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateMaterial(@Valid MaterialUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除物料管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteMaterial(Long id);
|
||||
|
||||
/**
|
||||
* 获得物料管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 物料管理
|
||||
*/
|
||||
MaterialDO getMaterial(Long id);
|
||||
|
||||
/**
|
||||
* 获得物料管理列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 物料管理列表
|
||||
*/
|
||||
List<MaterialDO> getMaterialList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得物料管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 物料管理分页
|
||||
*/
|
||||
PageResult<MaterialDO> getMaterialPage(MaterialPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得物料管理列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 物料管理列表
|
||||
*/
|
||||
List<MaterialDO> getMaterialList(MaterialExportReqVO exportReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package com.yunxi.scm.module.demo.service.material;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import com.yunxi.scm.module.demo.controller.admin.material.vo.*;
|
||||
import com.yunxi.scm.module.demo.dal.dataobject.material.MaterialDO;
|
||||
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||
|
||||
import com.yunxi.scm.module.demo.convert.material.MaterialConvert;
|
||||
import com.yunxi.scm.module.demo.dal.mysql.material.MaterialMapper;
|
||||
|
||||
import static com.yunxi.scm.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.yunxi.scm.module.demo.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 物料管理 Service 实现类
|
||||
*
|
||||
* @author ccongli
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class MaterialServiceImpl implements MaterialService {
|
||||
|
||||
@Resource
|
||||
private MaterialMapper materialMapper;
|
||||
|
||||
@Override
|
||||
public Long createMaterial(MaterialCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
MaterialDO material = MaterialConvert.INSTANCE.convert(createReqVO);
|
||||
materialMapper.insert(material);
|
||||
// 返回
|
||||
return material.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMaterial(MaterialUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateMaterialExists(updateReqVO.getId());
|
||||
// 更新
|
||||
MaterialDO updateObj = MaterialConvert.INSTANCE.convert(updateReqVO);
|
||||
materialMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMaterial(Long id) {
|
||||
// 校验存在
|
||||
validateMaterialExists(id);
|
||||
// 删除
|
||||
materialMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateMaterialExists(Long id) {
|
||||
if (materialMapper.selectById(id) == null) {
|
||||
throw exception(MATERIAL_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialDO getMaterial(Long id) {
|
||||
return materialMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MaterialDO> getMaterialList(Collection<Long> ids) {
|
||||
return materialMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MaterialDO> getMaterialPage(MaterialPageReqVO pageReqVO) {
|
||||
return materialMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MaterialDO> getMaterialList(MaterialExportReqVO exportReqVO) {
|
||||
return materialMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
package com.yunxi.scm.module.demo.service.material;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.yunxi.scm.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import com.yunxi.scm.module.demo.controller.admin.material.vo.*;
|
||||
import com.yunxi.scm.module.demo.dal.dataobject.material.MaterialDO;
|
||||
import com.yunxi.scm.module.demo.dal.mysql.material.MaterialMapper;
|
||||
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static com.yunxi.scm.module.demo.enums.ErrorCodeConstants.*;
|
||||
import static com.yunxi.scm.framework.test.core.util.AssertUtils.*;
|
||||
import static com.yunxi.scm.framework.test.core.util.RandomUtils.*;
|
||||
import static com.yunxi.scm.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static com.yunxi.scm.framework.common.util.object.ObjectUtils.*;
|
||||
import static com.yunxi.scm.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link MaterialServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author ccongli
|
||||
*/
|
||||
@Import(MaterialServiceImpl.class)
|
||||
public class MaterialServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private MaterialServiceImpl materialService;
|
||||
|
||||
@Resource
|
||||
private MaterialMapper materialMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateMaterial_success() {
|
||||
// 准备参数
|
||||
MaterialCreateReqVO reqVO = randomPojo(MaterialCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long materialId = materialService.createMaterial(reqVO);
|
||||
// 断言
|
||||
assertNotNull(materialId);
|
||||
// 校验记录的属性是否正确
|
||||
MaterialDO material = materialMapper.selectById(materialId);
|
||||
assertPojoEquals(reqVO, material);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateMaterial_success() {
|
||||
// mock 数据
|
||||
MaterialDO dbMaterial = randomPojo(MaterialDO.class);
|
||||
materialMapper.insert(dbMaterial);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
MaterialUpdateReqVO reqVO = randomPojo(MaterialUpdateReqVO.class, o -> {
|
||||
o.setId(dbMaterial.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
materialService.updateMaterial(reqVO);
|
||||
// 校验是否更新正确
|
||||
MaterialDO material = materialMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, material);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateMaterial_notExists() {
|
||||
// 准备参数
|
||||
MaterialUpdateReqVO reqVO = randomPojo(MaterialUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> materialService.updateMaterial(reqVO), MATERIAL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteMaterial_success() {
|
||||
// mock 数据
|
||||
MaterialDO dbMaterial = randomPojo(MaterialDO.class);
|
||||
materialMapper.insert(dbMaterial);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbMaterial.getId();
|
||||
|
||||
// 调用
|
||||
materialService.deleteMaterial(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(materialMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteMaterial_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> materialService.deleteMaterial(id), MATERIAL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetMaterialPage() {
|
||||
// mock 数据
|
||||
MaterialDO dbMaterial = randomPojo(MaterialDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setStatus(null);
|
||||
o.setType(null);
|
||||
o.setCategory(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
materialMapper.insert(dbMaterial);
|
||||
// 测试 name 不匹配
|
||||
materialMapper.insert(cloneIgnoreId(dbMaterial, o -> o.setName(null)));
|
||||
// 测试 status 不匹配
|
||||
materialMapper.insert(cloneIgnoreId(dbMaterial, o -> o.setStatus(null)));
|
||||
// 测试 type 不匹配
|
||||
materialMapper.insert(cloneIgnoreId(dbMaterial, o -> o.setType(null)));
|
||||
// 测试 category 不匹配
|
||||
materialMapper.insert(cloneIgnoreId(dbMaterial, o -> o.setCategory(null)));
|
||||
// 测试 createTime 不匹配
|
||||
materialMapper.insert(cloneIgnoreId(dbMaterial, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
MaterialPageReqVO reqVO = new MaterialPageReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setType(null);
|
||||
reqVO.setCategory(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<MaterialDO> pageResult = materialService.getMaterialPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbMaterial, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetMaterialList() {
|
||||
// mock 数据
|
||||
MaterialDO dbMaterial = randomPojo(MaterialDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setStatus(null);
|
||||
o.setType(null);
|
||||
o.setCategory(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
materialMapper.insert(dbMaterial);
|
||||
// 测试 name 不匹配
|
||||
materialMapper.insert(cloneIgnoreId(dbMaterial, o -> o.setName(null)));
|
||||
// 测试 status 不匹配
|
||||
materialMapper.insert(cloneIgnoreId(dbMaterial, o -> o.setStatus(null)));
|
||||
// 测试 type 不匹配
|
||||
materialMapper.insert(cloneIgnoreId(dbMaterial, o -> o.setType(null)));
|
||||
// 测试 category 不匹配
|
||||
materialMapper.insert(cloneIgnoreId(dbMaterial, o -> o.setCategory(null)));
|
||||
// 测试 createTime 不匹配
|
||||
materialMapper.insert(cloneIgnoreId(dbMaterial, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
MaterialExportReqVO reqVO = new MaterialExportReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setType(null);
|
||||
reqVO.setCategory(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
List<MaterialDO> list = materialService.getMaterialList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbMaterial, list.get(0));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 创建物料管理
|
||||
export function createMaterial(data) {
|
||||
return request({
|
||||
url: '/demo/material/create',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新物料管理
|
||||
export function updateMaterial(data) {
|
||||
return request({
|
||||
url: '/demo/material/update',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除物料管理
|
||||
export function deleteMaterial(id) {
|
||||
return request({
|
||||
url: '/demo/material/delete?id=' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 获得物料管理
|
||||
export function getMaterial(id) {
|
||||
return request({
|
||||
url: '/demo/material/get?id=' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 获得物料管理分页
|
||||
export function getMaterialPage(query) {
|
||||
return request({
|
||||
url: '/demo/material/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 导出物料管理 Excel
|
||||
export function exportMaterialExcel(query) {
|
||||
return request({
|
||||
url: '/demo/material/export-excel',
|
||||
method: 'get',
|
||||
params: query,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
@ -0,0 +1,300 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="queryParams.name" placeholder="请输入名称" clearable @keyup.enter.native="handleQuery"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
|
||||
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.MATERIAL_STATUS)"
|
||||
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-select v-model="queryParams.type" placeholder="请选择类型" clearable size="small">
|
||||
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.TRADE_ORDER_TYPE)"
|
||||
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="分类" prop="category">-->
|
||||
<!-- <el-select v-model="queryParams.category" placeholder="请选择分类" clearable size="small">-->
|
||||
<!-- <el-option v-for="dict in this.getDictDatas(DICT_TYPE.TRADE_ORDER_TYPE)"-->
|
||||
<!-- :key="dict.value" :label="dict.label" :value="dict.value"/>-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
|
||||
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 操作工具栏 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
||||
v-hasPermi="['demo:material:create']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
|
||||
v-hasPermi="['demo:material:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<!-- 列表 -->
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="ID" align="center" prop="id" />
|
||||
<el-table-column label="名称" align="center" prop="name" />
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template v-slot="scope">
|
||||
<dict-tag :type="DICT_TYPE.MATERIAL_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="类型" align="center" prop="type">
|
||||
<template v-slot="scope">
|
||||
<dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="scope.row.type" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="分类" align="center" prop="category">
|
||||
<template v-slot="scope">
|
||||
<dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="scope.row.category" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="图片" align="center" prop="imgurl">
|
||||
<template v-slot="scope">
|
||||
<image-preview :src="scope.row.imgurl" :width="'100px'"></image-preview>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="库存数量" align="center" prop="stock" />
|
||||
<el-table-column label="单价" align="center" prop="price" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template v-slot="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template v-slot="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['demo:material:update']">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['demo:material:delete']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页组件 -->
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"/>
|
||||
|
||||
<!-- 对话框(添加 / 修改) -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" v-dialogDrag append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.MATERIAL_STATUS)"
|
||||
:key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-select v-model="form.type" placeholder="请选择类型" clearable>
|
||||
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.TRADE_ORDER_TYPE)"
|
||||
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类" prop="category">
|
||||
<el-select v-model="form.category" placeholder="请选择分类(多选)" multiple clearable>
|
||||
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.TRADE_ORDER_TYPE)"
|
||||
:key="dict.value" :label="dict.label" :value="parseInt(dict.value)"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="图片">
|
||||
<imageUpload v-model="form.imgurl"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="库存数量" prop="stock">
|
||||
<el-input v-model="form.stock" placeholder="请输入库存数量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="单价" prop="price">
|
||||
<el-input v-model="form.price" placeholder="请输入单价" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { createMaterial, updateMaterial, deleteMaterial, getMaterial, getMaterialPage, exportMaterialExcel } from "@/api/demo/material";
|
||||
import ImageUpload from '@/components/ImageUpload';
|
||||
import ImagePreview from "@/components/ImagePreview";
|
||||
|
||||
export default {
|
||||
name: "Material",
|
||||
components: {
|
||||
ImageUpload,
|
||||
ImagePreview
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 导出遮罩层
|
||||
exportLoading: false,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 物料管理列表
|
||||
list: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
name: null,
|
||||
status: null,
|
||||
type: null,
|
||||
category: null,
|
||||
createTime: [],
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [{ required: true, message: "名称不能为空", trigger: "blur" }],
|
||||
status: [{ required: true, message: "状态不能为空", trigger: "blur" }],
|
||||
type: [{ required: true, message: "类型不能为空", trigger: "change" }],
|
||||
category: [{ required: true, message: "分类不能为空", trigger: "change", type: "array"}],
|
||||
imgurl: [{ required: true, message: "图片不能为空", trigger: "blur" }],
|
||||
stock: [{ required: true, message: "库存数量不能为空", trigger: "blur" }],
|
||||
price: [{ required: true, message: "单价不能为空", trigger: "blur" }],
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
// 执行查询
|
||||
getMaterialPage(this.queryParams).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 取消按钮 */
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
/** 表单重置 */
|
||||
reset() {
|
||||
this.form = {
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
status: undefined,
|
||||
type: undefined,
|
||||
category: undefined,
|
||||
imgurl: undefined,
|
||||
stock: undefined,
|
||||
price: undefined,
|
||||
remark: undefined,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加物料管理";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id;
|
||||
getMaterial(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改物料管理";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
// 修改的提交
|
||||
if (this.form.id != null) {
|
||||
updateMaterial(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
createMaterial(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const id = row.id;
|
||||
this.$modal.confirm('是否确认删除物料管理编号为"' + id + '"的数据项?').then(function() {
|
||||
return deleteMaterial(id);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
// 处理查询参数
|
||||
let params = {...this.queryParams};
|
||||
params.pageNo = undefined;
|
||||
params.pageSize = undefined;
|
||||
this.$modal.confirm('是否确认导出所有物料管理数据项?').then(() => {
|
||||
this.exportLoading = true;
|
||||
return exportMaterialExcel(params);
|
||||
}).then(response => {
|
||||
this.$download.excel(response, '物料管理.xls');
|
||||
this.exportLoading = false;
|
||||
}).catch(() => {});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue