approval-summary.vue
5.57 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
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
<template>
<workbench-card title="审批中心" subtitle="多类型待审一览" icon="el-icon-s-claim" tone="blue" :loading="loading">
<div class="approval-hub">
<div
v-for="item in items"
:key="item.key"
class="approval-hub__row"
:class="'is-' + item.tone"
@click="go(item.path)"
>
<span class="approval-hub__icon"><i :class="item.icon" /></span>
<div class="approval-hub__main">
<div class="approval-hub__name">{{ item.label }}</div>
<div class="approval-hub__hint">{{ item.hint }}</div>
</div>
<span class="approval-hub__count" :class="{ 'has-num': item.count > 0 }">{{ item.count }}</span>
<i class="el-icon-arrow-right approval-hub__arrow" />
</div>
</div>
</workbench-card>
</template>
<script>
import request from '@/utils/request'
import WorkbenchCard from '../workbench-card.vue'
import { fetchFlowWorkbenchCounts } from '../flow-counts'
export default {
name: 'WidgetApprovalSummary',
components: { WorkbenchCard },
data() {
return {
loading: false,
flowTodo: 0,
reimbursement: 0,
inventory: 0,
abnormal: 0
}
},
computed: {
items() {
return [
{
key: 'flow',
label: '流程待审',
hint: '待我审核的流程单据',
icon: 'el-icon-s-check',
tone: 'orange',
path: '/workFlow/flowTodo',
count: this.flowTodo
},
{
key: 'reimb',
label: '报销待审',
hint: '待审批的报销申请',
icon: 'el-icon-wallet',
tone: 'green',
path: '/lqReimbursementApplication',
count: this.reimbursement
},
{
key: 'inv',
label: '领用待审',
hint: '库存领用待审批',
icon: 'el-icon-box',
tone: 'cyan',
path: '/lqInventory/application-list',
count: this.inventory
},
{
key: 'abn',
label: '异常耗卡',
hint: '待处理异常消耗',
icon: 'el-icon-warning-outline',
tone: 'red',
path: '/lqXhHyhk',
count: this.abnormal
}
]
}
},
mounted() {
this.load()
},
methods: {
go(path) {
if (path) this.$router.push(path).catch(() => {})
},
async load() {
this.loading = true
try {
const [flowCounts, reimbRes, invRes, abnRes] = await Promise.all([
fetchFlowWorkbenchCounts().catch(() => ({ toBeReviewed: 0 })),
request({
url: '/api/Extend/LqReimbursementApplication/Actions/PendingApproval',
method: 'get',
data: { currentPage: 1, pageSize: 1 }
}).catch(() => ({ data: {} })),
request({
url: '/api/Extend/LqInventoryUsage/GetPendingApprovalList',
method: 'get',
data: { currentPage: 1, pageSize: 1 }
}).catch(() => ({ data: {} })),
request({
url: '/api/Extend/LqXhHyhk/Actions/GetAbnormalConsumeCount',
method: 'get',
data: {}
}).catch(() => ({ data: {} }))
])
this.flowTodo = flowCounts.toBeReviewed || 0
this.reimbursement = this.extractTotal(reimbRes.data)
this.inventory = this.extractTotal(invRes.data)
this.abnormal = (abnRes.data && abnRes.data.count) || 0
} finally {
this.loading = false
}
},
extractTotal(data) {
if (!data) return 0
if (data.pagination && data.pagination.total !== undefined) return data.pagination.total
if (data.pagination && data.pagination.Total !== undefined) return data.pagination.Total
return 0
}
}
}
</script>
<style lang="scss" scoped>
.approval-hub {
height: 100%;
display: flex;
flex-direction: column;
gap: 8px;
overflow: hidden;
}
.approval-hub__row {
flex: 1;
min-height: 0;
display: flex;
align-items: center;
gap: 10px;
padding: 8px 10px;
border-radius: 10px;
background: #f8fafc;
border: 1px solid transparent;
cursor: pointer;
transition: background 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
&:hover {
background: #fff;
border-color: #d6e8ff;
box-shadow: 0 4px 12px rgba(64, 158, 255, 0.08);
}
}
.approval-hub__icon {
width: 34px;
height: 34px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
flex-shrink: 0;
}
.is-orange .approval-hub__icon { background: #fff7ed; color: #f59e0b; }
.is-green .approval-hub__icon { background: #ecfdf5; color: #10b981; }
.is-cyan .approval-hub__icon { background: #ecfeff; color: #06b6d4; }
.is-red .approval-hub__icon { background: #fef2f2; color: #ef4444; }
.approval-hub__main {
flex: 1;
min-width: 0;
}
.approval-hub__name {
font-size: 13px;
font-weight: 600;
color: #1e293b;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.approval-hub__hint {
margin-top: 1px;
font-size: 11px;
color: #94a3b8;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.approval-hub__count {
min-width: 28px;
height: 28px;
padding: 0 8px;
border-radius: 14px;
background: #eef2f7;
color: #64748b;
font-size: 14px;
font-weight: 700;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
&.has-num {
background: #ecf5ff;
color: #409eff;
}
}
.is-red .approval-hub__count.has-num {
background: #fef2f2;
color: #ef4444;
}
.approval-hub__arrow {
color: #cbd5e1;
font-size: 12px;
flex-shrink: 0;
}
</style>