GrowCard.vue
5.3 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
<template>
<div class="md:flex" v-if="exchangeTab === 'tab1'">
<template v-for="(item, index) in growCardList" :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 }"
>
<!-- <template #extra>
<Tag :color="item.color">{{ item.action }}</Tag>
</template> -->
<div class="py-4 px-4 flex justify-between items-center">
<CountTo :startVal="1" :endVal="item.value" class="text-2xl" />
<!-- <Icon :icon="item.icon" :size="40" /> -->
</div>
<!-- <div class="p-2 px-4 flex justify-between">
<span>总{{ item.title }}</span>
<CountTo prefix="$" :startVal="1" :endVal="item.total" />
</div> -->
</Card>
</template>
</div>
<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>
</template>
<script lang="ts" setup>
import { CountTo } from '/@/components/CountTo/index';
import Icon from '@/components/Icon/Icon.vue';
import { Tag, Card } from 'ant-design-vue';
import { growCardList } from '../data';
import { useDataStoreWithOut } from '/@/store/modules/data';
import { computed, onMounted, ref, watch, watchEffect } from 'vue';
import { exchangeTab, businessPersonIn, customerCodeIn } from '/@/store/modules/user';
import { number } from 'vue-types';
import { getSalesData, getCustomerSalesData } from '/@/api/project/global';
import { useOrderStoreWithOut } from '/@/store/modules/order';
const dataStore = useDataStoreWithOut();
const growCardList = computed(() => {
const data = dataStore.getData;
return [
{
title: '订单完成',
icon: 'visit-count|svg',
value: data?.orderFinishedCount || 0,
total: 120000,
color: 'green',
action: '月',
},
{
title: '跟单和质检中',
icon: 'total-sales|svg',
value: data?.orderInspectingCount || 0,
total: 500000,
color: 'blue',
action: '月',
},
{
title: '利润分析表待审核',
icon: 'download-count|svg',
value: data?.orderProfitWaitAuditCount || 0,
total: 120000,
color: 'orange',
action: '周',
},
{
title: '项目报告书待审核',
icon: 'transaction|svg',
value: data?.orderReportWaitAuditCount || 0,
total: 50000,
color: 'purple',
action: '年',
},
{
title: '订单初始化',
icon: 'transaction|svg',
value: data?.orderCount || 0,
total: 50000,
color: 'purple',
action: '年',
},
];
});
const data2 = ref();
// watchEffect(async () => {
// data2.value = await getSalesData({
// businessPersonIn: businessPersonIn,
// customerCodeIn: customerCodeIn,
// });
// });
onMounted(async () => {
data2.value = await getSalesData({
businessPersonIn: businessPersonIn.value,
customerCodeIn: customerCodeIn.value,
});
});
watch(
[businessPersonIn, customerCodeIn],
async ([newBusinessPersonIn, newCustomerCodeIn], [oldBusinessPersonIn, oldCustomerCodeIn]) => {
console.log('businessPersonIn changed from', oldBusinessPersonIn, 'to', newBusinessPersonIn);
console.log('customerCodeIn changed from', oldCustomerCodeIn, 'to', newCustomerCodeIn);
// 在这里添加你希望在这两个值改变时执行的逻辑
data2.value = await getSalesData({
businessPersonIn: newBusinessPersonIn,
customerCodeIn: newCustomerCodeIn,
});
},
);
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: '日',
},
];
});
defineProps({
loading: {
type: Boolean,
},
exchangeTab: {
type: String,
},
});
</script>