| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <PanelHeader title="客æ·è¥æ¶è´¡ç®æ°å¼åæ" /> |
| | | <div class="main-panel panel-item-customers"> |
| | | <div class="filters-row"> |
| | | <el-select |
| | | v-model="customerValue" |
| | | class="customer-select" |
| | | placeholder="è¯·éæ©å®¢æ·" |
| | | clearable |
| | | filterable |
| | | @change="handleFilterChange" |
| | | > |
| | | <el-option |
| | | v-for="item in customerOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | |
| | | <DateTypeSwitch v-model="dateType" @change="handleFilterChange" /> |
| | | </div> |
| | | <Echarts |
| | | ref="chart" |
| | | :chartStyle="chartStyle" |
| | | :grid="grid" |
| | | :legend="barLegend" |
| | | :series="barSeries1" |
| | | :tooltip="tooltip" |
| | | :xAxis="xAxis1" |
| | | :yAxis="yAxis1" |
| | | :options="{ backgroundColor: 'transparent', textStyle: { color: '#B8C8E0' } }" |
| | | style="height: 260px" |
| | | /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted } from 'vue' |
| | | import Echarts from '@/components/Echarts/echarts.vue' |
| | | import PanelHeader from '../PanelHeader.vue' |
| | | import DateTypeSwitch from '../DateTypeSwitch.vue' |
| | | import { customerRevenueAnalysis } from '@/api/viewIndex.js' |
| | | import { listCustomer } from '@/api/basicData/customerFile.js' |
| | | |
| | | const dateType = ref(1) // 1=å¨ 2=æ 3=å£åº¦ |
| | | const customerValue = ref(null) |
| | | const customerOptions = ref([]) |
| | | |
| | | // è¥æ¶åææ°æ® |
| | | const revenueData = ref({ |
| | | items: [] |
| | | }) |
| | | |
| | | const chartStyle = { |
| | | width: '100%', |
| | | height: '150%', |
| | | } |
| | | |
| | | const grid = { |
| | | left: '3%', |
| | | right: '4%', |
| | | bottom: '3%', |
| | | containLabel: true, |
| | | } |
| | | |
| | | const barLegend = { |
| | | show: false, |
| | | textStyle: { color: '#B8C8E0' }, |
| | | data: ['è¥æ¶'], |
| | | } |
| | | |
| | | const barSeries1 = ref([ |
| | | { |
| | | name: 'è¥æ¶', |
| | | type: 'bar', |
| | | barGap: 0, |
| | | emphasis: { |
| | | focus: 'series', |
| | | }, |
| | | itemStyle: { |
| | | color: { |
| | | type: 'linear', |
| | | x: 0, |
| | | y: 1, |
| | | x2: 0, |
| | | y2: 0, |
| | | colorStops: [ |
| | | // linear-gradient(360deg, rgba(0,164,237,0) 0%, #4EE4FF 100%) |
| | | { offset: 0, color: 'rgba(0,164,237,0)' }, |
| | | { offset: 1, color: '#4EE4FF' }, |
| | | ], |
| | | }, |
| | | }, |
| | | data: [], |
| | | }, |
| | | ]) |
| | | |
| | | const tooltip = { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: 'shadow', |
| | | }, |
| | | formatter: function (params) { |
| | | let result = params[0].axisValueLabel + '<br/>' |
| | | params.forEach((item) => { |
| | | result += `<div style="color: #B8C8E0">${item.marker} ${item.seriesName}: ${item.value}</div>` |
| | | }) |
| | | return result |
| | | }, |
| | | } |
| | | |
| | | const xAxis1 = ref([ |
| | | { |
| | | type: 'category', |
| | | axisTick: { show: false }, |
| | | axisLabel: { color: '#B8C8E0' }, |
| | | data: [], |
| | | }, |
| | | ]) |
| | | |
| | | const yAxis1 = [ |
| | | { |
| | | type: 'value', |
| | | axisLabel: { color: '#B8C8E0' }, |
| | | }, |
| | | ] |
| | | |
| | | // è·å客æ·è¥æ¶åææ°æ® |
| | | const getCustomerRevenueAnalysis = () => { |
| | | if (customerOptions.value.length > 0 && !customerValue.value) { |
| | | // é»è®¤éä¸ç¬¬ä¸ä¸ªå®¢æ· |
| | | customerValue.value = customerOptions.value[0].value |
| | | } |
| | | |
| | | if (!customerValue.value) return |
| | | |
| | | const params = { |
| | | customerId: customerValue.value, |
| | | type: dateType.value |
| | | } |
| | | |
| | | customerRevenueAnalysis(params) |
| | | .then((res) => { |
| | | xAxis1.value[0].data = [] |
| | | barSeries1.value[0].data = [] |
| | | |
| | | const items = res.data?.items || [] |
| | | items.forEach((item) => { |
| | | xAxis1.value[0].data.push(item.name) |
| | | barSeries1.value[0].data.push(item.value) |
| | | }) |
| | | revenueData.value = res.data |
| | | }) |
| | | .catch((error) => { |
| | | console.error('è·å客æ·è¥æ¶åæå¤±è´¥:', error) |
| | | }) |
| | | } |
| | | |
| | | const fetchCustomerOptions = async () => { |
| | | try { |
| | | const params = { pageNum: 1, pageSize: 200 } |
| | | const res = await listCustomer(params) |
| | | const records = res?.records || res?.data?.records || res?.rows || [] |
| | | customerOptions.value = records.map((r) => ({ |
| | | label: r.customerName || r.name || r.customer || '-', |
| | | value: r.id ?? r.customerId ?? r.customerCode ?? r.customerName, |
| | | })) |
| | | |
| | | // è·åå°é项åï¼å¦æè¿æ²¡éä¸ï¼é»è®¤éä¸ç¬¬ä¸ä¸ª |
| | | if (customerOptions.value.length > 0 && !customerValue.value) { |
| | | customerValue.value = customerOptions.value[0].value |
| | | getCustomerRevenueAnalysis() |
| | | } |
| | | } catch (e) { |
| | | // æ¥å£å¼å¸¸æ¶ç»ä¸ç»æ¨¡æå®¢æ·ï¼ä¿è¯UIå¯ç¨ |
| | | customerOptions.value = [ |
| | | { label: 'åä¸ç²¾å¯', value: 'åä¸ç²¾å¯' }, |
| | | { label: 'æè¾°çµå', value: 'æè¾°çµå' }, |
| | | { label: 'å¯èªç§æ', value: 'å¯èªç§æ' }, |
| | | { label: 'éè¯å¶é ', value: 'éè¯å¶é ' }, |
| | | { label: 'è¿æ¯ææ', value: 'è¿æ¯ææ' }, |
| | | ] |
| | | } |
| | | } |
| | | |
| | | const handleFilterChange = () => { |
| | | getCustomerRevenueAnalysis() |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchCustomerOptions() |
| | | }) |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .main-panel { |
| | | display: flex; |
| | | flex-direction: column; |
| | | gap: 20px; |
| | | } |
| | | |
| | | .filters-row { |
| | | display: flex; |
| | | justify-content: flex-end; |
| | | align-items: center; |
| | | gap: 12px; |
| | | margin-bottom: 10px; |
| | | } |
| | | |
| | | .customer-select { |
| | | width: 180px; |
| | | } |
| | | |
| | | /* 䏿æ¡é£æ ¼ï¼ä¸ DateTypeSwitch ä¿æä¸è´ï¼æ·±è²åéæãæµ
è²æåãç»è¾¹æ¡ï¼ */ |
| | | .customer-select :deep(.el-input__wrapper), |
| | | .customer-select :deep(.el-select__wrapper) { |
| | | background-color: rgba(26, 88, 176, 0.3); |
| | | border: 1px solid rgba(255, 255, 255, 0.2); |
| | | box-shadow: none; |
| | | } |
| | | |
| | | .customer-select :deep(.el-input__inner) { |
| | | color: rgba(184, 200, 224, 0.9); |
| | | } |
| | | |
| | | .customer-select :deep(.el-input__inner::placeholder) { |
| | | color: rgba(184, 200, 224, 0.6); |
| | | } |
| | | |
| | | .customer-select :deep(.el-select__caret), |
| | | .customer-select :deep(.el-icon) { |
| | | color: rgba(184, 200, 224, 0.8); |
| | | } |
| | | |
| | | .panel-item-customers { |
| | | border: 1px solid #1a58b0; |
| | | padding: 18px; |
| | | width: 100%; |
| | | height: 478px; |
| | | } |
| | | </style> |