wanglt 6 meses atrás
pai
commit
e1a9135ba8

+ 19 - 22
ygtx-system/src/main/java/com/ygtx/system/service/impl/SysMenuServiceImpl.java

@@ -540,38 +540,35 @@ public class SysMenuServiceImpl implements ISysMenuService
     public List<Map<String, Object>> getDataList(int postType){
         List<Map<String, Object>> result = new ArrayList<>();
         if (postType==2) {
-            result.add(createMenu("计划工单总数", "128", "+12% 较上月", "up", "fa fa-calendar-check-o", "blue"));
-            result.add(createMenu("非计划工单总数", "45", "+8% 较上月", "down", "fa fa-exclamation-triangle", "orange"));
-            result.add(createMenu("总工时", "3240", "+5% 较上月", "same", "fa fa-clock-o", "gray"));
-            result.add(createMenu("平均工单完成率", "92%", "+3% 较上月", "up", "fa fa-line-chart", "green"));
-            result.add(createMenu("扣分工单数量", "12", "-2% 较上月", "down", "fa fa-minus-circle", "red"));
-            result.add(createMenu("班组总数", "8", "0 较上月", "same", "fa fa-users", "cyan"));
+            result.add(createMenu("计划工单总数", "128", "+12% 较上月"));
+            result.add(createMenu("非计划工单总数", "45", "+8% 较上月"));
+            result.add(createMenu("总工时", "3240", "+5% 较上月"));
+            result.add(createMenu("平均工单完成率", "92%", "+3% 较上月"));
+            result.add(createMenu("扣分工单数量", "12", "-2% 较上月"));
+            result.add(createMenu("班组总数", "8", "0 较上月"));
         } else if (postType==1) {
-            result.add(createMenu("年度计划工单", "36", "+5% 较上月", "up", "fa fa-calendar", "blue"));
-            result.add(createMenu("年度非计划工单", "12", "+2% 较上月", "up", "fa fa-calendar-times-o", "orange"));
-            result.add(createMenu("月度计划工单", "3", "0% 较上月", "same", "fa fa-calendar-check-o", "green"));
-            result.add(createMenu("月度非计划工单", "1", "-1 较上月", "down", "fa fa-exclamation-triangle", "red"));
-            result.add(createMenu("当日计划工单", "0", "0 较上月", "same", "fa fa-calendar-plus-o", "gray"));
-            result.add(createMenu("当日非计划工单", "0", "0 较上月", "same", "fa fa-exclamation-circle", "cyan"));
+            result.add(createMenu("年度计划工单", "36", "+5% 较上月"));
+            result.add(createMenu("年度非计划工单", "12", "+2% 较上月"));
+            result.add(createMenu("月度计划工单", "3", "0% 较上月"));
+            result.add(createMenu("月度非计划工单", "1", "-1 较上月"));
+            result.add(createMenu("当日计划工单", "0", "0 较上月"));
+            result.add(createMenu("当日非计划工单", "0", "0 较上月"));
         } else {
-            result.add(createMenu("年度计划工单", "8", "+2 较上月", "up", "fa fa-calendar", "blue"));
-            result.add(createMenu("年度非计划工单", "3", "+1 较上月", "up", "fa fa-exclamation-triangle", "orange"));
-            result.add(createMenu("月度计划工单", "1", "0 较上月", "same", "fa fa-calendar-check-o", "green"));
-            result.add(createMenu("月度非计划工单", "0", "0 较上月", "same", "fa fa-exclamation-circle", "red"));
-            result.add(createMenu("当前工分", "210", "+15 较上月", "up", "fa fa-star", "cyan"));
-            result.add(createMenu("扣分工单数", "1", "0 较上月", "same", "fa fa-minus-circle", "gray"));
+            result.add(createMenu("年度计划工单", "8", "+2 较上月"));
+            result.add(createMenu("年度非计划工单", "3", "+1 较上月"));
+            result.add(createMenu("月度计划工单", "1", "0 较上月"));
+            result.add(createMenu("月度非计划工单", "0", "0 较上月"));
+            result.add(createMenu("当前工分", "210", "+15 较上月"));
+            result.add(createMenu("扣分工单数", "1", "0 较上月"));
         }
         return result;
     }
 
-    private static Map<String, Object> createMenu(String title, String value, String desc, String trend, String icon, String color) {
+    private static Map<String, Object> createMenu(String title, String value, String desc) {
         Map<String, Object> map = new HashMap<>();
         map.put("title", title);
         map.put("value", value);
         map.put("desc", desc);
-        map.put("trend", trend);
-        map.put("icon", icon);
-        map.put("color", color);
         return map;
     }
 }

+ 14 - 19
ygtx-ui/src/components/Dashboard/ChartDisplay.vue

@@ -1,8 +1,13 @@
 <template>
   <div class="chart-display">
-    <ChartsGroupOne />
-    <ChartsGroupTwo />
-    <ChartsGroupThree />
+    <!-- postType == 2 时显示 ChartsGroupOne -->
+    <ChartsGroupOne v-if="postType === 2" :post-type="postType" />
+    
+    <!-- postType == 1 时显示 ChartsGroupTwo -->
+    <ChartsGroupTwo v-else-if="postType === 1" :post-type="postType" />
+    
+    <!-- 其他情况显示 ChartsGroupThree -->
+    <ChartsGroupThree v-else :post-type="postType" />
   </div>
 </template>
 
@@ -17,22 +22,17 @@ export default {
     ChartsGroupOne,
     ChartsGroupTwo,
     ChartsGroupThree
+  },
+  props: {
+    postType: {
+      type: Number,
+      default: 0
+    }
   }
 }
 </script>
 
 <style scoped>
-/* 悬浮卡片通用样式 */
-.floating-card {
-  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
-  transition: all 0.3s ease;
-}
-
-.floating-card:hover {
-  transform: translateY(-8px);
-  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
-}
-
 /* 图表样式 */
 .chart-container {
   height: 340px;
@@ -44,11 +44,6 @@ export default {
   backdrop-filter: blur(5px);
 }
 
-.chart-container:hover {
-  transform: translateY(-8px);
-  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
-}
-
 .chart {
   width: 100%;
   height: 100%;

+ 26 - 0
ygtx-ui/src/components/Dashboard/ChartsGroupOne.vue

@@ -21,6 +21,12 @@ import { getChartData } from '@/api/system/dashboard';
 
 export default {
   name: 'ChartsGroupOne',
+  props: {
+    postType: {
+      type: Number,
+      default: 0
+    }
+  },
   data() {
     return {
       barChart: null,
@@ -29,6 +35,17 @@ export default {
       showPieChart: true, // 控制班组成员工分分布饼图的显示
     }
   },
+  watch: {
+    postType: {
+      handler(newVal, oldVal) {
+        if (newVal !== oldVal) {
+          // 当 postType 变化时重新获取数据
+          this.fetchChartData();
+        }
+      },
+      immediate: true
+    }
+  },
   mounted() {
     this.initCharts()
   },
@@ -396,4 +413,13 @@ export default {
   width: 100%;
   height: 100%;
 }
+
+.post-type-debug {
+  margin-top: 10px;
+  padding: 5px;
+  background-color: #f0f0f0;
+  border-radius: 4px;
+  font-size: 12px;
+  color: #666;
+}
 </style>

+ 26 - 0
ygtx-ui/src/components/Dashboard/ChartsGroupThree.vue

@@ -22,6 +22,12 @@ import { getChartData } from '@/api/system/dashboard';
 
 export default {
   name: 'ChartsGroupThree',
+  props: {
+    postType: {
+      type: Number,
+      default: 0
+    }
+  },
   data() {
     return {
       personalWorkOrderChart: null,
@@ -30,6 +36,17 @@ export default {
       showPersonalPointsChart: true, // 控制个人工分统计图表的显示
     }
   },
+  watch: {
+    postType: {
+      handler(newVal, oldVal) {
+        if (newVal !== oldVal) {
+          // 当 postType 变化时重新获取数据
+          this.fetchChartData();
+        }
+      },
+      immediate: true
+    }
+  },
   mounted() {
     this.initCharts()
   },
@@ -386,4 +403,13 @@ export default {
   width: 100%;
   height: 100%;
 }
+
+.post-type-debug {
+  margin-top: 10px;
+  padding: 5px;
+  background-color: #f0f0f0;
+  border-radius: 4px;
+  font-size: 12px;
+  color: #666;
+}
 </style>

+ 26 - 0
ygtx-ui/src/components/Dashboard/ChartsGroupTwo.vue

@@ -29,6 +29,12 @@ import { getChartData } from '@/api/system/dashboard';
 
 export default {
   name: 'ChartsGroupTwo',
+  props: {
+    postType: {
+      type: Number,
+      default: 0
+    }
+  },
   data() {
     return {
       overtimeChart: null,
@@ -39,6 +45,17 @@ export default {
       showMtfChart: true, // 控制MTF曲线图的显示
     }
   },
+  watch: {
+    postType: {
+      handler(newVal, oldVal) {
+        if (newVal !== oldVal) {
+          // 当 postType 变化时重新获取数据
+          this.fetchChartData();
+        }
+      },
+      immediate: true
+    }
+  },
   mounted() {
     this.initCharts()
   },
@@ -553,4 +570,13 @@ export default {
   width: 100%;
   height: 100%;
 }
+
+.post-type-debug {
+  margin-top: 10px;
+  padding: 5px;
+  background-color: #f0f0f0;
+  border-radius: 4px;
+  font-size: 12px;
+  color: #666;
+}
 </style>

+ 59 - 22
ygtx-ui/src/components/Dashboard/DataStatistics.vue

@@ -33,8 +33,43 @@ import { getStatistics } from '@/api/system/dashboard'
 
 export default {
   name: 'DataStatistics',
+  props: {
+    postType: {
+      type: Number,
+      default: 0
+    }
+  },
   data() {
     return {
+      iconList: [
+          // postType == 2 的情况
+          [
+              {icon: "fa fa-calendar-check-o", color: "#165dff", bgcolor: "#e7eeff"},
+              {icon: "fa fa-exclamation-triangle", color: "#faad14", bgcolor: "#fef7e7"},
+              {icon: "fa fa-clock-o", color: "#4e5969", bgcolor: "#edeef0"},
+              {icon: "fa fa-line-chart", color: "#67C23A", bgcolor: "#edf9e8"},
+              {icon: "fa fa-minus-circle", color: "#ff4d4f", bgcolor: "#ffeded"},
+              {icon: "fa fa-users", color: "#36cfc9", bgcolor: "#ebfaf9"}
+          ],
+          // postType == 1 的情况
+          [
+              {icon: "fa fa-calendar", color: "#165dff", bgcolor: "#e7eeff"},
+              {icon: "fa fa-calendar-times-o", color: "#faad14", bgcolor: "#fef7e7"},
+              {icon: "fa fa-calendar-check-o", color: "#67C23A", bgcolor: "#edf9e8"},
+              {icon: "fa fa-exclamation-triangle", color: "#ff4d4f", bgcolor: "#ffeded"},
+              {icon: "fa fa-calendar-plus-o", color: "#4e5969", bgcolor: "#edeef0"},
+              {icon: "fa fa-exclamation-circle", color: "#36cfc9", bgcolor: "#ebfaf9"}
+          ],
+          // 其他情况 (else)
+          [
+              {icon: "fa fa-calendar", color: "#165dff", bgcolor: "#e7eeff"},
+              {icon: "fa fa-exclamation-triangle", color: "#faad14", bgcolor: "#fef7e7"},
+              {icon: "fa fa-calendar-check-o", color: "#67C23A", bgcolor: "#edf9e8"},
+              {icon: "fa fa-exclamation-circle", color: "#ff4d4f", bgcolor: "#ffeded"},
+              {icon: "fa fa-star", color: "#36cfc9", bgcolor: "#ebfaf9"},
+              {icon: "fa fa-minus-circle", color: "#4e5969", bgcolor: "#edeef0"}
+          ]
+      ],
       colorList: {
         blue:{color: '#165dff', bgcolor: '#e7eeff'},
         cyan:{color: '#36cfc9', bgcolor: '#ebfaf9'},
@@ -47,6 +82,17 @@ export default {
       statistics: []
     }
   },
+  watch: {
+    postType: {
+      handler(newVal, oldVal) {
+        if (newVal !== oldVal) {
+          // 当 postType 变化时重新获取数据
+          this.fetchStatistics()
+        }
+      },
+      immediate: true
+    }
+  },
   created() {
     this.fetchStatistics()
   },
@@ -56,14 +102,23 @@ export default {
       try {
         const response = await getStatistics()
         // 根据返回的数据结构处理 statistics
-        this.statistics = response.statistics.map(item => {
+        this.statistics = response.statistics.map((item, index) => {
+          // 根据 postType 选择对应的图标配置
+          let iconConfig = null
+          if (this.postType === 2) {
+            iconConfig = this.iconList[0][index] || this.iconList[0][0]
+          } else if (this.postType === 1) {
+            iconConfig = this.iconList[1][index] || this.iconList[1][0]
+          } else {
+            iconConfig = this.iconList[2][index] || this.iconList[2][0]
+          }
+          
           return {
             title: item.title,
             value: item.value,
             desc: item.desc,
-            trend: item.trend,
-            icon: item.icon,
-            color: this.colorList[item.color].color || '#409EFF'
+            icon: iconConfig.icon,
+            color: iconConfig.color
           }
         })
       } catch (error) {
@@ -74,49 +129,31 @@ export default {
             title: '计划工单总数', 
             value: '1,234', 
             desc: '+12% 较上月', 
-            trend: 'up',
-            icon: 'Document',
-            color: '#409EFF'
           },
           { 
             title: '非计划工单总数', 
             value: '567', 
             desc: '-5% 较上月', 
-            trend: 'down',
-            icon: 'Warning',
-            color: '#E6A23C'
           },
           { 
             title: '总工时', 
             value: '8,765', 
             desc: '0 较上月', 
-            trend: 'same',
-            icon: 'Odometer',
-            color: '#67C23A'
           },
           { 
             title: '平均工单完成率', 
             value: '92.5%', 
             desc: '+2% 较上月', 
-            trend: 'up',
-            icon: 'Check',
-            color: '#909399'
           },
           { 
             title: '扣分工单数量', 
             value: '45', 
             desc: '-3% 较上月', 
-            trend: 'down',
-            icon: 'CircleClose',
-            color: '#F56C6C'
           },
           { 
             title: '班组总数', 
             value: '12', 
             desc: '0 较上月', 
-            trend: 'same',
-            icon: 'User',
-            color: '#409EFF'
           }
         ]
       }

+ 5 - 1
ygtx-ui/src/store/modules/user.js

@@ -15,7 +15,8 @@ const useUserStore = defineStore(
       nickName: '',
       avatar: '',
       roles: [],
-      permissions: []
+      permissions: [],
+      postType: 0  // 添加postType状态
     }),
     actions: {
       // 登录
@@ -58,6 +59,8 @@ const useUserStore = defineStore(
             this.name = user.userName
             this.nickName = user.nickName
             this.avatar = avatar
+            // 设置postType
+            this.postType = res.postType || 0
             /* 初始密码提示 */
             if(res.isDefaultModifyPwd) {
               ElMessageBox.confirm('您的密码还是初始密码,请修改密码!',  '安全提示', {  confirmButtonText: '确定',  cancelButtonText: '取消',  type: 'warning' }).then(() => {
@@ -83,6 +86,7 @@ const useUserStore = defineStore(
             this.token = ''
             this.roles = []
             this.permissions = []
+            this.postType = 0  // 退出时重置postType
             removeToken()
             resolve()
           }).catch(error => {

+ 8 - 143
ygtx-ui/src/views/index.vue

@@ -4,14 +4,16 @@
     <FrequentFeatures />
     
     <!-- 第二部分:数据统计 -->
-    <DataStatistics />
+    <DataStatistics :post-type="postType" />
     
     <!-- 第三部分:图表展示 -->
-    <ChartDisplay />
+    <ChartDisplay :post-type="postType" />
   </div>
 </template>
 
 <script>
+import { mapState } from 'pinia'
+import useUserStore from '@/store/modules/user'
 import FrequentFeatures from '@/components/Dashboard/FrequentFeatures.vue'
 import DataStatistics from '@/components/Dashboard/DataStatistics.vue'
 import ChartDisplay from '@/components/Dashboard/ChartDisplay.vue'
@@ -22,6 +24,10 @@ export default {
     FrequentFeatures,
     DataStatistics,
     ChartDisplay
+  },
+  computed: {
+    // 从store中获取postType
+    ...mapState(useUserStore, ['postType'])
   }
 }
 </script>
@@ -33,24 +39,6 @@ export default {
   position: relative;
 }
 
-.section {
-  margin-bottom: 30px;
-  background-color: rgba(255, 255, 255, 0.85);
-  padding: 20px;
-  border-radius: 12px;
-  backdrop-filter: blur(10px);
-  position: relative;
-  transition: all 0.3s ease;
-}
-
-.section-title {
-  font-size: 18px;
-  font-weight: 600;
-  color: #303133;
-  margin-bottom: 20px;
-  padding-bottom: 10px;
-}
-
 /* 悬浮卡片通用样式 */
 .floating-card {
   box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
@@ -62,129 +50,6 @@ export default {
   box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
 }
 
-/* 高频功能样式 */
-.feature-row {
-  margin-bottom: -20px;
-}
-
-.feature-container {
-  display: flex;
-  flex-wrap: wrap;
-  gap: 20px; /* 替代 el-row 的 gutter */
-}
-
-.feature-card {
-  flex: 1 1 calc(20% - 20px); /* 每行 5 个(20% 宽度),减去 gap 的影响 */
-  min-width: 0; /* 防止内容溢出 */
-  box-sizing: border-box;
-  background: white;
-  border-radius: 8px;
-  padding: 16px;
-  text-align: center;
-  cursor: pointer;
-  transition: transform 0.3s, box-shadow 0.3s;
-}
-
-.feature-card:hover {
-  transform: translateY(-5px);
-  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
-}
-
-.feature-icon {
-  display: inline-flex; /* 让背景圆形和 icon 居中 */
-  align-items: center;
-  justify-content: center;
-  width: 48px; /* 圆形背景的宽度 */
-  height: 48px; /* 圆形背景的高度 */
-  border-radius: 50%; /* 圆形背景 */
-  background-color: rgba(59, 130, 246, 0.1); /* 浅色背景(蓝色示例) */
-  margin-bottom: 8px;
-}
-
-.feature-icon .icon {
-  font-size: 20px; /* icon 大小 */
-  color: #3b82f6; /* icon 颜色(蓝色示例) */
-}
-
-.feature-name {
-  font-size: 14px;
-}
-
-/* 数据统计样式 */
-.stat-card {
-  height: 120px;
-  display: flex;
-  background-color: rgba(245, 247, 250, 0.7);
-  border-radius: 8px;
-  padding: 20px;
-  box-sizing: border-box;
-  margin-bottom: 20px;
-  backdrop-filter: blur(5px);
-  position: relative;
-}
-
-.stat-card:hover {
-  transform: translateY(-8px);
-  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
-}
-
-.stat-icon-wrapper {
-  position: absolute;
-  top: 15px;
-  right: 15px;
-  z-index: 1; /* 确保图标在最上层 */
-}
-
-.stat-icon-bg {
-  width: 36px;
-  height: 36px;
-  border-radius: 50%;
-  background-color: rgba(245, 247, 250, 0.8);
-  display: flex;
-  align-items: center;
-  justify-content: center;
-}
-
-.stat-content {
-  flex: 1;
-  display: flex;
-  flex-direction: column;
-  justify-content: center;
-  align-items: flex-start;
-}
-
-.stat-title {
-  font-size: 14px;
-  color: #6B7280;
-  margin-bottom: 5px;
-  align-self: flex-start;
-}
-
-.stat-value {
-  font-size: 24px;
-  font-weight: 700;
-  color: #000;
-  margin-bottom: 5px;
-  align-self: flex-start;
-}
-
-.stat-desc {
-  font-size: 14px;
-  align-self: flex-start;
-}
-
-.stat-desc-up {
-  color: #67C23A; /* 绿色 */
-}
-
-.stat-desc-down {
-  color: #F56C6C; /* 红色 */
-}
-
-.stat-desc-same {
-  color: #909399; /* 灰色 */
-}
-
 /* 图表样式 */
 .chart-container {
   height: 340px;