quick-actions.vue
4.08 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
<template>
<workbench-card title="快捷入口" subtitle="常用功能一键直达" icon="el-icon-menu" tone="blue">
<div class="quick-grid">
<div
v-for="item in actions"
:key="item.path"
class="quick-item"
@click="go(item.path)"
>
<div class="quick-item__icon" :class="'is-' + item.tone">
<i :class="item.icon" />
</div>
<span class="quick-item__label">{{ item.label }}</span>
</div>
<div v-if="!actions.length" class="wb-empty">
<div class="wb-empty__circle"><i class="el-icon-menu" /></div>
<div class="wb-empty__title">暂无可用入口</div>
<div class="wb-empty__desc">当前账号菜单权限下无可展示快捷项</div>
</div>
</div>
</workbench-card>
</template>
<script>
import { mapGetters } from 'vuex'
import WorkbenchCard from '../workbench-card.vue'
const DEFAULT_ACTIONS = [
{ label: '战略看板', icon: 'el-icon-data-line', path: '/statisticsList/form9', encode: 'form9', tone: 'blue' },
{ label: '开单管理', icon: 'el-icon-document-add', path: '/lqKdKdjlb', encode: 'lqKdKdjlb', tone: 'green' },
{ label: '消耗管理', icon: 'el-icon-s-operation', path: '/lqXhHyhk', encode: 'lqXhHyhk', tone: 'purple' },
{ label: '会员管理', icon: 'el-icon-user', path: '/lqKhxx', encode: 'lqKhxx', tone: 'orange' },
{ label: '流程待办', icon: 'el-icon-s-check', path: '/workFlow/flowTodo', encode: 'flowTodo', tone: 'red' },
{ label: '报销申请', icon: 'el-icon-wallet', path: '/lqReimbursementApplication', encode: 'lqReimbursementApplication', tone: 'cyan' },
{ label: '门店管理', icon: 'el-icon-office-building', path: '/lqMdxx', encode: 'lqMdxx', tone: 'blue' },
{ label: '报表中心', icon: 'el-icon-data-analysis', path: '/report', encode: 'report', tone: 'green' }
]
export default {
name: 'WidgetQuickActions',
components: { WorkbenchCard },
computed: {
...mapGetters(['menuList']),
actions() {
const flat = []
const walk = (list) => {
;(list || []).forEach(m => {
if (m.urlAddress) flat.push(m)
if (m.children && m.children.length) walk(m.children)
})
}
walk(this.menuList)
const paths = new Set(flat.map(m => (m.urlAddress || '').replace(/^\//, '')))
return DEFAULT_ACTIONS.filter(a => {
const enc = a.encode.toLowerCase()
return [...paths].some(p => p.toLowerCase().includes(enc) || p.toLowerCase() === a.path.replace(/^\//, '').toLowerCase())
})
}
},
methods: {
go(path) {
if (path) this.$router.push(path).catch(() => {})
}
}
}
</script>
<style lang="scss" scoped>
@import '../widget-common.scss';
.quick-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
height: 100%;
align-content: start;
}
.quick-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 12px 6px;
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 14px rgba(64, 158, 255, 0.1);
}
&__icon {
width: 40px;
height: 40px;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
margin-bottom: 8px;
&.is-blue { background: #ecf5ff; color: #409eff; }
&.is-green { background: #ecfdf5; color: #10b981; }
&.is-purple { background: #f5f3ff; color: #8b5cf6; }
&.is-orange { background: #fff7ed; color: #f59e0b; }
&.is-red { background: #fef2f2; color: #ef4444; }
&.is-cyan { background: #ecfeff; color: #06b6d4; }
}
&__label {
font-size: 12px;
color: #475569;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
}
}
@media (max-width: 1200px) {
.quick-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
.quick-item { transition: none; }
}
</style>