WXL (wul)
2 天以前 d3c60e18b95b50751f8088fa2d23cd8ff7f173bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<template>
  <div class="statistics-cards" style="margin-bottom: 20px">
    <el-row :gutter="16">
      <el-col
        v-for="(item, index) in mergedCardList"
        :key="index"
        :xs="12"
        :sm="8"
        :md="dynamicColSpan"
        :lg="dynamicColSpan"
      >
        <el-tooltip
          :content="getTooltipContent(item.name)"
          placement="top"
          effect="light"
          popper-class="statistics-tooltip"
        >
          <el-card
            shadow="hover"
            :body-style="item.router ? 'cursor: pointer' : 'cursor: default'"
            :class="getCardClass(item.name)"
          >
            <div class="card-content" @click="handleCardClick(item)">
              <div class="card-label">
                <span class="label-text">{{ item.name }}</span>
              </div>
              <div class="card-value">
                {{
                  item.value !== undefined && item.value !== null
                    ? item.value
                    : 0
                }}
              </div>
            </div>
          </el-card>
        </el-tooltip>
      </el-col>
    </el-row>
  </div>
</template>
 
<script>
export default {
  name: "StatisticsCards",
  props: {
    cardlist: {
      type: Array,
      default: () => [],
    },
    colSpan: {
      type: Number,
      default: 4,
    },
    showExtra: {
      type: Boolean,
      default: true,
    },
    ycvalue: {
      type: Number,
      default: 0,
    },
    jgvalue: {
      type: Number,
      default: 0,
    },
    showWarningCondition: {
      type: Boolean,
      default: false,
    },
  },
  computed: {
    mergedCardList() {
      let list = [...this.cardlist];
 
      if (this.showExtra) {
        list.push({
          name: "异常",
          value: this.ycvalue,
        });
      }
 
      if (this.showWarningCondition) {
        list.push({
          name: "警告",
          value: this.jgvalue,
        });
      }
 
      return list;
    },
    // 动态计算每列占的栅格数
    dynamicColSpan() {
      const totalCards = this.mergedCardList.length;
 
      if (totalCards <= 4) return 6; // 一行4个
      if (totalCards <= 6) return 4; // 一行6个
      if (totalCards <= 8) return 3; // 一行8个
      return 2; // 一行12个
    },
  },
  methods: {
    getCardClass(name) {
      const classMap = {
        患者服务总量: "total-card",
        无需随访: "no-follow-card",
        需随访: "need-follow-card",
        待随访: "pending-card",
        已完成: "completed-card",
        异常: "error-card",
        警告: "warning-card",
      };
      return classMap[name] || "default-card";
    },
 
    getTooltipContent(name) {
      const tooltips = {
        患者服务总量: "患者服务总量 = 无需随访 + 需随访",
        无需随访: "无需随访:不需要进行随访的患者数量",
        需随访: "需随访 = 待随访 + 已完成",
        待随访: "待随访:等待进行随访的患者数量",
        已完成: "已完成:已完成随访的患者数量",
        异常: "异常数据统计",
        警告: "警告数据统计",
      };
      return tooltips[name] || "";
    },
 
    handleCardClick(item) {
      if (item.router) {
        this.$router.push(item.router);
      }
      this.$emit("card-click", item);
    },
  },
};
</script>
 
<style scoped>
.statistics-cards {
  padding: 4px;
}
 
.card-content {
  padding: 12px 8px;
  transition: all 0.3s ease;
  cursor: default;
}
 
.card-label {
  margin-bottom: 10px;
  font-size: 20px;
  font-weight: 600;
  color: #666;
}
 
.card-value {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 1px;
  transition: all 0.3s ease;
}
 
/* 悬浮效果 - 整体上移+阴影加深 */
.el-card {
  border-radius: 10px;
  transition: all 0.3s ease;
  border: none;
}
 
.el-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1) !important;
}
 
/* 响应式 */
@media (max-width: 768px) {
  .card-value {
    font-size: 22px;
  }
  .card-content {
    padding: 12px 8px;
  }
}
</style>
 
<style>
/* ===== 卡片背景色(全局样式) ===== */
 
/* 患者服务总量 - 浅紫色 */
.total-card .el-card__body {
  background: #f0edff;
  border-radius: 10px;
}
.total-card .card-value {
  color: #7c5cfc;
}
 
/* 无需随访 - 浅粉色 */
.no-follow-card .el-card__body {
  background: #fde8ef;
  border-radius: 10px;
}
.no-follow-card .card-value {
  color: #f06292;
}
 
/* 需随访 - 浅蓝色 */
.need-follow-card .el-card__body {
  background: #e3f2fd;
  border-radius: 10px;
}
.need-follow-card .card-value {
  color: #42a5f5;
}
 
/* 待随访 - 浅橙色 */
.pending-card .el-card__body {
  background: #fff3e0;
  border-radius: 10px;
}
.pending-card .card-value {
  color: #ff9800;
}
 
/* 已完成 - 浅绿色 */
.completed-card .el-card__body {
  background: #e8f5e9;
  border-radius: 10px;
}
.completed-card .card-value {
  color: #66bb6a;
}
 
/* 异常 - 浅红色 */
.error-card .el-card__body {
  background: #fce4ec;
  border-radius: 10px;
}
.error-card .card-value {
  color: #ef5350;
}
 
/* 警告 - 浅黄色 */
.warning-card .el-card__body {
  background: #fff8e1;
  border-radius: 10px;
}
.warning-card .card-value {
  color: #ffa726;
}
 
/* 默认卡片 */
.default-card .el-card__body {
  background: #f5f5f5;
  border-radius: 10px;
}
.default-card .card-value {
  color: #757575;
}
 
/* ===== 清新白底蓝字 Tooltip ===== */
.statistics-tooltip {
  background: #ffffff !important;
  color: #1976d2 !important;
  border: 1px solid #bbdefb !important;
  border-radius: 8px !important;
  padding: 10px 14px !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.15) !important;
}
 
.statistics-tooltip .popper__arrow {
  border-bottom-color: #bbdefb !important;
}
 
.statistics-tooltip .popper__arrow::after {
  border-bottom-color: #ffffff !important;
}
</style>