abnormal-consume-alert.vue
2.78 KB
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
<template>
<workbench-card title="异常耗卡提醒" subtitle="待处理异常" icon="el-icon-warning" tone="red" :loading="loading">
<div class="alert" :class="{ 'is-danger': count > 0 }" @click="go">
<div class="alert__icon"><i class="el-icon-warning-outline" /></div>
<div class="alert__num">{{ count }}</div>
<div class="alert__text">待处理异常耗卡</div>
<div class="alert__link">立即处理 <i class="el-icon-arrow-right" /></div>
</div>
</workbench-card>
</template>
<script>
import { mapGetters } from 'vuex'
import request from '@/utils/request'
import WorkbenchCard from '../workbench-card.vue'
export default {
name: 'WidgetAbnormalConsumeAlert',
components: { WorkbenchCard },
data() {
return { loading: false, count: 0 }
},
computed: {
...mapGetters(['userInfo']),
storeId() {
return (this.userInfo && this.userInfo.mdid) || ''
}
},
mounted() {
this.load()
},
methods: {
async load() {
this.loading = true
try {
const d = new Date()
const y = d.getFullYear()
const m = String(d.getMonth() + 1).padStart(2, '0')
const res = await request({
url: '/api/Extend/LqXhHyhk/Actions/GetAbnormalConsumeCount',
method: 'GET',
data: {
md: this.storeId || undefined,
hksj: `${y}-${m}-01,${y}-${m}-${new Date(y, d.getMonth() + 1, 0).getDate()}`
}
})
this.count = (res.data && res.data.count) || 0
} catch (e) {
this.count = 0
} finally {
this.loading = false
}
},
go() {
this.$router.push('/lqXhHyhk').catch(() => {})
}
}
}
</script>
<style lang="scss" scoped>
.alert {
height: 100%;
min-height: 110px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 12px;
border-radius: 10px;
background: #ecfdf5;
border: 1px solid #d1fae5;
cursor: pointer;
transition: box-shadow 200ms ease, border-color 200ms ease;
&:hover {
box-shadow: 0 4px 14px rgba(16, 185, 129, 0.12);
}
&.is-danger {
background: #fef2f2;
border-color: #fecaca;
.alert__icon { background: #fee2e2; color: #ef4444; }
.alert__num { color: #ef4444; }
&:hover { box-shadow: 0 4px 14px rgba(239, 68, 68, 0.12); }
}
}
.alert__icon {
width: 40px;
height: 40px;
border-radius: 12px;
background: #d1fae5;
color: #10b981;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
margin-bottom: 8px;
}
.alert__num {
font-size: 28px;
font-weight: 700;
color: #10b981;
line-height: 1.1;
letter-spacing: -0.02em;
}
.alert__text {
margin-top: 4px;
font-size: 13px;
color: #64748b;
}
.alert__link {
margin-top: 8px;
font-size: 12px;
color: #409eff;
}
</style>