烘胶开关添加
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user