| | |
| | | import Echarts from '@/components/Echarts/echarts.vue' |
| | | import PanelHeader from '../PanelHeader.vue' |
| | | import DateTypeSwitch from '../DateTypeSwitch.vue' |
| | | import { qualityStatistics } from '@/api/viewIndex.js' |
| | | 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 qualityStatisticsObject = ref({ |
| | | supplierNum: 0, |
| | | processNum: 0, |
| | | factoryNum: 0, |
| | | // 营收分析数据 |
| | | const revenueData = ref({ |
| | | items: [] |
| | | }) |
| | | |
| | | const chartStyle = { |
| | |
| | | }, |
| | | ] |
| | | |
| | | // 质检统计 |
| | | const qualityStatisticsInfo = () => { |
| | | qualityStatistics() |
| | | // 获取客户营收分析数据 |
| | | 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) => { |
| | | // 切换筛选条件时,先清空再填充,避免重复 push |
| | | xAxis1.value[0].data = [] |
| | | barSeries1.value[0].data = [] |
| | | |
| | | res.data.item.forEach((item) => { |
| | | xAxis1.value[0].data.push(item.date) |
| | | // 这里暂用 supplierNum 作为柱状图数值(接口返回里当前也有这三个字段) |
| | | barSeries1.value[0].data.push(item.supplierNum) |
| | | const items = res.data?.items || [] |
| | | items.forEach((item) => { |
| | | xAxis1.value[0].data.push(item.name) |
| | | barSeries1.value[0].data.push(item.value) |
| | | }) |
| | | qualityStatisticsObject.value.supplierNum = res.data.supplierNum |
| | | qualityStatisticsObject.value.processNum = res.data.processNum |
| | | qualityStatisticsObject.value.factoryNum = res.data.factoryNum |
| | | revenueData.value = res.data |
| | | }) |
| | | .catch((error) => { |
| | | console.error('获取质检统计失败:', error) |
| | | console.error('获取客户营收分析失败:', error) |
| | | }) |
| | | } |
| | | |
| | |
| | | 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 = [ |
| | |
| | | } |
| | | |
| | | const handleFilterChange = () => { |
| | | // 目前 qualityStatistics 接口未携带筛选参数,这里先统一触发刷新,避免重复数据 |
| | | // 若后端后续支持 customerId/type,可在 qualityStatistics() 处改为传参 |
| | | qualityStatisticsInfo() |
| | | getCustomerRevenueAnalysis() |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchCustomerOptions() |
| | | qualityStatisticsInfo() |
| | | }) |
| | | </script> |
| | | |