设备小部位新增
This commit is contained in:
69
jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql
Normal file
69
jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql
Normal file
@@ -0,0 +1,69 @@
|
||||
-- MES 设备小部位:建表 + 菜单 + 按钮权限 + 租户 admin 授权(可整文件一次执行)
|
||||
-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_xsl_equipment_sub_part:*
|
||||
-- 依赖:mes_xsl_equipment_category、mes_xsl_equipment_part;二级菜单父级为「MES XSL / XSLMES管理」(sys_permission.id 1900000000000000300 或按名称解析)
|
||||
-- 修改租户改 SET @mes_tenant_id;已跑过 Flyway 的旧库可另执行 V3.9.2_60 仅改 parent_id
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_sub_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`equipment_part_id` varchar(32) NOT NULL COMMENT '所属设备大部位主键 mes_xsl_equipment_part.id',
|
||||
`equipment_part_name` varchar(128) DEFAULT NULL COMMENT '设备大部位名称冗余(mes_xsl_equipment_part.part_name)',
|
||||
`sub_part_name` varchar(128) NOT NULL COMMENT '小部位名称',
|
||||
`sub_part_code` varchar(64) NOT NULL COMMENT '小部位代码(同租户未删除数据中唯一)',
|
||||
`sub_part_description` varchar(500) DEFAULT NULL COMMENT '部位描述',
|
||||
`enable_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用(字典xslmes_unit_status:0启用1停用)',
|
||||
`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_mesp_tenant_subcode` (`tenant_id`, `sub_part_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备小部位';
|
||||
|
||||
SET @mes_tenant_id = 1002;
|
||||
|
||||
SET @xslmes_root_pid = (
|
||||
SELECT MIN(`id`) FROM `sys_permission`
|
||||
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES XSL', 'XSLMES管理', 'XSLMES')
|
||||
);
|
||||
SET @xslmes_root_pid = IFNULL(@xslmes_root_pid, '1900000000000000300');
|
||||
|
||||
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 ('1860000000000000091', @xslmes_root_pid, '设备小部位', '/xslmes/mesXslEquipmentSubPart', 'xslmes/mesXslEquipmentSubPart/MesXslEquipmentSubPartList', NULL, 1, NULL, '1', 14, 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`);
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||
('1860000000000000092', '1860000000000000091', '新增', 2, 'mes:mes_xsl_equipment_sub_part:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000093', '1860000000000000091', '编辑', 2, 'mes:mes_xsl_equipment_sub_part:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000094', '1860000000000000091', '删除', 2, 'mes:mes_xsl_equipment_sub_part:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000095', '1860000000000000091', '批量删除', 2, 'mes:mes_xsl_equipment_sub_part:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000096', '1860000000000000091', '导出', 2, 'mes:mes_xsl_equipment_sub_part:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000097', '1860000000000000091', '导入', 2, 'mes:mes_xsl_equipment_sub_part: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 (
|
||||
'1860000000000000091',
|
||||
'1860000000000000092', '1860000000000000093', '1860000000000000094', '1860000000000000095',
|
||||
'1860000000000000096', '1860000000000000097'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
24
jeecg-boot/db/mes-xsl-equipment-sub-part.sql
Normal file
24
jeecg-boot/db/mes-xsl-equipment-sub-part.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- 仅建表:MES 设备小部位 mes_xsl_equipment_sub_part
|
||||
-- 完整初始化(建表 + 菜单 + 租户授权)请执行 mes-xsl-equipment-sub-part-menu-permission.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_sub_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`equipment_part_id` varchar(32) NOT NULL COMMENT '所属设备大部位主键 mes_xsl_equipment_part.id',
|
||||
`equipment_part_name` varchar(128) DEFAULT NULL COMMENT '设备大部位名称冗余(mes_xsl_equipment_part.part_name)',
|
||||
`sub_part_name` varchar(128) NOT NULL COMMENT '小部位名称',
|
||||
`sub_part_code` varchar(64) NOT NULL COMMENT '小部位代码(同租户未删除数据中唯一)',
|
||||
`sub_part_description` varchar(500) DEFAULT NULL COMMENT '部位描述',
|
||||
`enable_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用(字典xslmes_unit_status:0启用1停用)',
|
||||
`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_mesp_tenant_subcode` (`tenant_id`, `sub_part_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备小部位';
|
||||
@@ -0,0 +1,325 @@
|
||||
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.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentCategory;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentPart;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentCategoryService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentPartService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentSubPartService;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* MES 设备小部位
|
||||
*/
|
||||
@Tag(name = "MES设备小部位")
|
||||
@RestController
|
||||
@RequestMapping("/xslmes/mesXslEquipmentSubPart")
|
||||
@Slf4j
|
||||
public class MesXslEquipmentSubPartController extends JeecgController<MesXslEquipmentSubPart, IMesXslEquipmentSubPartService> {
|
||||
|
||||
private static final Set<String> ENABLE_STATUS = Set.of("0", "1");
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentSubPartService mesXslEquipmentSubPartService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentCategoryService mesXslEquipmentCategoryService;
|
||||
|
||||
@Autowired
|
||||
private IMesXslEquipmentPartService mesXslEquipmentPartService;
|
||||
|
||||
@Operation(summary = "MES设备小部位-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslEquipmentSubPart>> queryPageList(
|
||||
MesXslEquipmentSubPart model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslEquipmentSubPart> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslEquipmentSubPart> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslEquipmentSubPart> pageList = mesXslEquipmentSubPartService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-添加")
|
||||
@Operation(summary = "MES设备小部位-添加")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslEquipmentSubPart model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验:类别/大部位一致、小部位代码唯一、冗余名称-----------
|
||||
String err = validateForSave(model, null);
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验:类别/大部位一致、小部位代码唯一、冗余名称-----------
|
||||
mesXslEquipmentSubPartService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-编辑")
|
||||
@Operation(summary = "MES设备小部位-编辑")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslEquipmentSubPart model) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验:类别/大部位一致、小部位代码唯一、冗余名称-----------
|
||||
String err = validateForSave(model, model.getId());
|
||||
if (err != null) {
|
||||
return Result.error(err);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验:类别/大部位一致、小部位代码唯一、冗余名称-----------
|
||||
mesXslEquipmentSubPartService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-删除")
|
||||
@Operation(summary = "MES设备小部位-通过id删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslEquipmentSubPartService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES设备小部位-批量删除")
|
||||
@Operation(summary = "MES设备小部位-批量删除")
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslEquipmentSubPartService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES设备小部位-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslEquipmentSubPart> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslEquipmentSubPart entity = mesXslEquipmentSubPartService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验小部位代码是否重复(同租户未删除数据;dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkSubPartCode")
|
||||
public Result<String> checkSubPartCode(
|
||||
@RequestParam(name = "subPartCode", required = true) String subPartCode,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(subPartCode) || subPartCode.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslEquipmentSubPart ctx = new MesXslEquipmentSubPart();
|
||||
if (mesXslEquipmentSubPartService.isSubPartCodeDuplicated(subPartCode.trim(), dataId, ctx)) {
|
||||
return Result.error("小部位代码不能重复");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslEquipmentSubPart model) {
|
||||
return super.exportXls(request, model, MesXslEquipmentSubPart.class, "MES设备小部位");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_xsl_equipment_sub_part:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备小部位导入:小部位代码唯一、类别名称与大部位代码解析、与大部位类别一致性-----------
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> ent : fileMap.entrySet()) {
|
||||
MultipartFile file = ent.getValue();
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<MesXslEquipmentSubPart> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslEquipmentSubPart.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> codesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslEquipmentSubPart row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String sc = row.getSubPartCode();
|
||||
if (sc != null) {
|
||||
sc = sc.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(sc)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条小部位代码不能为空");
|
||||
}
|
||||
row.setSubPartCode(sc);
|
||||
String catName = row.getImportCategoryName();
|
||||
if (catName != null) {
|
||||
catName = catName.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(catName)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条设备类别名称不能为空");
|
||||
}
|
||||
MesXslEquipmentCategory cat =
|
||||
mesXslEquipmentCategoryService.findOneActiveByNameAndTenant(catName, row.getTenantId());
|
||||
if (cat == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条设备类别名称【" + catName + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
row.setEquipmentCategoryId(cat.getId());
|
||||
row.setEquipmentCategoryName(cat.getCategoryName());
|
||||
|
||||
String ipc = row.getImportEquipmentPartCode();
|
||||
if (ipc != null) {
|
||||
ipc = ipc.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(ipc)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条大部位代码不能为空");
|
||||
}
|
||||
MesXslEquipmentPart part =
|
||||
mesXslEquipmentPartService.findOneActiveByPartCodeAndTenant(ipc, row.getTenantId());
|
||||
if (part == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条大部位代码【" + ipc + "】不存在或未删除数据中无匹配");
|
||||
}
|
||||
if (!cat.getId().equals(part.getEquipmentCategoryId())) {
|
||||
return Result.error(
|
||||
"文件导入失败:第 " + rowNo + " 条设备类别名称与所选大部位不匹配(大部位所属类别须与类别名称一致)");
|
||||
}
|
||||
row.setEquipmentPartId(part.getId());
|
||||
row.setEquipmentPartName(part.getPartName());
|
||||
row.setImportCategoryName(null);
|
||||
row.setImportEquipmentPartCode(null);
|
||||
|
||||
if (oConvertUtils.isEmpty(row.getSubPartName()) || row.getSubPartName().trim().isEmpty()) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条小部位名称不能为空");
|
||||
}
|
||||
row.setSubPartName(row.getSubPartName().trim());
|
||||
|
||||
if (!codesInFile.add(sc)) {
|
||||
return Result.error("文件导入失败:小部位代码【" + sc + "】在导入文件中重复(小部位代码不能重复)");
|
||||
}
|
||||
if (mesXslEquipmentSubPartService.isSubPartCodeDuplicated(sc, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条小部位代码【" + sc + "】不能重复(同租户未删除数据中已存在)");
|
||||
}
|
||||
|
||||
if (row.getSubPartDescription() != null) {
|
||||
row.setSubPartDescription(row.getSubPartDescription().trim());
|
||||
}
|
||||
|
||||
String en = row.getEnableStatus();
|
||||
if (en != null) {
|
||||
en = en.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(en)) {
|
||||
en = "0";
|
||||
}
|
||||
if (!ENABLE_STATUS.contains(en)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条是否启用须为字典项值 0 或 1(xslmes_unit_status)");
|
||||
}
|
||||
row.setEnableStatus(en);
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslEquipmentSubPartService.saveBatch(list);
|
||||
log.info("设备小部位Excel导入完成,耗时{}ms,行数={}", System.currentTimeMillis() - start, list.size());
|
||||
return Result.ok("文件导入成功!数据行数:" + list.size());
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
log.error(msg, e);
|
||||
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
|
||||
return Result.error("文件导入失败: 存在重复数据(小部位代码不能重复)");
|
||||
}
|
||||
return Result.error("文件导入失败:" + e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备小部位导入:小部位代码唯一、类别名称与大部位代码解析、与大部位类别一致性-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验与冗余名称回填-----------
|
||||
private String validateForSave(MesXslEquipmentSubPart model, String excludeId) {
|
||||
if (oConvertUtils.isEmpty(model.getEquipmentCategoryId())) {
|
||||
return "请选择所属设备类别";
|
||||
}
|
||||
MesXslEquipmentCategory cat = mesXslEquipmentCategoryService.getById(model.getEquipmentCategoryId());
|
||||
if (cat == null) {
|
||||
return "所属设备类别不存在";
|
||||
}
|
||||
model.setEquipmentCategoryName(cat.getCategoryName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getEquipmentPartId())) {
|
||||
return "请选择所属设备大部位";
|
||||
}
|
||||
MesXslEquipmentPart part = mesXslEquipmentPartService.getById(model.getEquipmentPartId());
|
||||
if (part == null) {
|
||||
return "所属设备大部位不存在";
|
||||
}
|
||||
if (!model.getEquipmentCategoryId().equals(part.getEquipmentCategoryId())) {
|
||||
return "所属设备类别与所选设备大部位不匹配";
|
||||
}
|
||||
model.setEquipmentPartName(part.getPartName());
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getSubPartCode()) || model.getSubPartCode().trim().isEmpty()) {
|
||||
return "小部位代码不能为空";
|
||||
}
|
||||
String sc = model.getSubPartCode().trim();
|
||||
model.setSubPartCode(sc);
|
||||
if (mesXslEquipmentSubPartService.isSubPartCodeDuplicated(sc, excludeId, model)) {
|
||||
return "小部位代码不能重复";
|
||||
}
|
||||
|
||||
if (oConvertUtils.isEmpty(model.getSubPartName()) || model.getSubPartName().trim().isEmpty()) {
|
||||
return "小部位名称不能为空";
|
||||
}
|
||||
model.setSubPartName(model.getSubPartName().trim());
|
||||
|
||||
String en = model.getEnableStatus();
|
||||
if (en != null) {
|
||||
en = en.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(en)) {
|
||||
en = "0";
|
||||
}
|
||||
if (!ENABLE_STATUS.contains(en)) {
|
||||
return "是否启用不合法(须为字典项值 0 或 1,xslmes_unit_status)";
|
||||
}
|
||||
model.setEnableStatus(en);
|
||||
|
||||
if (model.getSubPartDescription() != null) {
|
||||
model.setSubPartDescription(model.getSubPartDescription().trim());
|
||||
}
|
||||
model.setImportCategoryName(null);
|
||||
model.setImportEquipmentPartCode(null);
|
||||
return null;
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备小部位保存前校验与冗余名称回填-----------
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
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 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_equipment_sub_part)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_equipment_sub_part")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES设备小部位")
|
||||
public class MesXslEquipmentSubPart implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "所属设备类别主键")
|
||||
private String equipmentCategoryId;
|
||||
|
||||
@Excel(name = "类别名称", width = 22)
|
||||
@Schema(description = "设备类别名称冗余展示")
|
||||
private String equipmentCategoryName;
|
||||
|
||||
@Schema(description = "所属设备大部位主键 mes_xsl_equipment_part.id")
|
||||
private String equipmentPartId;
|
||||
|
||||
@Excel(name = "大部位名称", width = 20)
|
||||
@Schema(description = "设备大部位名称冗余")
|
||||
private String equipmentPartName;
|
||||
|
||||
@Excel(name = "小部位名称", width = 20)
|
||||
@Schema(description = "小部位名称")
|
||||
private String subPartName;
|
||||
|
||||
@Excel(name = "小部位代码", width = 16)
|
||||
@Schema(description = "小部位代码(同租户未删除数据中唯一)")
|
||||
private String subPartCode;
|
||||
|
||||
@Excel(name = "部位描述", width = 28)
|
||||
@Schema(description = "部位描述")
|
||||
private String subPartDescription;
|
||||
|
||||
@Excel(name = "是否启用", width = 12, dicCode = "xslmes_unit_status")
|
||||
@Dict(dicCode = "xslmes_unit_status")
|
||||
@Schema(description = "是否启用(字典xslmes_unit_status:0启用1停用)")
|
||||
private String enableStatus;
|
||||
|
||||
/** Excel 导入用:设备类别名称,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "设备类别名称", width = 22)
|
||||
@Schema(description = "导入用设备类别名称")
|
||||
private String importCategoryName;
|
||||
|
||||
/** Excel 导入用:大部位代码 mes_xsl_equipment_part.part_code,不落库 */
|
||||
@TableField(exist = false)
|
||||
@Excel(name = "大部位代码", width = 16)
|
||||
@Schema(description = "导入用设备大部位代码")
|
||||
private String importEquipmentPartCode;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart;
|
||||
|
||||
public interface MesXslEquipmentSubPartMapper extends BaseMapper<MesXslEquipmentSubPart> {}
|
||||
@@ -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.MesXslEquipmentPart})等。
|
||||
* 包含:客户管理({@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.MesXslEquipmentPart})、设备小部位({@link org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart})等。
|
||||
*/
|
||||
package org.jeecg.modules.xslmes;
|
||||
|
||||
@@ -5,6 +5,14 @@ import org.jeecg.modules.xslmes.entity.MesXslEquipmentPart;
|
||||
|
||||
public interface IMesXslEquipmentPartService extends IService<MesXslEquipmentPart> {
|
||||
|
||||
/**
|
||||
* 按部位代码在指定租户下查找一条未删除记录(用于设备小部位导入解析等)。
|
||||
*
|
||||
* @param partCode 部位代码(已 trim)
|
||||
* @param tenantId 租户 ID,可为 null(不按租户过滤)
|
||||
*/
|
||||
MesXslEquipmentPart findOneActiveByPartCodeAndTenant(String partCode, Integer tenantId);
|
||||
|
||||
/**
|
||||
* 部位代码是否已被占用:同租户下未删除数据中部位代码不可重复。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentSubPart;
|
||||
|
||||
public interface IMesXslEquipmentSubPartService extends IService<MesXslEquipmentSubPart> {
|
||||
|
||||
/**
|
||||
* 小部位代码是否已被占用:同租户下未删除数据中小部位代码不可重复。
|
||||
*
|
||||
* @param subPartCode 小部位代码(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isSubPartCodeDuplicated(String subPartCode, String excludeId, MesXslEquipmentSubPart context);
|
||||
}
|
||||
@@ -60,4 +60,25 @@ public class MesXslEquipmentPartServiceImpl extends ServiceImpl<MesXslEquipmentP
|
||||
}
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备部位代码同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备部位按代码+租户查询单条,供设备小部位导入解析大部位-----------
|
||||
@Override
|
||||
public MesXslEquipmentPart findOneActiveByPartCodeAndTenant(String partCode, Integer tenantId) {
|
||||
if (oConvertUtils.isEmpty(partCode)) {
|
||||
return null;
|
||||
}
|
||||
LambdaQueryWrapper<MesXslEquipmentPart> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentPart::getPartCode, partCode.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentPart::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentPart::getDelFlag));
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentPart::getTenantId, tenantId);
|
||||
}
|
||||
w.last("LIMIT 1");
|
||||
return this.getOne(w, false);
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260515 for:【MES】设备部位按代码+租户查询单条,供设备小部位导入解析大部位-----------
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.MesXslEquipmentSubPart;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslEquipmentSubPartMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslEquipmentSubPartService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslEquipmentSubPartServiceImpl extends ServiceImpl<MesXslEquipmentSubPartMapper, MesXslEquipmentSubPart>
|
||||
implements IMesXslEquipmentSubPartService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260515 for:【MES】设备小部位代码同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isSubPartCodeDuplicated(String subPartCode, String excludeId, MesXslEquipmentSubPart context) {
|
||||
if (oConvertUtils.isEmpty(subPartCode)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslEquipmentSubPart> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslEquipmentSubPart::getSubPartCode, subPartCode.trim());
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslEquipmentSubPart::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslEquipmentSubPart::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslEquipmentSubPart::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslEquipmentSubPart::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
private static Integer resolveTenantId(MesXslEquipmentSubPart 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:20260515 for:【MES】设备小部位代码同租户不可重复;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
@@ -124,3 +124,25 @@ jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/
|
||||
jeecg-boot/db/mes-xsl-equipment-part.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-part-menu-permission.sql
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentPart/MesXslEquipmentPart.data.ts
|
||||
|
||||
-- author:jiangxh---date:20260515--for: 【MES】新增设备小部位(mes_xsl_equipment_sub_part,挂 MES 基础资料,类别/大部位冗余、小部位代码同租户唯一) ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_59__mes_xsl_equipment_sub_part.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-sub-part.sql
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslEquipmentSubPart.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslEquipmentSubPartMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentSubPartService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentSubPartServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslEquipmentSubPartController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslEquipmentPartService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslEquipmentPartServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentSubPart/MesXslEquipmentSubPartList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentSubPart/MesXslEquipmentSubPart.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentSubPart/MesXslEquipmentSubPart.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentSubPart/components/MesXslEquipmentSubPartModal.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslEquipmentSubPart/components/MesXslEquipmentPartSelectModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260515--for: 【MES】设备小部位菜单挂到 MES XSL(XSLMES管理)父级下 ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_60__mes_xsl_equipment_sub_part_menu_xslmes_root.sql
|
||||
jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
-- MES 设备小部位:建表 + 菜单 + 按钮 + 租户 admin 授权(与 jeecg-boot/db/mes-xsl-equipment-sub-part-menu-permission.sql 建表与菜单段一致)
|
||||
-- 权限前缀:mes:mes_xsl_equipment_sub_part:*(与 Controller、前端 v-auth 一致)
|
||||
-- 依赖:mes_xsl_equipment_category、mes_xsl_equipment_part;父菜单「MES基础资料」或「MES资料」
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_equipment_sub_part` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`equipment_category_id` varchar(32) NOT NULL COMMENT '所属设备类别主键 mes_xsl_equipment_category.id',
|
||||
`equipment_category_name` varchar(128) DEFAULT NULL COMMENT '设备类别名称冗余展示',
|
||||
`equipment_part_id` varchar(32) NOT NULL COMMENT '所属设备大部位主键 mes_xsl_equipment_part.id',
|
||||
`equipment_part_name` varchar(128) DEFAULT NULL COMMENT '设备大部位名称冗余(mes_xsl_equipment_part.part_name)',
|
||||
`sub_part_name` varchar(128) NOT NULL COMMENT '小部位名称',
|
||||
`sub_part_code` varchar(64) NOT NULL COMMENT '小部位代码(同租户未删除数据中唯一)',
|
||||
`sub_part_description` varchar(500) DEFAULT NULL COMMENT '部位描述',
|
||||
`enable_status` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否启用(字典xslmes_unit_status:0启用1停用)',
|
||||
`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_mesp_tenant_subcode` (`tenant_id`, `sub_part_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES设备小部位';
|
||||
|
||||
SET @mes_tenant_id = 1002;
|
||||
|
||||
SET @mes_base_pid = (
|
||||
SELECT MIN(`id`) FROM `sys_permission`
|
||||
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` IN ('MES基础资料', 'MES资料')
|
||||
);
|
||||
SET @mes_base_pid = IFNULL(@mes_base_pid, '1860000000000000001');
|
||||
|
||||
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 ('1860000000000000091', @mes_base_pid, '设备小部位', '/xslmes/mesXslEquipmentSubPart', 'xslmes/mesXslEquipmentSubPart/MesXslEquipmentSubPartList', NULL, 1, NULL, '1', 13, 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`);
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||
('1860000000000000092', '1860000000000000091', '新增', 2, 'mes:mes_xsl_equipment_sub_part:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000093', '1860000000000000091', '编辑', 2, 'mes:mes_xsl_equipment_sub_part:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000094', '1860000000000000091', '删除', 2, 'mes:mes_xsl_equipment_sub_part:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000095', '1860000000000000091', '批量删除', 2, 'mes:mes_xsl_equipment_sub_part:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000096', '1860000000000000091', '导出', 2, 'mes:mes_xsl_equipment_sub_part:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000097', '1860000000000000091', '导入', 2, 'mes:mes_xsl_equipment_sub_part: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 (
|
||||
'1860000000000000091',
|
||||
'1860000000000000092', '1860000000000000093', '1860000000000000094', '1860000000000000095',
|
||||
'1860000000000000096', '1860000000000000097'
|
||||
)
|
||||
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,18 @@
|
||||
-- MES 设备小部位:将二级菜单从「MES基础资料」挪到「MES XSL / XSLMES管理」根菜单下
|
||||
-- 依赖:V3.9.2_59 已写入 sys_permission id 1860000000000000091
|
||||
|
||||
UPDATE `sys_permission` p
|
||||
INNER JOIN (
|
||||
SELECT COALESCE(
|
||||
(SELECT MIN(s2.`id`) FROM `sys_permission` s2
|
||||
WHERE s2.`del_flag` = 0 AND s2.`menu_type` = 0
|
||||
AND s2.`name` IN ('MES XSL', 'XSLMES管理', 'XSLMES')),
|
||||
'1900000000000000300'
|
||||
) AS `pid`
|
||||
FROM DUAL
|
||||
) x ON 1 = 1
|
||||
SET p.`parent_id` = x.`pid`,
|
||||
p.`sort_no` = 14.00,
|
||||
p.`update_by` = 'admin',
|
||||
p.`update_time` = NOW()
|
||||
WHERE p.`id` = '1860000000000000091';
|
||||
@@ -0,0 +1,58 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslEquipmentSubPart/list',
|
||||
checkSubPartCode = '/xslmes/mesXslEquipmentSubPart/checkSubPartCode',
|
||||
save = '/xslmes/mesXslEquipmentSubPart/add',
|
||||
edit = '/xslmes/mesXslEquipmentSubPart/edit',
|
||||
deleteOne = '/xslmes/mesXslEquipmentSubPart/delete',
|
||||
deleteBatch = '/xslmes/mesXslEquipmentSubPart/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslEquipmentSubPart/importExcel',
|
||||
exportXls = '/xslmes/mesXslEquipmentSubPart/exportXls',
|
||||
queryById = '/xslmes/mesXslEquipmentSubPart/queryById',
|
||||
}
|
||||
|
||||
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 checkSubPartCode = (params: { subPartCode: string; dataId?: string }) =>
|
||||
defHttp.get(
|
||||
{ url: Api.checkSubPartCode, 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 });
|
||||
};
|
||||
@@ -0,0 +1,110 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { checkSubPartCode } from './MesXslEquipmentSubPart.api';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '小部位代码', align: 'center', dataIndex: 'subPartCode', width: 120 },
|
||||
{ title: '类别名称', align: 'center', dataIndex: 'equipmentCategoryName', width: 140 },
|
||||
{ title: '大部位名称', align: 'center', dataIndex: 'equipmentPartName', width: 140 },
|
||||
{ title: '小部位名称', align: 'center', dataIndex: 'subPartName', width: 140 },
|
||||
{ title: '部位描述', align: 'center', dataIndex: 'subPartDescription', width: 200, ellipsis: true },
|
||||
{ title: '是否启用', align: 'center', dataIndex: 'enableStatus_dictText', width: 100 },
|
||||
{ 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),
|
||||
},
|
||||
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{ label: '小部位代码', field: 'subPartCode', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '类别名称', field: 'equipmentCategoryName', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '大部位名称', field: 'equipmentPartName', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '小部位名称', field: 'subPartName', component: 'Input', colProps: { span: 6 } },
|
||||
{
|
||||
label: '是否启用',
|
||||
field: 'enableStatus',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_unit_status' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{
|
||||
label: '小部位代码',
|
||||
field: 'subPartCode',
|
||||
component: 'Input',
|
||||
componentProps: { placeholder: '同租户下小部位代码全局唯一(未删除数据中不可重复)' },
|
||||
dynamicRules: ({ model }) => [
|
||||
{ required: true, message: '请输入小部位代码' },
|
||||
{
|
||||
validator: async (_rule, value) => {
|
||||
const v = value == null ? '' : String(value).trim();
|
||||
if (!v) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
try {
|
||||
await checkSubPartCode({ subPartCode: v, dataId: model?.id });
|
||||
return Promise.resolve();
|
||||
} catch (e: any) {
|
||||
const msg = e?.response?.data?.message || e?.message || '小部位代码不能重复';
|
||||
return Promise.reject(msg);
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '',
|
||||
field: 'equipmentCategoryId',
|
||||
component: 'Input',
|
||||
show: false,
|
||||
dynamicRules: () => [{ required: true, message: '请选择所属设备类别' }],
|
||||
},
|
||||
{
|
||||
label: '所属类别',
|
||||
field: 'equipmentCategoryName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentCategoryPicker',
|
||||
},
|
||||
{
|
||||
label: '',
|
||||
field: 'equipmentPartId',
|
||||
component: 'Input',
|
||||
show: false,
|
||||
dynamicRules: () => [{ required: true, message: '请选择所属设备大部位' }],
|
||||
},
|
||||
{
|
||||
label: '所属大部位',
|
||||
field: 'equipmentPartName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentPartPicker',
|
||||
},
|
||||
{
|
||||
label: '小部位名称',
|
||||
field: 'subPartName',
|
||||
required: true,
|
||||
component: 'Input',
|
||||
componentProps: { placeholder: '请输入小部位名称' },
|
||||
},
|
||||
{
|
||||
label: '部位描述',
|
||||
field: 'subPartDescription',
|
||||
component: 'InputTextArea',
|
||||
componentProps: { rows: 3 },
|
||||
},
|
||||
{
|
||||
label: '是否启用',
|
||||
field: 'enableStatus',
|
||||
required: true,
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_unit_status', placeholder: '请选择' },
|
||||
defaultValue: '0',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="'mes:mes_xsl_equipment_sub_part:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equipment_sub_part:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<j-upload-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equipment_sub_part: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_equipment_sub_part: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_equipment_sub_part:edit' },
|
||||
]"
|
||||
:dropDownActions="getDropDownAction(record)"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslEquipmentSubPartModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslEquipmentSubPart" setup>
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesXslEquipmentSubPartModal from './components/MesXslEquipmentSubPartModal.vue';
|
||||
import { columns, searchFormSchema } from './MesXslEquipmentSubPart.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslEquipmentSubPart.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_equipment_sub_part:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,110 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" title="选择设备大部位" :width="960" @register="registerModal" @ok="handleOk">
|
||||
<BasicTable @register="registerTable" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicTable, useTable } from '/@/components/Table';
|
||||
import { list, queryById } from '/@/views/xslmes/mesXslEquipmentPart/MesXslEquipmentPart.api';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
const filterCategoryId = ref('');
|
||||
|
||||
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
}
|
||||
|
||||
function fetchPartPage(params: Recordable) {
|
||||
const p = { ...params };
|
||||
if (filterCategoryId.value) {
|
||||
p.equipmentCategoryId = filterCategoryId.value;
|
||||
}
|
||||
return list(p);
|
||||
}
|
||||
|
||||
const [registerTable, { reload, setProps, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] =
|
||||
useTable({
|
||||
api: fetchPartPage,
|
||||
columns: [
|
||||
{ title: '部位代码', dataIndex: 'partCode', width: 120 },
|
||||
{ title: '部位名称', dataIndex: 'partName', width: 160 },
|
||||
{ title: '类别名称', dataIndex: 'equipmentCategoryName', width: 160 },
|
||||
],
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{ label: '部位代码', field: 'partCode', component: 'Input', colProps: { span: 8 } },
|
||||
{ label: '部位名称', field: 'partName', 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) => {
|
||||
filterCategoryId.value = data?.equipmentCategoryId ? String(data.equipmentCategoryId) : '';
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setProps({
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
onChange: handleSelectionChange,
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
setModalProps({ confirmLoading: false });
|
||||
const pid = data?.equipmentPartId as string | undefined;
|
||||
if (pid) {
|
||||
setSelectedRowKeys?.([pid]);
|
||||
try {
|
||||
const raw = await queryById({ id: pid });
|
||||
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', { equipmentPartId: '', equipmentPartName: '' });
|
||||
closeModal();
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
equipmentPartId: row.id,
|
||||
equipmentPartName: row.partName || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<BasicModal @register="registerModal" :title="title" width="720" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm">
|
||||
<template #equipmentCategoryPicker="{ 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="openCategorySelect">选择类别</a-button>
|
||||
<a-button v-if="model.equipmentCategoryId && !isDetail" @click="clearCategory">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #equipmentPartPicker="{ 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="openPartSelect">选择大部位</a-button>
|
||||
<a-button v-if="model.equipmentPartId && !isDetail" @click="clearPart">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
</BasicForm>
|
||||
<MesXslEquipmentCategorySelectModal @register="registerCategoryModal" @select="onCategorySelect" />
|
||||
<MesXslEquipmentPartSelectModal @register="registerPartModal" @select="onPartSelect" />
|
||||
</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 { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { formSchema } from '../MesXslEquipmentSubPart.data';
|
||||
import { saveOrUpdate } from '../MesXslEquipmentSubPart.api';
|
||||
import MesXslEquipmentCategorySelectModal from '/@/views/xslmes/mesXslEquipmentType/components/MesXslEquipmentCategorySelectModal.vue';
|
||||
import MesXslEquipmentPartSelectModal from './MesXslEquipmentPartSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const { createMessage } = useMessage();
|
||||
const isUpdate = ref(true);
|
||||
const isDetail = ref(false);
|
||||
|
||||
const [registerCategoryModal, { openModal: openCategoryModal }] = useModal();
|
||||
const [registerPartModal, { openModal: openPartModal }] = useModal();
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
|
||||
labelWidth: 120,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
isDetail.value = !data?.showFooter;
|
||||
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
});
|
||||
|
||||
const title = computed(() =>
|
||||
!unref(isUpdate) ? '新增设备小部位' : unref(isDetail) ? '设备小部位详情' : '编辑设备小部位',
|
||||
);
|
||||
|
||||
function openCategorySelect() {
|
||||
const vals = getFieldsValue();
|
||||
openCategoryModal(true, { equipmentCategoryId: vals.equipmentCategoryId });
|
||||
}
|
||||
|
||||
function clearCategory() {
|
||||
setFieldsValue({ equipmentCategoryId: '', equipmentCategoryName: '', equipmentPartId: '', equipmentPartName: '' });
|
||||
}
|
||||
|
||||
function onCategorySelect(payload: { equipmentCategoryId?: string; equipmentCategoryName?: string }) {
|
||||
setFieldsValue({
|
||||
equipmentCategoryId: payload.equipmentCategoryId || '',
|
||||
equipmentCategoryName: payload.equipmentCategoryName || '',
|
||||
equipmentPartId: '',
|
||||
equipmentPartName: '',
|
||||
});
|
||||
}
|
||||
|
||||
function openPartSelect() {
|
||||
const vals = getFieldsValue();
|
||||
if (!vals.equipmentCategoryId) {
|
||||
createMessage.warning('请先选择所属设备类别');
|
||||
return;
|
||||
}
|
||||
openPartModal(true, {
|
||||
equipmentCategoryId: vals.equipmentCategoryId,
|
||||
equipmentPartId: vals.equipmentPartId,
|
||||
});
|
||||
}
|
||||
|
||||
function clearPart() {
|
||||
setFieldsValue({ equipmentPartId: '', equipmentPartName: '' });
|
||||
}
|
||||
|
||||
function onPartSelect(payload: { equipmentPartId?: string; equipmentPartName?: string }) {
|
||||
setFieldsValue({
|
||||
equipmentPartId: payload.equipmentPartId || '',
|
||||
equipmentPartName: payload.equipmentPartName || '',
|
||||
});
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate(values, isUpdate.value);
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user