dashboardConfig.js
4.38 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
/**
* 首页看板 / 表格静态配置(自 index_mixins 抽离)
*/
export const STATIC_DATA_LIST = [
{ label: '今日营业额', valueObj: 'merchantTodayTotal', tipsLabel: '今日成交量' },
{ label: '本月营业额', valueObj: 'merchantMonthTotal', tipsLabel: '本月成交量' },
{ label: '累计营业额', valueObj: 'merchantTotal', tipsLabel: '累计成交量' }
]
export const TOTAL_TABLE_SUM = [
{ name: 'filmTimesTotalSum' },
{ name: 'usedTotalSum' },
{ name: 'experienceTotalSum' },
{ name: 'upgradeTotalSum' },
{ name: 'orderMoneyTotalSum' },
{ name: 'customerUnitMoneySum' },
{ name: 'upgradeRateSum' }
]
export const TABLE_OBJ = [
{ name: '贴膜', unit: '/台', key: 'filmTimes', width: 'var(--fontSize110)' },
{ name: '核销', unit: '/张', key: 'usedTotal', width: 'var(--fontSize110)' },
{ name: '体验', unit: '/位', key: 'experienceTotal', width: 'var(--fontSize110)' },
{ name: '转化', unit: '/单', key: 'upgradeTotal', width: 'var(--fontSize110)' },
{ name: '营业额', unit: '', key: 'orderMoneyTotal', sort: false, width: 'var(--fontSize110)' },
{ name: '客单价', unit: '', key: 'customerUnitMoney', width: 'var(--fontSize110)' },
{ name: '转化率', unit: '', key: 'upgradeRate', width: 'var(--fontSize110)' }
]
export const ORDER_BY_TYPE_ENUM = {
true: [1, 3, 13, 5, 7, 9, 11],
false: [2, 4, 14, 6, 8, 10, 12]
}
export const WIDE_SUM_COLUMNS = ['orderMoneyTotalSum', 'customerUnitMoneySum']
export const CHANGE_BTN_DATA = [
{ label: '本日', valueObj: 'staffTodayTotal', valueFn: 'merchantTodayTotal' },
{ label: '本月', valueObj: 'staffMonthTotal', valueFn: 'merchantMonthTotal' },
{ label: '累计', valueObj: 'staffTotal', valueFn: 'merchantTotal' }
]
export const DEFAULT_TOTAL_LIST = [
{
name: '已预约',
itemName: 'totalInvited',
index: 2,
url: 'pages.tabDateIndex',
icon: 'icon_14',
activeIndex: 1,
waitname: '待预约客户',
waititemName: 'totalWaitToInvited',
waiturl: 'pages.tabDateIndex',
activeWIndex: 2
},
{
name: '转化订单',
itemName: 'totalUpgrade',
index: 4,
url: 'pages.index',
icon: 'icon_17',
activeIndex: 2
},
{
name: '战败订单',
itemName: 'totalNotUpgrade',
index: 5,
url: 'pages.index',
icon: 'icon_16',
activeIndex: 3
},
{
name: '客单价',
itemName: 'customerUnitPrice',
unit: '¥',
icon: 'icon_7',
index: 6,
url: 'tabOperating.index'
}
]
export const TECHNICIAN_TOTAL_LIST = [
{
name: '窗膜(本月/累计)',
itemName: 'currentMonthSunroofCount',
waititemName: 'totalSunroofCount'
},
{
name: '车衣(本月/累计)',
itemName: 'currentMonthCarSeatCount',
waititemName: 'totalCarSeatCount'
},
{
name: '精品(本月/累计)',
itemName: 'currentMonthPremiumCount',
waititemName: 'totalPremiumCount'
}
]
export const TABLE_BTN = [
{ text: '今日', type: 'today', active: true },
{ text: '本月', type: 'month' },
{ text: '自定义', type: 'date' }
]
export const LOGIN_ROLE_LABEL = {
1: '超管',
2: '商户管理员',
3: '区域运营',
4: '驻店负责人',
5: '广联销售',
6: '飞行督导',
7: '技师',
8: '技师督导'
}
/** 深拷贝看板表格配置(避免运行时 mutate 污染模块常量) */
export function cloneDashboardTableConfig() {
return {
staticDataList: STATIC_DATA_LIST.map(x => ({ ...x })),
totalTableSum: TOTAL_TABLE_SUM.map(x => ({ ...x })),
tableObj: TABLE_OBJ.map(x => ({ ...x })),
orderByTypeEnum: { ...ORDER_BY_TYPE_ENUM },
changeBtnData: CHANGE_BTN_DATA.map(x => ({ ...x })),
totalList: DEFAULT_TOTAL_LIST.map(x => ({ ...x })),
technicianTotalList: TECHNICIAN_TOTAL_LIST.map(x => ({ ...x })),
tableBtn: TABLE_BTN.map(x => ({ ...x })),
loginRoleLabel: { ...LOGIN_ROLE_LABEL }
}
}
/**
* 根据合计列动态计算表格宽度
*/
export function computeTableWidth(totalTableSum = [], tableObj = []) {
let sumWidth = 0
totalTableSum.forEach((element, index) => {
if (WIDE_SUM_COLUMNS.includes(element.name)) {
const length = element.total?.toString().length || 0
const labelWidth = length > 5 ? length * 20 : 118
if (tableObj[index]) tableObj[index].width = labelWidth + 'rpx'
sumWidth += labelWidth
}
})
return 118 * 5 + 232 + 30 + sumWidth
}
/**
* 产值完成率(百分比数值)
*/
export function computeRatePercent(outputValue = 0, targetValue = 0, round = (n, d) => n) {
if (!targetValue) return 0
const rate = round((outputValue / targetValue) * 100, 2)
return rate
}