#
Junjie
16 小时以前 b37e141c00a123cf362fae00c1e63175d41c4bbe
src/main/webapp/views/index.html
@@ -1,6 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>浙江中扬 - 自动化立体仓库 - WCS</title>
@@ -8,43 +7,498 @@
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../static/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../static/css/admin.css?v=318" media="all">
  <link rel="stylesheet" href="../static/css/loader.css" media="all">
  <link rel="stylesheet" href="../static/vue/element/element.css">
  <style>
    .layui-logo img {
      width: 25px;
    [v-cloak] {
      display: none;
    }
    .layui-logo cite {
      font-size: 18px;
      font-weight: 400;
      /*margin-left: 5px;*/
    }
    /* 弹窗样式 */
    .popup {
      position: fixed;
      top: 0;
      left: 0;
    html,
    body,
    #app {
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.5);
      display: none;
      justify-content: center;
      align-items: center;
      z-index: 9999;
      margin: 0;
      overflow: hidden;
    }
    .popup-content {
      background-color: #fff;
      padding: 20px;
      border-radius: 5px;
      box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.3);
    body {
      font-family: "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
      background: linear-gradient(180deg, #f3f6fb 0%, #e9eef6 100%);
      color: #1f2d3d;
    }
    .shell-container {
      height: 100%;
      padding: 12px;
      box-sizing: border-box;
      gap: 12px;
      background: transparent;
    }
    .layout-aside {
      position: relative;
      flex-shrink: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      border-radius: 16px;
      background: linear-gradient(180deg, #16324d 0%, #0d2237 100%);
      box-shadow: 0 14px 32px rgba(22, 50, 77, 0.18);
      transform: translateZ(0);
      backface-visibility: hidden;
      will-change: width;
      transition: width 0.22s cubic-bezier(0.22, 1, 0.36, 1),
      box-shadow 0.22s ease;
    }
    .layout-aside.is-animating {
      pointer-events: none;
    }
    .layout-panel {
      display: flex;
      flex-direction: column;
      min-width: 0;
      height: 100%;
      overflow: hidden;
      border-radius: 16px;
      background: #f5f7fa;
      box-shadow: 0 14px 32px rgba(83, 104, 129, 0.12);
      border: 1px solid #e4eaf2;
      transform: translateZ(0);
      backface-visibility: hidden;
    }
    .aside-logo {
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 78px;
      padding: 18px 16px 16px;
      box-sizing: border-box;
      color: #fff;
      border-bottom: 1px solid rgba(255, 255, 255, 0.08);
      transition: min-height 0.22s cubic-bezier(0.22, 1, 0.36, 1),
      padding 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    }
    .aside-logo-image {
      display: block;
      width: 100%;
      max-width: 178px;
      height: auto;
      object-fit: contain;
      transform: translateZ(0);
      transition: max-width 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    }
    .aside-logo.is-collapse {
      min-height: 64px;
      padding: 16px 10px 14px;
    }
    .aside-logo.is-collapse .aside-logo-image {
      max-width: 42px;
    }
    .aside-search {
      padding: 12px 12px 8px;
      box-sizing: border-box;
    }
    .aside-fade-enter-active,
    .aside-fade-leave-active {
      transition: opacity 0.14s ease, transform 0.18s ease;
    }
    .aside-fade-enter,
    .aside-fade-leave-to {
      opacity: 0;
      transform: translate3d(-10px, 0, 0);
    }
    .aside-search .el-input__inner {
      height: 36px;
      line-height: 36px;
      border: 1px solid rgba(255, 255, 255, 0.10);
      background: rgba(255, 255, 255, 0.08);
      color: #fff;
    }
    .aside-search .el-input__inner::placeholder {
      color: rgba(255, 255, 255, 0.48);
    }
    .aside-search .el-input__prefix {
      color: rgba(255, 255, 255, 0.58);
    }
    .aside-scroll {
      flex: 1;
      min-height: 0;
      transform: translateZ(0);
    }
    .aside-scroll .el-scrollbar__wrap {
      overflow-x: hidden;
    }
    .side-menu {
      border-right: none;
      background: transparent;
      transform: translateZ(0);
    }
    .side-menu .el-submenu__title,
    .side-menu .el-menu-item {
      height: 46px;
      line-height: 46px;
      margin: 0 10px 6px;
      border-radius: 10px;
      box-sizing: border-box;
      backface-visibility: hidden;
    }
    .side-menu .el-submenu__title:hover,
    .side-menu .el-menu-item:hover {
      background: rgba(255, 255, 255, 0.08) !important;
      color: #fff !important;
    }
    .side-menu .el-menu-item.is-active {
      background: linear-gradient(90deg, #3a7afe 0%, #2867e0 100%) !important;
      color: #fff !important;
      box-shadow: 0 8px 18px rgba(40, 103, 224, 0.26);
    }
    .side-menu .el-submenu .el-menu {
      background: transparent;
    }
    .side-menu.el-menu--collapse .el-submenu__title,
    .side-menu.el-menu--collapse .el-menu-item {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 !important;
      text-align: center;
    }
    /* AI助手抽屉动画 */
    .side-menu.el-menu--collapse .el-submenu__title > i:not(.el-submenu__icon-arrow),
    .side-menu.el-menu--collapse .el-menu-item [class^="el-icon-"],
    .side-menu.el-menu--collapse .el-menu-item [class*=" el-icon-"] {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
      margin: 0 !important;
      width: 100%;
      font-size: 22px;
      line-height: 1;
      text-align: center;
    }
    .side-menu.el-menu--collapse .el-submenu__icon-arrow {
      display: none !important;
    }
    .el-menu--popup {
      min-width: 188px;
      padding: 8px;
      border: none;
      border-radius: 14px;
      background: linear-gradient(180deg, #16324d 0%, #0d2237 100%) !important;
      box-shadow: 0 16px 32px rgba(13, 34, 55, 0.28);
    }
    .el-menu--popup .el-menu-item,
    .el-menu--popup .el-submenu__title {
      height: 44px;
      line-height: 44px;
      margin: 0 0 6px;
      border-radius: 10px;
      color: #c6d1df;
      background: transparent !important;
    }
    .el-menu--popup .el-menu-item:last-child,
    .el-menu--popup .el-submenu__title:last-child {
      margin-bottom: 0;
    }
    .el-menu--popup .el-menu-item:hover,
    .el-menu--popup .el-submenu__title:hover {
      color: #fff !important;
      background: rgba(255, 255, 255, 0.08) !important;
    }
    .el-menu--popup .el-menu-item.is-active {
      color: #fff !important;
      background: linear-gradient(90deg, #3a7afe 0%, #2867e0 100%) !important;
      box-shadow: 0 8px 18px rgba(40, 103, 224, 0.26);
    }
    .el-menu--popup .el-submenu__icon-arrow,
    .el-menu--popup [class^="el-icon-"],
    .el-menu--popup [class*=" el-icon-"] {
      color: inherit;
    }
    .side-menu .el-submenu__icon-arrow,
    .side-menu [class^="el-icon-"],
    .side-menu [class*=" el-icon-"] {
      color: inherit;
    }
    .aside-empty {
      padding: 24px 12px;
    }
    .aside-empty .el-empty__description p {
      color: rgba(255, 255, 255, 0.58);
    }
    .aside-loading {
      padding: 4px 12px 12px;
      box-sizing: border-box;
    }
    .aside-skeleton-item {
      position: relative;
      height: 46px;
      margin: 0 10px 6px;
      overflow: hidden;
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.08);
    }
    .aside-skeleton-item::after {
      content: "";
      position: absolute;
      inset: 0;
      transform: translateX(-100%);
      background: linear-gradient(90deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0.16) 48%,
      rgba(255, 255, 255, 0) 100%);
      animation: asideSkeletonShimmer 1.25s ease-in-out infinite;
    }
    .aside-skeleton-item:nth-child(3n) {
      width: calc(100% - 28px);
    }
    .aside-skeleton-item:nth-child(4n + 2) {
      width: calc(100% - 44px);
    }
    .aside-skeleton-item:nth-child(5n) {
      width: calc(100% - 36px);
    }
    .aside-footer {
      padding: 14px 16px 16px;
      border-top: 1px solid rgba(255, 255, 255, 0.08);
      color: rgba(255, 255, 255, 0.72);
      font-size: 12px;
      line-height: 1.7;
    }
    .aside-footer-copy {
      margin-bottom: 8px;
      color: rgba(255, 255, 255, 0.62);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .aside-footer-version {
      display: flex;
      align-items: center;
      gap: 8px;
      color: #fff;
    }
    .aside-footer-version-text {
      flex: 1;
      min-width: 0;
      font-size: 13px;
      font-weight: 500;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .header-bar {
      height: 60px !important;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 0 16px;
      box-sizing: border-box;
      background: #fff;
      border-bottom: 1px solid #e8edf5;
    }
    .header-left {
      min-width: 0;
      display: flex;
      align-items: center;
      gap: 12px;
    }
    .header-title-group {
      min-width: 0;
    }
    .header-title {
      color: #303133;
      font-size: 18px;
      font-weight: 600;
      line-height: 1.2;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .header-right {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 8px;
      flex-shrink: 0;
    }
    .lang-select {
      width: 160px;
    }
    .header-right .el-tag {
      border-radius: 999px;
    }
    .header-tag-clickable {
      cursor: pointer;
    }
    .user-dropdown {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      height: 38px;
      padding: 0 10px 0 6px;
      border: 1px solid #dce3ed;
      border-radius: 999px;
      background: #fff;
      cursor: pointer;
      user-select: none;
    }
    .user-name {
      display: inline-block;
      max-width: 96px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: #303133;
      font-size: 13px;
    }
    .tabs-row {
      display: flex;
      align-items: flex-end;
      gap: 10px;
      flex-shrink: 0;
      padding: 0 12px;
      background: #fff;
      border-bottom: 1px solid #e8edf5;
      box-sizing: border-box;
    }
    .page-tabs {
      flex: 1;
      min-width: 0;
    }
    .page-tabs .el-tabs__header {
      margin: 0;
    }
    .page-tabs .el-tabs__nav-wrap::after {
      height: 0;
    }
    .page-tabs .el-tabs__item {
      height: 38px;
      line-height: 38px;
    }
    .tabs-tools {
      display: flex;
      align-items: center;
      gap: 8px;
      padding-bottom: 6px;
      flex-shrink: 0;
    }
    .content-main {
      display: flex;
      flex: 1;
      padding: 12px;
      box-sizing: border-box;
      background: #f5f7fa;
      min-height: 0;
      overflow: hidden;
    }
    .frame-wrapper {
      flex: 1;
      position: relative;
      min-height: 0;
      overflow: hidden;
      border-radius: 12px;
      border: 1px solid #e5ebf3;
      background: #fff;
    }
    .page-frame {
      width: 100%;
      height: 100%;
      border: 0;
      display: block;
      background: #fff;
    }
    .page-loading {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      z-index: 10;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      background: rgba(255, 255, 255, 0.92);
      color: #606266;
      font-size: 14px;
    }
    .page-loading i {
      font-size: 18px;
      color: #409eff;
    }
    .license-dialog-text {
      color: #303133;
      font-size: 15px;
      line-height: 1.8;
      word-break: break-word;
    }
    @keyframes slideInRight {
      from {
        transform: translate3d(100%, 0, 0);
@@ -69,6 +523,12 @@
      }
    }
    @keyframes asideSkeletonShimmer {
      100% {
        transform: translateX(100%);
      }
    }
    .ai-drawer-layer {
      box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15) !important;
      border-radius: 8px 0 0 8px !important;
@@ -79,405 +539,1426 @@
    .ai-drawer-layer-close {
      animation: slideOutRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
    }
    .ai-assistant-btn {
      position: fixed;
      right: 20px;
      bottom: 40px;
      z-index: 9999;
      cursor: pointer;
    }
    @media (max-width: 1440px) {
      .user-name {
        max-width: 72px;
      }
    }
    @media (max-width: 1280px) {
      .header-right .el-tag {
        display: none;
      }
    }
  </style>
</head>
<body>
<div id="app" v-cloak>
  <el-container class="shell-container">
    <el-aside
        class="layout-aside"
        :class="{ 'is-animating': collapseAnimating }"
        :width="asideWidth">
      <div class="aside-logo" :class="{ 'is-collapse': asideCompact }">
        <img class="aside-logo-image" src="../static/images/zy-logo.png" alt="浙江中扬">
      </div>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <!-- 头部 -->
  <div class="layui-header">
    <div class="layui-logo">
      <img src="../static/images/zy-logo-dark.png" style="display: inline-block; width: 60%;height: auto">
      <!--          <span style="margin-top: 0; letter-spacing: 10px">中扬立库</span>-->
      <!--          <img src="../static/image/logo.svg"/>-->
      <!--          <cite>中扬 - Zoneyung</cite>-->
    </div>
      <transition name="aside-fade">
        <div class="aside-search" v-show="showAsideExtras">
          <el-input
              v-model.trim="menuKeyword"
              size="small"
              clearable
              prefix-icon="el-icon-search"
              :placeholder="t('index.searchMenu')">
          </el-input>
        </div>
      </transition>
    <ul class="layui-nav layui-layout-left">
      <li class="layui-nav-item" lay-unselect>
        <a ew-event="flexible" title="侧边伸缩"><i class="layui-icon layui-icon-shrink-right"></i></a>
      </li>
      <li class="layui-nav-item" lay-unselect>
        <a ew-event="refresh" title="刷新"><i class="layui-icon layui-icon-refresh-3"></i></a>
      </li>
    </ul>
    <ul class="layui-nav layui-layout-right">
      <!--      <li class="layui-nav-item" lay-unselect>-->
      <!--        <a ew-event="note" title="便签"><i class="layui-icon layui-icon-note"></i></a>-->
      <!--      </li>-->
      <li class="layui-nav-item" lay-unselect id="fakeShow"
          style="display: none;user-select: none;margin-right: 10px;">
        <div style="color: red;" id="fakeShowText">仿真模拟运行中</div>
      </li>
      <li class="layui-nav-item" lay-unselect id="licenseShow" style="display: none;user-select: none;">
        <div style="color: red;">临时许可证有效期:<span id="licenseDays">29</span>天</div>
      </li>
      <li class="layui-nav-item layui-hide-xs" lay-unselect>
        <a ew-event="fullScreen" title="全屏"><i class="layui-icon layui-icon-screen-full"></i></a>
      </li>
      <li class="layui-nav-item" lay-unselect>
        <a>
          <cite id="username" style="margin-right: 5px">管理员</cite>
        </a>
        <dl class="layui-nav-child">
          <dd lay-unselect><a ew-href="detail.html?resourceId=8">基本资料</a></dd>
          <hr>
          <dd lay-unselect><a id="logout">退出</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item" lay-unselect>
        <a ew-event="theme" title="主题"><i class="layui-icon layui-icon-more-vertical"></i></a>
      </li>
    </ul>
      <el-scrollbar class="aside-scroll">
        <div v-if="menuLoading" class="aside-loading" aria-hidden="true">
          <div
              v-for="n in 8"
              :key="'menu-skeleton-' + n"
              class="aside-skeleton-item">
          </div>
        </div>
        <template v-else>
          <el-menu
              ref="sideMenu"
              class="side-menu"
              :default-active="activeMenuKey"
              :collapse="menuCollapse"
              :collapse-transition="false"
              :default-openeds="defaultOpeneds"
              unique-opened
              background-color="transparent"
              text-color="#c6d1df"
              active-text-color="#ffffff">
            <el-submenu
                v-for="group in filteredMenus"
                :key="'group-' + group.menuId"
                :index="'group-' + group.menuId">
              <template slot="title">
                <i :class="resolveMenuIcon(group.menuCode)"></i>
                <span>{{ group.menu }}</span>
              </template>
              <el-menu-item
                  v-for="item in group.subMenu"
                  :key="item.tabKey"
                  :index="item.tabKey"
                  @click="handleMenuSelect(group, item)">
                {{ item.name }}
              </el-menu-item>
            </el-submenu>
          </el-menu>
          <div class="aside-empty" v-if="filteredMenus.length === 0">
            <el-empty
                :image-size="80"
                :description="menuKeyword ? t('index.noMatchedMenu') : t('index.noAvailableMenu')">
            </el-empty>
          </div>
        </template>
      </el-scrollbar>
      <transition name="aside-fade">
        <div class="aside-footer" v-show="showAsideExtras">
          <div class="aside-footer-copy">© 2026 {{ t('app.company') }}</div>
          <div class="aside-footer-version">
            <span class="aside-footer-version-text">{{ versionText }}</span>
            <el-tag
                v-if="versionType"
                size="mini"
                :type="versionTagType"
                effect="dark">
              {{ versionTypeTag }}
            </el-tag>
          </div>
        </div>
      </transition>
    </el-aside>
    <el-container class="layout-panel">
      <el-header class="header-bar">
        <div class="header-left">
          <el-button
              circle
              size="mini"
              :icon="isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'"
              @click="toggleCollapse">
          </el-button>
          <div class="header-title-group">
            <div class="header-title">{{ activeTabTitle }}</div>
          </div>
        </div>
        <div class="header-right">
          <el-tag
              v-if="licenseDisplayVisible"
              size="mini"
              :type="licenseTagType"
              effect="dark">
            {{ t('index.licenseDays', [licenseDays]) }}
          </el-tag>
          <el-tag
              v-if="fakeVisible"
              class="header-tag-clickable"
              size="mini"
              :type="fakeRunning ? 'danger' : 'info'"
              effect="dark"
              @click.native="toggleFakeSystem">
            {{ fakeRunning ? t('index.fakeRunning') : t('index.fakeStopped') }}
          </el-tag>
          <el-select
              v-model="currentLocale"
              size="mini"
              class="lang-select"
              @change="handleLocaleChange">
            <el-option
                v-for="item in localeOptions"
                :key="item.tag"
                :label="item.label"
                :value="item.tag">
            </el-option>
          </el-select>
          <el-button circle size="mini" icon="el-icon-refresh" @click="refreshActiveTab"></el-button>
          <el-button circle size="mini" icon="el-icon-full-screen" @click="toggleFullScreen"></el-button>
          <el-dropdown trigger="click" @command="handleUserCommand">
            <span class="user-dropdown">
              <el-avatar size="small">{{ userShortName }}</el-avatar>
              <span class="user-name" id="person-username">{{ userName }}</span>
              <i class="el-icon-arrow-down"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="profile">{{ t('common.profile') }}</el-dropdown-item>
              <el-dropdown-item command="logout" divided>{{ t('common.logout') }}</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <div class="tabs-row">
        <el-tabs
            class="page-tabs"
            v-model="activeTab"
            type="card"
            @tab-remove="removeTab">
          <el-tab-pane
              v-for="tab in tabs"
              :key="tab.name"
              :label="tab.title"
              :name="tab.name"
              :closable="!tab.home">
          </el-tab-pane>
        </el-tabs>
        <div class="tabs-tools">
          <el-tooltip :content="t('common.closeOtherTabs')" placement="top">
            <el-button size="mini" icon="el-icon-close" @click="closeOtherTabs"></el-button>
          </el-tooltip>
          <el-tooltip :content="t('common.backHome')" placement="top">
            <el-button size="mini" type="primary" icon="el-icon-house" @click="openHomeTab"></el-button>
          </el-tooltip>
        </div>
      </div>
      <el-main class="content-main">
        <div class="frame-wrapper">
          <div class="page-loading" v-if="pageLoading">
            <i class="el-icon-loading"></i>
            <span>{{ loadingText }}</span>
          </div>
          <iframe
              v-for="tab in tabs"
              :key="'frame-' + tab.name"
              class="page-frame"
              :data-tab-name="tab.name"
              v-show="activeTab === tab.name"
              :src="tab.currentSrc"
              @load="handleFrameLoad(tab.name)">
          </iframe>
        </div>
      </el-main>
    </el-container>
  </el-container>
  <el-dialog
      :title="t('index.licenseExpiring')"
      :visible.sync="licenseDialogVisible"
      width="420px"
      :close-on-click-modal="false">
    <div class="license-dialog-text">{{ licenseDialogText }}</div>
    <span slot="footer">
      <el-button type="primary" @click="licenseDialogVisible = false">{{ t('common.ok') }}</el-button>
    </span>
  </el-dialog>
  <div
      id="ai-assistant-btn"
      class="ai-assistant-btn"
      @mouseenter="showAiTip"
      @mouseleave="hideAiTip"
      @click="openAiAssistant">
  </div>
  <!-- 侧边栏 -->
  <div class="layui-side">
    <div class="layui-side-scroll">
      <ul id="menu-main" class="layui-nav layui-nav-tree arrow2" lay-filter="admin-side-nav" lay-shrink="_all">
      </ul>
    </div>
  </div>
  <!-- 主体部分 -->
  <div class="layui-body"></div>
  <!-- 底部 -->
  <div class="layui-footer layui-text">
    copyright © 2026 浙江中扬立库技术有限公司 all rights reserved.
    <span class="pull-right" id="system-version">Version loading...</span>
  </div>
</div>
<!--初始化加载层-->
<div class="layuimini-loader">
  <div class="layuimini-loader-inner"></div>
</div>
<!-- 弹窗内容 -->
<div class="popup" id="popup">
  <div class="popup-content">
    <h2 style="font-size: 28px;margin-bottom: 10px;">许可证即将过期</h2>
    <div id="popup-text" style="font-size: 28px;color: red"></div>
    <button
            style="background-color: #007bff;color: #fff;border: none;padding: 10px 20px;border-radius: 5px;cursor: pointer;font-size: 16px;"
            onclick="hidePopup()">关闭</button>
  </div>
</div>
<!-- 右下角SVG动画 -->
<div id="ai-assistant-btn" style="position: fixed; bottom: 40px; right: 20px; z-index: 9999; cursor: pointer;">
</div>
<script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../static/layui/layui.js"></script>
<script type="text/javascript" src="../static/js/handlebars/handlebars-v4.5.3.js"></script>
<script type="text/javascript" src="../static/js/common.js"></script>
<script type="text/javascript" src="../static/js/layer/layer.js"></script>
<script type="text/javascript" src="../static/js/common.js?v=20260309_i18n_fix1"></script>
<script type="text/javascript" src="../static/vue/js/vue.min.js"></script>
<script type="text/javascript" src="../static/vue/element/element.js"></script>
<script>
  // 版本信息变量
  var systemVersion = '...';
  var systemVersionType = '';
  var HOME_TAB_CONFIG = {
    title: "控制中心",
    url: baseUrl + "/views/watch/console.html",
    home: true,
    group: "实时监控",
    menuKey: ""
  };
  var PROFILE_TAB_CONFIG = {
    title: "基本资料",
    url: baseUrl + "/views/detail.html?resourceId=8",
    home: false,
    group: "账户中心",
    menuKey: ""
  };
  var SIDEBAR_TRANSITION_MS = 220;
  var SIDEBAR_EXPAND_CONTENT_DELAY = 180;
  var TAB_STORAGE_KEY = "wcs-element-home-tabs";
  var USER_STORAGE_KEY = "username";
  var INDEX_I18N_FALLBACKS = {
    "app.title": "浙江中扬 - 自动化立体仓库 - WCS",
    "app.company": "浙江中扬立库技术有限公司",
    "common.loadingPage": "正在加载页面...",
    "common.loadingTab": "正在加载 “{0}” ...",
    "common.refreshingTab": "正在刷新 “{0}” ...",
    "common.ok": "知道了",
    "common.prompt": "提示",
    "common.profile": "基本资料",
    "common.logout": "退出登录",
    "common.closeOtherTabs": "关闭其他页签",
    "common.backHome": "返回控制中心",
    "common.aiAssistant": "AI助手",
    "common.workPage": "工作页面",
    "common.businessPage": "业务页面",
    "index.searchMenu": "搜索菜单",
    "index.noMatchedMenu": "没有匹配菜单",
    "index.noAvailableMenu": "当前账号没有可用菜单",
    "index.licenseDays": "临时许可证有效期:{0}天",
    "index.fakeRunning": "仿真运行中",
    "index.fakeStopped": "仿真未运行",
    "index.licenseExpiring": "许可证即将过期",
    "index.homeTab": "控制中心",
    "index.homeGroup": "实时监控",
    "index.profileGroup": "账户中心",
    "index.versionLoading": "Version loading...",
    "index.licenseExpireAt": "许可证将于 {0} 过期,剩余有效期:{1} 天。",
    "index.confirmStopFake": "确定要停止仿真模拟吗?",
    "index.confirmStartFake": "确定要启动仿真模拟吗?",
    "index.fakeStoppedSuccess": "仿真模拟已停止",
    "index.fakeStartedSuccess": "仿真模拟已启动",
    "index.operationFailed": "操作失败",
    "index.menuLoadFailed": "菜单加载失败",
    "index.menuLoadFailedDetail": "菜单加载失败,请检查接口状态"
  };
  // 加载系统版本信息
  function loadSystemVersion() {
    $.ajax({
      url: baseUrl + "/openapi/getSystemVersion",
      headers: { 'token': localStorage.getItem('token') },
      method: 'GET',
      success: function (res) {
        if (res.code === 200) {
          systemVersion = res.data.version;
          systemVersionType = res.data.versionType;
          var versionTypeLabel = systemVersionType === 'prd' ? '' : ' (' + systemVersionType + ')';
          var versionTypeColor = systemVersionType === 'prd' ? 'rgb(25,190,107)' : 'rgb(245,166,35)';
  new Vue({
    el: "#app",
    data: function () {
      return {
        isCollapse: false,
        asideCompact: false,
        menuCollapse: false,
        showAsideExtras: true,
        collapseAnimating: false,
        collapseTimer: null,
        menuLoading: true,
        pageLoading: true,
        loadingText: window.WCS_I18N ? window.WCS_I18N.tl("正在加载页面...") : "正在加载页面...",
        menuKeyword: "",
        menus: [],
        defaultOpeneds: [],
        activeMenuKey: "",
        tabs: [],
        activeTab: HOME_TAB_CONFIG.url,
        version: "",
        versionType: "",
        licenseDays: null,
        licenseDialogVisible: false,
        licenseDialogText: "",
        currentLocale: window.WCS_I18N ? window.WCS_I18N.getLocale() : "zh-CN",
        localeOptions: [],
        fakeVisible: false,
        fakeRunning: false,
        fakeStatusInterval: null,
        menuSyncVersion: 0,
        menuSyncTimer: null,
        userName: localStorage.getItem(USER_STORAGE_KEY) || (window.WCS_I18N ? window.WCS_I18N.tl("管理员") : "管理员"),
        aiLayerIndex: null,
        aiTipIndex: null
      };
    },
    computed: {
      asideWidth: function () {
        return this.asideCompact ? "72px" : "248px";
      },
      filteredMenus: function () {
        var keyword = (this.menuKeyword || "").toLowerCase();
        var result = [];
        var i;
        var j;
        var group;
        var items;
        var item;
        var subMenu;
        var groupMatched;
        var text;
          // 更新页脚版本显示
          $('#system-version').html('Version ' + systemVersion + '<span style="margin-left:5px;padding:1px 6px;font-size:12px;border-radius:3px;background-color:' + versionTypeColor + ';color:#fff;">' + systemVersionType + '</span>');
          // 控制台输出版本信息
          console.log('%c 中扬立库平台 %c ' + systemVersion + ' %c ' + systemVersionType + ' ', 'background-color:rgb(53,73,94);color: #fff;border-radius:2px 0 0 2px;padding:2px 4px;', 'background-color:rgb(25,190,107);color: #fff;padding:2px 4px;font: 9pt "Apercu Regular", Georgia, "Times New Roman", Times, serif;', 'background-color:' + versionTypeColor + ';color: #fff;border-radius:0 2px 2px 0;padding:2px 4px;font: 9pt "Apercu Regular", Georgia, "Times New Roman", Times, serif;');
        if (!keyword) {
          return this.menus;
        }
      }
    });
  }
  $(function () {
    // 注入AI助手图标
    $('#ai-assistant-btn').html(getAiIconHtml(60, 60));
        for (i = 0; i < this.menus.length; i++) {
          group = this.menus[i];
          subMenu = [];
          groupMatched = (group.menu || "").toLowerCase().indexOf(keyword) > -1;
          items = group.subMenu || [];
    if ("" === localStorage.getItem('token')) {
      top.location.href = baseUrl + "/login";
    }
    // 加载版本信息
    loadSystemVersion();
  });
  // 显示弹窗
  function showPopup(res) {
    document.getElementById('popup').style.display = 'block';
    // 获取弹出窗口内容的容器元素
    var popupText = document.getElementById('popup-text');
    // 假设后台返回的字符串为 responseString
    if (res !== "") {
      // 获取当前日期
      const currentDate = new Date();
      // 创建新日期对象并添加天数
      const newDate = new Date();
      newDate.setDate(currentDate.getDate() + res + 1);
      // 将字符串设置为弹窗内容的文本
      popupText.textContent = "许可证将于" + new Intl.DateTimeFormat('zh-CN').format(newDate) + "过期,剩余有效期:" + res + "天!";
    } else {
      document.getElementById('popup').style.display = 'none';
    }
  }
  // 隐藏弹窗
  function hidePopup() {
    document.getElementById('popup').style.display = 'none';
  }
  layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
  }).extend({
    notice: 'notice/notice',
  }).use(['index', 'element', 'layer', 'admin', 'notice'], function () {
    var $ = layui.jquery;
    var index = layui.index;
    var element = layui.element;
    var layer = layui.layer;
    var admin = layui.admin;
    var notice = layui.notice;
    var easywebIframeMsg = localStorage.getItem("easyweb-iframe");
    if (!isEmpty(easywebIframeMsg)) {
      var easywebIframeObj = JSON.parse(easywebIframeMsg);
      if (easywebIframeObj.defaultTheme === undefined) {
        admin.changeTheme("theme-colorful");
      }
    }
    let fakeRunning = false
    let fakeStatusInterval = null
    function checkFakeStatus() {
      $.ajax({
        url: baseUrl + "/openapi/getFakeSystemRunStatus",
        headers: { 'token': localStorage.getItem('token') },
        method: 'GET',
        success: function (res) {
          if (res.code === 200) {
            if (res.data.isFake) {
              $("#fakeShow").show()
              let running = res.data.running
              if (running) {
                $("#fakeShowText").text("仿真模拟运行中")
              } else {
                $("#fakeShowText").text("仿真模拟未运行")
              }
              fakeRunning = running
              if (!fakeStatusInterval) {
                fakeStatusInterval = setInterval(checkFakeStatus, 1000);
              }
            } else {
              $("#fakeShow").hide()
              if (fakeStatusInterval) {
                clearInterval(fakeStatusInterval);
                fakeStatusInterval = null;
              }
          for (j = 0; j < items.length; j++) {
            item = items[j];
            text = ((item.name || "") + " " + (item.code || "")).toLowerCase();
            if (groupMatched || text.indexOf(keyword) > -1) {
              subMenu.push(item);
            }
          } else {
            top.location.href = baseUrl + "/login";
          }
          if (subMenu.length > 0) {
            result.push({
              menuId: group.menuId,
              menu: group.menu,
              menuCode: group.menuCode,
              subMenu: subMenu
            });
          }
        }
      });
    }
    checkFakeStatus();
    $("#fakeShow").on("click", function () {
      if (fakeRunning) {
        layer.confirm('确定要停止仿真模拟吗?', function (index) {
          layer.close(index);
          $.ajax({
            url: baseUrl + "/openapi/stopFakeSystem",
            headers: { 'token': localStorage.getItem('token') },
            method: 'POST',
            success: function (res) {
              if (res.code === 200) {
                layer.msg("仿真模拟已停止", { icon: 1 });
                $("#fakeShowText").text("仿真模拟未运行")
              } else {
                layer.msg(res.msg, { icon: 2 });
              }
            }
          });
        });
      } else {
        layer.confirm('确定要启动仿真模拟吗?', function (index) {
          layer.close(index);
          $.ajax({
            url: baseUrl + "/openapi/startFakeSystem",
            headers: { 'token': localStorage.getItem('token') },
            method: 'POST',
            success: function (res) {
              if (res.code === 200) {
                layer.msg("仿真模拟已启动", { icon: 1 });
                $("#fakeShowText").text("仿真模拟运行中")
              } else {
                layer.msg(res.msg, { icon: 2 });
              }
            }
          });
        });
      }
    });
    $.ajax({
      url: baseUrl + "/menu/auth",
      headers: { 'token': localStorage.getItem('token') },
      method: 'POST',
      // async: false,
      success: function (res) {
        // 关闭加载动画
        $('.layuimini-loader').fadeOut();
        if (res.code === 200) {
          var tpl = $('#menuTpl').html();
          var template = Handlebars.compile(tpl);
          var html = template(res);
          $("#menu-main").html(html);
          element.init();
        } else if (res.code === 403) {
          top.location.href = baseUrl + "/login";
        } else {
          layer.msg(res.msg, { icon: 2 });
        return result;
      },
      activeTabMeta: function () {
        return this.getTabByName(this.activeTab) || this.createTab(this.resolveHomeConfig());
      },
      activeTabTitle: function () {
        return this.activeTabMeta.title;
      },
      activeTabUrl: function () {
        return this.activeTabMeta.url;
      },
      versionText: function () {
        if (!this.version) {
          return this.t("index.versionLoading");
        }
      }
    });
    $.ajax({
      url: baseUrl + "/license/getLicenseDays",
      headers: { 'token': localStorage.getItem('token') },
      method: 'POST',
      success: function (res) {
        if (res.code == 200) {
          let days = res.data
          if (days <= 30) {
            $("#licenseShow").show()
            $("#licenseDays").html(days)
          }
          if (days <= 15) {
            showPopup(days)
          }
          if (days < 0) {
            top.location.href = baseUrl + "/login";
          }
        } else {
          top.location.href = baseUrl + "/login";
        return "Version " + this.version;
      },
      versionTypeTag: function () {
        return (this.versionType || "").toUpperCase();
      },
      versionTagType: function () {
        if (this.versionType === "prd") {
          return "success";
        }
        if (this.versionType === "dev") {
          return "warning";
        }
        return "info";
      },
      licenseVisible: function () {
        return this.licenseDays !== null && this.licenseDays <= 30;
      },
      licenseDisplayVisible: function () {
        return this.licenseVisible && this.licenseDays >= 0;
      },
      licenseTagType: function () {
        if (this.licenseDays !== null && this.licenseDays <= 15) {
          return "danger";
        }
        if (this.licenseDays !== null && this.licenseDays <= 30) {
          return "warning";
        }
        return "info";
      },
      userShortName: function () {
        return (this.userName || this.tl("管理员")).substring(0, 1);
      }
    });
    // 默认加载主页
    index.loadHome({
      menuPath: baseUrl + '/views/watch/console.html',
      menuName: '<i class="layui-icon layui-icon-home"></i>'
    });
    $('#username').text(localStorage.getItem('username'));
    $(document).on('click', '#logout', function () {
      window.location.href = "login.html";
      localStorage.removeItem('token');
      localStorage.removeItem('username');
      admin.closeAllTabs();
    });
    // 替换退出按钮变量
    var logout = document.getElementById('logout');
    var url = logout.getAttribute('href');
    logout.setAttribute('href', baseUrl + "/login");
    // AI助手弹窗索引
    var aiLayerIndex = null;
    // AI助手图标悬浮提示
    $('#ai-assistant-btn').on('mouseenter', function () {
      this.index = layer.tips('AI助手', this, {
        tips: [1, '#333'], // 上方显示,深色背景
        time: -1 // 不自动关闭
      });
    }).on('mouseleave', function () {
      layer.close(this.index);
    }).on('click', function () {
      // 如果已经打开过且未销毁,直接显示
      if (aiLayerIndex !== null && $('#layui-layer' + aiLayerIndex).length > 0) {
        var $layero = $('#layui-layer' + aiLayerIndex);
        var $shade = $('#layui-layer-shade' + aiLayerIndex);
        // 显示并重置状态
        $shade.show().css('opacity', 0.1);
        $layero.show();
        // 重新触发进入动画
        $layero.removeClass('ai-drawer-layer-close');
        $layero.removeClass('ai-drawer-layer');
        void $layero.get(0).offsetWidth; // 触发重绘
        $layero.addClass('ai-drawer-layer');
    },
    watch: {
      activeTab: function () {
        var tab = this.getTabByName(this.activeTab);
        this.syncMenuStateByUrl(tab ? tab.url : this.resolveHomeConfig().url);
        this.pageLoading = !!(tab && !tab.loaded);
        if (this.pageLoading) {
          this.loadingText = this.t("common.loadingTab", [tab.title]);
        }
        this.updateDocumentTitle(tab ? tab.title : this.resolveHomeConfig().title);
        this.persistTabs();
      }
    },
    created: function () {
      if (!localStorage.getItem("token")) {
        top.location.href = baseUrl + "/login";
        return;
      }
      layer.open({
        type: 2,
        title: false, // 隐藏默认标题栏,更简洁
        closeBtn: 0, // 隐藏关闭按钮,点击遮罩关闭
        shadeClose: false, // 改为手动控制关闭,以便播放动画
        shade: 0.1,
        area: ['600px', '100%'],
        offset: 'r', // 右侧悬浮
        anim: -1, // 禁用默认动画,使用CSS动画
        isOutAnim: false,
        skin: 'ai-drawer-layer', // 自定义皮肤
        content: 'ai/diagnosis.html',
        success: function (layero, index) {
          aiLayerIndex = index; // 记录索引
      this.restoreTabs();
      this.bindI18n();
      this.installCompatBridge();
      this.loadSystemVersion();
      this.loadMenu();
      this.loadLicenseDays();
      this.checkFakeStatus();
      this.startUserSync();
    },
    mounted: function () {
      $("#ai-assistant-btn").html(getAiIconHtml(60, 60));
      this.updateDocumentTitle(this.activeTabTitle);
    },
    beforeDestroy: function () {
      if (this.fakeStatusInterval) {
        clearInterval(this.fakeStatusInterval);
        this.fakeStatusInterval = null;
      }
      if (this.userSyncTimer) {
        clearInterval(this.userSyncTimer);
        this.userSyncTimer = null;
      }
      if (this.menuSyncTimer) {
        clearTimeout(this.menuSyncTimer);
        this.menuSyncTimer = null;
      }
      if (this.collapseTimer) {
        clearTimeout(this.collapseTimer);
        this.collapseTimer = null;
      }
      if (this.aiTipIndex) {
        layer.close(this.aiTipIndex);
        this.aiTipIndex = null;
      }
    },
    methods: {
      t: function (key, params) {
        var value = window.WCS_I18N ? window.WCS_I18N.t(key, params) : key;
        if (value !== key) {
          return value;
        }
        value = INDEX_I18N_FALLBACKS[key] || key;
        if (!params) {
          return value;
        }
        if (Object.prototype.toString.call(params) === "[object Array]") {
          for (var i = 0; i < params.length; i++) {
            value = value.replace(new RegExp("\\{" + i + "\\}", "g"), params[i]);
          }
          return value;
        }
        return value;
      },
      tl: function (text) {
        return window.WCS_I18N ? window.WCS_I18N.tl(text) : text;
      },
      bindI18n: function () {
        var that = this;
        if (!window.WCS_I18N) {
          return;
        }
        window.WCS_I18N.onReady(function (i18n) {
          that.currentLocale = i18n.getLocale();
          that.localeOptions = i18n.getLocaleOptions();
          that.refreshI18nState();
        });
      },
      refreshI18nState: function () {
        var that = this;
        var homeConfig = this.resolveHomeConfig();
        var profileConfig = this.resolveProfileConfig();
        var i;
        HOME_TAB_CONFIG.title = homeConfig.title;
        HOME_TAB_CONFIG.group = homeConfig.group;
        PROFILE_TAB_CONFIG.title = profileConfig.title;
        PROFILE_TAB_CONFIG.group = profileConfig.group;
        for (i = 0; i < this.tabs.length; i++) {
          if (this.isHomeTabUrl(this.tabs[i].url)) {
            this.tabs[i].title = homeConfig.title;
            this.tabs[i].group = homeConfig.group;
            this.tabs[i].home = true;
          } else if (this.resolveViewSrc(this.tabs[i].url) === this.resolveViewSrc(profileConfig.url)) {
            this.tabs[i].title = profileConfig.title;
            this.tabs[i].group = profileConfig.group;
          } else {
            this.tabs[i].title = this.translateTabTitle(this.tabs[i].title);
            this.tabs[i].group = this.tl(this.tabs[i].group);
          }
        }
        this.updateDocumentTitle(this.activeTabTitle);
        this.persistTabs();
        this.updateLicenseDialogText();
        this.$nextTick(function () {
          if (window.WCS_I18N) {
            window.WCS_I18N.apply(document.body);
          }
          that.syncAllFramesI18n();
        });
      },
      handleLocaleChange: function (locale) {
        if (window.WCS_I18N) {
          window.WCS_I18N.setLocale(locale);
        }
      },
      resolveHomeConfig: function () {
        return {
          title: this.t("index.homeTab"),
          url: HOME_TAB_CONFIG.url,
          home: true,
          group: this.t("index.homeGroup"),
          menuKey: HOME_TAB_CONFIG.menuKey || ""
        };
      },
      resolveProfileConfig: function () {
        return {
          title: this.t("common.profile"),
          url: PROFILE_TAB_CONFIG.url,
          home: false,
          group: this.t("index.profileGroup"),
          menuKey: PROFILE_TAB_CONFIG.menuKey || ""
        };
      },
      translateTabTitle: function (title) {
        return this.tl(title);
      },
      updateDocumentTitle: function (title) {
        document.title = title + " - " + this.t("app.title");
      },
      resolveMenuIcon: function (code) {
        var iconMap = {
          index: "el-icon-s-home",
          system: "el-icon-setting",
          set: "el-icon-s-tools",
          merchant: "el-icon-user",
          develop: "el-icon-monitor",
          stock: "el-icon-box",
          logReport: "el-icon-document",
          ioWork: "el-icon-s-operation",
          workFlow: "el-icon-connection",
          base: "el-icon-collection-tag",
          erp: "el-icon-s-order",
          sensor: "el-icon-cpu"
        };
        return iconMap[code] || "el-icon-menu";
      },
      createTab: function (config) {
        return {
          title: config.title,
          name: config.url,
          url: config.url,
          currentSrc: this.addNonce(config.url),
          home: !!config.home,
          group: config.group || "",
          menuKey: config.menuKey || "",
          loaded: false
        };
      },
      normalizeStoredTab: function (tab) {
        var created = this.createTab({
          title: this.translateTabTitle(tab.title),
          url: this.resolveViewSrc(tab.url),
          home: !!tab.home,
          group: this.tl(tab.group || ""),
          menuKey: tab.menuKey || ""
        });
        created.loaded = false;
        return created;
      },
      restoreTabs: function () {
        var homeTab = this.createTab(this.resolveHomeConfig());
        var raw = localStorage.getItem(TAB_STORAGE_KEY);
        var parsed;
        var tabs = [];
        var active;
        var i;
        var exists;
          // 背景模糊效果
          var shadeId = layero.attr('id').replace('layui-layer', 'layui-layer-shade');
          var $shade = $('#' + shadeId);
          $shade.css({
            'backdrop-filter': 'blur(3px)',
            'transition': 'opacity 0.8s'
          });
        if (raw) {
          try {
            parsed = JSON.parse(raw);
            if (parsed && parsed.tabs && parsed.tabs.length) {
              for (i = 0; i < parsed.tabs.length; i++) {
                tabs.push(this.normalizeStoredTab(parsed.tabs[i]));
              }
            }
            active = parsed ? parsed.activeTab : "";
          } catch (e) {
            tabs = [];
            active = "";
          }
        }
          // 点击遮罩关闭(带动画)
          $shade.on('click', function () {
            layero.addClass('ai-drawer-layer-close');
            $shade.css('opacity', 0);
            setTimeout(function () {
              // layer.close(index); // 不销毁,改为隐藏
              layero.hide();
              $shade.hide();
            }, 400);
        exists = false;
        for (i = 0; i < tabs.length; i++) {
          if (tabs[i].name === homeTab.name) {
            tabs[i].home = true;
            tabs[i].title = homeTab.title;
            exists = true;
            break;
          }
        }
        if (!exists) {
          tabs.unshift(homeTab);
        }
        if (tabs.length === 0) {
          tabs = [homeTab];
        }
        this.tabs = tabs;
        this.activeTab = this.hasTab(active) ? active : homeTab.name;
        this.loadingText = this.t("common.loadingTab", [this.activeTabTitle]);
        this.pageLoading = true;
        this.updateDocumentTitle(this.activeTabTitle);
      },
      persistTabs: function () {
        var tabs = [];
        var i;
        for (i = 0; i < this.tabs.length; i++) {
          tabs.push({
            title: this.tabs[i].title,
            url: this.tabs[i].url,
            home: this.tabs[i].home,
            group: this.tabs[i].group,
            menuKey: this.tabs[i].menuKey
          });
        }
      });
    });
        localStorage.setItem(TAB_STORAGE_KEY, JSON.stringify({
          tabs: tabs,
          activeTab: this.activeTab
        }));
      },
      hasTab: function (name) {
        return !!this.getTabByName(name);
      },
      isHomeTabUrl: function (url) {
        var homeUrl = this.resolveHomeConfig().url;
        return this.resolveViewSrc(url || homeUrl) === this.resolveViewSrc(homeUrl);
      },
      getTabByName: function (name) {
        var i;
        for (i = 0; i < this.tabs.length; i++) {
          if (this.tabs[i].name === name) {
            return this.tabs[i];
          }
        }
        return null;
      },
      addOrActivateTab: function (config) {
        var url = this.resolveViewSrc(config.url);
        var tab = this.getTabByName(url);
        if (!tab) {
          tab = this.createTab({
            title: config.title,
            url: url,
            home: !!config.home,
            group: config.group,
            menuKey: config.menuKey || this.findMenuKeyByUrl(url)
          });
          this.tabs.push(tab);
        } else {
          tab.title = config.title || tab.title;
          tab.group = config.group || tab.group;
          tab.menuKey = config.menuKey || tab.menuKey;
          if (config.home) {
            tab.home = true;
          }
        }
        this.loadingText = this.t("common.loadingTab", [tab.title]);
        this.pageLoading = !tab.loaded;
        this.activeTab = tab.name;
        this.syncMenuStateByUrl(tab.url);
      },
      openHomeTab: function () {
        this.addOrActivateTab(this.resolveHomeConfig());
      },
      openProfileTab: function () {
        this.addOrActivateTab(this.resolveProfileConfig());
      },
      closeAllTabs: function () {
        var homeConfig = this.resolveHomeConfig();
        this.tabs = [this.createTab(homeConfig)];
        this.activeTab = homeConfig.url;
        this.syncMenuStateByUrl(homeConfig.url);
        this.pageLoading = true;
        this.loadingText = this.t("common.loadingTab", [homeConfig.title]);
        this.persistTabs();
      },
      closeOtherTabs: function () {
        var active = this.getTabByName(this.activeTab);
        var homeTab = this.createTab(this.resolveHomeConfig());
        var result = [homeTab];
        if (active && active.name !== homeTab.name) {
          result.push(active);
        }
        this.tabs = result;
        this.persistTabs();
      },
      removeTab: function (name) {
        var i;
        var nextTabName = this.resolveHomeConfig().url;
        for (i = 0; i < this.tabs.length; i++) {
          if (this.tabs[i].name === name) {
            if (this.activeTab === name) {
              if (this.tabs[i + 1]) {
                nextTabName = this.tabs[i + 1].name;
              } else if (this.tabs[i - 1]) {
                nextTabName = this.tabs[i - 1].name;
              }
            }
            this.tabs.splice(i, 1);
            break;
          }
        }
        if (this.tabs.length === 0) {
          this.tabs.push(this.createTab(this.resolveHomeConfig()));
          nextTabName = this.resolveHomeConfig().url;
        }
        this.activeTab = nextTabName;
        this.persistTabs();
      },
      handleFrameLoad: function (name) {
        var tab = this.getTabByName(name);
        if (tab) {
          tab.loaded = true;
        }
        this.syncFrameI18n(name);
        if (this.activeTab === name) {
          this.pageLoading = false;
        }
      },
      refreshActiveTab: function () {
        var tab = this.getTabByName(this.activeTab);
        if (!tab) {
          return;
        }
        tab.loaded = false;
        tab.currentSrc = this.addNonce(tab.url);
        this.loadingText = this.t("common.refreshingTab", [tab.title]);
        this.pageLoading = true;
      },
      addNonce: function (url) {
        return url + (url.indexOf("?") === -1 ? "?" : "&") + "_t=" + new Date().getTime();
      },
      findFrameElement: function (name) {
        var frames;
        var i;
        if (!this.$el) {
          return null;
        }
        frames = this.$el.querySelectorAll("iframe[data-tab-name]");
        for (i = 0; i < frames.length; i++) {
          if (frames[i].getAttribute("data-tab-name") === name) {
            return frames[i];
          }
        }
        return null;
      },
      syncFrameI18n: function (name) {
        var that = this;
        var frame = this.findFrameElement(name);
        var frameWindow;
        var frameDocument;
        var script;
        function applyFrameI18n() {
          try {
            if (!frameWindow.WCS_I18N || typeof frameWindow.WCS_I18N.onReady !== "function") {
              return;
            }
            frameWindow.WCS_I18N.setLocale(that.currentLocale || "zh-CN", false);
            frameWindow.WCS_I18N.onReady(function (i18n) {
              i18n.apply(frameDocument.body || frameDocument.documentElement);
              if (frameDocument.title) {
                frameDocument.title = i18n.tl(frameDocument.title);
              }
            });
          } catch (e) {
          }
        }
        if (!frame) {
          return;
        }
        try {
          frameWindow = frame.contentWindow;
          frameDocument = frameWindow.document;
        } catch (e) {
          return;
        }
        try {
          frameWindow.localStorage.setItem("wcs_lang", this.currentLocale || "zh-CN");
        } catch (e) {
        }
        if (frameDocument && frameDocument.documentElement) {
          frameDocument.documentElement.lang = this.currentLocale || "zh-CN";
        }
        if (frameWindow.WCS_I18N && typeof frameWindow.WCS_I18N.onReady === "function") {
          applyFrameI18n();
          return;
        }
        if (!frameDocument || !frameDocument.head || frameDocument.getElementById("wcs-i18n-bridge-script")) {
          return;
        }
        script = frameDocument.createElement("script");
        script.id = "wcs-i18n-bridge-script";
        script.type = "text/javascript";
        script.src = baseUrl + "/static/js/common.js?v=20260309_i18n_fix1";
        script.onload = applyFrameI18n;
        frameDocument.head.appendChild(script);
      },
      syncAllFramesI18n: function () {
        var i;
        for (i = 0; i < this.tabs.length; i++) {
          this.syncFrameI18n(this.tabs[i].name);
        }
      },
      clearCollapseTimer: function () {
        if (this.collapseTimer) {
          clearTimeout(this.collapseTimer);
          this.collapseTimer = null;
        }
      },
      nextFrame: function (callback) {
        if (window.requestAnimationFrame) {
          window.requestAnimationFrame(function () {
            callback();
          });
          return;
        }
        setTimeout(callback, 16);
      },
      finishCollapseStage: function (callback, delay) {
        var that = this;
        this.clearCollapseTimer();
        this.collapseTimer = setTimeout(function () {
          that.collapseTimer = null;
          callback();
        }, delay);
      },
      toggleCollapse: function () {
        var that = this;
        if (this.collapseAnimating) {
          return;
        }
        this.collapseAnimating = true;
        if (this.isCollapse) {
          this.isCollapse = false;
          this.asideCompact = false;
          this.nextFrame(function () {
            that.finishCollapseStage(function () {
              that.menuCollapse = false;
              that.showAsideExtras = true;
              that.collapseAnimating = false;
              that.$nextTick(function () {
                that.syncMenuStateByUrl(that.activeTabUrl);
              });
            }, SIDEBAR_EXPAND_CONTENT_DELAY);
          });
          return;
        }
        this.isCollapse = true;
        this.showAsideExtras = false;
        this.menuCollapse = true;
        this.$nextTick(function () {
          that.nextFrame(function () {
            that.asideCompact = true;
            that.finishCollapseStage(function () {
              that.collapseAnimating = false;
            }, SIDEBAR_TRANSITION_MS);
          });
        });
      },
      handleMenuSelect: function (group, item) {
        this.addOrActivateTab({
          title: item.name,
          url: item.url,
          home: false,
          group: group.menu,
          menuKey: item.tabKey
        });
      },
      findMenuKeyByUrl: function (url) {
        var normalized = this.resolveViewSrc(url);
        var i;
        var j;
        var group;
        var item;
        for (i = 0; i < this.menus.length; i++) {
          group = this.menus[i];
          for (j = 0; j < group.subMenu.length; j++) {
            item = group.subMenu[j];
            if (item.url === normalized) {
              return item.tabKey;
            }
          }
        }
        return "";
      },
      findMenuGroupIndexByUrl: function (url) {
        var normalized = this.resolveViewSrc(url);
        var i;
        var j;
        var group;
        var item;
        for (i = 0; i < this.menus.length; i++) {
          group = this.menus[i];
          for (j = 0; j < group.subMenu.length; j++) {
            item = group.subMenu[j];
            if (item.url === normalized) {
              return "group-" + group.menuId;
            }
          }
        }
        return "";
      },
      normalizeMenuData: function (data) {
        var result = [];
        var i;
        var j;
        var group;
        var item;
        var subMenu;
        for (i = 0; i < data.length; i++) {
          group = data[i];
          subMenu = [];
          for (j = 0; j < (group.subMenu || []).length; j++) {
            item = group.subMenu[j];
            subMenu.push({
              id: item.id,
              name: item.name || item.code || this.tl("未命名页面"),
              code: item.code || "",
              url: this.buildMenuSrc(item.code, item.id),
              tabKey: this.buildMenuSrc(item.code, item.id)
            });
          }
          result.push({
            menuId: group.menuId,
            menu: group.menu || this.tl("未命名分组"),
            menuCode: group.menuCode || "",
            subMenu: subMenu
          });
        }
        return result;
      },
      buildMenuSrc: function (code, resourceId) {
        var normalized = code || "";
        var hash = "";
        var hashIndex = normalized.indexOf("#");
        var resolved;
        if (hashIndex > -1) {
          hash = normalized.substring(hashIndex);
          normalized = normalized.substring(0, hashIndex);
        }
        resolved = this.resolveViewSrc(normalized);
        if (resourceId && resolved.indexOf("resourceId=") === -1) {
          resolved += (resolved.indexOf("?") === -1 ? "?" : "&") + "resourceId=" + encodeURIComponent(resourceId);
        }
        return resolved + hash;
      },
      resolveViewSrc: function (path) {
        if (!path) {
          return this.resolveHomeConfig().url;
        }
        if (/^https?:\/\//.test(path) || path.indexOf(baseUrl) === 0) {
          return path;
        }
        if (path.indexOf("/views/") === 0) {
          return baseUrl + path;
        }
        if (path.indexOf("views/") === 0) {
          return baseUrl + "/" + path;
        }
        return baseUrl + "/views/" + path.replace(/^\/+/, "");
      },
      stripTags: function (value) {
        var div = document.createElement("div");
        div.innerHTML = value || "";
        return (div.textContent || div.innerText || "").trim();
      },
      collapseAllMenus: function () {
        var menu = this.$refs.sideMenu;
        var openedMenus;
        var i;
        if (!menu || !menu.openedMenus || !menu.openedMenus.length) {
          return;
        }
        openedMenus = menu.openedMenus.slice();
        for (i = 0; i < openedMenus.length; i++) {
          menu.close(openedMenus[i]);
        }
      },
      syncMenuStateByUrl: function (url) {
        var targetUrl = this.resolveViewSrc(url || this.resolveHomeConfig().url);
        var activeMenuKey = "";
        var groupIndex = "";
        var that = this;
        var syncVersion;
        var applyMenuState;
        if (!this.isHomeTabUrl(targetUrl)) {
          activeMenuKey = this.findMenuKeyByUrl(targetUrl);
          if (activeMenuKey) {
            groupIndex = this.findMenuGroupIndexByUrl(targetUrl);
          }
        }
        this.activeMenuKey = activeMenuKey;
        this.defaultOpeneds = groupIndex ? [groupIndex] : [];
        this.menuSyncVersion += 1;
        syncVersion = this.menuSyncVersion;
        applyMenuState = function () {
          var menu = that.$refs.sideMenu;
          var openedMenus;
          if (syncVersion !== that.menuSyncVersion) {
            return;
          }
          if (!menu) {
            return;
          }
          if (that.menuCollapse) {
            return;
          }
          openedMenus = menu.openedMenus ? menu.openedMenus.slice() : [];
          if (!groupIndex) {
            if (openedMenus.length) {
              that.collapseAllMenus();
            }
            return;
          }
          if (openedMenus.indexOf(groupIndex) > -1) {
            return;
          }
          if (openedMenus.length) {
            that.collapseAllMenus();
          }
          menu.open(groupIndex);
        };
        this.$nextTick(function () {
          applyMenuState();
          if (that.menuSyncTimer) {
            clearTimeout(that.menuSyncTimer);
            that.menuSyncTimer = null;
          }
          that.menuSyncTimer = setTimeout(function () {
            applyMenuState();
            that.menuSyncTimer = null;
          }, 160);
        });
      },
      loadMenu: function () {
        var that = this;
        this.menuLoading = true;
        $.ajax({
          url: baseUrl + "/menu/auth",
          headers: { token: localStorage.getItem("token") },
          method: "POST",
          success: function (res) {
            that.menuLoading = false;
            if (res.code === 200) {
              that.menus = that.normalizeMenuData(res.data || []);
              that.syncMenuStateByUrl(that.activeTabUrl);
            } else if (res.code === 403) {
              top.location.href = baseUrl + "/login";
            } else {
              that.$message.error(res.msg || that.t("index.menuLoadFailed"));
            }
          },
          error: function () {
            that.menuLoading = false;
            that.$message.error(that.t("index.menuLoadFailedDetail"));
          }
        });
      },
      loadSystemVersion: function () {
        var that = this;
        $.ajax({
          url: baseUrl + "/openapi/getSystemVersion",
          headers: { token: localStorage.getItem("token") },
          method: "GET",
          success: function (res) {
            if (res.code === 200) {
              that.version = res.data.version || "";
              that.versionType = res.data.versionType || "";
            }
          }
        });
      },
      loadLicenseDays: function () {
        var that = this;
        $.ajax({
          url: baseUrl + "/license/getLicenseDays",
          headers: { token: localStorage.getItem("token") },
          method: "POST",
          success: function (res) {
            var days;
            if (res.code !== 200) {
              top.location.href = baseUrl + "/login";
              return;
            }
            days = Number(res.data);
            that.licenseDays = days;
            if (days <= 15) {
              that.showPopup(days);
            }
            if (days < 0) {
              top.location.href = baseUrl + "/login";
            }
          }
        });
      },
      showPopup: function (days) {
        var currentDate;
        var expiryDate;
        var formattedDate;
        if (days === "" || days === null || typeof days === "undefined") {
          this.hidePopup();
          return;
        }
        currentDate = new Date();
        expiryDate = new Date();
        expiryDate.setDate(currentDate.getDate() + Number(days) + 1);
        formattedDate = new Intl.DateTimeFormat(this.currentLocale || "zh-CN").format(expiryDate);
        this.licenseDialogText = this.t("index.licenseExpireAt", [formattedDate, days]);
        this.licenseDialogVisible = true;
      },
      updateLicenseDialogText: function () {
        if (this.licenseDays === "" || this.licenseDays === null || typeof this.licenseDays === "undefined" || this.licenseDays > 15) {
          return;
        }
        this.showPopup(this.licenseDays);
      },
      hidePopup: function () {
        this.licenseDialogVisible = false;
      },
      checkFakeStatus: function () {
        var that = this;
        $.ajax({
          url: baseUrl + "/openapi/getFakeSystemRunStatus",
          headers: { token: localStorage.getItem("token") },
          method: "GET",
          success: function (res) {
            if (res.code !== 200) {
              top.location.href = baseUrl + "/login";
              return;
            }
            if (res.data.isFake) {
              that.fakeVisible = true;
              that.fakeRunning = !!res.data.running;
              if (!that.fakeStatusInterval) {
                that.fakeStatusInterval = setInterval(function () {
                  that.checkFakeStatus();
                }, 1000);
              }
            } else {
              that.fakeVisible = false;
              if (that.fakeStatusInterval) {
                clearInterval(that.fakeStatusInterval);
                that.fakeStatusInterval = null;
              }
            }
          }
        });
      },
      toggleFakeSystem: function () {
        var that = this;
        var url;
        var text;
        var successMsg;
        var running;
        if (!this.fakeVisible) {
          return;
        }
        if (this.fakeRunning) {
          url = baseUrl + "/openapi/stopFakeSystem";
          text = this.t("index.confirmStopFake");
          successMsg = this.t("index.fakeStoppedSuccess");
          running = false;
        } else {
          url = baseUrl + "/openapi/startFakeSystem";
          text = this.t("index.confirmStartFake");
          successMsg = this.t("index.fakeStartedSuccess");
          running = true;
        }
        this.$confirm(text, this.t("common.prompt"), {
          type: "warning"
        }).then(function () {
          $.ajax({
            url: url,
            headers: { token: localStorage.getItem("token") },
            method: "POST",
            success: function (res) {
              if (res.code === 200) {
                that.fakeRunning = running;
                that.$message.success(successMsg);
              } else {
                that.$message.error(res.msg || that.t("index.operationFailed"));
              }
            }
          });
        }).catch(function () {});
      },
      toggleFullScreen: function () {
        if (!document.fullscreenElement) {
          document.documentElement.requestFullscreen();
        } else {
          document.exitFullscreen();
        }
      },
      showAiTip: function () {
        this.hideAiTip();
        this.aiTipIndex = layer.tips(this.t("common.aiAssistant"), "#ai-assistant-btn", {
          tips: [1, "#333"],
          time: -1
        });
      },
      hideAiTip: function () {
        if (this.aiTipIndex) {
          layer.close(this.aiTipIndex);
          this.aiTipIndex = null;
        }
      },
      openAiAssistant: function () {
        var that = this;
        var $layero;
        var $shade;
        this.hideAiTip();
        if (this.aiLayerIndex !== null && $("#layui-layer" + this.aiLayerIndex).length > 0) {
          $layero = $("#layui-layer" + this.aiLayerIndex);
          $shade = $("#layui-layer-shade" + this.aiLayerIndex);
          $shade.show().css("opacity", 0.1);
          $layero.show();
          $layero.removeClass("ai-drawer-layer-close");
          $layero.removeClass("ai-drawer-layer");
          void $layero.get(0).offsetWidth;
          $layero.addClass("ai-drawer-layer");
          return;
        }
        layer.open({
          type: 2,
          title: false,
          closeBtn: 0,
          shadeClose: false,
          shade: 0.1,
          area: ["600px", "100%"],
          offset: "r",
          anim: -1,
          isOutAnim: false,
          skin: "ai-drawer-layer",
          content: "ai/diagnosis.html",
          success: function (layero, index) {
            var shadeId;
            var $shadeEl;
            that.aiLayerIndex = index;
            shadeId = layero.attr("id").replace("layui-layer", "layui-layer-shade");
            $shadeEl = $("#" + shadeId);
            $shadeEl.css({
              "backdrop-filter": "blur(3px)",
              transition: "opacity 0.8s"
            });
            $shadeEl.off("click.aiAssistant").on("click.aiAssistant", function () {
              layero.addClass("ai-drawer-layer-close");
              $shadeEl.css("opacity", 0);
              setTimeout(function () {
                layero.hide();
                $shadeEl.hide();
              }, 400);
            });
          }
        });
      },
      handleUserCommand: function (command) {
        if (command === "profile") {
          this.openProfileTab();
        } else if (command === "logout") {
          this.logout();
        }
      },
      logout: function () {
        localStorage.removeItem("token");
        localStorage.removeItem(USER_STORAGE_KEY);
        localStorage.removeItem(TAB_STORAGE_KEY);
        window.location.href = baseUrl + "/login";
      },
      startUserSync: function () {
        var that = this;
        this.userSyncTimer = setInterval(function () {
          that.userName = localStorage.getItem(USER_STORAGE_KEY) || that.tl("管理员");
        }, 1000);
      },
      installCompatBridge: function () {
        var that = this;
        window.admin = window.admin || {};
        window.admin.closeAllTabs = function () {
          that.closeAllTabs();
        };
        window.admin.changeTheme = window.admin.changeTheme || function () {};
        window.admin.activeNav = function (url) {
          that.syncMenuStateByUrl(that.resolveViewSrc(url));
        };
        window.index = window.index || {};
        window.index.loadView = function (param) {
          var url;
          if (!param || !param.menuPath) {
            return;
          }
          url = that.resolveViewSrc(param.menuPath);
          that.addOrActivateTab({
            title: that.stripTags(param.menuName) || that.t("common.workPage"),
            url: url,
            home: false,
            group: that.t("common.businessPage"),
            menuKey: that.findMenuKeyByUrl(url)
          });
        };
        window.index.loadHome = function (param) {
          var url;
          if (!param || !param.menuPath) {
            that.openHomeTab();
            return;
          }
          url = that.resolveViewSrc(param.menuPath);
          that.addOrActivateTab({
            title: that.stripTags(param.menuName) || that.resolveHomeConfig().title,
            url: url,
            home: true,
            group: that.resolveHomeConfig().group,
            menuKey: that.findMenuKeyByUrl(url)
          });
        };
        window.showPopup = function (days) {
          that.showPopup(days);
        };
        window.hidePopup = function () {
          that.hidePopup();
        };
      }
    }
  });
</script>
<script type="text/html" id="menuTpl">
  {{#each data}}
  <li class="layui-nav-item">
    <a><i class="layui-icon {{this.menuIcon}}"></i>&emsp;<cite>{{this.menu}}</cite></a>
    <dl class="layui-nav-child">
      {{#each this.subMenu}}
      <dd><a lay-href="{{this.code}}?resourceId={{this.id}}">{{this.name}}</a></dd>
      {{/each}}
    </dl>
  </li>
  {{/each}}
</script>
</body>
</html>
</html>