烘胶开关添加
This commit is contained in:
5
jeecg-boot/.vscode/settings.json
vendored
5
jeecg-boot/.vscode/settings.json
vendored
@@ -33,5 +33,8 @@
|
|||||||
"jeecg-boot-platform"
|
"jeecg-boot-platform"
|
||||||
],
|
],
|
||||||
"java.debug.settings.console": "integratedTerminal",
|
"java.debug.settings.console": "integratedTerminal",
|
||||||
"java.debug.settings.vmArgs": "-Dspring.main.banner-mode=log -Dspring.banner.charset=UTF-8 -Dlogging.charset.console=GBK"
|
"java.debug.settings.vmArgs": "-Dspring.main.banner-mode=log -Dspring.banner.charset=UTF-8 -Dlogging.charset.console=GBK",
|
||||||
|
"workbench.editorAssociations": {
|
||||||
|
"**/flyway/sql/mysql/*.sql": "default"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1236,3 +1236,14 @@ jeecgboot-vue3/src/views/xslmes/mesXslDryingRoomSlot/components/MesXslDryingRoom
|
|||||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingRoomSlot/components/MesXslDryingRoomSelectModal.vue
|
jeecgboot-vue3/src/views/xslmes/mesXslDryingRoomSlot/components/MesXslDryingRoomSelectModal.vue
|
||||||
jeecgboot-vue3/src/views/xslmes/mesXslDryingRoomSlot/components/MesXslDryingCategorySelectModal.vue
|
jeecgboot-vue3/src/views/xslmes/mesXslDryingRoomSlot/components/MesXslDryingCategorySelectModal.vue
|
||||||
-- author:jiangxh---date:20260703--for: 【MES】烘胶房库位(MES密炼工程,含导出;引用保护烘胶房/烘胶分类不可删) ---
|
-- author:jiangxh---date:20260703--for: 【MES】烘胶房库位(MES密炼工程,含导出;引用保护烘胶房/烘胶分类不可删) ---
|
||||||
|
|
||||||
|
-- author:jiangxh---date:20260708--for: 【MES】烘胶流程开启(总开关+二次确认,不校验烘胶房日期) ---
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslDryingProcessSwitch.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslDryingProcessSwitchMapper.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslDryingProcessSwitchService.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslDryingProcessSwitchServiceImpl.java
|
||||||
|
jeecg-boot/jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslDryingProcessSwitchController.java
|
||||||
|
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_163__mes_xsl_drying_process_switch.sql
|
||||||
|
jeecgboot-vue3/src/views/xslmes/mesXslDryingProcessSwitch/MesXslDryingProcessSwitchPage.vue
|
||||||
|
jeecgboot-vue3/src/views/xslmes/mesXslDryingProcessSwitch/MesXslDryingProcessSwitch.api.ts
|
||||||
|
-- author:jiangxh---date:20260708--for: 【MES】烘胶流程开启(总开关+二次确认,不校验烘胶房日期) ---
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package org.jeecg.modules.xslmes.controller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
|
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.vo.LoginUser;
|
||||||
|
import org.jeecg.modules.xslmes.common.MesXslTenantUtils;
|
||||||
|
import org.jeecg.modules.xslmes.entity.MesXslDryingProcessSwitch;
|
||||||
|
import org.jeecg.modules.xslmes.service.IMesXslDryingProcessSwitchService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES 烘胶流程开启(总开关,不校验烘胶房日期)
|
||||||
|
*/
|
||||||
|
@Tag(name = "MES烘胶流程开启")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/xslmes/mesXslDryingProcessSwitch")
|
||||||
|
@Slf4j
|
||||||
|
public class MesXslDryingProcessSwitchController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesXslDryingProcessSwitchService dryingProcessSwitchService;
|
||||||
|
|
||||||
|
@Operation(summary = "获取当前租户烘胶流程开关状态")
|
||||||
|
@GetMapping(value = "/get")
|
||||||
|
public Result<MesXslDryingProcessSwitch> getCurrent(
|
||||||
|
@RequestParam(name = "tenantId", required = false) Integer tenantId) {
|
||||||
|
return Result.OK(dryingProcessSwitchService.getCurrent(MesXslTenantUtils.resolveTenantId(tenantId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoLog(value = "MES烘胶流程开启-设置开关")
|
||||||
|
@Operation(summary = "设置烘胶流程开启/关闭(0关1开)")
|
||||||
|
@RequiresPermissions("mes:mes_xsl_drying_process_switch:toggle")
|
||||||
|
@PostMapping(value = "/setEnabled")
|
||||||
|
public Result<MesXslDryingProcessSwitch> setEnabled(@RequestBody SetEnabledRequest body) {
|
||||||
|
Integer enabled = body != null ? body.getEnabled() : null;
|
||||||
|
Integer tenantId = body != null ? body.getTenantId() : null;
|
||||||
|
String operator = resolveOperator();
|
||||||
|
MesXslDryingProcessSwitch row = dryingProcessSwitchService.setEnabled(tenantId, enabled, operator);
|
||||||
|
return Result.OK(
|
||||||
|
enabled != null && enabled == 1 ? "烘胶流程已开启" : "烘胶流程已关闭",
|
||||||
|
row);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询烘胶流程是否已开启(供其他业务调用)")
|
||||||
|
@GetMapping(value = "/isEnabled")
|
||||||
|
public Result<Boolean> isEnabled(@RequestParam(name = "tenantId", required = false) Integer tenantId) {
|
||||||
|
return Result.OK(dryingProcessSwitchService.isProcessEnabled(MesXslTenantUtils.resolveTenantId(tenantId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String resolveOperator() {
|
||||||
|
try {
|
||||||
|
Object principal = SecurityUtils.getSubject().getPrincipal();
|
||||||
|
if (principal instanceof LoginUser user) {
|
||||||
|
if (user.getRealname() != null && !user.getRealname().isBlank()) {
|
||||||
|
return user.getRealname();
|
||||||
|
}
|
||||||
|
return user.getUsername();
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// 非登录上下文
|
||||||
|
}
|
||||||
|
return "system";
|
||||||
|
}
|
||||||
|
|
||||||
|
@lombok.Data
|
||||||
|
public static class SetEnabledRequest {
|
||||||
|
/** 0-关闭 1-开启 */
|
||||||
|
private Integer enabled;
|
||||||
|
private Integer tenantId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
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.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MES 烘胶流程开启(表 mes_xsl_drying_process_switch,每租户一条)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("mes_xsl_drying_process_switch")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Schema(description = "MES烘胶流程开启")
|
||||||
|
public class MesXslDryingProcessSwitch implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "租户ID")
|
||||||
|
private Integer tenantId;
|
||||||
|
|
||||||
|
/** 0-关闭 1-开启 */
|
||||||
|
@Schema(description = "烘胶流程是否开启(0关1开)")
|
||||||
|
private Integer enabled;
|
||||||
|
|
||||||
|
private String createBy;
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
private String updateBy;
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package org.jeecg.modules.xslmes.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.jeecg.modules.xslmes.entity.MesXslDryingProcessSwitch;
|
||||||
|
|
||||||
|
/** MES 烘胶流程开启 */
|
||||||
|
public interface MesXslDryingProcessSwitchMapper extends BaseMapper<MesXslDryingProcessSwitch> {}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package org.jeecg.modules.xslmes.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.modules.xslmes.entity.MesXslDryingProcessSwitch;
|
||||||
|
|
||||||
|
public interface IMesXslDryingProcessSwitchService extends IService<MesXslDryingProcessSwitch> {
|
||||||
|
|
||||||
|
/** 获取当前租户配置(无记录时返回默认关闭状态,不落库) */
|
||||||
|
MesXslDryingProcessSwitch getCurrent(Integer tenantId);
|
||||||
|
|
||||||
|
/** 设置开启/关闭(0关1开) */
|
||||||
|
MesXslDryingProcessSwitch setEnabled(Integer tenantId, Integer enabled, String operator);
|
||||||
|
|
||||||
|
/** 烘胶流程是否已开启 */
|
||||||
|
boolean isProcessEnabled(Integer tenantId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package org.jeecg.modules.xslmes.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import java.util.Date;
|
||||||
|
import org.jeecg.modules.xslmes.common.MesXslTenantUtils;
|
||||||
|
import org.jeecg.modules.xslmes.entity.MesXslDryingProcessSwitch;
|
||||||
|
import org.jeecg.modules.xslmes.mapper.MesXslDryingProcessSwitchMapper;
|
||||||
|
import org.jeecg.modules.xslmes.service.IMesXslDryingProcessSwitchService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MesXslDryingProcessSwitchServiceImpl
|
||||||
|
extends ServiceImpl<MesXslDryingProcessSwitchMapper, MesXslDryingProcessSwitch>
|
||||||
|
implements IMesXslDryingProcessSwitchService {
|
||||||
|
|
||||||
|
private static final int OFF = 0;
|
||||||
|
private static final int ON = 1;
|
||||||
|
|
||||||
|
//update-begin---author:jiangxh ---date:20260708 for:【MES】烘胶流程开启-租户级开关读写-----------
|
||||||
|
@Override
|
||||||
|
public MesXslDryingProcessSwitch getCurrent(Integer tenantId) {
|
||||||
|
Integer tid = MesXslTenantUtils.resolveTenantId(tenantId);
|
||||||
|
if (tid == null) {
|
||||||
|
tid = 0;
|
||||||
|
}
|
||||||
|
MesXslDryingProcessSwitch row = getOneByTenant(tid);
|
||||||
|
if (row != null) {
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
MesXslDryingProcessSwitch def = new MesXslDryingProcessSwitch();
|
||||||
|
def.setTenantId(tid);
|
||||||
|
def.setEnabled(OFF);
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public MesXslDryingProcessSwitch setEnabled(Integer tenantId, Integer enabled, String operator) {
|
||||||
|
if (enabled == null || (enabled != OFF && enabled != ON)) {
|
||||||
|
throw new org.jeecg.common.exception.JeecgBootException("开关状态无效,仅支持 0(关闭)或 1(开启)");
|
||||||
|
}
|
||||||
|
Integer tid = MesXslTenantUtils.resolveTenantId(tenantId);
|
||||||
|
if (tid == null) {
|
||||||
|
throw new org.jeecg.common.exception.JeecgBootException("无法识别当前租户");
|
||||||
|
}
|
||||||
|
Date now = new Date();
|
||||||
|
MesXslDryingProcessSwitch row = getOneByTenant(tid);
|
||||||
|
if (row == null) {
|
||||||
|
row = new MesXslDryingProcessSwitch();
|
||||||
|
row.setTenantId(tid);
|
||||||
|
row.setEnabled(enabled);
|
||||||
|
row.setCreateBy(operator);
|
||||||
|
row.setCreateTime(now);
|
||||||
|
row.setUpdateBy(operator);
|
||||||
|
row.setUpdateTime(now);
|
||||||
|
save(row);
|
||||||
|
} else {
|
||||||
|
row.setEnabled(enabled);
|
||||||
|
row.setUpdateBy(operator);
|
||||||
|
row.setUpdateTime(now);
|
||||||
|
updateById(row);
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isProcessEnabled(Integer tenantId) {
|
||||||
|
MesXslDryingProcessSwitch current = getCurrent(tenantId);
|
||||||
|
return current != null && current.getEnabled() != null && current.getEnabled() == ON;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MesXslDryingProcessSwitch getOneByTenant(Integer tenantId) {
|
||||||
|
if (tenantId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<MesXslDryingProcessSwitch> w = new LambdaQueryWrapper<>();
|
||||||
|
w.eq(MesXslDryingProcessSwitch::getTenantId, tenantId);
|
||||||
|
w.orderByDesc(MesXslDryingProcessSwitch::getUpdateTime);
|
||||||
|
w.last("LIMIT 1");
|
||||||
|
return getOne(w, false);
|
||||||
|
}
|
||||||
|
//update-end---author:jiangxh ---date:20260708 for:【MES】烘胶流程开启-租户级开关读写-----------
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
-- MES 烘胶流程开启:建表 + 菜单 + 按钮 + 租户 admin 授权 + 默认关闭
|
||||||
|
-- 权限前缀 mes:mes_xsl_drying_process_switch,父菜单 MES密炼工程
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `mes_xsl_drying_process_switch` (
|
||||||
|
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||||
|
`tenant_id` int NOT NULL COMMENT '租户ID',
|
||||||
|
`enabled` int NOT NULL DEFAULT '0' COMMENT '烘胶流程是否开启(0关1开)',
|
||||||
|
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_mxdps_tenant` (`tenant_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES烘胶流程开启(每租户一条)';
|
||||||
|
|
||||||
|
SET @mes_tenant_id = 1002;
|
||||||
|
|
||||||
|
INSERT INTO `mes_xsl_drying_process_switch` (`id`, `tenant_id`, `enabled`, `create_by`, `create_time`, `update_by`, `update_time`)
|
||||||
|
SELECT '1996000000000000001', @mes_tenant_id, 0, 'admin', NOW(), 'admin', NOW()
|
||||||
|
FROM DUAL
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `mes_xsl_drying_process_switch` WHERE `tenant_id` = @mes_tenant_id);
|
||||||
|
|
||||||
|
SET @mes_mixer_pid = (
|
||||||
|
SELECT MIN(`id`) FROM `sys_permission`
|
||||||
|
WHERE `del_flag` = 0 AND `menu_type` = 0 AND `name` = 'MES密炼工程'
|
||||||
|
);
|
||||||
|
SET @mes_mixer_pid = IFNULL(@mes_mixer_pid, '1900000000000000800');
|
||||||
|
|
||||||
|
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 ('1860000000000000253', @mes_mixer_pid, '烘胶流程开启', '/xslmes/mesXslDryingProcessSwitch', 'xslmes/mesXslDryingProcessSwitch/MesXslDryingProcessSwitchPage', 'MesXslDryingProcessSwitchPage', 1, NULL, '1', 21, 1, 1, 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`), `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`);
|
||||||
|
|
||||||
|
UPDATE `sys_permission` SET `icon` = 'ant-design:poweroff-outlined' WHERE `id` = '1860000000000000253' AND `del_flag` = 0;
|
||||||
|
|
||||||
|
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `status`, `del_flag`, `create_by`, `create_time`) VALUES
|
||||||
|
('1860000000000000254', '1860000000000000253', '切换开关', 2, 'mes:mes_xsl_drying_process_switch:toggle', '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 ('1860000000000000253', '1860000000000000254')
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM `sys_role_permission` rp WHERE rp.`role_id` = r.`id` AND rp.`permission_id` = p.`id`
|
||||||
|
);
|
||||||
|
|
||||||
|
UPDATE `sys_permission` SET `is_leaf` = 0 WHERE `id` = @mes_mixer_pid AND `del_flag` = 0;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
get = '/xslmes/mesXslDryingProcessSwitch/get',
|
||||||
|
setEnabled = '/xslmes/mesXslDryingProcessSwitch/setEnabled',
|
||||||
|
isEnabled = '/xslmes/mesXslDryingProcessSwitch/isEnabled',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getDryingProcessSwitch = (params?: { tenantId?: number }) =>
|
||||||
|
defHttp.get({ url: Api.get, params });
|
||||||
|
|
||||||
|
export const setDryingProcessEnabled = (params: { enabled: 0 | 1; tenantId?: number }) =>
|
||||||
|
defHttp.post({ url: Api.setEnabled, params });
|
||||||
|
|
||||||
|
export const isDryingProcessEnabled = (params?: { tenantId?: number }) =>
|
||||||
|
defHttp.get({ url: Api.isEnabled, params });
|
||||||
@@ -0,0 +1,236 @@
|
|||||||
|
<template>
|
||||||
|
<div class="drying-process-switch-page">
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<div class="switch-hero" :class="enabled ? 'is-on' : 'is-off'">
|
||||||
|
<div class="switch-hero__badge">
|
||||||
|
<Icon :icon="enabled ? 'ant-design:check-circle-filled' : 'ant-design:pause-circle-filled'" :size="56" />
|
||||||
|
</div>
|
||||||
|
<h1 class="switch-hero__title">烘胶流程开启</h1>
|
||||||
|
<div class="switch-hero__status">
|
||||||
|
<span class="status-pill" :class="enabled ? 'status-pill--on' : 'status-pill--off'">
|
||||||
|
{{ enabled ? '当前:已开启' : '当前:已关闭' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p class="switch-hero__hint">
|
||||||
|
本开关为<strong>烘胶流程总闸</strong>,开启后相关业务方可执行烘胶流程;关闭后立即生效,<strong>请谨慎操作</strong>。
|
||||||
|
</p>
|
||||||
|
<div v-if="lastMeta" class="switch-hero__meta">
|
||||||
|
最近操作:{{ lastMeta.updateBy || '-' }} · {{ formatTime(lastMeta.updateTime) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="switch-actions">
|
||||||
|
<a-button
|
||||||
|
v-auth="'mes:mes_xsl_drying_process_switch:toggle'"
|
||||||
|
type="primary"
|
||||||
|
size="large"
|
||||||
|
class="action-btn action-btn--on"
|
||||||
|
:disabled="enabled || toggling"
|
||||||
|
:loading="toggling && pendingEnabled === 1"
|
||||||
|
@click="confirmToggle(1)"
|
||||||
|
>
|
||||||
|
<Icon icon="ant-design:play-circle-outlined" :size="22" />
|
||||||
|
<span>开启烘胶流程</span>
|
||||||
|
</a-button>
|
||||||
|
<a-button
|
||||||
|
v-auth="'mes:mes_xsl_drying_process_switch:toggle'"
|
||||||
|
danger
|
||||||
|
size="large"
|
||||||
|
class="action-btn action-btn--off"
|
||||||
|
:disabled="!enabled || toggling"
|
||||||
|
:loading="toggling && pendingEnabled === 0"
|
||||||
|
@click="confirmToggle(0)"
|
||||||
|
>
|
||||||
|
<Icon icon="ant-design:stop-outlined" :size="22" />
|
||||||
|
<span>关闭烘胶流程</span>
|
||||||
|
</a-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a-alert
|
||||||
|
class="switch-tip"
|
||||||
|
type="warning"
|
||||||
|
show-icon
|
||||||
|
message="操作提示"
|
||||||
|
description="点击「开启」或「关闭」后将弹出二次确认,确认后才会变更状态,请谨慎操作。"
|
||||||
|
/>
|
||||||
|
</a-spin>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="MesXslDryingProcessSwitchPage" setup>
|
||||||
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
import { Modal } from 'ant-design-vue';
|
||||||
|
import Icon from '/@/components/Icon';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
import { getDryingProcessSwitch, setDryingProcessEnabled } from './MesXslDryingProcessSwitch.api';
|
||||||
|
|
||||||
|
const { createMessage } = useMessage();
|
||||||
|
const loading = ref(false);
|
||||||
|
const toggling = ref(false);
|
||||||
|
const pendingEnabled = ref<0 | 1 | null>(null);
|
||||||
|
const switchData = ref<Recordable>({ enabled: 0 });
|
||||||
|
|
||||||
|
const enabled = computed(() => Number(switchData.value?.enabled) === 1);
|
||||||
|
const lastMeta = computed(() => switchData.value);
|
||||||
|
|
||||||
|
function formatTime(text?: string) {
|
||||||
|
if (!text) return '-';
|
||||||
|
return String(text).length > 19 ? String(text).substring(0, 19) : text;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadStatus() {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const raw = await getDryingProcessSwitch();
|
||||||
|
const data = (raw as any)?.enabled != null ? raw : (raw as any)?.result ?? raw;
|
||||||
|
switchData.value = { enabled: 0, ...(data || {}) };
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmToggle(next: 0 | 1) {
|
||||||
|
const isOn = next === 1;
|
||||||
|
Modal.confirm({
|
||||||
|
title: isOn ? '确认开启烘胶流程?' : '确认关闭烘胶流程?',
|
||||||
|
content: isOn
|
||||||
|
? '开启后,烘胶相关业务流程将允许执行,请谨慎操作并确认当前确需开启。'
|
||||||
|
: '关闭后,烘胶相关业务流程将被拦截,请谨慎操作并确认当前确需关闭。',
|
||||||
|
okText: isOn ? '确认开启' : '确认关闭',
|
||||||
|
cancelText: '取消',
|
||||||
|
okType: isOn ? 'primary' : 'danger',
|
||||||
|
centered: true,
|
||||||
|
width: 480,
|
||||||
|
onOk: () => doToggle(next),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doToggle(next: 0 | 1) {
|
||||||
|
toggling.value = true;
|
||||||
|
pendingEnabled.value = next;
|
||||||
|
try {
|
||||||
|
const raw = await setDryingProcessEnabled({ enabled: next });
|
||||||
|
const data = (raw as any)?.enabled != null ? raw : (raw as any)?.result ?? raw;
|
||||||
|
if (data && typeof data === 'object' && 'enabled' in data) {
|
||||||
|
switchData.value = { ...switchData.value, ...data };
|
||||||
|
} else {
|
||||||
|
switchData.value = { ...switchData.value, enabled: next };
|
||||||
|
}
|
||||||
|
createMessage.success(next === 1 ? '烘胶流程已开启' : '烘胶流程已关闭');
|
||||||
|
await loadStatus();
|
||||||
|
} finally {
|
||||||
|
toggling.value = false;
|
||||||
|
pendingEnabled.value = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadStatus();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.drying-process-switch-page {
|
||||||
|
min-height: calc(100vh - 160px);
|
||||||
|
padding: 24px;
|
||||||
|
background: linear-gradient(180deg, #f5f7fb 0%, #fff 320px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-hero {
|
||||||
|
max-width: 720px;
|
||||||
|
margin: 0 auto 32px;
|
||||||
|
padding: 40px 32px 32px;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 2px solid transparent;
|
||||||
|
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
|
||||||
|
transition: all 0.25s ease;
|
||||||
|
|
||||||
|
&.is-on {
|
||||||
|
background: linear-gradient(145deg, #f6ffed 0%, #fff 55%);
|
||||||
|
border-color: #b7eb8f;
|
||||||
|
|
||||||
|
.switch-hero__badge {
|
||||||
|
color: #52c41a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-off {
|
||||||
|
background: linear-gradient(145deg, #fff2f0 0%, #fff 55%);
|
||||||
|
border-color: #ffccc7;
|
||||||
|
|
||||||
|
.switch-hero__badge {
|
||||||
|
color: #ff4d4f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-hero__title {
|
||||||
|
margin: 12px 0 16px;
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-pill {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 8px 24px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
|
||||||
|
&--on {
|
||||||
|
color: #389e0d;
|
||||||
|
background: #d9f7be;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--off {
|
||||||
|
color: #cf1322;
|
||||||
|
background: #ffccc7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-hero__hint {
|
||||||
|
margin: 20px auto 0;
|
||||||
|
max-width: 560px;
|
||||||
|
color: rgba(0, 0, 0, 0.55);
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-hero__meta {
|
||||||
|
margin-top: 16px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: rgba(0, 0, 0, 0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 24px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-btn {
|
||||||
|
min-width: 220px;
|
||||||
|
height: 56px !important;
|
||||||
|
font-size: 18px !important;
|
||||||
|
font-weight: 600;
|
||||||
|
display: inline-flex !important;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
border-radius: 10px !important;
|
||||||
|
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-btn--on:not(:disabled) {
|
||||||
|
background: #52c41a !important;
|
||||||
|
border-color: #52c41a !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-tip {
|
||||||
|
max-width: 720px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -66,6 +66,9 @@
|
|||||||
"**/node_modules": true,
|
"**/node_modules": true,
|
||||||
"**/_tmp_build_out": true,
|
"**/_tmp_build_out": true,
|
||||||
"**/_build_verify_out": true
|
"**/_build_verify_out": true
|
||||||
|
},
|
||||||
|
"workbench.editorAssociations": {
|
||||||
|
"**/flyway/sql/mysql/*.sql": "default"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"launch": {
|
"launch": {
|
||||||
|
|||||||
Reference in New Issue
Block a user