vben
authored
|
1
|
<template>
|
柏杨
authored
|
2
|
<div class="md:flex" v-if="exchangeTab === 'tab1'">
|
Vben
authored
|
3
4
5
|
<template v-for="(item, index) in growCardList" :key="item.title">
<Card
size="small"
|
vben
authored
|
6
|
:loading="loading"
|
Vben
authored
|
7
|
:title="item.title"
|
|
8
|
class="md:w-1/4 w-full !md:mt-0"
|
sanmu
authored
|
9
|
:class="{ '!md:mr-4': index + 1 < 5, '!mt-4': index > 0 }"
|
Vben
authored
|
10
|
>
|
sanmu
authored
|
11
|
<!-- <template #extra>
|
Vben
authored
|
12
|
<Tag :color="item.color">{{ item.action }}</Tag>
|
sanmu
authored
|
13
|
</template> -->
|
Vben
authored
|
14
|
|
|
15
|
<div class="py-4 px-4 flex justify-between items-center">
|
sanmu
authored
|
16
17
|
<CountTo :startVal="1" :endVal="item.value" class="text-2xl" />
<!-- <Icon :icon="item.icon" :size="40" /> -->
|
Vben
authored
|
18
19
|
</div>
|
sanmu
authored
|
20
|
<!-- <div class="p-2 px-4 flex justify-between">
|
Vben
authored
|
21
22
|
<span>总{{ item.title }}</span>
<CountTo prefix="$" :startVal="1" :endVal="item.total" />
|
sanmu
authored
|
23
|
</div> -->
|
Vben
authored
|
24
25
|
</Card>
</template>
|
vben
authored
|
26
|
</div>
|
柏杨
authored
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
<div class="md:flex" v-if="exchangeTab === 'tab2'">
<template v-for="(item, index) in growCardList2" :key="item.title">
<Card
size="small"
:loading="loading"
:title="item.title"
class="md:w-1/4 w-full !md:mt-0"
:class="{ '!md:mr-4': index + 1 < 5, '!mt-4': index > 0 }"
>
<div class="py-4 px-4 flex justify-between items-center" style="font-size: 20px">
{{ item.value }}
</div>
</Card>
</template>
</div>
|
vben
authored
|
42
|
</template>
|
vben
authored
|
43
|
<script lang="ts" setup>
|
Vben
authored
|
44
|
import { CountTo } from '/@/components/CountTo/index';
|
vben
authored
|
45
|
import Icon from '@/components/Icon/Icon.vue';
|
Vben
authored
|
46
47
|
import { Tag, Card } from 'ant-design-vue';
import { growCardList } from '../data';
|
sanmu
authored
|
48
|
import { useDataStoreWithOut } from '/@/store/modules/data';
|
柏杨
authored
|
49
|
import { computed, onMounted, ref, watch, watchEffect } from 'vue';
|
柏杨
authored
|
50
51
52
53
54
55
56
|
import {
exchangeTab,
businessPersonIn,
customerCodeIn,
dateTime,
period,
} from '/@/store/modules/user';
|
柏杨
authored
|
57
|
import { number } from 'vue-types';
|
柏杨
authored
|
58
|
import { getSalesData, getApiData } from '/@/api/project/global';
|
柏杨
authored
|
59
|
import { useOrderStoreWithOut } from '/@/store/modules/order';
|
sanmu
authored
|
60
61
|
const dataStore = useDataStoreWithOut();
|
柏杨
authored
|
62
63
64
65
66
67
|
const data1 = ref();
watch(
[dateTime, period],
async ([newDateTime, newPeriod], [oldBusinessPersonIn, oldCustomerCodeIn]) => {
console.log('businessPersonIn changed from', oldBusinessPersonIn, 'to', newDateTime);
console.log('customerCodeIn changed from', oldCustomerCodeIn, 'to', newPeriod);
|
sanmu
authored
|
68
|
|
柏杨
authored
|
69
70
71
72
73
74
75
|
// 在这里添加你希望在这两个值改变时执行的逻辑
data1.value = await getApiData({
dateTime: newDateTime,
period: newPeriod,
});
},
);
|
sanmu
authored
|
76
77
|
const growCardList = computed(() => {
const data = dataStore.getData;
|
柏杨
authored
|
78
|
console.log(data1.value, '5656data1.value');
|
sanmu
authored
|
79
80
81
82
|
return [
{
title: '订单完成',
icon: 'visit-count|svg',
|
柏杨
authored
|
83
|
value: data1.value?.allCount || 0,
|
sanmu
authored
|
84
85
86
87
88
89
90
|
total: 120000,
color: 'green',
action: '月',
},
{
title: '跟单和质检中',
icon: 'total-sales|svg',
|
柏杨
authored
|
91
|
value: data1.value?.trackingAndInspectingList || 0,
|
sanmu
authored
|
92
93
94
95
96
97
98
|
total: 500000,
color: 'blue',
action: '月',
},
{
title: '利润分析表待审核',
icon: 'download-count|svg',
|
柏杨
authored
|
99
|
value: data1.value?.profitList || 0,
|
sanmu
authored
|
100
101
102
103
104
105
106
|
total: 120000,
color: 'orange',
action: '周',
},
{
title: '项目报告书待审核',
icon: 'transaction|svg',
|
柏杨
authored
|
107
|
value: data1.value?.reportList || 0,
|
sanmu
authored
|
108
109
110
111
112
113
114
|
total: 50000,
color: 'purple',
action: '年',
},
{
title: '订单初始化',
icon: 'transaction|svg',
|
柏杨
authored
|
115
|
value: data1.value?.orderInitList || 0,
|
sanmu
authored
|
116
117
118
119
120
121
|
total: 50000,
color: 'purple',
action: '年',
},
];
});
|
柏杨
authored
|
122
123
124
125
126
127
128
129
|
const data2 = ref();
// watchEffect(async () => {
// data2.value = await getSalesData({
// businessPersonIn: businessPersonIn,
// customerCodeIn: customerCodeIn,
// });
// });
onMounted(async () => {
|
柏杨
authored
|
130
131
132
133
134
|
data1.value = await getApiData({
dateTime: dateTime.value,
period: period.value,
});
console.log(data1.value, '56565656');
|
柏杨
authored
|
135
136
137
138
139
140
141
|
data2.value = await getSalesData({
businessPersonIn: businessPersonIn.value,
customerCodeIn: customerCodeIn.value,
});
});
watch(
[businessPersonIn, customerCodeIn],
|
柏杨
authored
|
142
143
144
|
async ([newDateTime, newPeriod], [oldBusinessPersonIn, oldCustomerCodeIn]) => {
console.log('businessPersonIn changed from', oldBusinessPersonIn, 'to', newDateTime);
console.log('customerCodeIn changed from', oldCustomerCodeIn, 'to', newPeriod);
|
柏杨
authored
|
145
146
147
|
// 在这里添加你希望在这两个值改变时执行的逻辑
data2.value = await getSalesData({
|
柏杨
authored
|
148
149
|
businessPersonIn: newDateTime,
customerCodeIn: newPeriod,
|
柏杨
authored
|
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
|
});
},
);
const growCardList2 = computed(() => {
return [
{
title: '总销售额',
icon: 'visit-count|svg',
value: data2.value?.yearlySalesAmountTarget || 0,
total: 120000,
color: 'green',
action: '年',
},
{
title: '总销售额完成率',
icon: 'visit-count|svg',
value: data2.value?.yearlySalesAmountCompletionRate || 0,
total: 120000,
color: 'green',
action: '年',
},
{
title: '每月销售额目标',
icon: 'visit-count|svg',
value: data2.value?.monthlySalesAmountTarget || 0,
total: 120000,
color: 'green',
action: '月',
},
{
title: '当月销售额完成率',
icon: 'visit-count|svg',
value: data2.value?.monthlySalesAmountCompletionRate || 0,
total: 120000,
color: 'green',
action: '月',
},
{
title: '今日销售额',
icon: 'visit-count|svg',
value: data2.value?.daylySalesAmount || 0,
total: 120000,
color: 'green',
action: '日',
},
];
});
|
vben
authored
|
197
198
199
200
201
|
defineProps({
loading: {
type: Boolean,
},
|
柏杨
authored
|
202
203
204
|
exchangeTab: {
type: String,
},
|
vben
authored
|
205
|
});
|
vben
authored
|
206
|
</script>
|