快检实验方法新增

This commit is contained in:
2026-05-25 11:01:26 +08:00
parent af8bf14b5e
commit a6579f019a
12 changed files with 1938 additions and 969 deletions

View File

@@ -1,147 +1,294 @@
-- 胶料快检实验方法主子表字典 + 建表 + 菜单质量管理下+ 按钮 + 租户 admin 授权
-- 权限前缀mes:mes_xsl_rubber_quick_test_method:*
-- 菜单 ID 1860000000000000177与数据点 170 段区分
-- 可与 Flyway V3.9.2_102 重复执行ON DUPLICATE / IF NOT EXISTS
-- SET @mes_tenant_id多租户 admin 授权目标租户
SET NAMES utf8mb4;
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES胶料快检转子类型', 'xslmes_rubber_quick_test_rotor_type', '1大转子2小转子', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_quick_test_rotor_type' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '大转子', '1', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_rubber_quick_test_rotor_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '1');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '小转子', '2', 2, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_rubber_quick_test_rotor_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '2');
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES胶料快检扭矩单位', 'xslmes_rubber_quick_test_torque_unit', 'Ib.indNmkg.cmNmmdm', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_quick_test_torque_unit' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, v.txt, v.val, v.ord, 1, 'admin', NOW()
FROM `sys_dict` d
CROSS JOIN (
SELECT 'Ib.in' AS txt, 'Ib.in' AS val, 1 AS ord UNION ALL
SELECT 'dNm', 'dNm', 2 UNION ALL
SELECT 'kg.cm', 'kg.cm', 3 UNION ALL
SELECT 'Nm', 'Nm', 4 UNION ALL
SELECT 'mdm', 'mdm', 5
) v
WHERE d.`dict_code` = 'xslmes_rubber_quick_test_torque_unit'
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = v.val);
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES胶料快检时间单位', 'xslmes_rubber_quick_test_time_unit', 'secminm:s', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_quick_test_time_unit' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, v.txt, v.val, v.ord, 1, 'admin', NOW()
FROM `sys_dict` d
CROSS JOIN (
SELECT 'sec' AS txt, 'sec' AS val, 1 AS ord UNION ALL
SELECT 'min', 'min', 2 UNION ALL
SELECT 'm:s', 'm:s', 3
) v
WHERE d.`dict_code` = 'xslmes_rubber_quick_test_time_unit'
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = v.val);
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES胶料快检门尼单位', 'xslmes_rubber_quick_test_mooney_unit', 'MU', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_quick_test_mooney_unit' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, 'MU', 'MU', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_rubber_quick_test_mooney_unit'
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'MU');
CREATE TABLE IF NOT EXISTS `mes_xsl_rubber_quick_test_method` (
`id` varchar(32) NOT NULL COMMENT '主键',
`method_code` varchar(16) NOT NULL COMMENT '方法编号租户内从001递增自动生成',
`method_name` varchar(128) NOT NULL COMMENT '实验方法名称同租户未删除唯一',
`quick_test_type_id` varchar(32) NOT NULL COMMENT '实验类型 mes_xsl_rubber_quick_test_type.id',
`quick_test_type_name` varchar(128) DEFAULT NULL COMMENT '实验类型名称冗余',
`test_temp_c` decimal(12,2) DEFAULT NULL COMMENT '实验温度°C',
`preheat_time_min` decimal(12,2) DEFAULT NULL COMMENT '预热时间min',
`test_time_min` decimal(12,2) DEFAULT NULL COMMENT '实验时间min',
`test_angle_deg` decimal(12,2) DEFAULT NULL COMMENT '实验角度Deg',
`test_freq_hz` decimal(12,2) DEFAULT NULL COMMENT '实验频率Hz',
`rotor_type` varchar(2) DEFAULT NULL COMMENT '转子类型字典xslmes_rubber_quick_test_rotor_type1大转子2小转子',
`rotor_speed_rpm` decimal(12,2) DEFAULT NULL COMMENT '转子速度rpm',
`method_desc` 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 '删除标记0正常1删除',
PRIMARY KEY (`id`),
KEY `idx_mrqtm_tenant_code` (`tenant_id`, `method_code`),
KEY `idx_mrqtm_type` (`quick_test_type_id`),
UNIQUE KEY `uk_mrqtm_tenant_name_del` (`tenant_id`, `method_name`, `del_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES胶料快检实验方法';
CREATE TABLE IF NOT EXISTS `mes_xsl_rubber_quick_test_method_line` (
`id` varchar(32) NOT NULL COMMENT '主键',
`method_id` varchar(32) NOT NULL COMMENT '主表 mes_xsl_rubber_quick_test_method.id',
`data_point_id` varchar(32) NOT NULL COMMENT '数据点 mes_xsl_rubber_quick_test_data_point.id',
`point_name` varchar(128) DEFAULT NULL COMMENT '数据点名称冗余只读带出',
`unit_type` varchar(64) DEFAULT NULL COMMENT '单位类型冗余只读带出',
`torque_unit_type` varchar(32) DEFAULT NULL COMMENT '扭矩单位类型字典xslmes_rubber_quick_test_torque_unit',
`time_unit_type` varchar(32) DEFAULT NULL COMMENT '时间单位类型字典xslmes_rubber_quick_test_time_unit',
`mooney_unit_type` varchar(32) DEFAULT NULL COMMENT '门尼单位类型字典xslmes_rubber_quick_test_mooney_unit',
`sort_no` int 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 '更新时间',
PRIMARY KEY (`id`),
KEY `idx_mrqtml_method` (`method_id`),
UNIQUE KEY `uk_mrqtml_method_point` (`method_id`, `data_point_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES胶料快检实验方法明细';
SET @mes_tenant_id = 1002;
SET @mes_quality_pid = IFNULL(
(SELECT `id` FROM `sys_permission` WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '质量管理' LIMIT 1),
'1860000000000000162'
);
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000177', @mes_quality_pid, '胶料快检实验方法', '/xslmes/mesXslRubberQuickTestMethod', 'xslmes/mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethodList', 'MesXslRubberQuickTestMethodList', 1, NULL, '1', 3, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0,
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
UPDATE `sys_permission` SET `icon` = 'ant-design:profile-outlined' WHERE `id` = '1860000000000000177' AND `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000178', '1860000000000000177', '新增', 2, 'mes:mes_xsl_rubber_quick_test_method:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000179', '1860000000000000177', '编辑', 2, 'mes:mes_xsl_rubber_quick_test_method:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000180', '1860000000000000177', '删除', 2, 'mes:mes_xsl_rubber_quick_test_method:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000181', '1860000000000000177', '批量删除', 2, 'mes:mes_xsl_rubber_quick_test_method:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000182', '1860000000000000177', '导出', 2, 'mes:mes_xsl_rubber_quick_test_method:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000183', '1860000000000000177', '导入', 2, 'mes:mes_xsl_rubber_quick_test_method:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
`is_leaf` = 1, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000177',
'1860000000000000178', '1860000000000000179', '1860000000000000180', '1860000000000000181',
'1860000000000000182', '1860000000000000183'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -1,104 +1,208 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
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 java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 胶料快检实验方法主表
*/
@Data
@TableName("mes_xsl_rubber_quick_test_method")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES胶料快检实验方法")
public class MesXslRubberQuickTestMethod implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Excel(name = "方法编号", width = 14)
@Schema(description = "方法编号租户内从001递增自动生成只读")
private String methodCode;
@Excel(name = "实验方法名称", width = 24)
@Schema(description = "实验方法名称(同租户未删除唯一)")
private String methodName;
@Excel(name = "实验类型", width = 20, dictTable = "mes_xsl_rubber_quick_test_type", dicText = "type_name", dicCode = "id")
@Dict(dictTable = "mes_xsl_rubber_quick_test_type", dicText = "type_name", dicCode = "id")
@Schema(description = "实验类型ID")
private String quickTestTypeId;
@Excel(name = "实验类型名称", width = 20)
@Schema(description = "实验类型名称冗余")
private String quickTestTypeName;
@Excel(name = "实验温度°C", width = 14, type = 10)
@Schema(description = "实验温度°C")
private BigDecimal testTempC;
@Excel(name = "预热时间min", width = 14, type = 10)
@Schema(description = "预热时间min")
private BigDecimal preheatTimeMin;
@Excel(name = "实验时间min", width = 14, type = 10)
@Schema(description = "实验时间min")
private BigDecimal testTimeMin;
@Excel(name = "实验角度Deg", width = 14, type = 10)
@Schema(description = "实验角度Deg")
private BigDecimal testAngleDeg;
@Excel(name = "实验频率Hz", width = 14, type = 10)
@Schema(description = "实验频率Hz")
private BigDecimal testFreqHz;
@Excel(name = "转子类型", width = 12, dicCode = "xslmes_rubber_quick_test_rotor_type")
@Dict(dicCode = "xslmes_rubber_quick_test_rotor_type")
@Schema(description = "转子类型字典xslmes_rubber_quick_test_rotor_type")
private String rotorType;
@Excel(name = "转子速度rpm", width = 14, type = 10)
@Schema(description = "转子速度rpm")
private BigDecimal rotorSpeedRpm;
@Excel(name = "方法描述", width = 40)
@Schema(description = "方法描述")
private String methodDesc;
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;
@TableLogic
@Schema(description = "删除状态0正常 1已删除")
private Integer delFlag;
@TableField(exist = false)
@Schema(description = "数据点明细")
private List<MesXslRubberQuickTestMethodLine> lineList;
}

View File

@@ -1,64 +1,128 @@
package org.jeecg.modules.xslmes.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.jeecg.common.aspect.annotation.Dict;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 胶料快检实验方法明细
*/
@Data
@TableName("mes_xsl_rubber_quick_test_method_line")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES胶料快检实验方法明细")
public class MesXslRubberQuickTestMethodLine implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Schema(description = "主表主键 mes_xsl_rubber_quick_test_method.id")
private String methodId;
@Schema(description = "数据点主键 mes_xsl_rubber_quick_test_data_point.id")
private String dataPointId;
@Schema(description = "数据点名称冗余(只读带出)")
private String pointName;
@Schema(description = "单位类型冗余(只读带出)")
private String unitType;
@Dict(dicCode = "xslmes_rubber_quick_test_torque_unit")
@Schema(description = "扭矩单位类型")
private String torqueUnitType;
@Dict(dicCode = "xslmes_rubber_quick_test_time_unit")
@Schema(description = "时间单位类型")
private String timeUnitType;
@Dict(dicCode = "xslmes_rubber_quick_test_mooney_unit")
@Schema(description = "门尼单位类型")
private String mooneyUnitType;
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

@@ -1,8 +1,16 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethodLine;
@Mapper
public interface MesXslRubberQuickTestMethodLineMapper extends BaseMapper<MesXslRubberQuickTestMethodLine> {}

View File

@@ -1,19 +1,38 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
@Mapper
public interface MesXslRubberQuickTestMethodMapper extends BaseMapper<MesXslRubberQuickTestMethod> {
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检实验方法租户内最大三位数字编号-----------
@Select(
"SELECT IFNULL(MAX(CAST(method_code AS UNSIGNED)), 0) FROM mes_xsl_rubber_quick_test_method "
+ "WHERE del_flag = 0 AND method_code REGEXP '^[0-9]+$' "
+ "AND (#{tenantId} IS NULL OR tenant_id = #{tenantId})")
Integer selectMaxNumericMethodCode(@Param("tenantId") Integer tenantId);
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检实验方法租户内最大三位数字编号-----------
}

View File

@@ -1,25 +1,50 @@
package org.jeecg.modules.xslmes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethodLine;
public interface IMesXslRubberQuickTestMethodService extends IService<MesXslRubberQuickTestMethod> {
String generateNextMethodCode(MesXslRubberQuickTestMethod context);
boolean isMethodNameDuplicated(String methodName, String excludeId, MesXslRubberQuickTestMethod context);
void saveMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList);
void updateMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList);
void delMain(String id);
void delBatchMain(Collection<? extends Serializable> idList);
List<MesXslRubberQuickTestMethodLine> selectLinesByMethodId(String methodId);
}

View File

@@ -1,166 +1,332 @@
package org.jeecg.modules.xslmes.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.List;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethodLine;
import org.jeecg.modules.xslmes.mapper.MesXslRubberQuickTestMethodLineMapper;
import org.jeecg.modules.xslmes.mapper.MesXslRubberQuickTestMethodMapper;
import org.jeecg.modules.xslmes.service.IMesXslRubberQuickTestMethodService;
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 MesXslRubberQuickTestMethodServiceImpl
extends ServiceImpl<MesXslRubberQuickTestMethodMapper, MesXslRubberQuickTestMethod>
implements IMesXslRubberQuickTestMethodService {
@Autowired
private MesXslRubberQuickTestMethodLineMapper mesXslRubberQuickTestMethodLineMapper;
//update-begin---author:jiangxh ---date:20260522 for【MES】胶料快检实验方法编号001递增、名称同租户唯一、主子保存-----------
@Override
public String generateNextMethodCode(MesXslRubberQuickTestMethod context) {
Integer tenantId = resolveTenantId(context);
Integer max = baseMapper.selectMaxNumericMethodCode(tenantId);
int next = (max == null ? 0 : max) + 1;
if (next > 999) {
throw new IllegalStateException("实验方法编号已超过999请联系管理员");
}
return String.format("%03d", next);
}
@Override
public boolean isMethodNameDuplicated(String methodName, String excludeId, MesXslRubberQuickTestMethod context) {
if (oConvertUtils.isEmpty(methodName)) {
return false;
}
Integer tenantId = resolveTenantId(context);
LambdaQueryWrapper<MesXslRubberQuickTestMethod> w = new LambdaQueryWrapper<>();
w.eq(MesXslRubberQuickTestMethod::getMethodName, methodName.trim());
w.and(
q ->
q.eq(MesXslRubberQuickTestMethod::getDelFlag, CommonConstant.DEL_FLAG_0)
.or()
.isNull(MesXslRubberQuickTestMethod::getDelFlag));
if (oConvertUtils.isNotEmpty(excludeId)) {
w.ne(MesXslRubberQuickTestMethod::getId, excludeId);
}
if (tenantId != null) {
w.eq(MesXslRubberQuickTestMethod::getTenantId, tenantId);
}
return this.count(w) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList) {
assertMethodNameUniqueForSave(main, null);
if (oConvertUtils.isEmpty(main.getMethodCode())) {
main.setMethodCode(generateNextMethodCode(main));
int next = (max == null ? 0 : max) + 1;
}
throw new IllegalStateException("实验方法编号已超过999请联系管理员");
}
return String.format("%03d", next);
}
@Override
public boolean isMethodNameDuplicated(String methodName, String excludeId, MesXslRubberQuickTestMethod context) {
if (oConvertUtils.isEmpty(methodName)) {
this.save(main);
insertLines(main.getId(), lineList);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateMain(MesXslRubberQuickTestMethod main, List<MesXslRubberQuickTestMethodLine> lineList) {
if (oConvertUtils.isEmpty(main.getId())) {
throw new JeecgBootException("缺少主键");
}
MesXslRubberQuickTestMethod old = this.getById(main.getId());
if (old == null) {
throw new JeecgBootException("实验方法不存在");
}
main.setMethodCode(old.getMethodCode());
assertMethodNameUniqueForSave(main, main.getId());
this.updateById(main);
mesXslRubberQuickTestMethodLineMapper.delete(
new LambdaQueryWrapper<MesXslRubberQuickTestMethodLine>()
.eq(MesXslRubberQuickTestMethodLine::getMethodId, main.getId()));
insertLines(main.getId(), lineList);
}
private void insertLines(String methodId, List<MesXslRubberQuickTestMethodLine> lineList) {
if (CollectionUtils.isEmpty(lineList)) {
return;
}
int sort = 0;
for (MesXslRubberQuickTestMethodLine line : lineList) {
line.setId(null);
line.setMethodId(methodId);
line.setSortNo(sort++);
mesXslRubberQuickTestMethodLineMapper.insert(line);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delMain(String id) {
mesXslRubberQuickTestMethodLineMapper.delete(
new LambdaQueryWrapper<MesXslRubberQuickTestMethodLine>()
.eq(MesXslRubberQuickTestMethodLine::getMethodId, id));
this.removeById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delBatchMain(Collection<? extends Serializable> idList) {
for (Serializable id : idList) {
delMain(id.toString());
}
}
}
@Override
}
@Override
public List<MesXslRubberQuickTestMethodLine> selectLinesByMethodId(String methodId) {
return mesXslRubberQuickTestMethodLineMapper.selectList(
new LambdaQueryWrapper<MesXslRubberQuickTestMethodLine>()
.eq(MesXslRubberQuickTestMethodLine::getMethodId, methodId)
.orderByAsc(MesXslRubberQuickTestMethodLine::getSortNo));
}
private void assertMethodNameUniqueForSave(MesXslRubberQuickTestMethod entity, String excludeId) {
if (entity == null || oConvertUtils.isEmpty(entity.getMethodName())) {
throw new JeecgBootException("实验方法名称不能为空");
assertMethodNameUniqueForSave(main, null);
if (oConvertUtils.isEmpty(main.getMethodCode())) {
main.setMethodCode(generateNextMethodCode(main));
}
String name = entity.getMethodName().trim();
entity.setMethodName(name);
if (isMethodNameDuplicated(name, excludeId, entity)) {
throw new JeecgBootException("实验方法名称已存在");
}
}
private static Integer resolveTenantId(MesXslRubberQuickTestMethod context) {
if (context != null && context.getTenantId() != null) {
return context.getTenantId();
}
String ts = TenantContext.getTenant();
if (oConvertUtils.isEmpty(ts)) {
try {
ts = TokenUtils.getTenantIdByRequest(SpringContextUtils.getHttpServletRequest());
} catch (Exception ignored) {
}
}
if (oConvertUtils.isEmpty(ts)) {
return null;
}
try {
return Integer.parseInt(ts.trim());
} catch (NumberFormatException e) {
return null;
}
}
//update-end---author:jiangxh ---date:20260522 for【MES】胶料快检实验方法编号001递增、名称同租户唯一、主子保存-----------
}

View File

@@ -1,12 +1,24 @@
package org.jeecg.modules.xslmes.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecg.modules.xslmes.entity.MesXslRubberQuickTestMethod;
/**
* 胶料快检实验方法主子保存页 VO
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MesXslRubberQuickTestMethodPage extends MesXslRubberQuickTestMethod {}

View File

@@ -1,146 +1,292 @@
-- MES 胶料快检实验方法主子表字典 + 建表 + 菜单质量管理下+ 按钮 + 租户 admin 授权
-- 权限前缀mes:mes_xsl_rubber_quick_test_method:*
-- 菜单 ID 1860000000000000177避免与数据点 170 段冲突
-- 依赖mes_xsl_rubber_quick_test_typemes_xsl_rubber_quick_test_data_point质量管理目录
SET NAMES utf8mb4;
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES胶料快检转子类型', 'xslmes_rubber_quick_test_rotor_type', '1大转子2小转子', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_quick_test_rotor_type' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '大转子', '1', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_rubber_quick_test_rotor_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '1');
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '小转子', '2', 2, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_rubber_quick_test_rotor_type' AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = '2');
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES胶料快检扭矩单位', 'xslmes_rubber_quick_test_torque_unit', 'Ib.indNmkg.cmNmmdm', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_quick_test_torque_unit' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, v.txt, v.val, v.ord, 1, 'admin', NOW()
FROM `sys_dict` d
CROSS JOIN (
SELECT 'Ib.in' AS txt, 'Ib.in' AS val, 1 AS ord UNION ALL
SELECT 'dNm', 'dNm', 2 UNION ALL
SELECT 'kg.cm', 'kg.cm', 3 UNION ALL
SELECT 'Nm', 'Nm', 4 UNION ALL
SELECT 'mdm', 'mdm', 5
) v
WHERE d.`dict_code` = 'xslmes_rubber_quick_test_torque_unit'
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = v.val);
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES胶料快检时间单位', 'xslmes_rubber_quick_test_time_unit', 'secminm:s', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_quick_test_time_unit' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, v.txt, v.val, v.ord, 1, 'admin', NOW()
FROM `sys_dict` d
CROSS JOIN (
SELECT 'sec' AS txt, 'sec' AS val, 1 AS ord UNION ALL
SELECT 'min', 'min', 2 UNION ALL
SELECT 'm:s', 'm:s', 3
) v
WHERE d.`dict_code` = 'xslmes_rubber_quick_test_time_unit'
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = v.val);
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES胶料快检门尼单位', 'xslmes_rubber_quick_test_mooney_unit', 'MU', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_rubber_quick_test_mooney_unit' AND `del_flag` = 0);
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, 'MU', 'MU', 1, 1, 'admin', NOW() FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_rubber_quick_test_mooney_unit'
AND NOT EXISTS (SELECT 1 FROM `sys_dict_item` i WHERE i.`dict_id` = d.id AND i.`item_value` = 'MU');
CREATE TABLE IF NOT EXISTS `mes_xsl_rubber_quick_test_method` (
`id` varchar(32) NOT NULL COMMENT '主键',
`method_code` varchar(16) NOT NULL COMMENT '方法编号租户内从001递增自动生成',
`method_name` varchar(128) NOT NULL COMMENT '实验方法名称同租户未删除唯一',
`quick_test_type_id` varchar(32) NOT NULL COMMENT '实验类型 mes_xsl_rubber_quick_test_type.id',
`quick_test_type_name` varchar(128) DEFAULT NULL COMMENT '实验类型名称冗余',
`test_temp_c` decimal(12,2) DEFAULT NULL COMMENT '实验温度°C',
`preheat_time_min` decimal(12,2) DEFAULT NULL COMMENT '预热时间min',
`test_time_min` decimal(12,2) DEFAULT NULL COMMENT '实验时间min',
`test_angle_deg` decimal(12,2) DEFAULT NULL COMMENT '实验角度Deg',
`test_freq_hz` decimal(12,2) DEFAULT NULL COMMENT '实验频率Hz',
`rotor_type` varchar(2) DEFAULT NULL COMMENT '转子类型字典xslmes_rubber_quick_test_rotor_type1大转子2小转子',
`rotor_speed_rpm` decimal(12,2) DEFAULT NULL COMMENT '转子速度rpm',
`method_desc` 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 '删除标记0正常1删除',
PRIMARY KEY (`id`),
KEY `idx_mrqtm_tenant_code` (`tenant_id`, `method_code`),
KEY `idx_mrqtm_type` (`quick_test_type_id`),
UNIQUE KEY `uk_mrqtm_tenant_name_del` (`tenant_id`, `method_name`, `del_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES胶料快检实验方法';
CREATE TABLE IF NOT EXISTS `mes_xsl_rubber_quick_test_method_line` (
`id` varchar(32) NOT NULL COMMENT '主键',
`method_id` varchar(32) NOT NULL COMMENT '主表 mes_xsl_rubber_quick_test_method.id',
`data_point_id` varchar(32) NOT NULL COMMENT '数据点 mes_xsl_rubber_quick_test_data_point.id',
`point_name` varchar(128) DEFAULT NULL COMMENT '数据点名称冗余只读带出',
`unit_type` varchar(64) DEFAULT NULL COMMENT '单位类型冗余只读带出',
`torque_unit_type` varchar(32) DEFAULT NULL COMMENT '扭矩单位类型字典xslmes_rubber_quick_test_torque_unit',
`time_unit_type` varchar(32) DEFAULT NULL COMMENT '时间单位类型字典xslmes_rubber_quick_test_time_unit',
`mooney_unit_type` varchar(32) DEFAULT NULL COMMENT '门尼单位类型字典xslmes_rubber_quick_test_mooney_unit',
`sort_no` int 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 '更新时间',
PRIMARY KEY (`id`),
KEY `idx_mrqtml_method` (`method_id`),
UNIQUE KEY `uk_mrqtml_method_point` (`method_id`, `data_point_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES胶料快检实验方法明细';
SET @mes_tenant_id = 1002;
SET @mes_quality_pid = IFNULL(
(SELECT `id` FROM `sys_permission` WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '质量管理' LIMIT 1),
'1860000000000000162'
);
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `keep_alive`, `internal_or_external`, `create_by`, `create_time`)
VALUES ('1860000000000000177', @mes_quality_pid, '胶料快检实验方法', '/xslmes/mesXslRubberQuickTestMethod', 'xslmes/mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethodList', 'MesXslRubberQuickTestMethodList', 1, NULL, '1', 3, 1, 0, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `url` = VALUES(`url`), `component` = VALUES(`component`), `component_name` = VALUES(`component_name`),
`menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`), `sort_no` = VALUES(`sort_no`),
`is_route` = VALUES(`is_route`), `is_leaf` = 0, `hidden` = 0, `status` = '1', `del_flag` = 0,
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`);
UPDATE `sys_permission` SET `icon` = 'ant-design:profile-outlined' WHERE `id` = '1860000000000000177' AND `del_flag` = 0;
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `is_leaf`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
('1860000000000000178', '1860000000000000177', '新增', 2, 'mes:mes_xsl_rubber_quick_test_method:add', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000179', '1860000000000000177', '编辑', 2, 'mes:mes_xsl_rubber_quick_test_method:edit', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000180', '1860000000000000177', '删除', 2, 'mes:mes_xsl_rubber_quick_test_method:delete', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000181', '1860000000000000177', '批量删除', 2, 'mes:mes_xsl_rubber_quick_test_method:deleteBatch', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000182', '1860000000000000177', '导出', 2, 'mes:mes_xsl_rubber_quick_test_method:exportXls', '1', 1, '1', 0, 'admin', NOW()),
('1860000000000000183', '1860000000000000177', '导入', 2, 'mes:mes_xsl_rubber_quick_test_method:importExcel', '1', 1, '1', 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
`parent_id` = VALUES(`parent_id`), `name` = VALUES(`name`), `menu_type` = VALUES(`menu_type`), `perms` = VALUES(`perms`), `perms_type` = VALUES(`perms_type`),
`is_leaf` = 1, `status` = '1', `del_flag` = 0;
INSERT INTO `sys_role_permission`(`id`, `role_id`, `permission_id`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.`id`, p.`id`, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`tenant_id` = @mes_tenant_id
AND r.`role_code` = 'admin'
AND p.`id` IN (
'1860000000000000177',
'1860000000000000178', '1860000000000000179', '1860000000000000180', '1860000000000000181',
'1860000000000000182', '1860000000000000183'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
);

View File

@@ -1,64 +1,128 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslRubberQuickTestMethod/list',
nextMethodCode = '/xslmes/mesXslRubberQuickTestMethod/nextMethodCode',
checkMethodName = '/xslmes/mesXslRubberQuickTestMethod/checkMethodName',
save = '/xslmes/mesXslRubberQuickTestMethod/add',
edit = '/xslmes/mesXslRubberQuickTestMethod/edit',
deleteOne = '/xslmes/mesXslRubberQuickTestMethod/delete',
deleteBatch = '/xslmes/mesXslRubberQuickTestMethod/deleteBatch',
importExcel = '/xslmes/mesXslRubberQuickTestMethod/importExcel',
exportXls = '/xslmes/mesXslRubberQuickTestMethod/exportXls',
queryById = '/xslmes/mesXslRubberQuickTestMethod/queryById',
queryLineList = '/xslmes/mesXslRubberQuickTestMethod/queryLineListByMethodId',
}
export const getExportUrl = Api.exportXls;
export const getImportUrl = Api.importExcel;
export const list = (params) => defHttp.get({ url: Api.list, params });
export const queryById = (params: { id: string }) => defHttp.get({ url: Api.queryById, params });
export const queryLineListByMethodId = (params: { id: string }) => defHttp.get({ url: Api.queryLineList, params });
export const fetchNextMethodCode = () => defHttp.get({ url: Api.nextMethodCode }, { successMessageMode: 'none' });
export const checkMethodName = (params: { methodName: string; dataId?: string }) =>
defHttp.get(
{ url: Api.checkMethodName, params },
{
successMessageMode: 'none',
errorMessageMode: 'none',
},
);
export const deleteOne = (params, handleSuccess) => {
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
};
export const batchDelete = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
},
});
};
export const saveOrUpdate = (params, isUpdate) => {
const url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url, params });
};

View File

@@ -1,136 +1,272 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button
type="primary"
v-auth="'mes:mes_xsl_rubber_quick_test_method:add'"
@click="handleAdd"
preIcon="ant-design:plus-outlined"
>
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_xsl_rubber_quick_test_method:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_xsl_rubber_quick_test_method:importExcel'"
preIcon="ant-design:import-outlined"
@click="onImportXls"
>
导入
</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
</a-menu>
</template>
<a-button v-auth="'mes:mes_xsl_rubber_quick_test_method:deleteBatch'">
批量操作
<Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
label: '编辑',
onClick: handleEdit.bind(null, record),
auth: 'mes:mes_xsl_rubber_quick_test_method:edit',
},
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslRubberQuickTestMethodModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslRubberQuickTestMethod" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslRubberQuickTestMethodModal from './components/MesXslRubberQuickTestMethodModal.vue';
import { columns, searchFormSchema } from './MesXslRubberQuickTestMethod.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslRubberQuickTestMethod.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '胶料快检实验方法',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
labelWidth: 120,
autoSubmitOnEnter: true,
showAdvancedButton: true,
},
actionColumn: {
width: 200,
fixed: 'right',
},
},
exportConfig: {
name: '胶料快检实验方法',
url: getExportUrl,
},
importConfig: {
url: getImportUrl,
success: handleSuccess,
},
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = 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 }, handleSuccess);
}
async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
}
function handleSuccess() {
selectedRowKeys.value = [];
reload();
}
function getDropDownAction(record) {
return [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'mes:mes_xsl_rubber_quick_test_method:delete',
},
];
}
</script>

View File

@@ -1,78 +1,156 @@
<template>
<BasicModal v-bind="$attrs" :title="modalTitle" :width="1000" @register="registerModal" @ok="handleOk">
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import { list } from '/@/views/xslmes/mesXslRubberQuickTestDataPoint/MesXslRubberQuickTestDataPoint.api';
const emit = defineEmits(['register', 'select']);
const filterQuickTestTypeId = ref('');
const selectedRows = ref<Recordable[]>([]);
const modalTitle = computed(() => '选择数据点(可多选)');
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
selectedRows.value = rows || [];
}
function fetchPointPage(params: Recordable) {
const p = { ...params };
if (filterQuickTestTypeId.value) {
p.quickTestTypeId = filterQuickTestTypeId.value;
}
return list(p);
}
const [registerTable, { reload, getSelectRows, clearSelectedRowKeys }] = useTable({
api: fetchPointPage,
columns: [
{ title: '数据点名称', dataIndex: 'pointName', width: 160 },
{ title: '实验类型', dataIndex: 'quickTestTypeName', width: 140 },
{ title: '单位类型', dataIndex: 'unitType', width: 120 },
{ title: '描述', dataIndex: 'pointDesc', width: 200, ellipsis: true },
],
rowKey: 'id',
useSearchForm: true,
formConfig: {
labelWidth: 90,
schemas: [
{ label: '数据点名称', field: 'pointName', component: 'Input', colProps: { span: 8 } },
],
},
pagination: { pageSize: 10 },
canResize: false,
showIndexColumn: false,
immediate: true,
rowSelection: {
type: 'checkbox',
columnWidth: 48,
onChange: handleSelectionChange,
},
clickToRowSelect: true,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
filterQuickTestTypeId.value = data?.quickTestTypeId ? String(data.quickTestTypeId) : '';
selectedRows.value = [];
clearSelectedRowKeys?.();
setModalProps({ confirmLoading: false });
reload();
});
async function handleOk() {
let rows = selectedRows.value?.length ? [...selectedRows.value] : ((getSelectRows?.() || []) as Recordable[]);
const valid = rows.filter((r) => r?.id && r.pointName != null);
if (!valid.length) {
closeModal();
return;
}
emit('select', valid);
closeModal();
}
</script>