Vben
authored
|
1
|
<template>
|
柏杨
authored
|
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
|
<div style="margin-bottom: 30px">
<span v-if="role === ROLE.ADMIN">
<span style="font-size: 18px; margin-right: 10px">业务员</span>
<a-select
v-model:value="value1"
show-search
placeholder="请选择"
style="width: 200px"
:options="customerCodeOptions"
:filter-option="filterOption"
@focus="handleFocus"
@blur="handleBlur"
@change="handleChangeBusiness"
/>
<span style="font-size: 18px; margin-left: 50px; margin-right: 10px">客户编码</span>
<a-select
v-model:value="value2"
show-search
placeholder="请选择"
style="width: 200px"
:options="businessPersonOptions"
:filter-option="filterOption"
@focus="handleFocus"
@blur="handleBlur"
@change="handleChangeCustomer"
/>
<span style="right: 10px"
><a-button
type="default"
@click="clearData"
:style="{ marginLeft: '100px', borderRadius: '5px 5px 5px 5px' }"
>
重置
</a-button>
<a-button
:style="{ marginLeft: '20px', borderRadius: '5px 5px 5px 5px' }"
shape="default"
type="primary"
@click="updateData"
>查询</a-button
></span
></span
>
<div style="position: fixed; top: 80px; right: 70px">
<a-radio-group
v-model:value="periodChange"
class="custom-radio-group"
:style="{ marginLeft: '100px' }"
>
<a-radio-button value="MONTH" @click="handlePeriodChange('MONTH')">月</a-radio-button>
<a-radio-button value="QUARTER" @click="handlePeriodChange('QUARTER')">季度</a-radio-button>
<a-radio-button value="YEAR" @click="handlePeriodChange('YEAR')">年</a-radio-button>
</a-radio-group>
</div></div
>
<div v-if="role !== ROLE.ADMIN" style="margin-bottom: 60px"></div>
|
柏杨
authored
|
58
|
<div ref="chartRef" :style="{ height: '400px', width }"></div>
|
Vben
authored
|
59
|
</template>
|
|
60
61
62
|
<script lang="ts">
import { basicProps } from './props';
</script>
|
vben
authored
|
63
|
<script lang="ts" setup>
|
柏杨
authored
|
64
|
import { computed, onMounted, ref, Ref, watchEffect } from 'vue';
|
Vben
authored
|
65
|
import { useECharts } from '/@/hooks/web/useECharts';
|
柏杨
authored
|
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
|
import { useDataStoreWithOut } from '/@/store/modules/data';
import { businessPersonIn, customerCodeIn, useUserStoreWithOut } from '@/store/modules/user';
//biaoji
import type { SelectProps } from 'ant-design-vue';
import { getCustomerSalesData } from '/@/api/project/global';
import { useOrderStoreWithOut } from '/@/store/modules/order';
import { useOrderInfo } from '/@/hooks/component/order';
import { ROLE } from '/@/views/project/order/type.d';
const userStore = useUserStoreWithOut();
const user = userStore.getUserInfo;
const role = computed(() => {
return user?.roleSmallVO?.code;
});
const orderStore = useOrderStoreWithOut();
console.log(orderStore, '5656order');
onMounted(async () => {
await orderStore.getDict();
});
const { customerCode: customerCodeOptions, businessPerson: businessPersonOptions } =
useOrderInfo(orderStore);
const periodChange = ref('MONTH');
// const businessPersonInChange = ref();
const businessPersonInChange: string[] = [];
const customerCodeInChange: string[] = [];
const handleChangeBusiness = (value: string) => {
if (businessPersonInChange.length === 0) {
// 如果数组为空,直接将 value 值放入数组
businessPersonInChange.push(value);
} else {
// 如果数组不为空,清空数组再将 value 值放入数组
businessPersonInChange.length = 0; // 也可以使用 array.splice(0, array.length);
businessPersonInChange.push(value);
}
console.log(`5656selected ${businessPersonInChange}`);
};
const handleChangeCustomer = (value: string) => {
if (customerCodeInChange.length === 0) {
// 如果数组为空,直接将 value 值放入数组
customerCodeInChange.push(value);
} else {
// 如果数组不为空,清空数组再将 value 值放入数组
customerCodeInChange.length = 0; // 也可以使用 array.splice(0, array.length);
customerCodeInChange.push(value);
}
console.log(`5656selected ${customerCodeInChange}`);
};
const handleBlur = () => {
console.log('5656blur');
};
const handleFocus = () => {
console.log('5656focus');
};
const filterOption = (input: string, option: any) => {
return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0;
};
const value1 = ref();
const value2 = ref();
function handlePeriodChange(value) {
periodChange.value = value;
}
//biaoji
|
Vben
authored
|
132
|
|
vben
authored
|
133
134
135
|
defineProps({
...basicProps,
});
|
柏杨
authored
|
136
|
const dataStore = useDataStoreWithOut();
|
vben
authored
|
137
138
139
|
const chartRef = ref<HTMLDivElement | null>(null);
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
|
柏杨
authored
|
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
|
function updateData() {
customerCodeIn.value = value1.value;
businessPersonIn.value = value2.value;
}
function clearData() {
customerCodeIn.value = null;
businessPersonIn.value = null;
value1.value = null;
value2.value = null;
}
watchEffect(async () => {
// const data1 = dataStore?.getCustomerChartData1 || {};
console.log(periodChange.value, '56565656periodChange');
const data2 = await getCustomerSalesData({
businessPersonIn: businessPersonIn.value,
customerCodeIn: customerCodeIn.value,
period: periodChange.value,
});
console.log(data2, '5656data2');
const x = [],
y = [],
z = [];
for (const key in data2) {
x.push(key);
y.push(data2[key].salesAmount);
z.push(data2[key].target);
}
const customerChartData1 = { x, y, z };
|
vben
authored
|
170
171
172
173
174
175
176
|
setOptions({
tooltip: {
trigger: 'axis',
axisPointer: {
lineStyle: {
width: 1,
color: '#019680',
|
Vben
authored
|
177
|
},
|
vben
authored
|
178
179
|
},
},
|
柏杨
authored
|
180
181
182
183
|
legend: {
data: ['销售额', '销售目标'],
},
grid: { left: '1%', right: '1%', top: '10 %', bottom: 0, containLabel: true },
|
vben
authored
|
184
185
|
xAxis: {
type: 'category',
|
柏杨
authored
|
186
|
data: customerChartData1?.x,
|
vben
authored
|
187
188
189
|
},
yAxis: {
type: 'value',
|
柏杨
authored
|
190
191
|
// // max: 8000,
// splitNumber: 4,
|
vben
authored
|
192
193
194
|
},
series: [
{
|
柏杨
authored
|
195
|
name: '销售额',
|
柏杨
authored
|
196
|
data: customerChartData1?.y,
|
vben
authored
|
197
198
199
|
type: 'bar',
barMaxWidth: 80,
},
|
柏杨
authored
|
200
|
{
|
柏杨
authored
|
201
|
name: '销售目标',
|
柏杨
authored
|
202
|
smooth: true,
|
柏杨
authored
|
203
|
data: customerChartData1?.z,
|
柏杨
authored
|
204
205
206
207
208
209
210
211
|
type: 'line',
areaStyle: {
color: 'rgba(255, 255, 255, 0)',
},
itemStyle: {
color: 'rgba(124, 205, 214)',
},
},
|
vben
authored
|
212
213
|
],
});
|
Vben
authored
|
214
215
|
});
</script>
|
柏杨
authored
|
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
<style scoped>
.custom-radio-group .ant-radio-button-wrapper {
background-color: white; /* 未选中按钮的背景颜色为白色 */
color: #1684fc; /* 未选中按钮的文字颜色为 #1684fc */
border-color: #1684fc; /* 未选中按钮的边框颜色 */
}
.custom-radio-group .ant-radio-button-wrapper-checked {
background-color: #1684fc; /* 选中按钮的背景颜色为 #1684fc */
color: white; /* 选中按钮的文字颜色为白色 */
border-color: #1684fc; /* 选中按钮的边框颜色 */
}
.custom-radio-group .ant-radio-button-wrapper-checked:hover {
background-color: #1684fc; /* 悬停在选中按钮时保持相同的背景颜色 */
color: white; /* 悬停在选中按钮时保持文字为白色 */
}
.custom-radio-group .ant-radio-button-wrapper:hover {
border-color: #1684fc; /* 悬停在未选中按钮时的边框颜色 */
}
.custom-radio-group .ant-radio-button-wrapper:not(.ant-radio-button-wrapper-checked):hover {
color: #1684fc; /* 悬停在未选中按钮时文字颜色为 #1684fc */
}
</style>
|