Selaa lähdekoodia

策略中心调测

learshaw 4 kuukautta sitten
vanhempi
commit
9da321b060

+ 8 - 0
ems-ui-cloud/src/api/mgr/energyStrategy.js

@@ -36,6 +36,14 @@ export function getEnergyStrategyByCode(strategyCode) {
   })
 }
 
+export function getSceneTypeCount(areaCode) {
+  return request({
+    url: '/ems/energyStrategy/sceneCount',
+    method: 'get',
+    params: { areaCode }
+  })
+}
+
 /**
  * 新增策略
  */

+ 80 - 49
ems-ui-cloud/src/router/index.js

@@ -7,28 +7,6 @@ import PvRoad from "@/views/largeScreen/pv-road/index.vue";
 
 Vue.use(Router);
 
-/**
- * Note: 路由配置项
- *
- * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
- * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
- *                                  // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
- *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
- *                                  // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
- * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
- * name:'router-name'               // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
- * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
- * roles: ['admin', 'common']       // 访问路由的角色权限
- * permissions: ['a:a:a', 'b:b:b']  // 访问路由的菜单权限
- * meta : {
- noCache: true                   // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
- title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
- icon: 'svg-name'                // 设置该路由的图标,对应路径src/assets/icons/svg
- breadcrumb: false               // 如果设置为false,则不会在breadcrumb面包屑中显示
- activeMenu: '/system/user'      // 当路由设置了该属性,则会高亮相对应的侧边栏。
- }
- */
-
 // 公共路由
 export const constantRoutes = [
   {
@@ -42,7 +20,6 @@ export const constantRoutes = [
       }
     ]
   },
-
   {
     path: '/login',
     component: () => import('@/views/login'),
@@ -63,7 +40,26 @@ export const constantRoutes = [
     component: () => import('@/views/error/401'),
     hidden: true
   },
-  //智慧园区管理平台
+
+  // ========================================
+  // 🔥 策略编排路由(静态路由,不依赖菜单)
+  // ========================================
+  {
+    path: '/mgr/strategy',
+    component: Layout,
+    hidden: true,
+    children: [
+      {
+        path: 'editor/:strategyCode',
+        component: () => import('@/views/mgr/strategy/editor'),
+        name: 'StrategyEditor',
+        meta: {
+          title: '策略编排',
+          activeMenu: '/mgr/strategy'
+        }
+      }
+    ]
+  },
   {
     path: '/largeScreen',
     name: 'largeScreen',
@@ -74,9 +70,7 @@ export const constantRoutes = [
       {
         path: 'home',
         name: 'home',
-        meta: {
-          title: '首页'
-        },
+        meta: { title: '首页' },
         components: {
           default: () => import('@/views/largeScreen/center.vue'),
           left: () => import('@/views/largeScreen/home/left.vue'),
@@ -86,9 +80,7 @@ export const constantRoutes = [
       {
         path: 'source',
         name: 'source',
-        meta: {
-          title: '源'
-        },
+        meta: { title: '源' },
         components: {
           default: () => import('@/views/largeScreen/center.vue'),
           left: () => import('@/views/largeScreen/source/left.vue'),
@@ -98,9 +90,7 @@ export const constantRoutes = [
       {
         path: 'storage',
         name: 'storage',
-        meta: {
-          title: '储'
-        },
+        meta: { title: '储' },
         components: {
           default: () => import('@/views/largeScreen/center.vue'),
           left: () => import('@/views/largeScreen/storage/left.vue'),
@@ -110,9 +100,7 @@ export const constantRoutes = [
       {
         path: 'soc',
         name: 'soc',
-        meta: {
-          title: '荷'
-        },
+        meta: { title: '荷' },
         components: {
           default: () => import('@/views/largeScreen/center.vue'),
           left: () => import('@/views/largeScreen/soc/left.vue'),
@@ -122,9 +110,7 @@ export const constantRoutes = [
       {
         path: 'net',
         name: 'net',
-        meta: {
-          title: '网'
-        },
+        meta: { title: '网' },
         components: {
           default: () => import('@/views/largeScreen/center.vue'),
           left: () => import('@/views/largeScreen/net/left.vue'),
@@ -134,9 +120,7 @@ export const constantRoutes = [
       {
         path: 'device',
         name: 'device',
-        meta: {
-          title: '设备'
-        },
+        meta: { title: '设备' },
         components: {
           default: () => import('@/views/largeScreen/center.vue'),
           left: () => import('@/views/largeScreen/device/left.vue'),
@@ -155,15 +139,13 @@ export const constantRoutes = [
       {
         path: 'road-home',
         name: 'road-home',
-        meta: {
-          title: '首页'
-        },
+        meta: { title: '首页' },
         components: {
           default: () => import('@/views/largeScreen/pv-road/center.vue'),
           left: () => import('@/views/largeScreen/source/left.vue'),
           right: () => import('@/views/largeScreen/source/pv-road-right.vue')
         }
-      },
+      }
     ]
   },
   {
@@ -197,6 +179,57 @@ export const constantRoutes = [
 
 // 动态路由,基于用户权限动态去加载
 export const dynamicRoutes = [
+  // ========================================
+  // 🔥 策略管理路由组(仅包含需要菜单的页面)
+  // 注意:策略编排已移至 constantRoutes,不在这里
+  // ========================================
+  {
+    path: '/mgr/strategy',
+    component: Layout,
+    redirect: '/mgr/strategy/index',
+    meta: {
+      title: '策略管理',
+      icon: 'el-icon-s-operation'
+    },
+    children: [
+      // ✅ 策略中心(入口页面)
+      {
+        path: 'index',
+        component: () => import('@/views/mgr/strategy/index'),
+        name: 'StrategyIndex',
+        meta: {
+          title: '策略中心',
+          icon: 'el-icon-menu'
+        }
+      },
+
+      // ✅ 策略日志
+      {
+        path: 'log',
+        component: () => import('@/views/mgr/strategy/log'),
+        name: 'StrategyLog',
+        meta: {
+          title: '策略日志',
+          icon: 'el-icon-document'
+        }
+      },
+
+      // ✅ 策略模板
+      {
+        path: 'template',
+        component: () => import('@/views/mgr/strategy/template'),
+        name: 'StrategyTemplate',
+        meta: {
+          title: '策略模板',
+          icon: 'el-icon-files'
+        }
+      }
+    ]
+  },
+
+  // ========================================
+  // 其他系统路由保持不变
+  // ========================================
   {
     path: '/system/user-auth',
     component: Layout,
@@ -272,17 +305,15 @@ export const dynamicRoutes = [
 // 防止连续点击多次路由报错
 let routerPush = Router.prototype.push;
 let routerReplace = Router.prototype.replace;
-// push
 Router.prototype.push = function push(location) {
   return routerPush.call(this, location).catch(err => err);
 };
-// replace
 Router.prototype.replace = function push(location) {
   return routerReplace.call(this, location).catch(err => err);
 };
 
 export default new Router({
-  mode: 'history', // 去掉url中的#
+  mode: 'history',
   scrollBehavior: () => ({y: 0}),
   routes: constantRoutes
 });

+ 1 - 1
ems-ui-cloud/src/views/mgr/strategy/editor.vue

@@ -877,7 +877,7 @@ export default {
 
     // 返回上级页面
     goBack() {
-      this.$router.push('/strategy-mgr/strategy-index');
+      this.$router.push(this.parentPath);
     },
 
     // 辅助方法

+ 22 - 10
ems-ui-cloud/src/views/mgr/strategy/index.vue

@@ -558,7 +558,8 @@ import {
   changeStrategyState,
   executeStrategy,
   getExecLogList,
-  listStrategyTemplate
+  listStrategyTemplate,
+  getSceneTypeCount
 } from '@/api/mgr/energyStrategy';
 import { areaTreeSelect } from '@/api/basecfg/area';
 import Treeselect from '@riophae/vue-treeselect';
@@ -655,6 +656,7 @@ export default {
   created() {
     this.loadAreaTree();
     this.loadTemplates();
+    this.loadSceneCounts();
     this.getList();
   },
 
@@ -684,6 +686,15 @@ export default {
       });
     },
 
+    loadSceneCounts(areaCode) {
+      getSceneTypeCount(areaCode).then(response => {
+        this.sceneCountMap = response.data || {};
+      }).catch(() => {
+        // 失败时至少显示总数
+        this.sceneCountMap = { 'ALL': this.total };
+      });
+    },
+
     // 获取策略列表
     getList() {
       this.loading = true;
@@ -714,7 +725,12 @@ export default {
         this.strategyList = response.rows || [];
         this.total = response.total || 0;
         this.loading = false;
-        this.updateSceneCounts();
+
+        // 修正:刷新场景统计,传入当前区块筛选条件
+        const areaParam = (this.currentAreaCode && this.currentAreaCode !== '-1')
+          ? this.currentAreaCode
+          : null;
+        this.loadSceneCounts(areaParam);  // 调用 loadSceneCounts 而不是 updateSceneCounts
       }).catch(() => {
         this.strategyList = [];
         this.total = 0;
@@ -722,10 +738,6 @@ export default {
       });
     },
 
-    updateSceneCounts() {
-      this.sceneCountMap['ALL'] = this.total;
-    },
-
     refreshList() {
       this.getList();
       this.$message.success('刷新成功');
@@ -846,8 +858,8 @@ export default {
           const strategyCode = this.strategyForm.strategyCode;
           // 跳转到编排页面 - 使用相对路径
           this.$router.push({
-            path: '/strategy-mgr/strategy-editor',
-            query: { strategyCode: strategyCode }
+            name: 'StrategyEditor',
+        params: { strategyCode: strategyCode }
           });
         }).catch(error => {
           this.saveLoading = false;
@@ -859,8 +871,8 @@ export default {
     // 点击卡片进入编排
     handleCardClick(strategy) {
       this.$router.push({
-        path: '/strategy-mgr/strategy-editor',
-        query: { strategyCode: strategy.strategyCode }
+        name: 'StrategyEditor',  // 使用路由名称
+        params: { strategyCode: strategy.strategyCode }
       });
     },