gongchunyi
3 天以前 5b1500969cdf102a6db9e3f56faec5aa67f68496
src/views/reportAnalysis/dataDashboard/components/basic/left-bottom.vue
@@ -47,6 +47,15 @@
import { customerRevenueAnalysis } from '@/api/viewIndex.js'
import { listCustomer } from '@/api/basicData/customerFile.js'
/** 客户营收分析下拉默认选中该客户(不存在则退回列表第一项) */
const DEFAULT_REVENUE_CUSTOMER_NAME = '鑫鹤门窗'
const pickDefaultCustomerValue = (options) => {
  if (!options?.length) return null
  const matched = options.find((o) => o.label === DEFAULT_REVENUE_CUSTOMER_NAME)
  return matched ? matched.value : options[0].value
}
const dateType = ref(1) // 1=周 2=月 3=季度
const customerValue = ref(null)
const customerOptions = ref([])
@@ -133,8 +142,7 @@
// 获取客户营收分析数据
const getCustomerRevenueAnalysis = () => {
  if (customerOptions.value.length > 0 && !customerValue.value) {
    // 默认选中第一个客户
    customerValue.value = customerOptions.value[0].value
    customerValue.value = pickDefaultCustomerValue(customerOptions.value)
  }
  if (!customerValue.value) return
@@ -171,9 +179,9 @@
      value: r.id ?? r.customerId ?? r.customerCode ?? r.customerName,
    }))
    
    // 获取到选项后,如果还没选中,默认选中第一个
    // 获取到选项后,如果还没选中,默认「鑫鹤门窗」(无则第一项)
    if (customerOptions.value.length > 0 && !customerValue.value) {
      customerValue.value = customerOptions.value[0].value
      customerValue.value = pickDefaultCustomerValue(customerOptions.value)
      getCustomerRevenueAnalysis()
    }
  } catch (e) {