From 8afaccb9619d058cc90f974d966e8f884a9113d6 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期三, 28 十月 2026 17:44:05 +0800
Subject: [PATCH] feat(chdl): 长辉品牌登录页 + 数采监控页面 + 接口地址切到长辉环境
---
src/views/mes/dv/collect/index.vue | 483 +++++++++++++
.gitignore | 5
src/views/mes/dv/collect/modules/detail.vue | 298 ++++++++
public/logos/CHDL.svg | 30
src/api/mes/dv/collect/index.ts | 167 ++++
src/api/system/company-config/index.ts | 28
company.config.ts | 8
src/locales/langs/en-US/authentication.json | 7
src/views/mes/dv/collect/data.ts | 263 +++++++
src/locales/langs/zh-CN/authentication.json | 7
src/packages/effects/layouts/src/basic/index.ts | 1
src/views/_core/authentication/login.vue | 342 ++++++--
.env.production | 8
src/layouts/auth-scene.vue | 530 ++++++++++++++
src/layouts/auth.vue | 24
15 files changed, 2,086 insertions(+), 115 deletions(-)
diff --git a/.env.production b/.env.production
index 5abb0d7..d33974f 100644
--- a/.env.production
+++ b/.env.production
@@ -1,11 +1,11 @@
-VITE_COMPANY=TEST
+VITE_COMPANY=CHDL
VITE_BASE=/
-# 璇锋眰璺緞
-VITE_BASE_URL=http://36.213.90.123:9501
+# 璇锋眰璺緞锛堥暱杈� chdl锛歯ginx 9006 鍙嶄唬鍚庣 9005锛�
+VITE_BASE_URL=http://101.245.92.159:9006
# 鎺ュ彛鍦板潃
-VITE_GLOB_API_URL=http://36.213.90.123:9501/admin-api
+VITE_GLOB_API_URL=http://101.245.92.159:9006/admin-api
# 鏂囦欢涓婁紶绫诲瀷锛歴erver - 鍚庣涓婁紶锛� client - 鍓嶇鐩磋繛涓婁紶锛屼粎鏀寔S3鏈嶅姟
VITE_UPLOAD_TYPE=server
diff --git a/.gitignore b/.gitignore
index 33d4363..f225e64 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,4 +30,7 @@
# Cache
.cache/
-.temp/
\ No newline at end of file
+.temp/
+
+# Build archives
+dist*.zip
diff --git a/company.config.ts b/company.config.ts
index 29c8362..d35ed92 100644
--- a/company.config.ts
+++ b/company.config.ts
@@ -66,10 +66,10 @@
apiUrl: 'http://36.213.150.237:9006/admin-api',
},
CHDL: {
- name: '闀胯緣鐢靛姏',
- logo: '/logos/YZFXLogo.png',
- favicon: '/logos/YZFXLogo.ico',
- apiUrl: 'http://36.213.150.237:9004/admin-api',
+ name: '闀胯緣鐢靛姏宸ヤ笟鏅洪�犲钩鍙�',
+ logo: '/logos/CHDL.svg',
+ favicon: '/logos/CHDL.svg',
+ apiUrl: 'http://101.245.92.159:9006/admin-api',
},
HM: {
name: '鎯犵墽',
diff --git a/public/logos/CHDL.svg b/public/logos/CHDL.svg
new file mode 100644
index 0000000..9f8251c
--- /dev/null
+++ b/public/logos/CHDL.svg
@@ -0,0 +1,30 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48" role="img" aria-label="闀胯緣鐢靛姏">
+ <title>闀胯緣鐢靛姏</title>
+ <defs>
+ <linearGradient id="chdl-shell" x1="7" y1="4" x2="41" y2="45" gradientUnits="userSpaceOnUse">
+ <stop offset="0" stop-color="#1E5A8F"/>
+ <stop offset="0.55" stop-color="#123A5C"/>
+ <stop offset="1" stop-color="#0A2135"/>
+ </linearGradient>
+ <linearGradient id="chdl-bolt" x1="24" y1="9" x2="24" y2="39" gradientUnits="userSpaceOnUse">
+ <stop offset="0" stop-color="#A8EEFF"/>
+ <stop offset="0.5" stop-color="#4FC8FF"/>
+ <stop offset="1" stop-color="#1E9BEE"/>
+ </linearGradient>
+ <radialGradient id="chdl-sheen" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(16 12) rotate(48) scale(30)">
+ <stop offset="0" stop-color="#FFFFFF" stop-opacity="0.22"/>
+ <stop offset="1" stop-color="#FFFFFF" stop-opacity="0"/>
+ </radialGradient>
+ </defs>
+
+ <!-- 宸ヤ笟鍏竟褰㈠澹� -->
+ <path d="M24 3 L42.19 13.5 V34.5 L24 45 L5.81 34.5 V13.5 Z" fill="url(#chdl-shell)"/>
+ <path d="M24 3 L42.19 13.5 V34.5 L24 45 L5.81 34.5 V13.5 Z" fill="url(#chdl-sheen)"/>
+ <path d="M24 3 L42.19 13.5 V34.5 L24 45 L5.81 34.5 V13.5 Z" fill="none" stroke="#3FC8FF" stroke-opacity="0.6" stroke-width="1.2"/>
+
+ <!-- 鍐呭湀鍒诲害鐜� -->
+ <path d="M24 7 L38.72 15.5 V32.5 L24 41 L9.28 32.5 V15.5 Z" fill="none" stroke="#FFFFFF" stroke-opacity="0.14" stroke-width="1"/>
+
+ <!-- 鐢靛姏闂數 -->
+ <path d="M27.6 8.4 L15.6 26.4 H21.9 L20.2 39.6 L32.4 21.6 H26.1 Z" fill="url(#chdl-bolt)"/>
+</svg>
diff --git a/src/api/mes/dv/collect/index.ts b/src/api/mes/dv/collect/index.ts
new file mode 100644
index 0000000..807809b
--- /dev/null
+++ b/src/api/mes/dv/collect/index.ts
@@ -0,0 +1,167 @@
+import type { PageParam, PageResult } from '@vben/request';
+
+import { requestClient } from '#/api/request';
+
+export namespace MesCollectApi {
+ /** 鏁伴噰璁惧鐘舵�� */
+ export interface CollectDevice {
+ machineryId?: number; // 璁惧鍙拌处缂栧彿
+ machineryCode?: string; // 璁惧缂栫爜
+ machineryName?: string; // 璁惧鍚嶇О
+ workstationId?: number; // 宸ヤ綔绔欑紪鍙�
+ workstationName?: string; // 宸ヤ綔绔欏悕绉�
+ collectDeviceCode?: string; // 鏁伴噰璁惧缂栧彿
+ collectEnabled?: boolean; // 鏄惁鍚敤鏁伴噰
+ lastCollectTime?: string; // 鏈�杩戦噰闆嗘椂闂�
+ online?: boolean; // 鏄惁鍦ㄧ嚎锛�5 鍒嗛挓鍐呮湁鏁版嵁锛�
+ sts?: number; // 杩愯鐘舵�侊細1寰呮満 2鐢熶骇
+ stsName?: string; // 杩愯鐘舵�佸悕绉�
+ opm?: number; // 杩愯妯″紡
+ opmName?: string; // 杩愯妯″紡鍚嶇О
+ ot?: number; // 娌规俯
+ temps?: string; // 鍚勬娓╁害 JSON
+ taskId?: number; // 鐢熶骇浠诲姟缂栧彿
+ taskCode?: string; // 鐢熶骇浠诲姟缂栫爜
+ taskName?: string; // 鐢熶骇浠诲姟鍚嶇О
+ workOrderId?: number; // 鐢熶骇宸ュ崟缂栧彿
+ workOrderCode?: string; // 鐢熶骇宸ュ崟缂栫爜
+ activeAlarmCount?: number; // 鏈秷闄ゆ姤璀︽暟閲�
+ }
+
+ /** 鏁伴噰瀹炴椂鏁版嵁 */
+ export interface CollectRealtime {
+ id?: number; // 缂栧彿
+ machineryId?: number; // 璁惧鍙拌处缂栧彿
+ deviceCode?: string; // 鏁伴噰璁惧缂栧彿
+ taskId?: number; // 鐢熶骇浠诲姟缂栧彿
+ workOrderId?: number; // 鐢熶骇宸ュ崟缂栧彿
+ collectTime?: string; // 閲囬泦鏃堕棿
+ sts?: number; // 杩愯鐘舵��
+ stsName?: string; // 杩愯鐘舵�佸悕绉�
+ opm?: number; // 杩愯妯″紡
+ opmName?: string; // 杩愯妯″紡鍚嶇О
+ asts?: number; // 闄勫姞鐘舵��
+ ot?: number; // 娌规俯
+ temps?: string; // 鍚勬娓╁害 JSON
+ dataJson?: string; // 瀹屾暣鏁版嵁 JSON
+ }
+
+ /** 鏁伴噰鎶ヨ */
+ export interface CollectAlarm {
+ id?: number; // 缂栧彿
+ machineryId?: number; // 璁惧鍙拌处缂栧彿
+ deviceCode?: string; // 鏁伴噰璁惧缂栧彿
+ taskId?: number; // 鐢熶骇浠诲姟缂栧彿
+ workOrderId?: number; // 鐢熶骇宸ュ崟缂栧彿
+ wmId?: number; // 鎶ヨ鏍囪瘑锛�2浜х敓 0娑堝け
+ wmMsg?: string; // 鎶ヨ鍐呭
+ wmTime?: string; // 鎶ヨ鏃堕棿
+ status?: number; // 鐘舵�侊細0鏈秷闄� 1宸叉秷闄�
+ statusName?: string; // 鐘舵�佸悕绉�
+ clearTime?: string; // 娑堥櫎鏃堕棿
+ collectTime?: string; // 鎶ユ枃閲囬泦鏃堕棿
+ dataJson?: string; // 瀹屾暣鏁版嵁 JSON
+ }
+
+ /** 鏁伴噰鍛ㄦ湡杩囩▼鏁版嵁 */
+ export interface CollectCycle {
+ id?: number;
+ machineryId?: number;
+ deviceCode?: string;
+ cycleNo?: number;
+ collectTime?: string;
+ dataJson?: string;
+ }
+
+ /** 鏁伴噰鍙傛暟鍙樻洿鏃ュ織 */
+ export interface CollectOperateLog {
+ id?: number;
+ machineryId?: number;
+ deviceCode?: string;
+ varId?: string;
+ oldValue?: string;
+ newValue?: string;
+ modifyTime?: string;
+ collectTime?: string;
+ dataJson?: string;
+ }
+
+ /** 鏁伴噰宸ヨ壓鍙傛暟蹇収 */
+ export interface CollectTech {
+ id?: number;
+ machineryId?: number;
+ deviceCode?: string;
+ collectTime?: string;
+ dataJson?: string;
+ }
+}
+
+/** 鏌ヨ鏁伴噰璁惧鐘舵�佸垪琛� */
+export function getCollectDeviceList() {
+ return requestClient.get<MesCollectApi.CollectDevice[]>(
+ '/mes/collect/device/list',
+ );
+}
+
+/** 鏌ヨ璁惧鏈�鏂板疄鏃剁姸鎬� */
+export function getCollectRealtime(deviceCode: string) {
+ return requestClient.get<MesCollectApi.CollectRealtime>(
+ '/mes/collect/realtime/get',
+ { params: { deviceCode } },
+ );
+}
+
+/** 鍒嗛〉鏌ヨ瀹炴椂鐘舵�佸巻鍙� */
+export function getCollectRealtimeHistoryPage(params: PageParam) {
+ return requestClient.get<PageResult<MesCollectApi.CollectRealtime>>(
+ '/mes/collect/realtime/history-page',
+ { params },
+ );
+}
+
+/** 鍒嗛〉鏌ヨ鍛ㄦ湡杩囩▼鏁版嵁 */
+export function getCollectCyclePage(params: PageParam) {
+ return requestClient.get<PageResult<MesCollectApi.CollectCycle>>(
+ '/mes/collect/cycle/page',
+ { params },
+ );
+}
+
+/** 鏌ヨ鍛ㄦ湡杩囩▼鏁版嵁鏄庣粏 */
+export function getCollectCycle(id: number) {
+ return requestClient.get<MesCollectApi.CollectCycle>(
+ '/mes/collect/cycle/get',
+ { params: { id } },
+ );
+}
+
+/** 鏌ヨ璁惧鏈�鏂板伐鑹哄弬鏁板揩鐓� */
+export function getCollectTech(deviceCode: string) {
+ return requestClient.get<MesCollectApi.CollectTech>(
+ '/mes/collect/tech/get',
+ { params: { deviceCode } },
+ );
+}
+
+/** 鍒嗛〉鏌ヨ鍙傛暟鍙樻洿鏃ュ織 */
+export function getCollectOperateLogPage(params: PageParam) {
+ return requestClient.get<PageResult<MesCollectApi.CollectOperateLog>>(
+ '/mes/collect/operate-log/page',
+ { params },
+ );
+}
+
+/** 鍒嗛〉鏌ヨ鎶ヨ璁板綍 */
+export function getCollectAlarmPage(params: PageParam) {
+ return requestClient.get<PageResult<MesCollectApi.CollectAlarm>>(
+ '/mes/collect/alarm/page',
+ { params },
+ );
+}
+
+/** 浜哄伐纭娑堥櫎鎶ヨ */
+export function ackCollectAlarm(id: number) {
+ return requestClient.put('/mes/collect/alarm/ack', null, {
+ params: { id },
+ });
+}
diff --git a/src/api/system/company-config/index.ts b/src/api/system/company-config/index.ts
index dbd1405..cedf943 100644
--- a/src/api/system/company-config/index.ts
+++ b/src/api/system/company-config/index.ts
@@ -12,11 +12,31 @@
}
}
-/** 鑾峰緱鍏徃鍝佺墝淇℃伅锛堝厤鐧诲綍鍏紑锛岀櫥褰曢〉 / 搴旂敤鍚姩鏃朵娇鐢級 */
+/**
+ * 鑾峰緱鍏徃鍝佺墝淇℃伅锛堝厤鐧诲綍鍏紑锛岀櫥褰曢〉 / 搴旂敤鍚姩鏃朵娇鐢級
+ *
+ * 璇ユ帴鍙e彧鏄睍绀哄寮洪」锛氬悗绔湭閮ㄧ讲璇ユā鍧椼�佹垨杩斿洖鏈櫥褰曟椂锛�
+ * 閮戒笉搴旀墦鏂櫥褰曟祦绋嬨�傚洜姝や娇鐢� raw 妯″紡鑷鍒ゆ柇涓氬姟鐮侊紝
+ * 閬垮厤璧板叏灞�閿欒鎷︽埅鍣ㄢ�斺�斿惁鍒欐帴鍙h繑鍥� 401 浼氳褰撴垚鐧诲綍鎬佸け鏁堬紝
+ * 瑙﹀彂 refreshToken 澶辫触骞跺脊鍑恒�屽唴閮ㄦ湇鍔″櫒閿欒銆嶆彁绀恒��
+ */
export async function getCompanyConfig() {
- return requestClient.get<SystemCompanyConfigApi.CompanyConfig | null>(
- '/system/company-config/get',
- );
+ try {
+ const response = await requestClient.get<{
+ code: number;
+ data: null | SystemCompanyConfigApi.CompanyConfig;
+ }>('/system/company-config/get', {
+ responseReturn: 'raw',
+ });
+ const body = response?.data;
+ if (body && body.code === 0) {
+ return body.data ?? null;
+ }
+ return null;
+ } catch {
+ // 鍚庣涓嶅彲鐢ㄦ垨鏈厤缃椂锛岄潤榛樺洖閫�鍒扮紪璇戞湡榛樿鍝佺墝
+ return null;
+ }
}
/** 淇濆瓨鍏徃鍝佺墝淇℃伅 */
diff --git a/src/layouts/auth-scene.vue b/src/layouts/auth-scene.vue
new file mode 100644
index 0000000..ceb323b
--- /dev/null
+++ b/src/layouts/auth-scene.vue
@@ -0,0 +1,530 @@
+<script lang="ts" setup>
+import { computed } from 'vue';
+
+import {
+ AuthenticationColorToggle,
+ Copyright,
+ LanguageToggle,
+ ThemeToggle,
+} from '@vben/layouts';
+import { $t } from '@vben/locales';
+import { preferences } from '@vben/preferences';
+
+interface Props {
+ appName?: string;
+ logo?: string;
+ pageDescription?: string;
+ pageTitle?: string;
+}
+
+defineOptions({ name: 'AuthScene' });
+
+const props = withDefaults(defineProps<Props>(), {
+ appName: '',
+ logo: '',
+ pageDescription: '',
+ pageTitle: '',
+});
+
+/**
+ * 浠〃鍒诲害锛�240掳 鎵帬鍐呭潎甯� 61 鏍癸紝姣� 5 鏍逛负涓诲埢搴︺��
+ * 瑙掑害浠� -210掳 璧风畻锛圫VG 涓『鏃堕拡涓烘锛夛紝涓庝笅鏂瑰渾寮ц矾寰勪繚鎸佷竴鑷淬��
+ */
+const gaugeTicks = Array.from({ length: 61 }, (_, index) => {
+ const angle = -210 + index * 4;
+ const major = index % 5 === 0;
+ return { angle, length: major ? 13 : 6 };
+});
+
+const showBrand = computed(() => Boolean(props.logo || props.appName));
+</script>
+
+<template>
+ <div class="auth-scene">
+ <!-- ==================== 宸︼細宸ヤ笟浠〃鍙伴潰 ==================== -->
+ <aside class="auth-scene__face">
+ <div class="auth-scene__grid" aria-hidden="true"></div>
+ <div class="auth-scene__glow" aria-hidden="true"></div>
+
+ <svg
+ class="auth-scene__gauge"
+ viewBox="0 0 400 400"
+ aria-hidden="true"
+ focusable="false"
+ >
+ <!-- 澶栧湀杞ㄩ亾 -->
+ <path
+ class="gauge__track"
+ d="M 70.1 275 A 150 150 0 1 1 329.9 275"
+ />
+ <!-- 鍐呭湀铏氱嚎杞ㄩ亾 -->
+ <path
+ class="gauge__track gauge__track--dashed"
+ d="M 96.1 260 A 120 120 0 1 1 303.9 260"
+ />
+ <!-- 宸茶鏁板姬 -->
+ <path
+ class="gauge__value"
+ d="M 70.1 275 A 150 150 0 0 1 311.5 99.6"
+ />
+ <!-- 鍒诲害 -->
+ <g>
+ <line
+ v-for="tick in gaugeTicks"
+ :key="tick.angle"
+ :class="[
+ 'gauge__tick',
+ { 'gauge__tick--major': tick.length > 10 },
+ ]"
+ x1="200"
+ y1="50"
+ x2="200"
+ :y2="50 + tick.length"
+ :transform="`rotate(${tick.angle} 200 200)`"
+ />
+ </g>
+ <!-- 鎸囬拡 -->
+ <g class="gauge__needle">
+ <line x1="200" y1="200" x2="200" y2="92" />
+ </g>
+ <circle class="gauge__hub" cx="200" cy="200" r="7" />
+ <circle class="gauge__hub-dot" cx="200" cy="200" r="2.5" />
+ </svg>
+
+ <header v-if="showBrand" class="auth-scene__brand">
+ <img
+ v-if="logo"
+ :key="logo"
+ :alt="appName"
+ :src="logo"
+ class="auth-scene__logo"
+ />
+ <p v-if="appName" class="auth-scene__name">{{ appName }}</p>
+ </header>
+
+ <div class="auth-scene__intro">
+ <p class="auth-scene__eyebrow">
+ <span class="auth-scene__eyebrow-rule" aria-hidden="true"></span>
+ {{ $t('authentication.loginEyebrow') }}
+ </p>
+ <h1 v-if="pageTitle" class="auth-scene__title">{{ pageTitle }}</h1>
+ <p v-if="pageDescription" class="auth-scene__desc">
+ {{ pageDescription }}
+ </p>
+ </div>
+ </aside>
+
+ <!-- ==================== 鍙筹細鐧诲綍闈㈡澘 ==================== -->
+ <section class="auth-scene__panel">
+ <div class="auth-scene__toolbar">
+ <AuthenticationColorToggle />
+ <LanguageToggle />
+ <ThemeToggle />
+ </div>
+
+ <div class="auth-scene__form">
+ <span class="auth-scene__corner auth-scene__corner--tl" aria-hidden="true"></span>
+ <span class="auth-scene__corner auth-scene__corner--tr" aria-hidden="true"></span>
+ <span class="auth-scene__corner auth-scene__corner--bl" aria-hidden="true"></span>
+ <span class="auth-scene__corner auth-scene__corner--br" aria-hidden="true"></span>
+
+ <RouterView v-slot="{ Component, route }">
+ <Transition appear mode="out-in" name="slide-up">
+ <KeepAlive :include="['Login']">
+ <component
+ :is="Component"
+ :key="route.fullPath"
+ class="side-content w-full"
+ data-side="bottom"
+ />
+ </KeepAlive>
+ </Transition>
+ </RouterView>
+ </div>
+
+ <div class="auth-scene__copyright">
+ <slot name="copyright">
+ <Copyright
+ v-if="preferences.copyright.enable"
+ v-bind="preferences.copyright"
+ />
+ </slot>
+ </div>
+ </section>
+ </div>
+</template>
+
+<style scoped>
+/* ==================== 楠ㄦ灦 ==================== */
+.auth-scene {
+ display: grid;
+ grid-template-columns: minmax(0, 1.15fr) minmax(24rem, 0.85fr);
+ min-height: 100svh;
+ overflow-x: hidden;
+ background: hsl(var(--background));
+}
+
+/* ==================== 宸︼細浠〃鍙伴潰 ==================== */
+.auth-scene__face {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ overflow: hidden;
+ padding: clamp(2rem, 3.2vw, 3.25rem) clamp(2rem, 4vw, 4.5rem);
+ isolation: isolate;
+ color: #e8eef7;
+ background:
+ radial-gradient(
+ 115% 85% at 6% 4%,
+ hsl(var(--primary) / 0.22) 0%,
+ transparent 58%
+ ),
+ linear-gradient(158deg, #111823 0%, #090d13 55%, #05070a 100%);
+}
+
+/* 钃濆浘缃戞牸 */
+.auth-scene__grid {
+ position: absolute;
+ z-index: -2;
+ inset: 0;
+ background-image:
+ linear-gradient(to right, rgb(255 255 255 / 0.055) 1px, transparent 1px),
+ linear-gradient(to bottom, rgb(255 255 255 / 0.055) 1px, transparent 1px),
+ linear-gradient(to right, rgb(255 255 255 / 0.025) 1px, transparent 1px),
+ linear-gradient(to bottom, rgb(255 255 255 / 0.025) 1px, transparent 1px);
+ background-size:
+ 96px 96px,
+ 96px 96px,
+ 24px 24px,
+ 24px 24px;
+ mask-image: radial-gradient(135% 105% at 18% 12%, #000 20%, transparent 76%);
+}
+
+/* 鍐峰厜鏅� */
+.auth-scene__glow {
+ position: absolute;
+ z-index: -1;
+ top: 6%;
+ right: -16%;
+ width: 44rem;
+ height: 44rem;
+ border-radius: 9999px;
+ background: radial-gradient(
+ circle,
+ hsl(var(--primary) / 0.28) 0%,
+ transparent 68%
+ );
+ filter: blur(30px);
+ pointer-events: none;
+}
+
+/* 浠〃 */
+.auth-scene__gauge {
+ position: absolute;
+ z-index: -1;
+ top: 45%;
+ right: -18%;
+ width: min(40rem, 56vw);
+ height: auto;
+ translate: 0 -50%;
+ pointer-events: none;
+}
+
+.gauge__track {
+ fill: none;
+ stroke: rgb(255 255 255 / 0.16);
+ stroke-width: 1;
+}
+
+.gauge__track--dashed {
+ stroke: rgb(255 255 255 / 0.08);
+ stroke-dasharray: 1 7;
+ stroke-linecap: round;
+}
+
+.gauge__value {
+ fill: none;
+ stroke: hsl(var(--primary) / 0.9);
+ stroke-width: 2;
+ stroke-linecap: round;
+ filter: drop-shadow(0 0 7px hsl(var(--primary) / 0.6));
+}
+
+.gauge__tick {
+ stroke: rgb(255 255 255 / 0.2);
+ stroke-width: 1;
+}
+
+.gauge__tick--major {
+ stroke: rgb(255 255 255 / 0.48);
+ stroke-width: 1.5;
+}
+
+.gauge__needle {
+ stroke: hsl(var(--primary));
+ stroke-width: 2.5;
+ stroke-linecap: round;
+ transform: rotate(-42deg);
+ transform-origin: 200px 200px;
+ animation: gauge-needle 11s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
+}
+
+@keyframes gauge-needle {
+ from {
+ transform: rotate(-45deg);
+ }
+
+ to {
+ transform: rotate(-39deg);
+ }
+}
+
+.gauge__hub {
+ fill: #0a0e14;
+ stroke: hsl(var(--primary) / 0.9);
+ stroke-width: 1.5;
+}
+
+.gauge__hub-dot {
+ fill: hsl(var(--primary));
+}
+
+/* 鍝佺墝 */
+.auth-scene__brand {
+ position: relative;
+ display: flex;
+ align-items: center;
+ gap: 0.875rem;
+}
+
+/* 娣辫壊鍙伴潰涓婄殑娴呰壊閾墝鎵樺簳锛氳娣辫摑鏍囪瘑鍦ㄧ煶澧ㄥ簳涓婁緷鐒舵竻鏅� */
+.auth-scene__logo {
+ width: 2.75rem;
+ height: 2.75rem;
+ padding: 0.25rem;
+ object-fit: contain;
+ border-radius: 0.625rem;
+ /* 鍐疯皟閲戝睘閾墝锛屼笌鏁翠綋钃濊壊璋冪粺涓�锛岄伩鍏嶇函鐧藉湪鐭冲ⅷ搴曚笂杩囦簬鍒虹溂 */
+ background: rgb(233 240 249 / 0.96);
+ box-shadow:
+ inset 0 0 0 1px rgb(255 255 255 / 0.75),
+ 0 4px 14px -6px rgb(0 0 0 / 0.55);
+}
+
+.auth-scene__name {
+ margin: 0;
+ font-size: 1.0625rem;
+ font-weight: 600;
+ letter-spacing: 0.02em;
+ color: #f2f6fb;
+}
+
+/* 涓绘枃妗� */
+.auth-scene__intro {
+ position: relative;
+ z-index: 1;
+ max-width: 33rem;
+ margin-top: auto;
+ padding-top: 3.5rem;
+}
+
+/* 鏂囧瓧鍖哄簳閮ㄥ帇鏆楋紝淇濊瘉浠〃鐩樺浘鏍风┛杩囨椂鏂囨浠嶆竻鏅� */
+.auth-scene__intro::before {
+ position: absolute;
+ z-index: -1;
+ inset: -1.5rem -6rem -2.5rem -3rem;
+ content: '';
+ background: radial-gradient(
+ 120% 100% at 0% 100%,
+ rgb(5 7 10 / 0.82) 0%,
+ rgb(5 7 10 / 0.45) 45%,
+ transparent 78%
+ );
+ pointer-events: none;
+}
+
+.auth-scene__eyebrow {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ margin: 0 0 1.25rem;
+ font-family: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', monospace;
+ font-size: 0.6875rem;
+ font-weight: 600;
+ letter-spacing: 0.3em;
+ text-transform: uppercase;
+ color: hsl(var(--primary) / 0.95);
+}
+
+.auth-scene__eyebrow-rule {
+ width: 2.5rem;
+ height: 1px;
+ background: linear-gradient(90deg, hsl(var(--primary)), transparent);
+}
+
+.auth-scene__title {
+ margin: 0;
+ font-size: clamp(1.875rem, 2.5vw, 2.625rem);
+ font-weight: 700;
+ line-height: 1.26;
+ letter-spacing: -0.01em;
+ color: #f7fafd;
+}
+
+.auth-scene__desc {
+ max-width: 29rem;
+ margin: 1.125rem 0 0;
+ font-size: 0.9375rem;
+ line-height: 1.75;
+ color: #93a1b5;
+}
+
+/* ==================== 鍙筹細鐧诲綍闈㈡澘 ==================== */
+.auth-scene__panel {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ overflow-y: auto;
+ padding: clamp(3.5rem, 5vw, 5rem) clamp(1.5rem, 4.5vw, 4rem);
+ /* 鏈哄姞宸ュ彴闈細姣斿崱鐗囦綆涓�灞傜殑娴呯伆锛屼繚璇佺櫧鍗″湪娴呰壊涓婚涓嬫湁灞傛 */
+ background-color: hsl(var(--background-deep));
+ background-image:
+ linear-gradient(to right, hsl(var(--foreground) / 0.035) 1px, transparent 1px),
+ linear-gradient(to bottom, hsl(var(--foreground) / 0.035) 1px, transparent 1px);
+ background-size: 24px 24px;
+}
+
+.auth-scene__toolbar {
+ position: absolute;
+ top: 1.25rem;
+ right: 1.25rem;
+ display: flex;
+ align-items: center;
+ gap: 0.125rem;
+}
+
+.auth-scene__form {
+ position: relative;
+ width: 100%;
+ max-width: 24rem;
+ margin-inline: auto;
+ padding: clamp(1.75rem, 2.5vw, 2.25rem);
+ border: 1px solid hsl(var(--border));
+ border-radius: 1.25rem;
+ background: hsl(var(--card));
+ box-shadow:
+ inset 0 1px 0 hsl(0 0% 100% / 0.7),
+ 0 1px 2px hsl(var(--foreground) / 0.06),
+ 0 24px 56px -28px hsl(var(--foreground) / 0.35);
+}
+
+/* 鍗$墖鍥涜瀹氫綅鏍囪 */
+.auth-scene__corner {
+ position: absolute;
+ width: 0.875rem;
+ height: 0.875rem;
+ border-color: hsl(var(--primary) / 0.55);
+ border-style: solid;
+ border-width: 0;
+ pointer-events: none;
+}
+
+.auth-scene__corner--tl {
+ top: -1px;
+ left: -1px;
+ border-top-width: 2px;
+ border-left-width: 2px;
+ border-top-left-radius: 1.25rem;
+}
+
+.auth-scene__corner--tr {
+ top: -1px;
+ right: -1px;
+ border-top-width: 2px;
+ border-right-width: 2px;
+ border-top-right-radius: 1.25rem;
+}
+
+.auth-scene__corner--bl {
+ bottom: -1px;
+ left: -1px;
+ border-bottom-width: 2px;
+ border-left-width: 2px;
+ border-bottom-left-radius: 1.25rem;
+}
+
+.auth-scene__corner--br {
+ right: -1px;
+ bottom: -1px;
+ border-right-width: 2px;
+ border-bottom-width: 2px;
+ border-bottom-right-radius: 1.25rem;
+}
+
+.auth-scene__copyright {
+ position: absolute;
+ bottom: 1rem;
+ left: 0;
+ width: 100%;
+ text-align: center;
+ font-size: 0.75rem;
+ color: hsl(var(--muted-foreground));
+}
+
+/* ==================== 鍝嶅簲寮� ==================== */
+@media (max-width: 1023px) {
+ .auth-scene {
+ grid-template-columns: minmax(0, 1fr);
+ }
+
+ .auth-scene__face {
+ min-height: 14rem;
+ padding: 1.5rem 1.5rem 1.75rem;
+ }
+
+ .auth-scene__gauge {
+ top: 58%;
+ right: -34%;
+ width: 26rem;
+ opacity: 0.6;
+ }
+
+ .auth-scene__intro {
+ padding-top: 2.25rem;
+ }
+
+ .auth-scene__title {
+ font-size: 1.5rem;
+ line-height: 1.32;
+ }
+
+ .auth-scene__desc {
+ margin-top: 0.625rem;
+ font-size: 0.875rem;
+ line-height: 1.6;
+ }
+
+ .auth-scene__panel {
+ justify-content: flex-start;
+ /* 椤堕儴鐣欏嚭宸ュ叿鏍忛珮搴︼紝閬垮厤鍙充笂瑙掓寜閽帇浣忕櫥褰曞崱鐗� */
+ padding: 4.25rem 1.25rem 4.5rem;
+ }
+
+ .auth-scene__form {
+ padding: 1.5rem;
+ }
+
+ .auth-scene__copyright {
+ position: static;
+ margin-top: 2.5rem;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .gauge__needle {
+ animation: none;
+ }
+}
+</style>
\ No newline at end of file
diff --git a/src/layouts/auth.vue b/src/layouts/auth.vue
index 9bf8bb3..0a997a6 100644
--- a/src/layouts/auth.vue
+++ b/src/layouts/auth.vue
@@ -1,11 +1,12 @@
<script lang="ts" setup>
import { computed, onMounted } from 'vue';
-import { AuthPageLayout } from '@vben/layouts';
import { preferences } from '@vben/preferences';
import { $t } from '#/locales';
import { useCompanyConfigStore } from '#/store/company-config';
+
+import AuthScene from './auth-scene.vue';
declare const __APP_LOGO__: string;
@@ -16,14 +17,17 @@
companyConfigStore.loadFromServer();
});
-const appName = computed(() => preferences.copyright.companyName);
-// 鐧诲綍椤� logo 浼樺厛鍙栨暟鎹簱閰嶇疆锛坧references.logo.source锛夛紝鏈厤缃椂鍥為��缂栬瘧鏈熼粯璁� __APP_LOGO__
+// 鍏徃鍚嶄紭鍏堝彇鏁版嵁搴撻厤缃紝鏈厤缃椂鍥為��缂栬瘧鏈熼粯璁わ紙preferences.copyright.companyName锛�
+const appName = computed(
+ () => companyConfigStore.companyName || preferences.copyright.companyName,
+);
+// 鐧诲綍椤� logo 浼樺厛鍙栨暟鎹簱閰嶇疆锛坈ompanyConfig / preferences.logo.source锛夛紝鏈厤缃椂鍥為��缂栬瘧鏈熼粯璁� __APP_LOGO__
const logo = computed(() => {
- const source = preferences.logo.source || __APP_LOGO__;
+ const source =
+ companyConfigStore.logoUrl || preferences.logo.source || __APP_LOGO__;
// 鏈厤缃叕鍙告爣蹇楁椂涓嶅睍绀烘鏋舵紨绀� Logo銆�
return source?.includes('@vbenjs/static-source') ? '' : source;
});
-const logoDark = computed(() => preferences.logo.sourceDark);
// 鏍囬/鎻忚堪浼樺厛鍙栧叕鍙镐俊鎭厤缃紝鏈厤缃椂鍥為��鏍囧搧鏂囨
const pageTitle = computed(
() => companyConfigStore.loginTitle || $t('authentication.pageTitle'),
@@ -34,14 +38,14 @@
</script>
<template>
- <AuthPageLayout
+ <AuthScene
:app-name="appName"
:logo="logo"
- :logo-dark="logoDark"
:page-description="pageDescription"
:page-title="pageTitle"
>
- <!-- 鑷畾涔夊伐鍏锋爮 -->
- <!-- <template #toolbar></template> -->
- </AuthPageLayout>
+ <template #copyright>
+ <span v-if="appName">{{ appName }}</span>
+ </template>
+ </AuthScene>
</template>
diff --git a/src/locales/langs/en-US/authentication.json b/src/locales/langs/en-US/authentication.json
new file mode 100644
index 0000000..addc3a8
--- /dev/null
+++ b/src/locales/langs/en-US/authentication.json
@@ -0,0 +1,7 @@
+{
+ "pageTitle": "Every operation, traceable",
+ "pageDesc": "One manufacturing operations backbone for production, quality, equipment and inventory.",
+ "loginEyebrow": "Operator authentication",
+ "loginSubmit": "Enter console",
+ "loginSubmitting": "Verifying"
+}
diff --git a/src/locales/langs/zh-CN/authentication.json b/src/locales/langs/zh-CN/authentication.json
new file mode 100644
index 0000000..9229e8b
--- /dev/null
+++ b/src/locales/langs/zh-CN/authentication.json
@@ -0,0 +1,7 @@
+{
+ "pageTitle": "璁╂瘡涓�閬撳伐搴忛兘鏈夋嵁鍙煡",
+ "pageDesc": "鐢熶骇銆佽川閲忋�佽澶囥�佷粨鍌ㄤ竴浣撶殑鍒堕�犺繍钀ュ簳搴э紝鎶婅溅闂寸幇鍦哄彉鎴愬彲璇荤殑鏁版嵁銆�",
+ "loginEyebrow": "鎿嶄綔鍛樿韩浠介獙璇�",
+ "loginSubmit": "杩涘叆鎺у埗鍙�",
+ "loginSubmitting": "姝e湪鏍¢獙"
+}
diff --git a/src/packages/effects/layouts/src/basic/index.ts b/src/packages/effects/layouts/src/basic/index.ts
index b3a01cd..11b501e 100644
--- a/src/packages/effects/layouts/src/basic/index.ts
+++ b/src/packages/effects/layouts/src/basic/index.ts
@@ -1 +1,2 @@
export { default as BasicLayout } from './layout.vue';
+export { Copyright } from './copyright';
diff --git a/src/views/_core/authentication/login.vue b/src/views/_core/authentication/login.vue
index 0a7547b..acd4e37 100644
--- a/src/views/_core/authentication/login.vue
+++ b/src/views/_core/authentication/login.vue
@@ -1,104 +1,41 @@
<script lang="ts" setup>
import type { VbenFormSchema } from '@vben/common-ui';
-import type { AuthApi } from '#/api/core/auth';
+import { computed, onMounted, reactive, ref } from 'vue';
-import { computed, onMounted, ref } from 'vue';
-
-import { AuthenticationLogin, Verification, z } from '@vben/common-ui';
-import { isCaptchaEnable, isTenantEnable } from '@vben/hooks';
+import { useVbenForm, Verification, VbenCheckbox, z } from '@vben/common-ui';
+import { isCaptchaEnable } from '@vben/hooks';
+import { IconifyIcon } from '@vben/icons';
import { $t } from '@vben/locales';
-import { useAccessStore } from '@vben/stores';
-import {
- checkCaptcha,
- getCaptcha,
- getTenantByWebsite,
- getTenantSimpleList,
-} from '#/api/core/auth';
+import { checkCaptcha, getCaptcha } from '#/api/core/auth';
import { useAuthStore } from '#/store';
defineOptions({ name: 'Login' });
const authStore = useAuthStore();
-const accessStore = useAccessStore();
-const tenantEnable = isTenantEnable();
const captchaEnable = isCaptchaEnable();
-const loginRef = ref();
const verifyRef = ref();
-
const captchaType = 'blockPuzzle'; // 楠岃瘉鐮佺被鍨嬶細'blockPuzzle' | 'clickWord'
-/** 鑾峰彇绉熸埛鍒楄〃 */
-const tenantList = ref<AuthApi.TenantResult[]>([]); // 绉熸埛鍒楄〃
-async function fetchTenantList() {
- if (!tenantEnable) {
- return;
- }
- try {
- // 鑾峰彇绉熸埛鍒楄〃
- tenantList.value = await getTenantSimpleList();
- } catch (error) {
- console.error('鑾峰彇绉熸埛鍒楄〃澶辫触:', error);
- }
-}
+/** 璁颁綇璐﹀彿锛氭部鐢ㄥ師鏈� key锛屼繚璇佽�佺敤鎴峰凡璁颁綇鐨勮处鍙蜂笉涓㈠け */
+const REMEMBER_ME_KEY = `REMEMBER_ME_USERNAME_${location.hostname}`;
+const rememberedUsername = localStorage.getItem(REMEMBER_ME_KEY) || '';
+const rememberMe = ref(Boolean(rememberedUsername));
-/** 澶勭悊鐧诲綍 */
-async function handleLogin(values: any) {
- // 濡傛灉寮�鍚獙璇佺爜锛屽垯鍏堥獙璇侀獙璇佺爜
- if (captchaEnable) {
- verifyRef.value.show();
- return;
- }
- // 鏃犻獙璇佺爜锛岀洿鎺ョ櫥褰�
- await authStore.authLogin('username', values);
-}
-
-/** 楠岃瘉鐮侀�氳繃锛屾墽琛岀櫥褰� */
-async function handleVerifySuccess({ captchaVerification }: any) {
- try {
- await authStore.authLogin('username', {
- ...(await loginRef.value.getFormApi().getValues()),
- captchaVerification,
- });
- } catch (error) {
- console.error('Error in handleLogin:', error);
- }
-}
-
-/** 缁勪欢鎸傝浇鏃惰幏鍙栫鎴蜂俊鎭� */
-onMounted(() => {
- fetchTenantList();
-});
+/** 绛夊緟楠岃瘉鐮侀�氳繃鍚庡啀鎻愪氦鐨勮〃鍗曞�� */
+const pendingValues = ref<Record<string, any>>({});
const formSchema = computed((): VbenFormSchema[] => {
return [
- // {
- // component: 'VbenSelect',
- // componentProps: {
- // options: tenantList.value.map((item) => ({
- // label: item.name,
- // value: item.id.toString(),
- // })),
- // placeholder: $t('authentication.tenantTip'),
- // },
- // fieldName: 'tenantId',
- // label: $t('authentication.tenant'),
- // dependencies: {
- // triggerFields: ['tenantId'],
- // if: tenantEnable,
- // trigger(values) {
- // accessStore.setTenantId(values.tenantId ? Number(values.tenantId) : null);
- // },
- // },
- // },
{
component: 'VbenInput',
componentProps: {
- placeholder: $t('authentication.usernameTip'),
- autocomplete: 'username',
'aria-label': $t('authentication.username'),
+ autocomplete: 'username',
+ class: 'login-field',
+ placeholder: $t('authentication.usernameTip'),
},
fieldName: 'username',
label: $t('authentication.username'),
@@ -110,9 +47,10 @@
{
component: 'VbenInputPassword',
componentProps: {
- placeholder: $t('authentication.passwordTip'),
- autocomplete: 'current-password',
'aria-label': $t('authentication.password'),
+ autocomplete: 'current-password',
+ class: 'login-field',
+ placeholder: $t('authentication.passwordTip'),
},
fieldName: 'password',
label: $t('authentication.password'),
@@ -123,22 +61,100 @@
},
];
});
+
+const [Form, formApi] = useVbenForm(
+ reactive({
+ commonConfig: {
+ hideLabel: false,
+ hideRequiredMark: true,
+ },
+ layout: 'vertical' as const,
+ schema: formSchema,
+ showDefaultActions: false,
+ }),
+);
+
+/** 璋冪敤鐧诲綍鎺ュ彛 */
+async function submitLogin(values: Record<string, any>) {
+ try {
+ await authStore.authLogin('username', values);
+ } catch (error) {
+ // 閿欒鎻愮ず鐢辫姹傛嫤鎴櫒缁熶竴寮瑰嚭锛岃繖閲屼粎閬垮厤鏈崟鑾风殑 Promise 鎷掔粷
+ console.error('鐧诲綍澶辫触:', error);
+ }
+}
+
+/** 鎻愪氦锛氭牎楠� -> 璁颁綇璐﹀彿 -> 楠岃瘉鐮� -> 鐧诲綍 */
+async function handleSubmit() {
+ if (authStore.loginLoading) {
+ return;
+ }
+ const { valid } = await formApi.validate();
+ if (!valid) {
+ return;
+ }
+ const values = await formApi.getValues();
+ localStorage.setItem(
+ REMEMBER_ME_KEY,
+ rememberMe.value ? String(values.username ?? '') : '',
+ );
+
+ if (captchaEnable) {
+ pendingValues.value = values;
+ verifyRef.value.show();
+ return;
+ }
+ await submitLogin(values);
+}
+
+/** 楠岃瘉鐮侀�氳繃锛屾墽琛岀櫥褰� */
+async function handleVerifySuccess({ captchaVerification }: any) {
+ await submitLogin({ ...pendingValues.value, captchaVerification });
+}
+
+onMounted(() => {
+ if (rememberedUsername) {
+ formApi.setFieldValue('username', rememberedUsername);
+ }
+});
</script>
<template>
- <div>
- <AuthenticationLogin
- ref="loginRef"
- :form-schema="formSchema"
- :loading="authStore.loginLoading"
- :show-code-login="false"
- :show-qrcode-login="false"
- :show-third-party-login="false"
- :show-register="false"
- :show-forget-password="false"
- :show-doc-link="false"
- @submit="handleLogin"
- />
+ <div class="login">
+ <header class="login__head">
+ <h2 class="login__title">{{ $t('authentication.welcomeBack') }}</h2>
+ <p class="login__desc">{{ $t('authentication.loginSubtitle') }}</p>
+ </header>
+
+ <Form @keydown.enter.prevent="handleSubmit" />
+
+ <div class="login__row">
+ <VbenCheckbox v-model="rememberMe" name="rememberMe">
+ {{ $t('authentication.rememberMe') }}
+ </VbenCheckbox>
+ </div>
+
+ <button
+ :disabled="authStore.loginLoading"
+ class="login__submit"
+ type="button"
+ @click="handleSubmit"
+ >
+ <span class="login__submit-text">
+ {{
+ authStore.loginLoading
+ ? $t('authentication.loginSubmitting')
+ : $t('authentication.loginSubmit')
+ }}
+ </span>
+ <span class="login__submit-icon" aria-hidden="true">
+ <IconifyIcon
+ :class="{ 'animate-pulse': authStore.loginLoading }"
+ icon="lucide:arrow-right"
+ />
+ </span>
+ </button>
+
<Verification
ref="verifyRef"
v-if="captchaEnable"
@@ -151,3 +167,145 @@
/>
</div>
</template>
+
+<style scoped>
+.login {
+ --login-control-height: 2.75rem;
+}
+
+/* ---------- 鏍囬 ---------- */
+.login__head {
+ margin-bottom: 1.5rem;
+}
+
+.login__title {
+ margin: 0;
+ font-size: 1.5rem;
+ font-weight: 700;
+ line-height: 1.3;
+ letter-spacing: -0.01em;
+ color: hsl(var(--foreground));
+}
+
+.login__desc {
+ margin: 0.5rem 0 0;
+ font-size: 0.875rem;
+ line-height: 1.6;
+ color: hsl(var(--muted-foreground));
+}
+
+/* ---------- 瀛楁 ---------- */
+.login :deep(label) {
+ margin-bottom: 0.375rem;
+ font-size: 0.75rem;
+ font-weight: 600;
+ letter-spacing: 0.08em;
+ color: hsl(var(--muted-foreground));
+}
+
+.login :deep(.login-field) {
+ height: var(--login-control-height);
+ border-radius: 0.625rem;
+ border-color: hsl(var(--border));
+ background: hsl(var(--muted) / 0.55);
+ font-size: 0.9375rem;
+ transition:
+ background 0.24s cubic-bezier(0.32, 0.72, 0, 1),
+ box-shadow 0.24s cubic-bezier(0.32, 0.72, 0, 1);
+}
+
+.login :deep(.login-field:focus-visible) {
+ background: hsl(var(--background));
+ box-shadow: inset 0 0 0 1px hsl(var(--primary));
+}
+
+/* placeholder 鍔犳繁锛屼繚璇佸湪娴呯伆搴曚笂浠嶅彲杈ㄨ瘑锛圓A锛� */
+.login :deep(.login-field::placeholder) {
+ color: hsl(var(--muted-foreground));
+ opacity: 1;
+}
+
+/* 瀵嗙爜鍙鎬ф寜閽笌杈撳叆妗嗗榻� */
+.login :deep(.login-field ~ button) {
+ padding-right: 0.75rem;
+}
+
+/* ---------- 璁颁綇璐﹀彿 ---------- */
+.login__row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin: 0.25rem 0 1.25rem;
+ font-size: 0.875rem;
+}
+
+/* ---------- 鎻愪氦鎸夐挳 ---------- */
+.login__submit {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 0.625rem;
+ width: 100%;
+ height: var(--login-control-height);
+ border: none;
+ border-radius: 0.625rem;
+ background: hsl(var(--primary));
+ color: hsl(var(--primary-foreground));
+ font-size: 0.9375rem;
+ font-weight: 600;
+ letter-spacing: 0.04em;
+ cursor: pointer;
+ box-shadow:
+ inset 0 1px 0 rgb(255 255 255 / 0.18),
+ 0 10px 24px -16px hsl(var(--primary) / 0.95);
+ transition:
+ transform 0.18s cubic-bezier(0.32, 0.72, 0, 1),
+ background 0.18s ease;
+}
+
+.login__submit:hover:not(:disabled) {
+ background: hsl(var(--primary) / 0.92);
+}
+
+.login__submit:focus-visible {
+ outline: 2px solid hsl(var(--ring));
+ outline-offset: 2px;
+}
+
+.login__submit:active:not(:disabled) {
+ transform: scale(0.985);
+}
+
+.login__submit:disabled {
+ cursor: not-allowed;
+ opacity: 0.72;
+}
+
+.login__submit-text {
+ line-height: 1;
+}
+
+.login__submit-icon {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 1.5rem;
+ height: 1.5rem;
+ border-radius: 9999px;
+ background: rgb(255 255 255 / 0.16);
+ font-size: 0.875rem;
+ transition: transform 0.18s cubic-bezier(0.32, 0.72, 0, 1);
+}
+
+.login__submit:hover:not(:disabled) .login__submit-icon {
+ transform: translateX(2px);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .login :deep(.login-field),
+ .login__submit,
+ .login__submit-icon {
+ transition: none;
+ }
+}
+</style>
diff --git a/src/views/mes/dv/collect/data.ts b/src/views/mes/dv/collect/data.ts
new file mode 100644
index 0000000..e996801
--- /dev/null
+++ b/src/views/mes/dv/collect/data.ts
@@ -0,0 +1,263 @@
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { MesCollectApi } from '#/api/mes/dv/collect';
+
+/** 璁惧鍦ㄧ嚎鐘舵�佸睍绀洪厤缃� */
+export function getOnlineConfig(online?: boolean) {
+ return online
+ ? { color: 'green', label: '鍦ㄧ嚎', value: true }
+ : { color: 'default', label: '绂荤嚎', value: false };
+}
+
+/** 杩愯鐘舵�佸睍绀洪厤缃� */
+export function getStsConfig(sts?: number) {
+ if (sts === 2) return { color: 'green', label: '鐢熶骇' };
+ if (sts === 1) return { color: 'orange', label: '寰呮満' };
+ return { color: 'default', label: '-' };
+}
+
+/** 瑙f瀽 dataJson 閲岀殑鏁板�煎瀷瀛楁 */
+export function parseDataJson(dataJson?: string): Record<string, number | string> {
+ if (!dataJson) return {};
+ try {
+ const obj = JSON.parse(dataJson);
+ const result: Record<string, number | string> = {};
+ Object.keys(obj).forEach((k) => {
+ const v = obj[k];
+ if (typeof v === 'number') {
+ // 娴偣鏁颁繚鐣� 2 浣嶏紝閬垮厤 1.9984014E-15 杩欑被绉戝璁℃暟娉�
+ result[k] = Number.isInteger(v) ? v : Number(v.toFixed(2));
+ } else {
+ result[k] = v;
+ }
+ });
+ return result;
+ } catch {
+ return {};
+ }
+}
+
+/** 浠� dataJson 鎻愬彇鎸囧畾 key 鐨勬暟鍊� */
+export function getJsonNumber(
+ dataJson: string | undefined,
+ key: string,
+): number | undefined {
+ const parsed = parseDataJson(dataJson);
+ const v = parsed[key];
+ return typeof v === 'number' ? v : undefined;
+}
+
+/** 璁惧鐘舵�佸垪琛ㄧ殑鏌ヨ琛ㄥ崟 */
+export function useDeviceSearchSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'keyword',
+ label: '璁惧鍚嶇О',
+ component: 'Input',
+ componentProps: {
+ placeholder: '杈撳叆璁惧鍚嶇О鎴栫紪鐮佹悳绱�',
+ allowClear: true,
+ },
+ },
+ {
+ fieldName: 'online',
+ label: '鍦ㄧ嚎鐘舵��',
+ component: 'Select',
+ componentProps: {
+ allowClear: true,
+ placeholder: '鍏ㄩ儴',
+ options: [
+ { label: '鍦ㄧ嚎', value: true },
+ { label: '绂荤嚎', value: false },
+ ],
+ },
+ },
+ ];
+}
+
+/** 瀹炴椂鍘嗗彶鍒嗛〉鐨勬煡璇㈣〃鍗� */
+export function useHistorySearchSchema(
+ deviceOptions: { label: string; value: string }[],
+): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'deviceCode',
+ label: '鏁伴噰璁惧',
+ component: 'Select',
+ componentProps: {
+ allowClear: true,
+ placeholder: '鍏ㄩ儴璁惧',
+ options: deviceOptions,
+ showSearch: true,
+ optionFilterProp: 'label',
+ },
+ },
+ {
+ fieldName: 'collectTime',
+ label: '閲囬泦鏃堕棿',
+ component: 'RangePicker',
+ componentProps: {
+ showTime: true,
+ format: 'YYYY-MM-DD HH:mm:ss',
+ valueFormat: 'YYYY-MM-DD HH:mm:ss',
+ },
+ },
+ ];
+}
+
+/** 鎶ヨ鍒嗛〉鐨勬煡璇㈣〃鍗� */
+export function useAlarmSearchSchema(
+ deviceOptions: { label: string; value: string }[],
+): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'deviceCode',
+ label: '鏁伴噰璁惧',
+ component: 'Select',
+ componentProps: {
+ allowClear: true,
+ placeholder: '鍏ㄩ儴璁惧',
+ options: deviceOptions,
+ showSearch: true,
+ optionFilterProp: 'label',
+ },
+ },
+ {
+ fieldName: 'status',
+ label: '鎶ヨ鐘舵��',
+ component: 'Select',
+ componentProps: {
+ allowClear: true,
+ placeholder: '鍏ㄩ儴',
+ options: [
+ { label: '鏈秷闄�', value: 0 },
+ { label: '宸叉秷闄�', value: 1 },
+ ],
+ },
+ },
+ {
+ fieldName: 'wmTime',
+ label: '鎶ヨ鏃堕棿',
+ component: 'RangePicker',
+ componentProps: {
+ showTime: true,
+ format: 'YYYY-MM-DD HH:mm:ss',
+ valueFormat: 'YYYY-MM-DD HH:mm:ss',
+ },
+ },
+ ];
+}
+
+/** 璁惧鐘舵�佽〃鏍煎垪 */
+export function useDeviceGridColumns(): VxeTableGridOptions<MesCollectApi.CollectDevice>['columns'] {
+ return [
+ {
+ field: 'machineryName',
+ title: '璁惧鍚嶇О',
+ minWidth: 140,
+ slots: { default: 'machineryName' },
+ },
+ { field: 'machineryCode', title: '璁惧缂栫爜', width: 140 },
+ { field: 'collectDeviceCode', title: '鏁伴噰缂栫爜', width: 130 },
+ {
+ field: 'online',
+ title: '鍦ㄧ嚎鐘舵��',
+ width: 100,
+ slots: { default: 'online' },
+ },
+ {
+ field: 'sts',
+ title: '杩愯鐘舵��',
+ width: 100,
+ slots: { default: 'sts' },
+ },
+ {
+ field: 'lastCollectTime',
+ title: '鏈�杩戦噰闆�',
+ width: 170,
+ },
+ {
+ field: 'currentData',
+ title: '褰撳墠鏁版嵁',
+ minWidth: 260,
+ slots: { default: 'currentData' },
+ },
+ {
+ field: 'activeAlarmCount',
+ title: '鏈秷闄ゆ姤璀�',
+ width: 110,
+ slots: { default: 'alarm' },
+ },
+ {
+ field: 'taskName',
+ title: '褰撳墠浠诲姟',
+ width: 160,
+ formatter: ({ cellValue }: any) => cellValue || '-',
+ },
+ {
+ field: 'workstationName',
+ title: '宸ヤ綔绔�',
+ width: 140,
+ formatter: ({ cellValue }: any) => cellValue || '-',
+ },
+ {
+ field: 'actions',
+ title: '鎿嶄綔',
+ width: 130,
+ fixed: 'right',
+ slots: { default: 'actions' },
+ },
+ ];
+}
+
+/** 瀹炴椂鍘嗗彶琛ㄦ牸鍒� */
+export function useHistoryGridColumns(): VxeTableGridOptions<MesCollectApi.CollectRealtime>['columns'] {
+ return [
+ { field: 'id', title: '缂栧彿', width: 90 },
+ { field: 'deviceCode', title: '鏁伴噰璁惧', width: 140 },
+ { field: 'collectTime', title: '閲囬泦鏃堕棿', width: 170 },
+ {
+ field: 'stsName',
+ title: '杩愯鐘舵��',
+ width: 100,
+ formatter: ({ cellValue }: any) => cellValue || '-',
+ },
+ {
+ field: 'dataJson',
+ title: '閲囬泦鏁版嵁',
+ minWidth: 320,
+ slots: { default: 'dataJson' },
+ },
+ { field: 'taskId', title: '浠诲姟缂栧彿', width: 100 },
+ { field: 'workOrderId', title: '宸ュ崟缂栧彿', width: 100 },
+ ];
+}
+
+/** 鎶ヨ琛ㄦ牸鍒� */
+export function useAlarmGridColumns(): VxeTableGridOptions<MesCollectApi.CollectAlarm>['columns'] {
+ return [
+ { field: 'id', title: '缂栧彿', width: 90 },
+ { field: 'deviceCode', title: '鏁伴噰璁惧', width: 140 },
+ {
+ field: 'wmMsg',
+ title: '鎶ヨ鍐呭',
+ minWidth: 200,
+ formatter: ({ cellValue }: any) => cellValue || '-',
+ },
+ { field: 'wmTime', title: '鎶ヨ鏃堕棿', width: 170 },
+ {
+ field: 'statusName',
+ title: '鐘舵��',
+ width: 100,
+ slots: { default: 'status' },
+ },
+ { field: 'clearTime', title: '娑堥櫎鏃堕棿', width: 170 },
+ {
+ field: 'actions',
+ title: '鎿嶄綔',
+ width: 120,
+ fixed: 'right',
+ slots: { default: 'actions' },
+ },
+ ];
+}
diff --git a/src/views/mes/dv/collect/index.vue b/src/views/mes/dv/collect/index.vue
new file mode 100644
index 0000000..abbc449
--- /dev/null
+++ b/src/views/mes/dv/collect/index.vue
@@ -0,0 +1,483 @@
+<script lang="ts" setup>
+import type { MesCollectApi } from '#/api/mes/dv/collect';
+
+import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
+
+import { CountTo, Page, useVbenModal } from '@vben/common-ui';
+import { IconifyIcon } from '@vben/icons';
+
+import {
+ Badge,
+ Button,
+ Card,
+ Col,
+ Empty,
+ Input,
+ message,
+ Row,
+ Select,
+ Space,
+ Table,
+ Tag,
+ Tooltip,
+} from 'ant-design-vue';
+
+import { getCollectDeviceList } from '#/api/mes/dv/collect';
+
+import DetailModal from './modules/detail.vue';
+
+defineOptions({ name: 'MesDvCollect' });
+
+/** 鑷姩鍒锋柊闂撮殧锛堟绉掞級 */
+const REFRESH_INTERVAL = 10_000;
+
+const allRows = ref<MesCollectApi.CollectDevice[]>([]);
+const rows = ref<MesCollectApi.CollectDevice[]>([]);
+const loading = ref(false);
+const errorMsg = ref('');
+const lastRefresh = ref('');
+
+const keyword = ref('');
+const onlineFilter = ref<string | undefined>(undefined);
+const autoRefresh = ref(true);
+let timer: ReturnType<typeof setInterval> | undefined;
+
+const [DetailModalComp, detailModalApi] = useVbenModal({
+ connectedComponent: DetailModal,
+ destroyOnClose: true,
+});
+
+/** KPI 缁熻 */
+const kpi = computed(() => {
+ const total = allRows.value.length;
+ const online = allRows.value.filter((r) => r.online).length;
+ const alarm = allRows.value.reduce(
+ (s, r) => s + (r.activeAlarmCount ?? 0),
+ 0,
+ );
+ const running = allRows.value.filter((r) => r.sts === 2).length;
+ return { total, online, offline: total - online, alarm, running };
+});
+
+/** KPI 鍗$墖閰嶇疆 */
+const kpiCards = computed(() => [
+ {
+ label: '璁惧鎬绘暟',
+ value: kpi.value.total,
+ unit: '鍙�',
+ icon: 'lucide:monitor-cog',
+ color: '#409eff',
+ gradient: 'linear-gradient(135deg, #409eff, #66b1ff)',
+ sub: `杩愯 ${kpi.value.running} 鍙癭,
+ },
+ {
+ label: '鍦ㄧ嚎璁惧',
+ value: kpi.value.online,
+ unit: '鍙�',
+ icon: 'lucide:wifi',
+ color: '#67c23a',
+ gradient: 'linear-gradient(135deg, #67c23a, #85ce61)',
+ sub: `绂荤嚎 ${kpi.value.offline} 鍙癭,
+ },
+ {
+ label: '鏈秷闄ゆ姤璀�',
+ value: kpi.value.alarm,
+ unit: '鏉�',
+ icon: 'lucide:bell-ring',
+ color: kpi.value.alarm > 0 ? '#f56c6c' : '#909399',
+ gradient:
+ kpi.value.alarm > 0
+ ? 'linear-gradient(135deg, #f56c6c, #f89898)'
+ : 'linear-gradient(135deg, #909399, #b1b3b8)',
+ sub: kpi.value.alarm > 0 ? '闇�瑕佸鐞�' : '涓�鍒囨甯�',
+ },
+ {
+ label: '閲囬泦棰戠巼',
+ value: 10,
+ unit: '绉�',
+ icon: 'lucide:refresh-cw',
+ color: '#e6a23c',
+ gradient: 'linear-gradient(135deg, #e6a23c, #ebb563)',
+ sub: autoRefresh.value ? '鑷姩鍒锋柊涓�' : '宸叉殏鍋�',
+ },
+]);
+
+/** 鍔犺浇璁惧鍒楄〃 */
+async function load() {
+ loading.value = true;
+ errorMsg.value = '';
+ try {
+ const list = await getCollectDeviceList();
+ allRows.value = list || [];
+ applyFilter();
+ lastRefresh.value = new Date().toLocaleTimeString('zh-CN', {
+ hour12: false,
+ });
+ } catch (e: any) {
+ errorMsg.value = e?.message || '鍔犺浇鏁伴噰璁惧澶辫触锛岃閲嶈瘯';
+ allRows.value = [];
+ rows.value = [];
+ } finally {
+ loading.value = false;
+ }
+}
+
+/** 鍓嶇杩囨护 */
+function applyFilter() {
+ let list = allRows.value;
+ const kw = keyword.value.trim();
+ if (kw) {
+ list = list.filter(
+ (r) =>
+ r.machineryName?.includes(kw) ||
+ r.machineryCode?.includes(kw) ||
+ r.collectDeviceCode?.includes(kw),
+ );
+ }
+ if (onlineFilter.value !== undefined) {
+ const target = onlineFilter.value === 'online';
+ list = list.filter((r) => Boolean(r.online) === target);
+ }
+ rows.value = list;
+}
+
+/** 閲嶇疆绛涢�� */
+function handleReset() {
+ keyword.value = '';
+ onlineFilter.value = undefined;
+ applyFilter();
+}
+
+/** 鍒囨崲鑷姩鍒锋柊 */
+function toggleAutoRefresh() {
+ autoRefresh.value = !autoRefresh.value;
+ setupTimer();
+ message.info(
+ autoRefresh.value ? '宸插紑鍚嚜鍔ㄥ埛鏂帮紙10 绉掞級' : '宸插叧闂嚜鍔ㄥ埛鏂�',
+ );
+}
+
+function setupTimer() {
+ if (timer) {
+ clearInterval(timer);
+ timer = undefined;
+ }
+ if (autoRefresh.value) {
+ timer = setInterval(() => load(), REFRESH_INTERVAL);
+ }
+}
+
+/** 鎵撳紑璇︽儏 */
+function handleDetail(row: MesCollectApi.CollectDevice) {
+ detailModalApi
+ .setData({
+ deviceCode: row.collectDeviceCode,
+ machineryName: row.machineryName,
+ })
+ .open();
+}
+
+/** 瑙f瀽 dataJson */
+function parseData(row: any): Record<string, number | string> {
+ const raw = row.dataJson;
+ if (!raw) return {};
+ try {
+ const obj = JSON.parse(raw);
+ const out: Record<string, number | string> = {};
+ Object.keys(obj).forEach((k) => {
+ const v = obj[k];
+ out[k] =
+ typeof v === 'number'
+ ? Number.isInteger(v)
+ ? v
+ : Number(v.toFixed(2))
+ : v;
+ });
+ return out;
+ } catch {
+ return {};
+ }
+}
+
+/** 褰撳墠鏁版嵁鏍囩 */
+function dataTags(row: any) {
+ const data = parseData(row);
+ return Object.keys(data)
+ .slice(0, 3)
+ .map((k) => ({ key: k, value: data[k] }));
+}
+
+/** 琛ㄦ牸鍒� */
+const columns = [
+ {
+ title: '璁惧',
+ dataIndex: 'machineryName',
+ width: 170,
+ fixed: 'left' as const,
+ customRender: ({ record }: any) => record,
+ },
+ {
+ title: '鏁伴噰缂栫爜',
+ dataIndex: 'collectDeviceCode',
+ width: 130,
+ },
+ {
+ title: '鐘舵��',
+ dataIndex: 'online',
+ width: 110,
+ customRender: ({ record }: any) => record,
+ },
+ {
+ title: '褰撳墠鏁版嵁',
+ dataIndex: 'currentData',
+ minWidth: 300,
+ customRender: ({ record }: any) => record,
+ },
+ {
+ title: '鏈�杩戦噰闆�',
+ dataIndex: 'lastCollectTime',
+ width: 165,
+ },
+ {
+ title: '鎶ヨ',
+ dataIndex: 'activeAlarmCount',
+ width: 80,
+ align: 'center' as const,
+ customRender: ({ record }: any) => record,
+ },
+ {
+ title: '鎿嶄綔',
+ dataIndex: 'actions',
+ width: 90,
+ align: 'center' as const,
+ fixed: 'right' as const,
+ customRender: ({ record }: any) => record,
+ },
+];
+
+onMounted(() => {
+ load();
+ setupTimer();
+});
+
+onBeforeUnmount(() => {
+ if (timer) clearInterval(timer);
+});
+</script>
+
+<style scoped>
+:deep(.ant-table-thead > tr > th) {
+ background: #fafafa !important;
+ color: #606266;
+ font-weight: 600;
+}
+
+/* 琛ㄥご宸﹀唴杈硅窛锛岄伩鍏嶈创杈� */
+:deep(.ant-table-thead > tr > th:first-child) {
+ padding-left: 16px !important;
+}
+
+/* 鍗曞厓鏍煎乏鍐呰竟璺� */
+:deep(.ant-table-tbody > tr > td) {
+ padding-top: 12px;
+ padding-bottom: 12px;
+ padding-left: 16px;
+ padding-right: 16px;
+}
+
+/* 浜ゅ弶琛岃儗鏅� */
+:deep(.ant-table-tbody > tr:hover > td) {
+ background: #f5f7fa;
+}
+</style>
+
+<template>
+ <Page auto-content-height>
+ <DetailModalComp />
+
+ <!-- KPI 鍗$墖鍖� -->
+ <Row :gutter="16" class="mb-4">
+ <Col
+ v-for="card in kpiCards"
+ :key="card.label"
+ :lg="6"
+ :md="12"
+ :sm="12"
+ :xl="6"
+ :xs="24"
+ class="mb-4"
+ >
+ <Card class="h-full transition-all hover:shadow-lg">
+ <div class="flex items-center gap-4">
+ <div
+ class="flex size-14 flex-shrink-0 items-center justify-center rounded-xl text-white"
+ :style="{ background: card.gradient }"
+ >
+ <IconifyIcon class="size-7" :icon="card.icon" />
+ </div>
+ <div class="min-w-0 flex-1">
+ <div class="text-muted-foreground mb-1 text-sm">
+ {{ card.label }}
+ </div>
+ <div class="flex items-baseline gap-1">
+ <CountTo
+ class="text-2xl font-bold leading-tight"
+ :end-val="card.value"
+ :duration="1200"
+ :style="{ color: card.color }"
+ />
+ <span class="text-muted-foreground text-xs">{{ card.unit }}</span>
+ </div>
+ <div class="text-muted-foreground mt-1 text-xs">
+ {{ card.sub }}
+ </div>
+ </div>
+ </div>
+ </Card>
+ </Col>
+ </Row>
+
+ <!-- 宸ュ叿鏍忥細鍗曡绱у噾甯冨眬 -->
+ <div class="mb-3 flex items-center gap-2">
+ <Input
+ v-model:value="keyword"
+ style="width: 200px"
+ placeholder="璁惧鍚嶇О / 缂栫爜"
+ allow-clear
+ @press-enter="applyFilter"
+ >
+ <template #prefix>
+ <IconifyIcon class="text-gray-400" icon="lucide:search" />
+ </template>
+ </Input>
+
+ <Select
+ v-model:value="onlineFilter"
+ style="width: 110px"
+ allow-clear
+ placeholder="鍏ㄩ儴鐘舵��"
+ :options="[
+ { label: '鍦ㄧ嚎', value: 'online' },
+ { label: '绂荤嚎', value: 'offline' },
+ ]"
+ />
+
+ <Button type="primary" :loading="loading" @click="load">鏌ヨ</Button>
+ <Button @click="handleReset">閲嶇疆</Button>
+
+ <Button
+ :type="autoRefresh ? 'default' : 'dashed'"
+ @click="toggleAutoRefresh"
+ >
+ <template #icon>
+ <IconifyIcon :icon="autoRefresh ? 'lucide:pause' : 'lucide:play'" />
+ </template>
+ {{ autoRefresh ? '鏆傚仠' : '鑷姩鍒锋柊' }}
+ </Button>
+
+ <span v-if="lastRefresh" class="text-muted-foreground ml-auto text-xs">
+ 鏇存柊浜� {{ lastRefresh }}
+ </span>
+ </div>
+
+ <!-- 閿欒鎻愮ず -->
+ <div
+ v-if="errorMsg"
+ class="mb-4 flex items-center gap-2 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600"
+ >
+ <IconifyIcon icon="lucide:alert-circle" />
+ {{ errorMsg }}
+ </div>
+
+ <!-- 鏁版嵁琛ㄦ牸锛歠lex-1 + min-h-0 璁╄〃鏍煎尯鑷�傚簲鍓╀綑楂樺害骞跺彲婊氬姩 -->
+ <div class="flex min-h-0 flex-1 flex-col">
+ <Table
+ :columns="columns"
+ :data-source="rows"
+ :loading="loading"
+ :pagination="{
+ pageSize: 20,
+ showSizeChanger: true,
+ showTotal: (t: number) => `鍏� ${t} 鍙拌澶嘸,
+ }"
+ :row-key="(r: any) => r.machineryId"
+ size="middle"
+ :scroll="{ x: 1100 }"
+ class="flex-1"
+ :header-cell-style="{
+ background: '#fafafa',
+ color: '#606266',
+ fontWeight: 600,
+ padding: '12px 16px',
+ whiteSpace: 'nowrap',
+ }"
+ :cell-style="{ padding: '12px 16px' }"
+ >
+ <template #bodyCell="{ column, record }">
+ <!-- 璁惧鍚嶇О -->
+ <template v-if="column.dataIndex === 'machineryName'">
+ <a class="flex flex-col" @click="handleDetail(record)">
+ <span class="font-medium text-blue-600 hover:text-blue-700">
+ {{ record.machineryName }}
+ </span>
+ <span class="text-muted-foreground text-xs">
+ {{ record.machineryCode }}
+ </span>
+ </a>
+ </template>
+
+ <!-- 鍦ㄧ嚎鐘舵�� -->
+ <template v-else-if="column.dataIndex === 'online'">
+ <Badge
+ :status="record.online ? 'success' : 'default'"
+ :text="record.online ? '鍦ㄧ嚎' : '绂荤嚎'"
+ />
+ </template>
+
+ <!-- 褰撳墠鏁版嵁 -->
+ <template v-else-if="column.dataIndex === 'currentData'">
+ <div v-if="dataTags(record).length > 0" class="flex flex-wrap gap-1">
+ <Tag
+ v-for="tag in dataTags(record)"
+ :key="tag.key"
+ class="!m-0 font-mono text-xs"
+ color="blue"
+ >
+ {{ tag.key }}: {{ tag.value }}
+ </Tag>
+ </div>
+ <span v-else class="text-gray-400 text-xs">鏆傛棤鏁版嵁</span>
+ </template>
+
+ <!-- 鎶ヨ鏁� -->
+ <template v-else-if="column.dataIndex === 'activeAlarmCount'">
+ <Tooltip
+ v-if="(record.activeAlarmCount ?? 0) > 0"
+ :title="`${record.activeAlarmCount} 鏉℃湭娑堥櫎鎶ヨ`"
+ >
+ <Tag color="red" class="!m-0 cursor-pointer">
+ <IconifyIcon class="mr-0.5 inline" icon="lucide:bell" />
+ {{ record.activeAlarmCount }}
+ </Tag>
+ </Tooltip>
+ <span v-else class="text-gray-300">鈥�</span>
+ </template>
+
+ <!-- 鎿嶄綔 -->
+ <template v-else-if="column.dataIndex === 'actions'">
+ <Button type="link" size="small" @click="handleDetail(record)">
+ 璇︽儏
+ </Button>
+ </template>
+ </template>
+
+ <template #emptyText>
+ <Empty
+ :image="Empty.PRESENTED_IMAGE_SIMPLE"
+ description="鏆傛棤鏁伴噰璁惧"
+ />
+ </template>
+ </Table>
+ </div>
+ </Page>
+</template>
diff --git a/src/views/mes/dv/collect/modules/detail.vue b/src/views/mes/dv/collect/modules/detail.vue
new file mode 100644
index 0000000..beef727
--- /dev/null
+++ b/src/views/mes/dv/collect/modules/detail.vue
@@ -0,0 +1,298 @@
+<script lang="ts" setup>
+import type { MesCollectApi } from '#/api/mes/dv/collect';
+
+import { computed, ref } from 'vue';
+
+import { useVbenModal } from '@vben/common-ui';
+import { IconifyIcon } from '@vben/icons';
+
+import {
+ Button,
+ Card,
+ DatePicker,
+ Descriptions,
+ Empty,
+ message,
+ Spin,
+ Table,
+ Tabs,
+ Tag,
+} from 'ant-design-vue';
+
+import {
+ ackCollectAlarm,
+ getCollectAlarmPage,
+ getCollectRealtimeHistoryPage,
+} from '#/api/mes/dv/collect';
+
+defineOptions({ name: 'MesDvCollectDetail' });
+
+const deviceCode = ref('');
+const machineryName = ref('');
+const activeTab = ref('history');
+
+const historyLoading = ref(false);
+const historyList = ref<MesCollectApi.CollectRealtime[]>([]);
+const historyTotal = ref(0);
+const historyPage = ref(1);
+const historyPageSize = ref(20);
+const timeRange = ref<[string, string] | undefined>();
+
+const alarmLoading = ref(false);
+const alarmList = ref<MesCollectApi.CollectAlarm[]>([]);
+const alarmTotal = ref(0);
+const alarmPage = ref(1);
+const alarmPageSize = ref(10);
+
+const [Modal, modalApi] = useVbenModal({
+ onOpenChange(isOpen) {
+ if (!isOpen) return;
+ const data = modalApi.getData<{
+ deviceCode: string;
+ machineryName: string;
+ }>();
+ deviceCode.value = data?.deviceCode || '';
+ machineryName.value = data?.machineryName || '';
+ historyPage.value = 1;
+ alarmPage.value = 1;
+ timeRange.value = undefined;
+ activeTab.value = 'history';
+ loadHistory();
+ loadAlarm();
+ },
+});
+
+/** 瑙f瀽 dataJson */
+function parseData(raw?: string): Record<string, number | string> {
+ if (!raw) return {};
+ try {
+ const obj = JSON.parse(raw);
+ const out: Record<string, number | string> = {};
+ Object.keys(obj).forEach((k) => {
+ const v = obj[k];
+ out[k] =
+ typeof v === 'number'
+ ? Number.isInteger(v)
+ ? v
+ : Number(v.toFixed(2))
+ : v;
+ });
+ return out;
+ } catch {
+ return {};
+ }
+}
+
+/** 鍔犺浇鍘嗗彶 */
+async function loadHistory() {
+ if (!deviceCode.value) return;
+ historyLoading.value = true;
+ try {
+ const params: any = {
+ pageNo: historyPage.value,
+ pageSize: historyPageSize.value,
+ deviceCode: deviceCode.value,
+ };
+ if (timeRange.value?.length === 2) {
+ params.collectTime = timeRange.value;
+ }
+ const result = await getCollectRealtimeHistoryPage(params);
+ historyList.value = result.list || [];
+ historyTotal.value = result.total || 0;
+ } catch {
+ message.error('鍔犺浇鍘嗗彶鏁版嵁澶辫触');
+ } finally {
+ historyLoading.value = false;
+ }
+}
+
+/** 鍔犺浇鎶ヨ */
+async function loadAlarm() {
+ if (!deviceCode.value) return;
+ alarmLoading.value = true;
+ try {
+ const result = await getCollectAlarmPage({
+ pageNo: alarmPage.value,
+ pageSize: alarmPageSize.value,
+ deviceCode: deviceCode.value,
+ });
+ alarmList.value = result.list || [];
+ alarmTotal.value = result.total || 0;
+ } catch {
+ message.error('鍔犺浇鎶ヨ璁板綍澶辫触');
+ } finally {
+ alarmLoading.value = false;
+ }
+}
+
+/** 纭娑堥櫎 */
+async function handleAck(row: MesCollectApi.CollectAlarm) {
+ try {
+ await ackCollectAlarm(row.id!);
+ message.success('宸茬‘璁ゆ秷闄�');
+ loadAlarm();
+ } catch {
+ message.error('鎿嶄綔澶辫触');
+ }
+}
+
+function handleTimeChange(val: any) {
+ timeRange.value = val;
+ historyPage.value = 1;
+ loadHistory();
+}
+
+/** 鍘嗗彶鍒� */
+const historyColumns = [
+ { title: '閲囬泦鏃堕棿', dataIndex: 'collectTime', width: 170 },
+ {
+ title: '閲囬泦鏁版嵁',
+ dataIndex: 'dataJson',
+ ellipsis: true,
+ },
+];
+
+/** 鎶ヨ鍒� */
+const alarmColumns = [
+ { title: '鎶ヨ鏃堕棿', dataIndex: 'wmTime', width: 170 },
+ { title: '鎶ヨ鍐呭', dataIndex: 'wmMsg', ellipsis: true },
+ { title: '鐘舵��', dataIndex: 'status', width: 100 },
+ { title: '鎿嶄綔', dataIndex: 'actions', width: 110, align: 'center' as const },
+];
+
+const historyPagination = computed(() => ({
+ current: historyPage.value,
+ pageSize: historyPageSize.value,
+ total: historyTotal.value,
+ showSizeChanger: true,
+ size: 'small' as const,
+ showTotal: (t: number) => `鍏� ${t} 鏉,
+}));
+
+const alarmPagination = computed(() => ({
+ current: alarmPage.value,
+ pageSize: alarmPageSize.value,
+ total: alarmTotal.value,
+ showSizeChanger: true,
+ size: 'small' as const,
+ showTotal: (t: number) => `鍏� ${t} 鏉,
+}));
+
+function handleHistoryChange(p: any) {
+ historyPage.value = p.current;
+ historyPageSize.value = p.pageSize;
+ loadHistory();
+}
+
+function handleAlarmChange(p: any) {
+ alarmPage.value = p.current;
+ alarmPageSize.value = p.pageSize;
+ loadAlarm();
+}
+</script>
+
+<template>
+ <Modal :title="`${machineryName} 路 璁惧璇︽儏`" class="w-[1100px]">
+ <div class="mb-4 flex items-center gap-3 rounded-lg bg-gray-50 p-3">
+ <IconifyIcon class="text-blue-500" icon="lucide:cpu" />
+ <span class="text-sm">
+ 鏁伴噰缂栫爜锛�<b class="font-mono">{{ deviceCode }}</b>
+ </span>
+ <span class="text-muted-foreground ml-auto text-xs">
+ 璁惧鍚嶇О锛歿{ machineryName }}
+ </span>
+ </div>
+
+ <Tabs v-model:active-key="activeTab" type="card">
+ <Tabs.TabPane key="history" tab="閲囬泦鍘嗗彶">
+ <div class="mb-3 flex items-center gap-3">
+ <span class="text-sm">鏃堕棿鑼冨洿锛�</span>
+ <DatePicker.RangePicker
+ show-time
+ format="YYYY-MM-DD HH:mm:ss"
+ value-format="YYYY-MM-DD HH:mm:ss"
+ @change="handleTimeChange"
+ />
+ <Button size="small" @click="loadHistory">
+ <template #icon>
+ <IconifyIcon icon="lucide:refresh-cw" />
+ </template>
+ 鍒锋柊
+ </Button>
+ </div>
+
+ <Spin :spinning="historyLoading">
+ <Table
+ v-if="historyList.length > 0"
+ :columns="historyColumns"
+ :data-source="historyList"
+ :pagination="historyPagination"
+ :row-key="(r: any) => r.id"
+ size="small"
+ :scroll="{ y: 380 }"
+ @change="handleHistoryChange"
+ >
+ <template #bodyCell="{ column, record }">
+ <template v-if="column.dataIndex === 'dataJson'">
+ <div class="flex flex-wrap gap-1">
+ <Tag
+ v-for="(v, k) in parseData(record.dataJson)"
+ :key="k"
+ class="!m-0 font-mono text-xs"
+ color="blue"
+ >
+ {{ k }}: {{ v }}
+ </Tag>
+ </div>
+ </template>
+ </template>
+ </Table>
+ <Empty
+ v-else
+ :image="Empty.PRESENTED_IMAGE_SIMPLE"
+ description="鏆傛棤閲囬泦鍘嗗彶"
+ />
+ </Spin>
+ </Tabs.TabPane>
+
+ <Tabs.TabPane key="alarm" :tab="`鎶ヨ璁板綍 (${alarmTotal})`">
+ <Spin :spinning="alarmLoading">
+ <Table
+ v-if="alarmList.length > 0"
+ :columns="alarmColumns"
+ :data-source="alarmList"
+ :pagination="alarmPagination"
+ :row-key="(r: any) => r.id"
+ size="small"
+ :scroll="{ y: 380 }"
+ @change="handleAlarmChange"
+ >
+ <template #bodyCell="{ column, record }">
+ <template v-if="column.dataIndex === 'status'">
+ <Tag :color="record.status === 0 ? 'red' : 'default'">
+ {{ record.status === 0 ? '鏈秷闄�' : '宸叉秷闄�' }}
+ </Tag>
+ </template>
+ <template v-else-if="column.dataIndex === 'actions'">
+ <Button
+ v-if="record.status === 0"
+ type="link"
+ size="small"
+ @click="handleAck(record)"
+ >
+ 纭娑堥櫎
+ </Button>
+ <span v-else class="text-gray-400">-</span>
+ </template>
+ </template>
+ </Table>
+ <Empty
+ v-else
+ :image="Empty.PRESENTED_IMAGE_SIMPLE"
+ description="鏆傛棤鎶ヨ璁板綍"
+ />
+ </Spin>
+ </Tabs.TabPane>
+ </Tabs>
+ </Modal>
+</template>
--
Gitblit v1.9.3