工序管理
This commit is contained in:
63
jeecg-boot/db/mes-process-operation-menu-permission.sql
Normal file
63
jeecg-boot/db/mes-process-operation-menu-permission.sql
Normal file
@@ -0,0 +1,63 @@
|
||||
-- MES 工序管理:建表 + 菜单 + 按钮权限 + 租户 admin 授权(可整文件一次执行)
|
||||
-- 权限前缀与 Controller、前端 v-auth 一致:mes:mes_process_operation:*
|
||||
-- 修改租户:改 SET @mes_tenant_id;仅建表可只执行下面 CREATE 段或单独文件 mes-process-operation.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_process_operation` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`operation_code` varchar(64) NOT NULL COMMENT '工序编码',
|
||||
`operation_name` varchar(128) NOT NULL COMMENT '工序名称',
|
||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
|
||||
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_mpo_operation_code` (`operation_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 ('1860000000000000060', @mes_base_pid, '工序管理', '/xslmes/mesXslProcessOperation', 'xslmes/mesXslProcessOperation/MesXslProcessOperationList', NULL, 1, NULL, '1', 9, 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
|
||||
('1860000000000000061', '1860000000000000060', '新增', 2, 'mes:mes_process_operation:add', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000062', '1860000000000000060', '编辑', 2, 'mes:mes_process_operation:edit', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000063', '1860000000000000060', '删除', 2, 'mes:mes_process_operation:delete', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000064', '1860000000000000060', '批量删除', 2, 'mes:mes_process_operation:deleteBatch', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000065', '1860000000000000060', '导出', 2, 'mes:mes_process_operation:exportXls', '1', '1', 0, 'admin', NOW()),
|
||||
('1860000000000000066', '1860000000000000060', '导入', 2, 'mes:mes_process_operation: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 (
|
||||
'1860000000000000060',
|
||||
'1860000000000000061', '1860000000000000062', '1860000000000000063', '1860000000000000064',
|
||||
'1860000000000000065', '1860000000000000066'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM `sys_role_permission` rp
|
||||
WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||
);
|
||||
18
jeecg-boot/db/mes-process-operation.sql
Normal file
18
jeecg-boot/db/mes-process-operation.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- 仅建表(与 Flyway V3.9.2_53 表结构一致)。建表+菜单+授权请执行 mes-process-operation-menu-permission.sql
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mes_process_operation` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`operation_code` varchar(64) NOT NULL COMMENT '工序编码',
|
||||
`operation_name` varchar(128) NOT NULL COMMENT '工序名称',
|
||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
|
||||
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_mpo_operation_code` (`operation_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES工序管理';
|
||||
@@ -0,0 +1,210 @@
|
||||
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.MesXslProcessOperation;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslProcessOperationService;
|
||||
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/mesXslProcessOperation")
|
||||
@Slf4j
|
||||
public class MesXslProcessOperationController extends JeecgController<MesXslProcessOperation, IMesXslProcessOperationService> {
|
||||
|
||||
@Autowired
|
||||
private IMesXslProcessOperationService mesXslProcessOperationService;
|
||||
|
||||
@Operation(summary = "MES工序管理-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslProcessOperation>> queryPageList(
|
||||
MesXslProcessOperation model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslProcessOperation> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
Page<MesXslProcessOperation> page = new Page<>(pageNo, pageSize);
|
||||
IPage<MesXslProcessOperation> pageList = mesXslProcessOperationService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-添加")
|
||||
@Operation(summary = "MES工序管理-添加")
|
||||
@RequiresPermissions("mes:mes_process_operation:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MesXslProcessOperation model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
if (oConvertUtils.isEmpty(model.getOperationCode()) || oConvertUtils.isEmpty(model.getOperationName())) {
|
||||
return Result.error("工序编码、工序名称不能为空");
|
||||
}
|
||||
String code = model.getOperationCode().trim();
|
||||
model.setOperationCode(code);
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(code, null, model)) {
|
||||
return Result.error("工序编码已存在");
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
mesXslProcessOperationService.save(model);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-编辑")
|
||||
@Operation(summary = "MES工序管理-编辑")
|
||||
@RequiresPermissions("mes:mes_process_operation:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MesXslProcessOperation model) {
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
if (oConvertUtils.isEmpty(model.getOperationCode()) || oConvertUtils.isEmpty(model.getOperationName())) {
|
||||
return Result.error("工序编码、工序名称不能为空");
|
||||
}
|
||||
String code = model.getOperationCode().trim();
|
||||
model.setOperationCode(code);
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(code, model.getId(), model)) {
|
||||
return Result.error("工序编码已存在");
|
||||
}
|
||||
//update-end---author:jiangxh ---date:20260514 for:【MES】工序编码、名称必填;同租户工序编码不可重复-----------
|
||||
mesXslProcessOperationService.updateById(model);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-删除")
|
||||
@Operation(summary = "MES工序管理-通过id删除")
|
||||
@RequiresPermissions("mes:mes_process_operation:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
mesXslProcessOperationService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES工序管理-批量删除")
|
||||
@Operation(summary = "MES工序管理-批量删除")
|
||||
@RequiresPermissions("mes:mes_process_operation:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
mesXslProcessOperationService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
@Operation(summary = "MES工序管理-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MesXslProcessOperation> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
MesXslProcessOperation entity = mesXslProcessOperationService.getById(id);
|
||||
if (entity == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "校验工序编码是否重复(仅未删除数据;同租户,dataId 为编辑时当前主键)")
|
||||
@GetMapping(value = "/checkOperationCode")
|
||||
public Result<String> checkOperationCode(
|
||||
@RequestParam(name = "operationCode", required = true) String operationCode,
|
||||
@RequestParam(name = "dataId", required = false) String dataId) {
|
||||
if (oConvertUtils.isEmpty(operationCode) || operationCode.trim().isEmpty()) {
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
MesXslProcessOperation ctx = new MesXslProcessOperation();
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(operationCode.trim(), dataId, ctx)) {
|
||||
return Result.error("该工序编码已存在");
|
||||
}
|
||||
return Result.OK("该值可用!");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_process_operation:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslProcessOperation model) {
|
||||
return super.exportXls(request, model, MesXslProcessOperation.class, "MES工序管理");
|
||||
}
|
||||
|
||||
@RequiresPermissions("mes:mes_process_operation:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
//update-begin---author:jiangxh ---date:20260514 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<MesXslProcessOperation> list = ExcelImportUtil.importExcel(file.getInputStream(), MesXslProcessOperation.class, params);
|
||||
if (list == null) {
|
||||
list = List.of();
|
||||
}
|
||||
Set<String> codesInFile = new HashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
MesXslProcessOperation row = list.get(i);
|
||||
int rowNo = i + 1;
|
||||
if (row == null) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条数据无效(空行)");
|
||||
}
|
||||
String code = row.getOperationCode();
|
||||
if (code != null) {
|
||||
code = code.trim();
|
||||
}
|
||||
if (oConvertUtils.isEmpty(code)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条工序编码不能为空");
|
||||
}
|
||||
row.setOperationCode(code);
|
||||
if (oConvertUtils.isEmpty(row.getOperationName()) || row.getOperationName().trim().isEmpty()) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条工序名称不能为空");
|
||||
}
|
||||
row.setOperationName(row.getOperationName().trim());
|
||||
if (!codesInFile.add(code)) {
|
||||
return Result.error("文件导入失败:工序编码【" + code + "】在导入文件中重复");
|
||||
}
|
||||
if (mesXslProcessOperationService.isOperationCodeDuplicated(code, null, row)) {
|
||||
return Result.error("文件导入失败:第 " + rowNo + " 条工序编码【" + code + "】已存在(未删除数据中不允许重复)");
|
||||
}
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
mesXslProcessOperationService.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:20260514 for:【MES】工序导入:文件内编码不重复,且与库中未删除数据不重复-----------
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* MES 工序管理(表 mes_process_operation)
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_process_operation")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "MES工序管理")
|
||||
public class MesXslProcessOperation implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "工序编码", width = 20)
|
||||
@Schema(description = "工序编码(同租户内唯一)")
|
||||
private String operationCode;
|
||||
|
||||
@Excel(name = "工序名称", width = 24)
|
||||
@Schema(description = "工序名称")
|
||||
private String operationName;
|
||||
|
||||
@Excel(name = "备注", width = 28)
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
private Integer tenantId;
|
||||
private String sysOrgCode;
|
||||
private String createBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
|
||||
|
||||
/**
|
||||
* MES 工序管理 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface MesXslProcessOperationMapper extends BaseMapper<MesXslProcessOperation> {}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* MES XSL 业务模块(Maven 工程名:jeecg-module-xslmes)。
|
||||
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})等。
|
||||
* 包含:客户管理({@link org.jeecg.modules.xslmes.entity.MesXslCustomer})、工序管理({@link org.jeecg.modules.xslmes.entity.MesXslProcessOperation})等。
|
||||
*/
|
||||
package org.jeecg.modules.xslmes;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProcessOperation;
|
||||
|
||||
public interface IMesXslProcessOperationService extends IService<MesXslProcessOperation> {
|
||||
|
||||
/**
|
||||
* 工序编码是否已被占用(仅统计未删除:del_flag 为 0 或 null)。租户与 MybatisInterceptor 注入逻辑一致。
|
||||
*
|
||||
* @param operationCode 工序编码(已 trim 后传入)
|
||||
* @param excludeId 编辑时排除自身主键,新增传 null
|
||||
* @param context 当前提交的实体(可取 tenantId;可为 null)
|
||||
*/
|
||||
boolean isOperationCodeDuplicated(String operationCode, String excludeId, MesXslProcessOperation context);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
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.MesXslProcessOperation;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslProcessOperationMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslProcessOperationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MesXslProcessOperationServiceImpl extends ServiceImpl<MesXslProcessOperationMapper, MesXslProcessOperation>
|
||||
implements IMesXslProcessOperationService {
|
||||
|
||||
//update-begin---author:jiangxh ---date:20260514 for:【MES】工序编码同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
@Override
|
||||
public boolean isOperationCodeDuplicated(String operationCode, String excludeId, MesXslProcessOperation context) {
|
||||
if (oConvertUtils.isEmpty(operationCode)) {
|
||||
return false;
|
||||
}
|
||||
Integer tenantId = resolveTenantId(context);
|
||||
LambdaQueryWrapper<MesXslProcessOperation> w = new LambdaQueryWrapper<>();
|
||||
w.eq(MesXslProcessOperation::getOperationCode, operationCode.trim());
|
||||
// 仅与「未删除」数据判重:del_flag=0 或历史空值视为正常行,排除已删除(del_flag=1)
|
||||
w.and(
|
||||
q ->
|
||||
q.eq(MesXslProcessOperation::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.or()
|
||||
.isNull(MesXslProcessOperation::getDelFlag));
|
||||
if (oConvertUtils.isNotEmpty(excludeId)) {
|
||||
w.ne(MesXslProcessOperation::getId, excludeId);
|
||||
}
|
||||
if (tenantId != null) {
|
||||
w.eq(MesXslProcessOperation::getTenantId, tenantId);
|
||||
}
|
||||
return this.count(w) > 0;
|
||||
}
|
||||
|
||||
/** 与 MybatisInterceptor 注入 tenant_id 的取值顺序尽量一致,避免前端未传 tenantId 时查不到已存在数据 */
|
||||
private static Integer resolveTenantId(MesXslProcessOperation 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:20260514 for:【MES】工序编码同租户唯一;仅统计未删除(del_flag=0 或 null)-----------
|
||||
}
|
||||
58
jeecg-boot/jeecg-module-system/jeecg-system-biz/docs/代码修改日志
Normal file
58
jeecg-boot/jeecg-module-system/jeecg-system-biz/docs/代码修改日志
Normal file
@@ -0,0 +1,58 @@
|
||||
-- author:jiangxh---date:20260513--for: 【MES】MES基础资料下新增工序管理(mes_process_operation,与原材料检验项目同级菜单) ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_53__mes_process_operation.sql
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/entity/MesProcessOperation.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/mapper/MesProcessOperationMapper.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/IMesProcessOperationService.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/impl/MesProcessOperationServiceImpl.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/controller/MesProcessOperationController.java
|
||||
jeecg-boot/db/mes-process-operation.sql
|
||||
jeecgboot-vue3/src/views/mes/processoperation/index.vue
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperationList.vue
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperation.data.ts
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperation.api.ts
|
||||
jeecgboot-vue3/src/views/mes/material/modules/MesProcessOperationModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260513--for: 【MES】补全工序管理后端/前端/Flyway 源码文件 ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_53__mes_process_operation.sql
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/entity/MesProcessOperation.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/mapper/MesProcessOperationMapper.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/IMesProcessOperationService.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/impl/MesProcessOperationServiceImpl.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/controller/MesProcessOperationController.java
|
||||
jeecg-boot/db/mes-process-operation.sql
|
||||
jeecgboot-vue3/src/views/mes/processoperation/index.vue
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperationList.vue
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperation.data.ts
|
||||
jeecgboot-vue3/src/views/mes/material/MesProcessOperation.api.ts
|
||||
jeecgboot-vue3/src/views/mes/material/modules/MesProcessOperationModal.vue
|
||||
|
||||
-- author:jiangxh---date:20260513--for: 【MES】工序管理-工序编码同租户下不可重复 ---
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/IMesProcessOperationService.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/service/impl/MesProcessOperationServiceImpl.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/mes/material/controller/MesProcessOperationController.java
|
||||
|
||||
-- author:jiangxh---date:20260514--for: 【MES】工序管理迁至 jeecg-module-xslmes,前端 xslmes/mesXslProcessOperation,菜单挂 MES基础资料、租户1002 授权脚本,Flyway V3.9.2_54 同步路由组件 ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslProcessOperation.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslProcessOperationMapper.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslProcessOperationService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslProcessOperationServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslProcessOperationController.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/package-info.java
|
||||
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_54__mes_process_operation_menu_xslmes_mes_base.sql
|
||||
jeecg-boot/db/mes-process-operation-menu-permission.sql
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/MesXslProcessOperationList.vue
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/MesXslProcessOperation.data.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/MesXslProcessOperation.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/components/MesXslProcessOperationModal.vue
|
||||
jeecgboot-vue3/src/views/mes/processoperation/index.vue
|
||||
|
||||
-- author:jiangxh---date:20260514--for: 【MES】mes-process-operation-menu-permission.sql 增补建表段,避免只执行菜单脚本未建表 ---
|
||||
jeecg-boot/db/mes-process-operation-menu-permission.sql
|
||||
jeecg-boot/db/mes-process-operation.sql
|
||||
|
||||
-- author:jiangxh---date:20260514--for: 【MES】工序编码唯一:排除已删除、表单异步校验接口、Excel 导入校验 ---
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslProcessOperationServiceImpl.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslProcessOperationService.java
|
||||
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslProcessOperationController.java
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/MesXslProcessOperation.api.ts
|
||||
jeecgboot-vue3/src/views/xslmes/mesXslProcessOperation/MesXslProcessOperation.data.ts
|
||||
@@ -0,0 +1,23 @@
|
||||
-- MES 工序管理:将菜单挂到「MES基础资料」下,url/component 对齐 xslmes 前端(与客户管理同目录风格)
|
||||
-- 依赖:V3.9.2_53 已创建 mes_process_operation 表及 sys_permission id 1860000000000000060~066
|
||||
|
||||
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基础资料', 'MES资料')),
|
||||
'1860000000000000001'
|
||||
) AS `pid`
|
||||
FROM DUAL
|
||||
) x ON 1 = 1
|
||||
SET p.`parent_id` = x.`pid`,
|
||||
p.`url` = '/xslmes/mesXslProcessOperation',
|
||||
p.`component` = 'xslmes/mesXslProcessOperation/MesXslProcessOperationList',
|
||||
p.`component_name` = NULL,
|
||||
p.`is_leaf` = 0,
|
||||
p.`update_by` = 'admin',
|
||||
p.`update_time` = NOW()
|
||||
WHERE p.`id` = '1860000000000000060';
|
||||
|
||||
UPDATE `sys_permission` SET `name` = '新增' WHERE `id` = '1860000000000000061' AND `name` = '添加';
|
||||
10
jeecgboot-vue3/src/views/mes/processoperation/index.vue
Normal file
10
jeecgboot-vue3/src/views/mes/processoperation/index.vue
Normal file
@@ -0,0 +1,10 @@
|
||||
<template>
|
||||
<MesXslProcessOperationList />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 兼容旧菜单 component:mes/processoperation/index(V3.9.2_53 历史配置),实际页面在 xslmes。
|
||||
*/
|
||||
import MesXslProcessOperationList from '/@/views/xslmes/mesXslProcessOperation/MesXslProcessOperationList.vue';
|
||||
</script>
|
||||
@@ -0,0 +1,59 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslProcessOperation/list',
|
||||
checkOperationCode = '/xslmes/mesXslProcessOperation/checkOperationCode',
|
||||
save = '/xslmes/mesXslProcessOperation/add',
|
||||
edit = '/xslmes/mesXslProcessOperation/edit',
|
||||
deleteOne = '/xslmes/mesXslProcessOperation/delete',
|
||||
deleteBatch = '/xslmes/mesXslProcessOperation/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslProcessOperation/importExcel',
|
||||
exportXls = '/xslmes/mesXslProcessOperation/exportXls',
|
||||
queryById = '/xslmes/mesXslProcessOperation/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 });
|
||||
|
||||
/** 工序编码唯一性校验(仅未删除数据;同租户;编辑传 dataId) */
|
||||
export const checkOperationCode = (params: { operationCode: string; dataId?: string }) =>
|
||||
defHttp.get(
|
||||
{ url: Api.checkOperationCode, 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,66 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { checkOperationCode } from './MesXslProcessOperation.api';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '工序编码', align: 'center', dataIndex: 'operationCode', width: 140 },
|
||||
{ title: '工序名称', align: 'center', dataIndex: 'operationName', width: 180 },
|
||||
{ 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: '修改人', align: 'center', dataIndex: 'updateBy', width: 100 },
|
||||
{
|
||||
title: '修改时间',
|
||||
align: 'center',
|
||||
dataIndex: 'updateTime',
|
||||
width: 165,
|
||||
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
|
||||
},
|
||||
{ title: '备注', align: 'center', dataIndex: 'remark', width: 200, ellipsis: true },
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{ label: '工序编码', field: 'operationCode', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '工序名称', field: 'operationName', component: 'Input', colProps: { span: 6 } },
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{
|
||||
label: '工序编码',
|
||||
field: 'operationCode',
|
||||
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 checkOperationCode({ operationCode: 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: 'operationName',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
componentProps: { placeholder: '请输入工序名称' },
|
||||
},
|
||||
{ label: '备注', field: 'remark', component: 'InputTextArea', componentProps: { rows: 3 } },
|
||||
];
|
||||
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="'mes:mes_process_operation:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_process_operation:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<j-upload-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_process_operation: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_process_operation: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_process_operation:edit' },
|
||||
]"
|
||||
:dropDownActions="getDropDownAction(record)"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslProcessOperationModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslProcessOperation" setup>
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesXslProcessOperationModal from './components/MesXslProcessOperationModal.vue';
|
||||
import { columns, searchFormSchema } from './MesXslProcessOperation.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslProcessOperation.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_process_operation:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<BasicModal @register="registerModal" :title="title" width="50%" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { formSchema } from '../MesXslProcessOperation.data';
|
||||
import { saveOrUpdate } from '../MesXslProcessOperation.api';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(true);
|
||||
const isDetail = ref(false);
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
|
||||
labelWidth: 120,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
isDetail.value = !data?.showFooter;
|
||||
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
});
|
||||
|
||||
const title = computed(() =>
|
||||
!unref(isUpdate) ? '新增工序' : unref(isDetail) ? '工序详情' : '编辑工序',
|
||||
);
|
||||
|
||||
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