原材料检验项目功能、原材料检验标准功能

This commit is contained in:
2026-05-12 14:09:41 +08:00
parent b737dddb2a
commit f5ba828eff
27 changed files with 1338 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
-- 原材料检验项目菜单与权限合并进 db/mes-material-menu.sql
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `mes_raw_material_inspect_item` (
`id` varchar(32) NOT NULL COMMENT '主键',
`inspect_item_name` varchar(200) NOT NULL COMMENT '检验项目名称',
`inspect_item_name_en` varchar(200) DEFAULT NULL COMMENT '英文名称',
`unit_name` varchar(64) DEFAULT NULL COMMENT '单位',
`item_mark` varchar(100) DEFAULT NULL COMMENT '标记',
`test_standard_no` varchar(128) DEFAULT NULL COMMENT '试验标准编号',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记',
PRIMARY KEY (`id`),
KEY `idx_rmii_name` (`inspect_item_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES原材料检验项目';

View File

@@ -0,0 +1,45 @@
-- 原材料检验标准主表 + 子表
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `mes_raw_material_inspect_std` (
`id` varchar(32) NOT NULL COMMENT '主键',
`standard_no` varchar(64) NOT NULL COMMENT '标准编号',
`mixer_material_id` varchar(32) NOT NULL COMMENT '密炼物料ID',
`material_name` varchar(200) DEFAULT NULL COMMENT '物料名称',
`material_desc` varchar(500) DEFAULT NULL COMMENT '物料描述',
`material_kind` varchar(200) DEFAULT NULL COMMENT '种类',
`version_no` varchar(64) DEFAULT NULL COMMENT '版本',
`issue_no` varchar(64) DEFAULT NULL COMMENT '发行编号',
`version_status` varchar(64) DEFAULT NULL COMMENT '版本状态',
`enable_flag` int NOT NULL DEFAULT '0' COMMENT '启用标记1启用 0停用',
`effective_date` datetime DEFAULT NULL COMMENT '生效日期',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记',
PRIMARY KEY (`id`),
KEY `idx_rmis_std_no` (`standard_no`),
KEY `idx_rmis_mixer` (`mixer_material_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES原材料检验标准';
CREATE TABLE IF NOT EXISTS `mes_raw_material_inspect_std_line` (
`id` varchar(32) NOT NULL COMMENT '主键',
`std_id` varchar(32) NOT NULL COMMENT '标准主表ID',
`inspect_item_id` varchar(32) NOT NULL COMMENT '原材料检验项目ID',
`inspect_item_name` varchar(200) DEFAULT NULL COMMENT '检验项目名称',
`allow_min` decimal(24,6) DEFAULT NULL COMMENT '容许最小值',
`include_min_flag` int NOT NULL DEFAULT '0' COMMENT '包含最小值1是 0否',
`allow_max` decimal(24,6) DEFAULT NULL COMMENT '容许最大值',
`include_max_flag` int NOT NULL DEFAULT '0' COMMENT '包含最大值1是 0否',
`sort_no` int DEFAULT NULL COMMENT '排序',
`create_by` varchar(32) DEFAULT NULL,
`create_time` datetime DEFAULT NULL,
`update_by` varchar(32) DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_rmisl_std` (`std_id`),
KEY `idx_rmisl_item` (`inspect_item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES原材料检验标准-检验项明细';

View File

@@ -0,0 +1,96 @@
package org.jeecg.modules.mes.material.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectItem;
import org.jeecg.modules.mes.material.service.IMesRawMaterialInspectItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
@Slf4j
@Tag(name = "MES-原材料检验项目")
@RestController
@RequestMapping("/mes/material/rawMaterialInspectItem")
public class MesRawMaterialInspectItemController
extends JeecgController<MesRawMaterialInspectItem, IMesRawMaterialInspectItemService> {
@Autowired private IMesRawMaterialInspectItemService mesRawMaterialInspectItemService;
@GetMapping("/list")
public Result<IPage<MesRawMaterialInspectItem>> queryPageList(
MesRawMaterialInspectItem model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesRawMaterialInspectItem> queryWrapper =
QueryGenerator.initQueryWrapper(model, req.getParameterMap());
IPage<MesRawMaterialInspectItem> pageList =
mesRawMaterialInspectItemService.page(new Page<>(pageNo, pageSize), queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "MES-原材料检验项目-添加")
@Operation(summary = "MES-原材料检验项目-添加")
@RequiresPermissions("mes:mes_raw_material_inspect_item:add")
@PostMapping("/add")
public Result<String> add(@RequestBody MesRawMaterialInspectItem model) {
mesRawMaterialInspectItemService.save(model);
return Result.OK("添加成功!");
}
@AutoLog(value = "MES-原材料检验项目-编辑")
@Operation(summary = "MES-原材料检验项目-编辑")
@RequiresPermissions("mes:mes_raw_material_inspect_item:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesRawMaterialInspectItem model) {
mesRawMaterialInspectItemService.updateById(model);
return Result.OK("编辑成功!");
}
@AutoLog(value = "MES-原材料检验项目-通过id删除")
@Operation(summary = "MES-原材料检验项目-通过id删除")
@RequiresPermissions("mes:mes_raw_material_inspect_item:delete")
@DeleteMapping("/delete")
public Result<String> delete(@RequestParam(name = "id") String id) {
mesRawMaterialInspectItemService.removeById(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "MES-原材料检验项目-批量删除")
@Operation(summary = "MES-原材料检验项目-批量删除")
@RequiresPermissions("mes:mes_raw_material_inspect_item:deleteBatch")
@DeleteMapping("/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids") String ids) {
mesRawMaterialInspectItemService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@GetMapping("/queryById")
public Result<MesRawMaterialInspectItem> queryById(@RequestParam(name = "id") String id) {
return Result.OK(mesRawMaterialInspectItemService.getById(id));
}
@RequiresPermissions("mes:mes_raw_material_inspect_item:exportXls")
@RequestMapping("/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesRawMaterialInspectItem model) {
return super.exportXls(request, model, MesRawMaterialInspectItem.class, "MES原材料检验项目");
}
@RequiresPermissions("mes:mes_raw_material_inspect_item:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, MesRawMaterialInspectItem.class);
}
}

View File

@@ -0,0 +1,128 @@
package org.jeecg.modules.mes.material.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStd;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStdLine;
import org.jeecg.modules.mes.material.service.IMesRawMaterialInspectStdService;
import org.jeecg.modules.mes.material.vo.MesRawMaterialInspectStdPage;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
@Slf4j
@Tag(name = "MES-原材料检验标准")
@RestController
@RequestMapping("/mes/material/rawMaterialInspectStd")
public class MesRawMaterialInspectStdController extends JeecgController<MesRawMaterialInspectStd, IMesRawMaterialInspectStdService> {
@Autowired private IMesRawMaterialInspectStdService mesRawMaterialInspectStdService;
@GetMapping("/list")
public Result<IPage<MesRawMaterialInspectStd>> queryPageList(
MesRawMaterialInspectStd model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesRawMaterialInspectStd> queryWrapper =
QueryGenerator.initQueryWrapper(model, req.getParameterMap());
IPage<MesRawMaterialInspectStd> pageList =
mesRawMaterialInspectStdService.page(new Page<>(pageNo, pageSize), queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "MES-原材料检验标准-添加")
@Operation(summary = "MES-原材料检验标准-添加")
@RequiresPermissions("mes:mes_raw_material_inspect_std:add")
@PostMapping("/add")
public Result<String> add(@RequestBody MesRawMaterialInspectStdPage page) {
MesRawMaterialInspectStd main = new MesRawMaterialInspectStd();
BeanUtils.copyProperties(page, main);
mesRawMaterialInspectStdService.saveMain(main, page.getLineList());
return Result.OK("添加成功!");
}
@AutoLog(value = "MES-原材料检验标准-编辑")
@Operation(summary = "MES-原材料检验标准-编辑")
@RequiresPermissions("mes:mes_raw_material_inspect_std:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesRawMaterialInspectStdPage page) {
MesRawMaterialInspectStd main = new MesRawMaterialInspectStd();
BeanUtils.copyProperties(page, main);
mesRawMaterialInspectStdService.updateMain(main, page.getLineList());
return Result.OK("编辑成功!");
}
@AutoLog(value = "MES-原材料检验标准-通过id删除")
@Operation(summary = "MES-原材料检验标准-通过id删除")
@RequiresPermissions("mes:mes_raw_material_inspect_std:delete")
@DeleteMapping("/delete")
public Result<String> delete(@RequestParam(name = "id") String id) {
mesRawMaterialInspectStdService.delMain(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "MES-原材料检验标准-批量删除")
@Operation(summary = "MES-原材料检验标准-批量删除")
@RequiresPermissions("mes:mes_raw_material_inspect_std:deleteBatch")
@DeleteMapping("/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids") String ids) {
mesRawMaterialInspectStdService.delBatchMain(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@GetMapping("/queryById")
public Result<MesRawMaterialInspectStd> queryById(@RequestParam(name = "id") String id) {
return Result.OK(mesRawMaterialInspectStdService.getById(id));
}
@GetMapping("/queryLineListByStdId")
public Result<java.util.List<MesRawMaterialInspectStdLine>> queryLineListByStdId(
@RequestParam(name = "id") String id) {
return Result.OK(mesRawMaterialInspectStdService.selectLinesByStdId(id));
}
@AutoLog(value = "MES-原材料检验标准-启用停用")
@Operation(summary = "MES-原材料检验标准-启用停用")
@RequiresPermissions("mes:mes_raw_material_inspect_std:enable")
@PostMapping("/setEnable")
public Result<String> setEnable(@RequestBody java.util.Map<String, Object> body) {
String id = body.get("id") == null ? null : body.get("id").toString();
int flag = body.get("enableFlag") == null ? 0 : Integer.parseInt(body.get("enableFlag").toString());
if (StringUtils.isBlank(id)) {
return Result.error("id不能为空");
}
MesRawMaterialInspectStd db = mesRawMaterialInspectStdService.getById(id);
if (db == null) {
return Result.error("记录不存在");
}
mesRawMaterialInspectStdService.setEnable(id, flag);
return Result.OK(flag == 1 ? "已启用" : "已停用");
}
@RequiresPermissions("mes:mes_raw_material_inspect_std:exportXls")
@RequestMapping("/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesRawMaterialInspectStd model) {
return super.exportXls(request, model, MesRawMaterialInspectStd.class, "MES原材料检验标准");
}
@RequiresPermissions("mes:mes_raw_material_inspect_std:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, MesRawMaterialInspectStd.class);
}
}

View File

@@ -0,0 +1,56 @@
package org.jeecg.modules.mes.material.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
@Data
@TableName("mes_raw_material_inspect_item")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES原材料检验项目")
public class MesRawMaterialInspectItem implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Excel(name = "检验项目名称", width = 22)
private String inspectItemName;
@Excel(name = "英文名称", width = 22)
private String inspectItemNameEn;
@Excel(name = "单位", width = 12)
private String unitName;
@Excel(name = "标记", width = 15)
private String itemMark;
@Excel(name = "试验标准编号", width = 18)
private String testStandardNo;
@Excel(name = "备注", width = 25)
private String remark;
private Integer tenantId;
private String sysOrgCode;
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
private Integer delFlag;
}

View File

@@ -0,0 +1,74 @@
package org.jeecg.modules.mes.material.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
@Data
@TableName("mes_raw_material_inspect_std")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES原材料检验标准")
public class MesRawMaterialInspectStd implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Excel(name = "标准编号", width = 18)
private String standardNo;
private String mixerMaterialId;
@Excel(name = "物料名称", width = 22)
private String materialName;
@Excel(name = "物料描述", width = 28)
private String materialDesc;
@Excel(name = "种类", width = 20)
private String materialKind;
@Excel(name = "版本", width = 12)
private String versionNo;
@Excel(name = "发行编号", width = 15)
private String issueNo;
@Excel(name = "版本状态", width = 12)
private String versionStatus;
@Excel(name = "启用", width = 8)
private Integer enableFlag;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "生效日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
private Date effectiveDate;
private Integer tenantId;
private String sysOrgCode;
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
private Integer delFlag;
}

View File

@@ -0,0 +1,54 @@
package org.jeecg.modules.mes.material.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
@Data
@TableName("mes_raw_material_inspect_std_line")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES原材料检验标准-检验项明细")
public class MesRawMaterialInspectStdLine implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
private String stdId;
private String inspectItemId;
private String inspectItemName;
private BigDecimal allowMin;
private Integer includeMinFlag;
private BigDecimal allowMax;
private Integer includeMaxFlag;
private Integer sortNo;
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}

View File

@@ -0,0 +1,6 @@
package org.jeecg.modules.mes.material.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectItem;
public interface MesRawMaterialInspectItemMapper extends BaseMapper<MesRawMaterialInspectItem> {}

View File

@@ -0,0 +1,6 @@
package org.jeecg.modules.mes.material.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStdLine;
public interface MesRawMaterialInspectStdLineMapper extends BaseMapper<MesRawMaterialInspectStdLine> {}

View File

@@ -0,0 +1,6 @@
package org.jeecg.modules.mes.material.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStd;
public interface MesRawMaterialInspectStdMapper extends BaseMapper<MesRawMaterialInspectStd> {}

View File

@@ -0,0 +1,6 @@
package org.jeecg.modules.mes.material.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectItem;
public interface IMesRawMaterialInspectItemService extends IService<MesRawMaterialInspectItem> {}

View File

@@ -0,0 +1,23 @@
package org.jeecg.modules.mes.material.service;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStd;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStdLine;
public interface IMesRawMaterialInspectStdService extends IService<MesRawMaterialInspectStd> {
void saveMain(MesRawMaterialInspectStd main, List<MesRawMaterialInspectStdLine> lineList);
void updateMain(MesRawMaterialInspectStd main, List<MesRawMaterialInspectStdLine> lineList);
void delMain(String id);
void delBatchMain(Collection<? extends Serializable> idList);
List<MesRawMaterialInspectStdLine> selectLinesByStdId(String stdId);
void setEnable(String id, int enableFlag);
}

View File

@@ -0,0 +1,12 @@
package org.jeecg.modules.mes.material.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectItem;
import org.jeecg.modules.mes.material.mapper.MesRawMaterialInspectItemMapper;
import org.jeecg.modules.mes.material.service.IMesRawMaterialInspectItemService;
import org.springframework.stereotype.Service;
@Service
public class MesRawMaterialInspectItemServiceImpl
extends ServiceImpl<MesRawMaterialInspectItemMapper, MesRawMaterialInspectItem>
implements IMesRawMaterialInspectItemService {}

View File

@@ -0,0 +1,121 @@
package org.jeecg.modules.mes.material.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectItem;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStd;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStdLine;
import org.jeecg.modules.mes.material.mapper.MesRawMaterialInspectStdLineMapper;
import org.jeecg.modules.mes.material.mapper.MesRawMaterialInspectStdMapper;
import org.jeecg.modules.mes.material.service.IMesRawMaterialInspectItemService;
import org.jeecg.modules.mes.material.service.IMesRawMaterialInspectStdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@Service
public class MesRawMaterialInspectStdServiceImpl extends ServiceImpl<MesRawMaterialInspectStdMapper, MesRawMaterialInspectStd>
implements IMesRawMaterialInspectStdService {
@Autowired private MesRawMaterialInspectStdLineMapper mesRawMaterialInspectStdLineMapper;
@Autowired private IMesRawMaterialInspectItemService mesRawMaterialInspectItemService;
@Override
@Transactional(rollbackFor = Exception.class)
public void saveMain(MesRawMaterialInspectStd main, List<MesRawMaterialInspectStdLine> lineList) {
if (main.getEnableFlag() == null) {
main.setEnableFlag(0);
}
this.save(main);
insertLines(main.getId(), lineList);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateMain(MesRawMaterialInspectStd main, List<MesRawMaterialInspectStdLine> lineList) {
this.updateById(main);
mesRawMaterialInspectStdLineMapper.delete(
new LambdaQueryWrapper<MesRawMaterialInspectStdLine>().eq(MesRawMaterialInspectStdLine::getStdId, main.getId()));
insertLines(main.getId(), lineList);
}
private void insertLines(String stdId, List<MesRawMaterialInspectStdLine> lineList) {
if (CollectionUtils.isEmpty(lineList)) {
return;
}
int sort = 0;
for (MesRawMaterialInspectStdLine line : lineList) {
line.setId(null);
line.setStdId(stdId);
if (line.getIncludeMinFlag() == null) {
line.setIncludeMinFlag(0);
}
if (line.getIncludeMaxFlag() == null) {
line.setIncludeMaxFlag(0);
}
line.setSortNo(sort++);
fillInspectItemName(line);
mesRawMaterialInspectStdLineMapper.insert(line);
}
}
private void fillInspectItemName(MesRawMaterialInspectStdLine line) {
if (StringUtils.isBlank(line.getInspectItemId())) {
return;
}
if (StringUtils.isNotBlank(line.getInspectItemName())) {
return;
}
MesRawMaterialInspectItem item = mesRawMaterialInspectItemService.getById(line.getInspectItemId());
if (item != null) {
line.setInspectItemName(item.getInspectItemName());
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delMain(String id) {
mesRawMaterialInspectStdLineMapper.delete(
new LambdaQueryWrapper<MesRawMaterialInspectStdLine>().eq(MesRawMaterialInspectStdLine::getStdId, id));
this.removeById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delBatchMain(Collection<? extends Serializable> idList) {
for (Serializable id : idList) {
delMain(id.toString());
}
}
@Override
public List<MesRawMaterialInspectStdLine> selectLinesByStdId(String stdId) {
return mesRawMaterialInspectStdLineMapper.selectList(
new LambdaQueryWrapper<MesRawMaterialInspectStdLine>()
.eq(MesRawMaterialInspectStdLine::getStdId, stdId)
.orderByAsc(MesRawMaterialInspectStdLine::getSortNo));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void setEnable(String id, int enableFlag) {
MesRawMaterialInspectStd entity = this.getById(id);
if (entity == null) {
return;
}
if (enableFlag == 1) {
entity.setEnableFlag(1);
entity.setEffectiveDate(new Date());
} else {
entity.setEnableFlag(0);
entity.setEffectiveDate(null);
}
this.updateById(entity);
}
}

View File

@@ -0,0 +1,14 @@
package org.jeecg.modules.mes.material.vo;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStd;
import org.jeecg.modules.mes.material.entity.MesRawMaterialInspectStdLine;
@Data
@EqualsAndHashCode(callSuper = true)
public class MesRawMaterialInspectStdPage extends MesRawMaterialInspectStd {
private List<MesRawMaterialInspectStdLine> lineList;
}

View File

@@ -3,6 +3,7 @@ import { Modal } from 'ant-design-vue';
enum Api {
list = '/mes/material/mixerMaterial/list',
queryById = '/mes/material/mixerMaterial/queryById',
save = '/mes/material/mixerMaterial/add',
edit = '/mes/material/mixerMaterial/edit',
deleteOne = '/mes/material/mixerMaterial/delete',
@@ -14,6 +15,7 @@ enum Api {
export const getExportUrl = Api.exportXls;
export const getImportUrl = Api.importExcel;
export const list = (params) => defHttp.get({ url: Api.list, params });
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
export const deleteOne = (params, handleSuccess) =>
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());

View File

@@ -0,0 +1,25 @@
import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';
enum Api {
list = '/mes/material/rawMaterialInspectItem/list',
save = '/mes/material/rawMaterialInspectItem/add',
edit = '/mes/material/rawMaterialInspectItem/edit',
deleteOne = '/mes/material/rawMaterialInspectItem/delete',
deleteBatch = '/mes/material/rawMaterialInspectItem/deleteBatch',
importExcel = '/mes/material/rawMaterialInspectItem/importExcel',
exportXls = '/mes/material/rawMaterialInspectItem/exportXls',
}
export const getExportUrl = Api.exportXls;
export const getImportUrl = Api.importExcel;
export const list = (params) => defHttp.get({ url: Api.list, params });
export const deleteOne = (params, handleSuccess) =>
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
export const batchDelete = (params, handleSuccess) =>
Modal.confirm({
title: '确认删除',
content: '是否删除选中数据',
onOk: () => defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => handleSuccess()),
});
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });

View File

@@ -0,0 +1,24 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
export const columns: BasicColumn[] = [
{ title: '检验项目名称', align: 'center', dataIndex: 'inspectItemName', width: 200 },
{ title: '英文名称', align: 'center', dataIndex: 'inspectItemNameEn', width: 200 },
{ title: '单位', align: 'center', dataIndex: 'unitName', width: 100 },
{ title: '标记', align: 'center', dataIndex: 'itemMark', width: 120 },
{ title: '试验标准编号', align: 'center', dataIndex: 'testStandardNo', width: 160 },
];
export const searchFormSchema: FormSchema[] = [
{ label: '检验项目名称', field: 'inspectItemName', component: 'Input', colProps: { span: 6 } },
{ label: '试验标准编号', field: 'testStandardNo', component: 'Input', colProps: { span: 6 } },
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{ label: '检验项目名称', field: 'inspectItemName', component: 'Input', required: true },
{ label: '英文名称', field: 'inspectItemNameEn', component: 'Input' },
{ label: '单位', field: 'unitName', component: 'Input' },
{ label: '标记', field: 'itemMark', component: 'Input' },
{ label: '试验标准编号', field: 'testStandardNo', component: 'Input' },
{ label: '备注', field: 'remark', component: 'InputTextArea' },
];

View File

@@ -0,0 +1,58 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_raw_material_inspect_item:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
</template>
<template #action="{ record }">
<TableAction
:actions="[{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_raw_material_inspect_item:edit' }]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesRawMaterialInspectItemModal @register="registerModal" @success="reload" />
</div>
</template>
<script lang="ts" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import MesRawMaterialInspectItemModal from './modules/MesRawMaterialInspectItemModal.vue';
import { columns, searchFormSchema } from './MesRawMaterialInspectItem.data';
import { list, deleteOne } from './MesRawMaterialInspectItem.api';
const [registerModal, { openModal }] = useModal();
const { tableContext } = useListPage({
tableProps: {
title: '原材料检验项目',
api: list,
columns,
canResize: true,
formConfig: { labelWidth: 120, schemas: searchFormSchema, autoSubmitOnEnter: true },
actionColumn: { width: 120 },
},
});
const [registerTable, { reload }, { rowSelection }] = tableContext;
function handleAdd() {
openModal(true, { isUpdate: false, showFooter: true });
}
function handleEdit(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: true });
}
function handleDetail(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: false });
}
async function handleDelete(record) {
await deleteOne({ id: record.id }, reload);
}
function getDropDownAction(record) {
return [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'mes:mes_raw_material_inspect_item:delete',
},
];
}
</script>

View File

@@ -0,0 +1,39 @@
import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';
enum Api {
list = '/mes/material/rawMaterialInspectStd/list',
save = '/mes/material/rawMaterialInspectStd/add',
edit = '/mes/material/rawMaterialInspectStd/edit',
deleteOne = '/mes/material/rawMaterialInspectStd/delete',
deleteBatch = '/mes/material/rawMaterialInspectStd/deleteBatch',
importExcel = '/mes/material/rawMaterialInspectStd/importExcel',
exportXls = '/mes/material/rawMaterialInspectStd/exportXls',
queryById = '/mes/material/rawMaterialInspectStd/queryById',
queryLineList = '/mes/material/rawMaterialInspectStd/queryLineListByStdId',
setEnable = '/mes/material/rawMaterialInspectStd/setEnable',
}
export const getExportUrl = Api.exportXls;
export const getImportUrl = Api.importExcel;
export const list = (params) => defHttp.get({ url: Api.list, params });
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
export const queryLineListByStdId = (params) => defHttp.get({ url: Api.queryLineList, params });
export const deleteOne = (params, handleSuccess) =>
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
export const batchDelete = (params, handleSuccess) => {
Modal.confirm({
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () =>
defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => handleSuccess()),
});
};
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });
export const setEnable = (params) => defHttp.post({ url: Api.setEnable, params });

View File

@@ -0,0 +1,126 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { JVxeColumn, JVxeTypes } from '/@/components/jeecg/JVxeTable/types';
function enableText(v: unknown) {
if (v === 1) return '启用';
if (v === 0) return '停用';
return '-';
}
export const columns: BasicColumn[] = [
{ title: '标准编号', align: 'center', dataIndex: 'standardNo', width: 140 },
{ title: '物料名称', align: 'center', dataIndex: 'materialName', width: 160 },
{ title: '种类', align: 'center', dataIndex: 'materialKind', width: 140, ellipsis: true },
{ title: '版本', align: 'center', dataIndex: 'versionNo', width: 100 },
{ title: '发行编号', align: 'center', dataIndex: 'issueNo', width: 120 },
{ title: '版本状态', align: 'center', dataIndex: 'versionStatus', width: 100 },
{
title: '启用',
align: 'center',
dataIndex: 'enableFlag',
width: 80,
customRender: ({ text }) => enableText(text),
},
{ title: '生效日期', align: 'center', dataIndex: 'effectiveDate', width: 170 },
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
{ title: '创建时间', align: 'center', dataIndex: 'createTime', width: 170 },
];
export const searchFormSchema: FormSchema[] = [
{ label: '标准编号', field: 'standardNo', component: 'Input', colProps: { span: 6 } },
{ label: '物料名称', field: 'materialName', component: 'Input', colProps: { span: 6 } },
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{ label: '', field: 'mixerMaterialId', component: 'Input', show: false },
{
label: '标准编号',
field: 'standardNo',
component: 'Input',
required: true,
colProps: { span: 12 },
},
{
label: '密炼物料',
field: 'materialName',
component: 'Input',
slot: 'mixerMaterialPicker',
rules: [{ required: true, message: '请选择密炼物料' }],
colProps: { span: 12 },
},
{
label: '物料描述',
field: 'materialDesc',
component: 'Input',
componentProps: { readonly: true },
colProps: { span: 12 },
},
{
label: '种类',
field: 'materialKind',
component: 'Input',
componentProps: { readonly: true },
colProps: { span: 12 },
},
{ label: '版本', field: 'versionNo', component: 'Input', colProps: { span: 12 } },
{ label: '发行编号', field: 'issueNo', component: 'Input', colProps: { span: 12 } },
{ label: '版本状态', field: 'versionStatus', component: 'Input', colProps: { span: 12 } },
{
label: '创建人',
field: 'createBy',
component: 'Input',
componentProps: { readonly: true },
ifShow: ({ values }) => !!values?.id,
colProps: { span: 12 },
},
{
label: '创建时间',
field: 'createTime',
component: 'Input',
componentProps: { readonly: true },
ifShow: ({ values }) => !!values?.id,
colProps: { span: 12 },
},
{
label: '生效日期',
field: 'effectiveDate',
component: 'Input',
componentProps: { readonly: true },
ifShow: ({ values }) => !!values?.id,
colProps: { span: 12 },
},
];
export const lineJVxeColumns: JVxeColumn[] = [
{
title: '检验项目',
key: 'inspectItemId',
type: JVxeTypes.selectDictSearch,
width: 260,
async: true,
dict: 'mes_raw_material_inspect_item,inspect_item_name,id',
tipsContent: '输入关键字搜索检验项目',
validateRules: [{ required: true, message: '${title}必选' }],
},
{ title: '容许最小值', key: 'allowMin', type: JVxeTypes.inputNumber, width: 140 },
{
title: '包含最小值',
key: 'includeMinFlag',
type: JVxeTypes.checkbox,
width: 120,
align: 'center',
customValue: [1, 0],
defaultValue: 0,
},
{ title: '容许最大值', key: 'allowMax', type: JVxeTypes.inputNumber, width: 140 },
{
title: '包含最大值',
key: 'includeMaxFlag',
type: JVxeTypes.checkbox,
width: 120,
align: 'center',
customValue: [1, 0],
defaultValue: 0,
},
];

View File

@@ -0,0 +1,90 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_raw_material_inspect_std:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"
>新增</a-button
>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_raw_material_inspect_std:edit' },
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesRawMaterialInspectStdModal @register="registerModal" @success="reload" />
</div>
</template>
<script lang="ts" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import MesRawMaterialInspectStdModal from './modules/MesRawMaterialInspectStdModal.vue';
import { columns, searchFormSchema } from './MesRawMaterialInspectStd.data';
import { list, deleteOne, setEnable } from './MesRawMaterialInspectStd.api';
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const { tableContext } = useListPage({
tableProps: {
title: '原材料检验标准',
api: list,
columns,
canResize: true,
formConfig: { labelWidth: 100, schemas: searchFormSchema, autoSubmitOnEnter: true },
actionColumn: { width: 200 },
},
});
const [registerTable, { reload }, { rowSelection }] = tableContext;
function handleAdd() {
openModal(true, { isUpdate: false, showFooter: true });
}
function handleEdit(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: true });
}
function handleDetail(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: false });
}
async function handleDelete(record) {
await deleteOne({ id: record.id }, reload);
}
async function handleEnable(record: Recordable) {
await setEnable({ id: record.id, enableFlag: 1 });
createMessage.success('已启用');
reload();
}
async function handleDisable(record: Recordable) {
await setEnable({ id: record.id, enableFlag: 0 });
createMessage.success('已停用');
reload();
}
function getDropDownAction(record) {
const actions: any[] = [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'mes:mes_raw_material_inspect_std:delete',
},
];
if (record.enableFlag !== 1) {
actions.push({
label: '启用',
auth: 'mes:mes_raw_material_inspect_std:enable',
popConfirm: { title: '启用后将记录当前时间到生效日期', confirm: () => handleEnable(record) },
});
} else {
actions.push({
label: '停用',
auth: 'mes:mes_raw_material_inspect_std:enable',
popConfirm: { title: '停用后将清除生效日期', confirm: () => handleDisable(record) },
});
}
return actions;
}
</script>

View File

@@ -0,0 +1,93 @@
<template>
<BasicModal v-bind="$attrs" title="选择密炼物料" :width="960" @register="registerModal" @ok="handleOk">
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import { list as mixerList, queryById as queryMixerById } from '../MesMixerMaterial.api';
import { columns as mixerColumns, searchFormSchema as mixerSearch } from '../MesMixerMaterial.data';
import { useMessage } from '/@/hooks/web/useMessage';
const emit = defineEmits(['register', 'select']);
const { createMessage } = useMessage();
const selectedRow = ref<Recordable | null>(null);
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
api: mixerList,
columns: mixerColumns.slice(0, 6),
rowKey: 'id',
useSearchForm: true,
formConfig: {
labelWidth: 90,
schemas: mixerSearch,
},
pagination: { pageSize: 10 },
canResize: false,
showIndexColumn: false,
immediate: true,
rowSelection: {
type: 'radio',
columnWidth: 48,
onChange: (_keys, rows) => {
selectedRow.value = rows?.[0] ?? null;
},
},
clickToRowSelect: true,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
selectedRow.value = null;
clearSelectedRowKeys?.();
setModalProps({ confirmLoading: false });
const mid = data?.mixerMaterialId as string | undefined;
if (mid) {
setSelectedRowKeys?.([mid]);
try {
const raw = await queryMixerById({ id: mid });
const row = (raw as any)?.id != null ? raw : (raw as any)?.result;
if (row) {
selectedRow.value = row;
}
} catch {
// ignore
}
}
reload();
});
function buildKind(row: Recordable) {
const a = row.majorCategoryId_dictText || '';
const b = row.minorCategoryId_dictText || '';
if (a && b) return `${a} / ${b}`;
return a || b || '';
}
async function handleOk() {
const keys = (getSelectRowKeys?.() || []) as string[];
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
if (!row && keys.length) {
try {
const raw = await queryMixerById({ id: keys[0] });
row = (raw as any)?.id != null ? raw : (raw as any)?.result;
} catch {
// ignore
}
}
if (!row?.id) {
createMessage.warning('请选择一条密炼物料');
return;
}
emit('select', {
mixerMaterialId: row.id,
materialName: row.materialName || '',
materialDesc: row.materialDesc || '',
materialKind: buildKind(row),
});
closeModal();
}
</script>

View File

@@ -0,0 +1,38 @@
<template>
<BasicModal @register="registerModal" :title="title" width="50%" v-bind="$attrs" @ok="handleSubmit">
<BasicForm @register="registerForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import { computed, ref, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from '../MesRawMaterialInspectItem.data';
import { saveOrUpdate } from '../MesRawMaterialInspectItem.api';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
setProps({ disabled: !data?.showFooter });
});
const title = computed(() => (!unref(isUpdate) ? '新增检验项目' : '编辑检验项目'));
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, isUpdate.value);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,161 @@
<template>
<BasicModal
v-bind="$attrs"
destroyOnClose
:title="title"
width="1000px"
@register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm" name="MesRawMaterialInspectStdForm">
<template #mixerMaterialPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input
v-model:value="model[field]"
read-only
placeholder="请点击选择密炼物料"
style="flex: 1"
:disabled="!showFooterFlag"
/>
<a-button type="primary" :disabled="!showFooterFlag" @click="openMixerSelect">选择</a-button>
<a-button v-if="model.mixerMaterialId && showFooterFlag" @click="clearMixer">清除</a-button>
</a-input-group>
</template>
</BasicForm>
<a-divider orientation="left">检验项目明细</a-divider>
<JVxeTable
v-if="tableReady"
ref="lineTableRef"
toolbar
row-number
keep-source
:max-height="360"
:loading="lineLoading"
:columns="lineJVxeColumns"
:dataSource="lineDataSource"
:disabled="!showFooterFlag"
/>
<MesMixerMaterialSelectModal @register="registerMixerModal" @select="onMixerSelect" />
</BasicModal>
</template>
<script lang="ts" setup>
import { computed, ref, unref } from 'vue';
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import type { JVxeTableInstance } from '/@/components/jeecg/JVxeTable/types';
import { formSchema, lineJVxeColumns } from '../MesRawMaterialInspectStd.data';
import { saveOrUpdate, queryById, queryLineListByStdId } from '../MesRawMaterialInspectStd.api';
import MesMixerMaterialSelectModal from './MesMixerMaterialSelectModal.vue';
import { useMessage } from '/@/hooks/web/useMessage';
const emit = defineEmits(['register', 'success']);
const { createMessage } = useMessage();
const isUpdate = ref(false);
const showFooterFlag = ref(true);
const tableReady = ref(false);
const lineLoading = ref(false);
const lineDataSource = ref<Recordable[]>([]);
const lineTableRef = ref<JVxeTableInstance>();
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
labelWidth: 110,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { span: 12 },
});
const [registerMixerModal, { openModal: openMixerModal }] = useModal();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
tableReady.value = false;
lineDataSource.value = [];
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
showFooterFlag.value = !!data?.showFooter;
setProps({ disabled: !data?.showFooter });
if (unref(isUpdate) && data?.record?.id) {
lineLoading.value = true;
try {
const mainRaw = await queryById({ id: data.record.id });
const m = (mainRaw as any)?.id != null ? mainRaw : (mainRaw as any)?.result ?? mainRaw;
const linesRaw = await queryLineListByStdId({ id: data.record.id });
const list = Array.isArray(linesRaw) ? linesRaw : (linesRaw as any)?.result ?? [];
await setFieldsValue({ ...m });
lineDataSource.value = [...(list || [])];
} finally {
lineLoading.value = false;
}
}
tableReady.value = true;
});
const title = computed(() => {
if (!showFooterFlag.value && unref(isUpdate)) {
return '原材料检验标准详情';
}
return !unref(isUpdate) ? '新增原材料检验标准' : '编辑原材料检验标准';
});
function openMixerSelect() {
const mid = getFieldsValue()?.mixerMaterialId;
openMixerModal(true, { mixerMaterialId: mid });
}
function onMixerSelect(payload: Recordable | null) {
if (!payload) {
return;
}
setFieldsValue({
mixerMaterialId: payload.mixerMaterialId,
materialName: payload.materialName,
materialDesc: payload.materialDesc,
materialKind: payload.materialKind,
});
}
function clearMixer() {
setFieldsValue({
mixerMaterialId: '',
materialName: '',
materialDesc: '',
materialKind: '',
});
}
async function handleSubmit() {
try {
const values = await validate();
const lineRef = lineTableRef.value as any;
if (lineRef?.validateTable) {
const err = await lineRef.validateTable();
if (err) {
createMessage.warning('请完善检验项目明细');
return;
}
}
const tableData = (lineRef?.getTableData?.() || []) as Recordable[];
const lineList = tableData
.filter((r) => r && r.inspectItemId)
.map((r) => ({
inspectItemId: r.inspectItemId,
inspectItemName: r.inspectItemName,
allowMin: r.allowMin,
allowMax: r.allowMax,
includeMinFlag: r.includeMinFlag ?? 0,
includeMaxFlag: r.includeMaxFlag ?? 0,
}));
if (!lineList.length) {
createMessage.warning('请至少添加一行检验项目');
return;
}
setModalProps({ confirmLoading: true });
await saveOrUpdate({ ...values, lineList }, unref(isUpdate));
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,7 @@
<template>
<MesRawMaterialInspectItemList />
</template>
<script lang="ts" setup>
import MesRawMaterialInspectItemList from '../material/MesRawMaterialInspectItemList.vue';
</script>

View File

@@ -0,0 +1,7 @@
<template>
<MesRawMaterialInspectStdList />
</template>
<script lang="ts" setup>
import MesRawMaterialInspectStdList from '../material/MesRawMaterialInspectStdList.vue';
</script>