设备点检配置新增
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
-- MES 设备点检配置(主子表):建表 + 菜单 + 按钮 + 租户 admin 授权
|
||||
-- 权限前缀:mes:mes_xsl_equip_inspect_config:*
|
||||
-- 父菜单:设备管理;类型字典复用 xslmes_im_item_category(须先有点检及保养项目功能)
|
||||
-- Flyway:V3.9.2_78__mes_xsl_equip_inspect_config.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equip_inspect_config` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`equipment_ledger_id` varchar(32) NOT NULL COMMENT '设备台账主键 mes_xsl_equipment_ledger.id',
|
||||
`equipment_name` varchar(500) DEFAULT NULL COMMENT '设备名称冗余',
|
||||
`equipment_code` varchar(500) DEFAULT NULL COMMENT '设备编号冗余',
|
||||
`config_type` varchar(500) NOT NULL COMMENT '配置类型(字典xslmes_im_item_category:inspect点检/maintain保养;同设备同类型唯一)',
|
||||
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||
`sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
|
||||
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_meic_tenant_equip_type` (`tenant_id`, `equipment_ledger_id`, `config_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备点检配置';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equip_inspect_config_line` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`config_id` varchar(32) NOT NULL COMMENT '主表主键 mes_xsl_equip_inspect_config.id',
|
||||
`inspect_maintain_item_id` varchar(32) NOT NULL COMMENT '点检及保养项目主键 mes_xsl_inspect_maintain_item.id',
|
||||
`item_code` varchar(500) DEFAULT NULL COMMENT '点检项目编号冗余',
|
||||
`item_name` varchar(500) DEFAULT NULL COMMENT '项目名称冗余',
|
||||
`item_category` varchar(500) DEFAULT NULL COMMENT '项目类别冗余',
|
||||
`item_type` varchar(500) DEFAULT NULL COMMENT '项目类型冗余',
|
||||
`equipment_part_name` varchar(500) DEFAULT NULL COMMENT '设备部位名称冗余',
|
||||
`equipment_sub_part_name` varchar(500) DEFAULT NULL COMMENT '设备小部位名称冗余',
|
||||
`inspect_method` varchar(500) DEFAULT NULL COMMENT '点检方式冗余',
|
||||
`judgment_criteria` varchar(500) DEFAULT NULL COMMENT '判断基准冗余',
|
||||
`sort_no` int DEFAULT '0' COMMENT '排序号',
|
||||
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_meicl_config` (`config_id`),
|
||||
KEY `idx_meicl_item` (`inspect_maintain_item_id`),
|
||||
UNIQUE KEY `uk_meicl_config_item` (`config_id`, `inspect_maintain_item_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备点检配置明细';
|
||||
|
||||
SET @mes_tenant_id = 1002;
|
||||
|
||||
SET @mes_equip_pid = (
|
||||
SELECT `id` FROM `sys_permission`
|
||||
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
|
||||
|
||||
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 ('1860000000000000148', @mes_equip_pid, '设备点检配置', '/xslmes/mesXslEquipInspectConfig', 'xslmes/mesXslEquipInspectConfig/MesXslEquipInspectConfigList', NULL, 1, NULL, '1', 12, 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` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
|
||||
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`), `icon` = 'ant-design:control-outlined';
|
||||
|
||||
UPDATE `sys_permission` SET `icon` = 'ant-design:control-outlined' WHERE `id` = '1860000000000000148' AND `del_flag` = 0;
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||
('1860000000000000149', '1860000000000000148', '新增', 2, 'mes:mes_xsl_equip_inspect_config:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000150', '1860000000000000148', '编辑', 2, 'mes:mes_xsl_equip_inspect_config:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000151', '1860000000000000148', '删除', 2, 'mes:mes_xsl_equip_inspect_config:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000152', '1860000000000000148', '批量删除', 2, 'mes:mes_xsl_equip_inspect_config:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000153', '1860000000000000148', '导出', 2, 'mes:mes_xsl_equip_inspect_config:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000154', '1860000000000000148', '导入', 2, 'mes:mes_xsl_equip_inspect_config:importExcel', '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`),
|
||||
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
|
||||
|
||||
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 (
|
||||
'1860000000000000148',
|
||||
'1860000000000000149', '1860000000000000150', '1860000000000000151', '1860000000000000152',
|
||||
'1860000000000000153', '1860000000000000154'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
@@ -0,0 +1,230 @@
|
||||
package org.jeecg.modules.xslmes.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 java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
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.constant.CommonConstant;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfig;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfigLine;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslInspectMaintainItem;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipInspectConfigService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentLedgerService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslInspectMaintainItemService;
|
||||
import org.jeecg.modules.xslmes.vo.MesXslEquipInspectConfigPage;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* MES 设备点检配置(主子表)
|
||||
*/
|
||||
@Tag(name = "MES设备点检配置")
|
||||
@RestController
|
||||
@RequestMapping("/xslmes/mesXslEquipInspectConfig")
|
||||
@Slf4j
|
||||
public class MesXslEquipInspectConfigController
|
||||
extends JeecgController<MesXslEquipInspectConfig, IMesXslEquipInspectConfigService> {
|
||||
|
||||
private static final Set<String> CONFIG_TYPE = Set.of("inspect", "maintain");
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipInspectConfigService mesXslEquipInspectConfigService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentLedgerService mesXslEquipmentLedgerService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslInspectMaintainItemService mesXslInspectMaintainItemService;
|
||||
|
||||
@Operation(summary = "MES设备点检配置-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslEquipInspectConfig>> queryPageList(
|
||||
MesXslEquipInspectConfig model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslEquipInspectConfig> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
Page<MesXslEquipInspectConfig> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslEquipInspectConfig> pageList = mesXslEquipInspectConfigService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备点检配置-添加")
|
||||
@Operation(summary = "MES设备点检配置-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_equip_inspect_config:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslEquipInspectConfigPage page) {
|
||||
MesXslEquipInspectConfig main = new MesXslEquipInspectConfig();
|
||||
BeanUtils.copyProperties(page, main);
|
||||
//update-begin---author:jiangxh ---date:20260519 for:【MES】设备点检配置保存校验-----------
|
||||
String err = validateForSave(main, page.getLineList(), null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260519 for:【MES】设备点检配置保存校验-----------
|
||||
mesXslEquipInspectConfigService.saveMain(main, page.getLineList());
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备点检配置-编辑")
|
||||
@Operation(summary = "MES设备点检配置-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_equip_inspect_config:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslEquipInspectConfigPage page) {
|
||||
MesXslEquipInspectConfig main = new MesXslEquipInspectConfig();
|
||||
BeanUtils.copyProperties(page, main);
|
||||
//update-begin---author:jiangxh ---date:20260519 for:【MES】设备点检配置保存校验-----------
|
||||
String err = validateForSave(main, page.getLineList(), main.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260519 for:【MES】设备点检配置保存校验-----------
|
||||
mesXslEquipInspectConfigService.updateMain(main, page.getLineList());
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备点检配置-删除")
|
||||
@Operation(summary = "MES设备点检配置-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equip_inspect_config:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslEquipInspectConfigService.delMain(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备点检配置-批量删除")
|
||||
@Operation(summary = "MES设备点检配置-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equip_inspect_config:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslEquipInspectConfigService.delBatchMain(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备点检配置-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslEquipInspectConfig> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslEquipInspectConfig entity = mesXslEquipInspectConfigService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备点检配置-查询明细")
|
||||
@GetMapping(value = "/queryLineListByConfigId")
|
||||
public Result<List<MesXslEquipInspectConfigLine>> queryLineListByConfigId(
|
||||
@RequestParam(name = "id", required = true) String id) {
|
||||
return Result.OK(mesXslEquipInspectConfigService.selectLinesByConfigId(id));
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equip_inspect_config:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipInspectConfig model) {
|
||||
return super.exportXls(request, model, MesXslEquipInspectConfig.class, "MES设备点检配置");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equip_inspect_config:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, MesXslEquipInspectConfig.class);
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260519 for:【MES】设备点检配置:主表唯一、明细项目不重复、从点检保养项目带出-----------
|
||||
private String validateForSave(
|
||||
MesXslEquipInspectConfig main, List<MesXslEquipInspectConfigLine> lineList, String excludeId) {
|
||||
if (main == null) {
|
||||
return "参数不能为空";
|
||||
}
|
||||
if (oConvertUtils.isEmpty(main.getEquipmentLedgerId())) {
|
||||
return "请选择设备台账";
|
||||
}
|
||||
MesXslEquipmentLedger ledger = mesXslEquipmentLedgerService.getById(main.getEquipmentLedgerId());
|
||||
if (ledger == null || isDeleted(ledger.getDelFlag())) {
|
||||
return "设备台账不存在或已删除";
|
||||
}
|
||||
main.setEquipmentName(ledger.getEquipmentName());
|
||||
main.setEquipmentCode(ledger.getEquipmentCode());
|
||||
|
||||
String configType = main.getConfigType();
|
||||
if (configType != null) {
|
||||
configType = configType.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(configType) || !CONFIG_TYPE.contains(configType)) {
|
||||
return "类型无效,请选择点检或保养";
|
||||
}
|
||||
main.setConfigType(configType);
|
||||
|
||||
if (mesXslEquipInspectConfigService.isConfigDuplicated(
|
||||
main.getEquipmentLedgerId(), configType, excludeId, main)) {
|
||||
return "该设备在此类型(点检/保养)下已存在配置,不能重复添加";
|
||||
}
|
||||
|
||||
if (lineList == null || lineList.isEmpty()) {
|
||||
return "请至少添加一条点检项目明细";
|
||||
}
|
||||
|
||||
Set<String> itemIds = new HashSet<>();
|
||||
int sort = 0;
|
||||
for (int i = 0; i < lineList.size(); i++) {
|
||||
MesXslEquipInspectConfigLine line = lineList.get(i);
|
||||
if (line == null) {
|
||||
continue;
|
||||
}
|
||||
int rowNo = i + 1;
|
||||
if (oConvertUtils.isEmpty(line.getInspectMaintainItemId())) {
|
||||
return "第 " + rowNo + " 行未选择点检及保养项目";
|
||||
}
|
||||
String itemId = line.getInspectMaintainItemId().trim();
|
||||
if (!itemIds.add(itemId)) {
|
||||
return "第 " + rowNo + " 行点检项目与前面行重复,同一配置中点检项目不能重复";
|
||||
}
|
||||
MesXslInspectMaintainItem item = mesXslInspectMaintainItemService.getById(itemId);
|
||||
if (item == null || isDeleted(item.getDelFlag())) {
|
||||
return "第 " + rowNo + " 行点检及保养项目不存在或已删除";
|
||||
}
|
||||
if (!configType.equals(item.getItemCategory())) {
|
||||
return "第 " + rowNo + " 行项目类别与配置类型不一致(配置为"
|
||||
+ ("inspect".equals(configType) ? "点检" : "保养")
|
||||
+ ")";
|
||||
}
|
||||
line.setInspectMaintainItemId(itemId);
|
||||
line.setItemCode(item.getItemCode());
|
||||
line.setItemName(item.getItemName());
|
||||
line.setItemCategory(item.getItemCategory());
|
||||
line.setItemType(item.getItemType());
|
||||
line.setEquipmentPartName(item.getEquipmentPartName());
|
||||
line.setEquipmentSubPartName(item.getEquipmentSubPartName());
|
||||
line.setInspectMethod(item.getInspectMethod());
|
||||
line.setJudgmentCriteria(item.getJudgmentCriteria());
|
||||
line.setSortNo(sort++);
|
||||
}
|
||||
if (itemIds.isEmpty()) {
|
||||
return "请至少添加一条点检项目明细";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isDeleted(Integer delFlag) {
|
||||
return delFlag != null && delFlag.equals(CommonConstant.DEL_FLAG_1);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260519 for:【MES】设备点检配置:主表唯一、明细项目不重复、从点检保养项目带出-----------
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
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.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
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 设备点检配置主表(表 mes_xsl_equip_inspect_config)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equip_inspect_config")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备点检配置")
|
||||
public class MesXslEquipInspectConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "设备台账主键 mes_xsl_equipment_ledger.id")
|
||||
private String equipmentLedgerId;
|
||||
|
||||
@Excel(name = "设备名称", width = 22)
|
||||
@Schema(description = "设备名称冗余")
|
||||
private String equipmentName;
|
||||
|
||||
@Excel(name = "设备编号", width = 18)
|
||||
@Schema(description = "设备编号冗余")
|
||||
private String equipmentCode;
|
||||
|
||||
@Excel(name = "类型", width = 12, dicCode = "xslmes_im_item_category")
|
||||
@Dict(dicCode = "xslmes_im_item_category")
|
||||
@Schema(description = "配置类型(字典xslmes_im_item_category:inspect点检/maintain保养;同设备同类型唯一)")
|
||||
private String configType;
|
||||
|
||||
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;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "点检项目明细")
|
||||
private List<MesXslEquipInspectConfigLine> lineList;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
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 设备点检配置明细(表 mes_xsl_equip_inspect_config_line)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equip_inspect_config_line")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备点检配置明细")
|
||||
public class MesXslEquipInspectConfigLine implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "主表主键 mes_xsl_equip_inspect_config.id")
|
||||
private String configId;
|
||||
|
||||
@Schema(description = "点检及保养项目主键 mes_xsl_inspect_maintain_item.id")
|
||||
private String inspectMaintainItemId;
|
||||
|
||||
@Schema(description = "点检项目编号冗余")
|
||||
private String itemCode;
|
||||
|
||||
@Schema(description = "项目名称冗余")
|
||||
private String itemName;
|
||||
|
||||
@Dict(dicCode = "xslmes_im_item_category")
|
||||
@Schema(description = "项目类别冗余")
|
||||
private String itemCategory;
|
||||
|
||||
@Dict(dicCode = "xslmes_im_item_type")
|
||||
@Schema(description = "项目类型冗余")
|
||||
private String itemType;
|
||||
|
||||
@Schema(description = "设备部位名称冗余")
|
||||
private String equipmentPartName;
|
||||
|
||||
@Schema(description = "设备小部位名称冗余")
|
||||
private String equipmentSubPartName;
|
||||
|
||||
@Dict(dicCode = "xslmes_im_inspect_method")
|
||||
@Schema(description = "点检方式冗余")
|
||||
private String inspectMethod;
|
||||
|
||||
@Schema(description = "判断基准冗余")
|
||||
private String judgmentCriteria;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfigLine;
|
||||
|
||||
public interface MesXslEquipInspectConfigLineMapper extends BaseMapper<MesXslEquipInspectConfigLine> {}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfig;
|
||||
|
||||
public interface MesXslEquipInspectConfigMapper extends BaseMapper<MesXslEquipInspectConfig> {}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* MES XSL 业务模块(Maven 工程名:jeecg-module-xslmes)。
|
||||
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})、设备类别({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory})、设备类型({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentType})、设备台账({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger})、设备部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})、点检及保养项目({@link org.jeecg.modules.xslmes.entity.MesXslInspectMaintainItem})、备品件类别({@link org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory})、备品件信息({@link org.jeecg.modules.xslmes.entity.MesXslSparePart})、厂家信息({@link org.jeecg.modules.xslmes.entity.MesXslManufacturer})、停机主类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType})、停机类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeType})等。
|
||||
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})、设备类别({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory})、设备类型({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentType})、设备台账({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger})、设备部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})、点检及保养项目({@link org.jeecg.modules.xslmes.entity.MesXslInspectMaintainItem})、设备点检配置({@link org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfig})、备品件类别({@link org.jeecg.modules.xslmes.entity.MesXslSparePartsCategory})、备品件信息({@link org.jeecg.modules.xslmes.entity.MesXslSparePart})、厂家信息({@link org.jeecg.modules.xslmes.entity.MesXslManufacturer})、停机主类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeMainType})、停机类型({@link org.jeecg.modules.xslmes.entity.MesXslDowntimeType})等。
|
||||
*/
|
||||
package org.jeecg.modules.xslmes;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
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.MesXslEquipInspectConfig;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfigLine;
|
||||
|
||||
public interface IMesXslEquipInspectConfigService extends IService<MesXslEquipInspectConfig> {
|
||||
|
||||
void saveMain(MesXslEquipInspectConfig main, List<MesXslEquipInspectConfigLine> lineList);
|
||||
|
||||
void updateMain(MesXslEquipInspectConfig main, List<MesXslEquipInspectConfigLine> lineList);
|
||||
|
||||
void delMain(String id);
|
||||
|
||||
void delBatchMain(Collection<? extends Serializable> idList);
|
||||
|
||||
List<MesXslEquipInspectConfigLine> selectLinesByConfigId(String configId);
|
||||
|
||||
boolean isConfigDuplicated(String equipmentLedgerId, String configType, String excludeId, MesXslEquipInspectConfig context);
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
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.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.TokenUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfig;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfigLine;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipInspectConfigLineMapper;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipInspectConfigMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipInspectConfigService;
|
||||
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 MesXslEquipInspectConfigServiceImpl
|
||||
extends ServiceImpl<MesXslEquipInspectConfigMapper, MesXslEquipInspectConfig>
|
||||
implements IMesXslEquipInspectConfigService {
|
||||
|
||||
@Autowired
|
||||
private MesXslEquipInspectConfigLineMapper mesXslEquipInspectConfigLineMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveMain(MesXslEquipInspectConfig main, List<MesXslEquipInspectConfigLine> lineList) {
|
||||
this.save(main);
|
||||
insertLines(main.getId(), lineList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateMain(MesXslEquipInspectConfig main, List<MesXslEquipInspectConfigLine> lineList) {
|
||||
this.updateById(main);
|
||||
mesXslEquipInspectConfigLineMapper.delete(
|
||||
new LambdaQueryWrapper<MesXslEquipInspectConfigLine>()
|
||||
.eq(MesXslEquipInspectConfigLine::getConfigId, main.getId()));
|
||||
insertLines(main.getId(), lineList);
|
||||
}
|
||||
|
||||
private void insertLines(String configId, List<MesXslEquipInspectConfigLine> lineList) {
|
||||
if (CollectionUtils.isEmpty(lineList)) {
|
||||
return;
|
||||
}
|
||||
int sort = 0;
|
||||
for (MesXslEquipInspectConfigLine line : lineList) {
|
||||
line.setId(null);
|
||||
line.setConfigId(configId);
|
||||
line.setSortNo(sort++);
|
||||
mesXslEquipInspectConfigLineMapper.insert(line);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delMain(String id) {
|
||||
mesXslEquipInspectConfigLineMapper.delete(
|
||||
new LambdaQueryWrapper<MesXslEquipInspectConfigLine>().eq(MesXslEquipInspectConfigLine::getConfigId, 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<MesXslEquipInspectConfigLine> selectLinesByConfigId(String configId) {
|
||||
return mesXslEquipInspectConfigLineMapper.selectList(
|
||||
new LambdaQueryWrapper<MesXslEquipInspectConfigLine>()
|
||||
.eq(MesXslEquipInspectConfigLine::getConfigId, configId)
|
||||
.orderByAsc(MesXslEquipInspectConfigLine::getSortNo));
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260519 for:【MES】设备点检配置:同设备同类型(点检/保养)仅允许一条主数据-----------
|
||||
@Override
|
||||
public boolean isConfigDuplicated(
|
||||
String equipmentLedgerId, String configType, String excludeId, MesXslEquipInspectConfig context) {
|
||||
if (oConvertUtils.isEmpty(equipmentLedgerId) || oConvertUtils.isEmpty(configType)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslEquipInspectConfig> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipInspectConfig::getEquipmentLedgerId, equipmentLedgerId.trim());
|
||||
w.eq(MesXslEquipInspectConfig::getConfigType, configType.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipInspectConfig::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipInspectConfig::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslEquipInspectConfig::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipInspectConfig::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslEquipInspectConfig 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) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ts)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(ts);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260519 for:【MES】设备点检配置:同设备同类型(点检/保养)仅允许一条主数据-----------
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.jeecg.modules.xslmes.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipInspectConfig;
|
||||
|
||||
/**
|
||||
* 设备点检配置主子保存页 VO,继承主表实体(含 {@link MesXslEquipInspectConfig#lineList} 明细)。
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MesXslEquipInspectConfigPage extends MesXslEquipInspectConfig {}
|
||||
@@ -339,3 +339,26 @@ jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainI
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslInspectMaintainItemModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentTypeFilterSelectModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslInspectMaintainItem/components/MesXslEquipmentSubPartFilterSelectModal.vue
|
||||
-- author:jiangxh---date:20260519--for: 【MES】设备点检配置主子表(设备台账+类型唯一、明细从点检保养项目带出)---
|
||||
jeecg-boot/db/mes-xsl-equip-inspect-config-menu-permission.sql
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_78__mes_xsl_equip_inspect_config.sql
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipInspectConfig.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipInspectConfigLine.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/vo/MesXslEquipInspectConfigPage.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipInspectConfigMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipInspectConfigLineMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipInspectConfigService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipInspectConfigServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipInspectConfigController.java
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectConfig/MesXslEquipInspectConfigList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectConfig/MesXslEquipInspectConfig.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectConfig/MesXslEquipInspectConfig.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectConfig/components/MesXslEquipInspectConfigModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectConfig/components/MesXslEquipmentLedgerSelectModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectConfig/components/MesXslInspectMaintainItemSelectModal.vue
|
||||
-- author:jiangxh---date:20260519--for: 【MES】修复设备点检配置保存失败(Page VO 与主实体重复 lineList 导致编译错误)---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/vo/MesXslEquipInspectConfigPage.java
|
||||
-- author:jiangxh---date:20260519--for: 【MES】设备点检配置明细改为多选点检保养项目、禁用JVxe新增---
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectConfig/components/MesXslEquipInspectConfigModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectConfig/components/MesXslInspectMaintainItemSelectModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipInspectConfig/MesXslEquipInspectConfig.data.ts
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
-- MES 设备点检配置(主子表):与 jeecg-boot/db/mes-xsl-equip-inspect-config-menu-permission.sql 一致
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equip_inspect_config` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`equipment_ledger_id` varchar(32) NOT NULL COMMENT '设备台账主键 mes_xsl_equipment_ledger.id',
|
||||
`equipment_name` varchar(500) DEFAULT NULL COMMENT '设备名称冗余',
|
||||
`equipment_code` varchar(500) DEFAULT NULL COMMENT '设备编号冗余',
|
||||
`config_type` varchar(500) NOT NULL COMMENT '配置类型(字典xslmes_im_item_category:inspect点检/maintain保养;同设备同类型唯一)',
|
||||
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||
`sys_org_code` varchar(500) DEFAULT NULL COMMENT '部门',
|
||||
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_meic_tenant_equip_type` (`tenant_id`, `equipment_ledger_id`, `config_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备点检配置';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equip_inspect_config_line` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`config_id` varchar(32) NOT NULL COMMENT '主表主键 mes_xsl_equip_inspect_config.id',
|
||||
`inspect_maintain_item_id` varchar(32) NOT NULL COMMENT '点检及保养项目主键 mes_xsl_inspect_maintain_item.id',
|
||||
`item_code` varchar(500) DEFAULT NULL COMMENT '点检项目编号冗余',
|
||||
`item_name` varchar(500) DEFAULT NULL COMMENT '项目名称冗余',
|
||||
`item_category` varchar(500) DEFAULT NULL COMMENT '项目类别冗余',
|
||||
`item_type` varchar(500) DEFAULT NULL COMMENT '项目类型冗余',
|
||||
`equipment_part_name` varchar(500) DEFAULT NULL COMMENT '设备部位名称冗余',
|
||||
`equipment_sub_part_name` varchar(500) DEFAULT NULL COMMENT '设备小部位名称冗余',
|
||||
`inspect_method` varchar(500) DEFAULT NULL COMMENT '点检方式冗余',
|
||||
`judgment_criteria` varchar(500) DEFAULT NULL COMMENT '判断基准冗余',
|
||||
`sort_no` int DEFAULT '0' COMMENT '排序号',
|
||||
`create_by` varchar(500) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(500) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_meicl_config` (`config_id`),
|
||||
KEY `idx_meicl_item` (`inspect_maintain_item_id`),
|
||||
UNIQUE KEY `uk_meicl_config_item` (`config_id`, `inspect_maintain_item_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备点检配置明细';
|
||||
|
||||
SET @mes_tenant_id = 1002;
|
||||
|
||||
SET @mes_equip_pid = (
|
||||
SELECT `id` FROM `sys_permission`
|
||||
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = '设备管理'
|
||||
LIMIT 1
|
||||
);
|
||||
SET @mes_equip_pid = IFNULL(@mes_equip_pid, '1860000000000000133');
|
||||
|
||||
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 ('1860000000000000148', @mes_equip_pid, '设备点检配置', '/xslmes/mesXslEquipInspectConfig', 'xslmes/mesXslEquipInspectConfig/MesXslEquipInspectConfigList', NULL, 1, NULL, '1', 12, 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` = VALUES(`is_leaf`), `hidden` = VALUES(`hidden`), `status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`),
|
||||
`keep_alive` = VALUES(`keep_alive`), `internal_or_external` = VALUES(`internal_or_external`), `icon` = 'ant-design:control-outlined';
|
||||
|
||||
UPDATE `sys_permission` SET `icon` = 'ant-design:control-outlined' WHERE `id` = '1860000000000000148' AND `del_flag` = 0;
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||
('1860000000000000149', '1860000000000000148', '新增', 2, 'mes:mes_xsl_equip_inspect_config:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000150', '1860000000000000148', '编辑', 2, 'mes:mes_xsl_equip_inspect_config:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000151', '1860000000000000148', '删除', 2, 'mes:mes_xsl_equip_inspect_config:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000152', '1860000000000000148', '批量删除', 2, 'mes:mes_xsl_equip_inspect_config:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000153', '1860000000000000148', '导出', 2, 'mes:mes_xsl_equip_inspect_config:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000154', '1860000000000000148', '导入', 2, 'mes:mes_xsl_equip_inspect_config:importExcel', '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`),
|
||||
`status` = VALUES(`status`), `del_flag` = VALUES(`del_flag`);
|
||||
|
||||
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 (
|
||||
'1860000000000000148',
|
||||
'1860000000000000149', '1860000000000000150', '1860000000000000151', '1860000000000000152',
|
||||
'1860000000000000153', '1860000000000000154'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
@@ -0,0 +1,51 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslEquipInspectConfig/list',
|
||||
save = '/xslmes/mesXslEquipInspectConfig/add',
|
||||
edit = '/xslmes/mesXslEquipInspectConfig/edit',
|
||||
deleteOne = '/xslmes/mesXslEquipInspectConfig/delete',
|
||||
deleteBatch = '/xslmes/mesXslEquipInspectConfig/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslEquipInspectConfig/importExcel',
|
||||
exportXls = '/xslmes/mesXslEquipInspectConfig/exportXls',
|
||||
queryById = '/xslmes/mesXslEquipInspectConfig/queryById',
|
||||
queryLineList = '/xslmes/mesXslEquipInspectConfig/queryLineListByConfigId',
|
||||
}
|
||||
|
||||
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 queryLineListByConfigId = (params: { id: string }) => defHttp.get({ url: Api.queryLineList, params });
|
||||
|
||||
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 });
|
||||
};
|
||||
@@ -0,0 +1,86 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { JVxeColumn, JVxeTypes } from '/@/components/jeecg/JVxeTable/types';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '设备名称', align: 'center', dataIndex: 'equipmentName', width: 160 },
|
||||
{ title: '设备编号', align: 'center', dataIndex: 'equipmentCode', width: 140 },
|
||||
{ title: '类型', align: 'center', dataIndex: 'configType_dictText', width: 90 },
|
||||
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
|
||||
{
|
||||
title: '创建时间',
|
||||
align: 'center',
|
||||
dataIndex: 'createTime',
|
||||
width: 165,
|
||||
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
|
||||
},
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{ label: '设备名称', field: 'equipmentName', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '设备编号', field: 'equipmentCode', component: 'Input', colProps: { span: 6 } },
|
||||
{
|
||||
label: '类型',
|
||||
field: 'configType',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_im_item_category' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{ label: '', field: 'equipmentLedgerId', component: 'Input', show: false },
|
||||
{
|
||||
label: '设备名称',
|
||||
field: 'equipmentName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentLedgerPicker',
|
||||
dynamicRules: () => [{ required: true, message: '请选择设备台账' }],
|
||||
},
|
||||
{
|
||||
label: '设备编号',
|
||||
field: 'equipmentCode',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true, placeholder: '选择设备后自动带出' },
|
||||
},
|
||||
{
|
||||
label: '类型',
|
||||
field: 'configType',
|
||||
component: 'JDictSelectTag',
|
||||
required: true,
|
||||
componentProps: { dictCode: 'xslmes_im_item_category', placeholder: '点检/保养' },
|
||||
},
|
||||
];
|
||||
|
||||
export const lineJVxeColumns: JVxeColumn[] = [
|
||||
{ title: '', key: 'inspectMaintainItemId', type: JVxeTypes.hidden },
|
||||
{ title: '点检项目编号', key: 'itemCode', type: JVxeTypes.normal, width: 130, disabled: true },
|
||||
{ title: '项目名称', key: 'itemName', type: JVxeTypes.normal, width: 140, disabled: true },
|
||||
{
|
||||
title: '项目类别',
|
||||
key: 'itemCategory',
|
||||
type: JVxeTypes.select,
|
||||
width: 100,
|
||||
disabled: true,
|
||||
dictCode: 'xslmes_im_item_category',
|
||||
},
|
||||
{
|
||||
title: '项目类型',
|
||||
key: 'itemType',
|
||||
type: JVxeTypes.select,
|
||||
width: 100,
|
||||
disabled: true,
|
||||
dictCode: 'xslmes_im_item_type',
|
||||
},
|
||||
{ title: '设备部位', key: 'equipmentPartName', type: JVxeTypes.normal, width: 120, disabled: true },
|
||||
{ title: '设备小部位', key: 'equipmentSubPartName', type: JVxeTypes.normal, width: 120, disabled: true },
|
||||
{
|
||||
title: '点检方式',
|
||||
key: 'inspectMethod',
|
||||
type: JVxeTypes.select,
|
||||
width: 100,
|
||||
disabled: true,
|
||||
dictCode: 'xslmes_im_inspect_method',
|
||||
},
|
||||
{ title: '判断基准', key: 'judgmentCriteria', type: JVxeTypes.normal, width: 180, disabled: true },
|
||||
];
|
||||
@@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equip_inspect_config:add'"
|
||||
@click="handleAdd"
|
||||
preIcon="ant-design:plus-outlined"
|
||||
>
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equip_inspect_config:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<j-upload-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equip_inspect_config: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_equip_inspect_config: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_equip_inspect_config:edit' },
|
||||
]"
|
||||
:dropDownActions="getDropDownAction(record)"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslEquipInspectConfigModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslEquipInspectConfig" setup>
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesXslEquipInspectConfigModal from './components/MesXslEquipInspectConfigModal.vue';
|
||||
import { columns, searchFormSchema } from './MesXslEquipInspectConfig.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslEquipInspectConfig.api';
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '设备点检配置',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
labelWidth: 100,
|
||||
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_equip_inspect_config:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,239 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
destroyOnClose
|
||||
:title="title"
|
||||
width="1100px"
|
||||
@register="registerModal"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<BasicForm @register="registerForm">
|
||||
<template #equipmentLedgerPicker="{ model, field }">
|
||||
<a-input-group compact style="display: flex; width: 100%">
|
||||
<a-input v-model:value="model[field]" read-only placeholder="请选择设备台账" style="flex: 1" />
|
||||
<a-button type="primary" :disabled="isDetail" @click="openLedgerSelect">选择</a-button>
|
||||
<a-button v-if="model.equipmentLedgerId && !isDetail" @click="clearLedger">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
</BasicForm>
|
||||
<a-divider orientation="left">点检项目明细</a-divider>
|
||||
<JVxeTable
|
||||
v-if="tableReady"
|
||||
ref="lineTableRef"
|
||||
toolbar
|
||||
row-number
|
||||
rowSelection
|
||||
keep-source
|
||||
:insert-row="false"
|
||||
:max-height="380"
|
||||
:loading="lineLoading"
|
||||
:columns="lineJVxeColumns"
|
||||
:dataSource="lineDataSource"
|
||||
:disabled="!showFooterFlag"
|
||||
:toolbar-config="{ btn: ['remove'], slots: ['suffix'] }"
|
||||
:add-btn-cfg="{ enabled: false }"
|
||||
>
|
||||
<template #toolbarSuffix>
|
||||
<a-button
|
||||
v-if="showFooterFlag"
|
||||
type="primary"
|
||||
preIcon="ant-design:plus-outlined"
|
||||
@click="openBatchItemSelect"
|
||||
>
|
||||
选择点检及保养项目
|
||||
</a-button>
|
||||
</template>
|
||||
</JVxeTable>
|
||||
<MesXslEquipmentLedgerSelectModal @register="registerLedgerModal" @select="onLedgerSelect" />
|
||||
<MesXslInspectMaintainItemSelectModal @register="registerItemModal" @select="onItemsSelect" />
|
||||
</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 { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { formSchema, lineJVxeColumns } from '../MesXslEquipInspectConfig.data';
|
||||
import { saveOrUpdate, queryById, queryLineListByConfigId } from '../MesXslEquipInspectConfig.api';
|
||||
import MesXslEquipmentLedgerSelectModal from './MesXslEquipmentLedgerSelectModal.vue';
|
||||
import MesXslInspectMaintainItemSelectModal from './MesXslInspectMaintainItemSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const { createMessage } = useMessage();
|
||||
const isUpdate = ref(false);
|
||||
const isDetail = 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 [registerLedgerModal, { openModal: openLedgerModal }] = useModal();
|
||||
const [registerItemModal, { openModal: openItemModal }] = 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;
|
||||
isDetail.value = !data?.showFooter;
|
||||
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 queryLineListByConfigId({ 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(() =>
|
||||
!unref(isUpdate) ? '新增设备点检配置' : unref(isDetail) ? '设备点检配置详情' : '编辑设备点检配置',
|
||||
);
|
||||
|
||||
function itemToLineRow(item: Recordable) {
|
||||
return {
|
||||
inspectMaintainItemId: item.id,
|
||||
itemCode: item.itemCode,
|
||||
itemName: item.itemName,
|
||||
itemCategory: item.itemCategory,
|
||||
itemType: item.itemType,
|
||||
equipmentPartName: item.equipmentPartName,
|
||||
equipmentSubPartName: item.equipmentSubPartName,
|
||||
inspectMethod: item.inspectMethod,
|
||||
judgmentCriteria: item.judgmentCriteria,
|
||||
};
|
||||
}
|
||||
|
||||
function getExistingItemIds(): Set<string> {
|
||||
const lineRef = lineTableRef.value as any;
|
||||
const tableData = (lineRef?.getTableData?.() || lineDataSource.value || []) as Recordable[];
|
||||
const ids = new Set<string>();
|
||||
for (const r of tableData) {
|
||||
if (r?.inspectMaintainItemId) {
|
||||
ids.add(String(r.inspectMaintainItemId));
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
function openLedgerSelect() {
|
||||
const vals = getFieldsValue();
|
||||
openLedgerModal(true, { equipmentLedgerId: vals.equipmentLedgerId });
|
||||
}
|
||||
|
||||
function clearLedger() {
|
||||
setFieldsValue({ equipmentLedgerId: '', equipmentName: '', equipmentCode: '' });
|
||||
}
|
||||
|
||||
function onLedgerSelect(payload: { equipmentLedgerId?: string; equipmentName?: string; equipmentCode?: string }) {
|
||||
setFieldsValue({
|
||||
equipmentLedgerId: payload.equipmentLedgerId || '',
|
||||
equipmentName: payload.equipmentName || '',
|
||||
equipmentCode: payload.equipmentCode || '',
|
||||
});
|
||||
}
|
||||
|
||||
function openBatchItemSelect() {
|
||||
const configType = getFieldsValue()?.configType;
|
||||
if (!configType) {
|
||||
createMessage.warning('请先选择类型(点检/保养)');
|
||||
return;
|
||||
}
|
||||
openItemModal(true, { itemCategory: configType, multiple: true });
|
||||
}
|
||||
|
||||
function onItemsSelect(payload: Recordable | Recordable[]) {
|
||||
const items = Array.isArray(payload) ? payload : payload ? [payload] : [];
|
||||
if (!items.length) {
|
||||
return;
|
||||
}
|
||||
const existing = getExistingItemIds();
|
||||
const toAdd: Recordable[] = [];
|
||||
const skipped: string[] = [];
|
||||
for (const item of items) {
|
||||
if (!item?.id) {
|
||||
continue;
|
||||
}
|
||||
const id = String(item.id);
|
||||
if (existing.has(id)) {
|
||||
skipped.push(item.itemName || item.itemCode || id);
|
||||
continue;
|
||||
}
|
||||
existing.add(id);
|
||||
toAdd.push(itemToLineRow(item));
|
||||
}
|
||||
if (!toAdd.length) {
|
||||
if (skipped.length) {
|
||||
createMessage.warning('所选项目均已在明细中,未添加新行');
|
||||
}
|
||||
return;
|
||||
}
|
||||
const lineRef = lineTableRef.value as any;
|
||||
if (lineRef?.pushRows) {
|
||||
lineRef.pushRows(toAdd);
|
||||
} else {
|
||||
lineDataSource.value = [...lineDataSource.value, ...toAdd];
|
||||
}
|
||||
if (skipped.length) {
|
||||
createMessage.warning(`已添加 ${toAdd.length} 项,跳过 ${skipped.length} 项重复项目`);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
const lineRef = lineTableRef.value as any;
|
||||
const tableData = (lineRef?.getTableData?.() || []) as Recordable[];
|
||||
const lineList = tableData
|
||||
.filter((r) => r && r.inspectMaintainItemId)
|
||||
.map((r) => ({
|
||||
inspectMaintainItemId: r.inspectMaintainItemId,
|
||||
itemCode: r.itemCode,
|
||||
itemName: r.itemName,
|
||||
itemCategory: r.itemCategory,
|
||||
itemType: r.itemType,
|
||||
equipmentPartName: r.equipmentPartName,
|
||||
equipmentSubPartName: r.equipmentSubPartName,
|
||||
inspectMethod: r.inspectMethod,
|
||||
judgmentCriteria: r.judgmentCriteria,
|
||||
}));
|
||||
if (!lineList.length) {
|
||||
createMessage.warning('请通过「选择点检及保养项目」至少添加一条明细');
|
||||
return;
|
||||
}
|
||||
const ids = new Set<string>();
|
||||
for (const line of lineList) {
|
||||
if (ids.has(line.inspectMaintainItemId)) {
|
||||
createMessage.warning('明细中点检项目不能重复');
|
||||
return;
|
||||
}
|
||||
ids.add(line.inspectMaintainItemId);
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate({ ...values, lineList }, unref(isUpdate));
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" title="选择设备台账" :width="1000" @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, queryById } from '/@/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.api';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
}
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: list,
|
||||
columns: [
|
||||
{ title: '设备名称', dataIndex: 'equipmentName', width: 160 },
|
||||
{ title: '设备编号', dataIndex: 'equipmentCode', width: 140 },
|
||||
{ title: '设备类别', dataIndex: 'equipmentCategoryName', width: 120 },
|
||||
{ title: '设备类型', dataIndex: 'equipmentTypeName', width: 120 },
|
||||
],
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{ label: '设备名称', field: 'equipmentName', component: 'Input', colProps: { span: 8 } },
|
||||
{ label: '设备编号', field: 'equipmentCode', component: 'Input', colProps: { span: 8 } },
|
||||
],
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
onChange: handleSelectionChange,
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
const lid = data?.equipmentLedgerId as string | undefined;
|
||||
if (lid) {
|
||||
setSelectedRowKeys?.([lid]);
|
||||
try {
|
||||
const raw = await queryById({ id: lid });
|
||||
const row = (raw as any)?.id != null ? raw : (raw as any)?.result;
|
||||
if (row) {
|
||||
selectedRow.value = row;
|
||||
}
|
||||
} catch {
|
||||
// 忽略
|
||||
}
|
||||
}
|
||||
reload();
|
||||
});
|
||||
|
||||
async function handleOk() {
|
||||
const keys = (getSelectRowKeys?.() || []) as string[];
|
||||
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
|
||||
if (!row && keys.length) {
|
||||
try {
|
||||
const raw = await queryById({ id: keys[0] });
|
||||
row = (raw as any)?.id != null ? raw : (raw as any)?.result;
|
||||
} catch {
|
||||
// 忽略
|
||||
}
|
||||
}
|
||||
if (!row?.id) {
|
||||
emit('select', { equipmentLedgerId: '', equipmentName: '', equipmentCode: '' });
|
||||
closeModal();
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
equipmentLedgerId: row.id,
|
||||
equipmentName: row.equipmentName || '',
|
||||
equipmentCode: row.equipmentCode || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" :title="modalTitle" :width="1100" @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/mesXslInspectMaintainItem/MesXslInspectMaintainItem.api';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
|
||||
const multipleMode = ref(true);
|
||||
const filterItemCategory = ref('');
|
||||
const selectedRows = ref<Recordable[]>([]);
|
||||
|
||||
const modalTitle = computed(() => (multipleMode.value ? '选择点检及保养项目(可多选)' : '选择点检及保养项目'));
|
||||
|
||||
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
|
||||
selectedRows.value = rows || [];
|
||||
}
|
||||
|
||||
function fetchItemPage(params: Recordable) {
|
||||
const p = { ...params };
|
||||
if (filterItemCategory.value) {
|
||||
p.itemCategory = filterItemCategory.value;
|
||||
}
|
||||
return list(p);
|
||||
}
|
||||
|
||||
const [registerTable, { reload, getSelectRows, clearSelectedRowKeys }] = useTable({
|
||||
api: fetchItemPage,
|
||||
columns: [
|
||||
{ title: '项目编号', dataIndex: 'itemCode', width: 120 },
|
||||
{ title: '项目名称', dataIndex: 'itemName', width: 140 },
|
||||
{ title: '项目类别', dataIndex: 'itemCategory_dictText', width: 90 },
|
||||
{ title: '项目类型', dataIndex: 'itemType_dictText', width: 90 },
|
||||
{ title: '设备部位', dataIndex: 'equipmentPartName', width: 110 },
|
||||
{ title: '设备小部位', dataIndex: 'equipmentSubPartName', width: 110 },
|
||||
{ title: '点检方式', dataIndex: 'inspectMethod_dictText', width: 90 },
|
||||
{ title: '判断基准', dataIndex: 'judgmentCriteria', width: 160, ellipsis: true },
|
||||
],
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{ label: '项目编号', field: 'itemCode', component: 'Input', colProps: { span: 8 } },
|
||||
{ label: '项目名称', field: 'itemName', 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) => {
|
||||
multipleMode.value = data?.multiple !== false;
|
||||
filterItemCategory.value = data?.itemCategory ? String(data.itemCategory) : '';
|
||||
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.itemCode != null || r.itemName != null));
|
||||
if (!valid.length) {
|
||||
closeModal();
|
||||
return;
|
||||
}
|
||||
if (multipleMode.value) {
|
||||
emit('select', valid);
|
||||
} else {
|
||||
emit('select', valid[0]);
|
||||
}
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user