AreaStatistic.nvue 2.01 KB
<template>
  <view class="fixed-date">
    <DatePicker @change="handleDateChange" :has-today="false"></DatePicker>
  </view>
  <view class="h-page">
    <view class="mall" style="height: 0;overflow: hidden;">
      <MallSelectNvue has-store="1" choose-group="0" @change="handlStoreChange" />
    </view>
    <AreaStatisticsComp ref="areaStatisticRef" />
  </view>
</template>

<script setup>
  import {
    ref,
    onMounted,
    computed,
    nextTick
  } from 'vue'

  import {
    getUserIndicatorIndexApi,
    getAreaAnalysisStatisApi
  } from '@/api'
  import DatePicker from '@/components/DatePicker.nvue'
  import PageOptions from '@/components/PageOptions.vue'
  import CustomNavBar from '@/components/CustomNav.nvue'
  import MallSelectNvue from '@/components/MallSelect.nvue';
  import IndicatorsFilter from '@/components/IndicatorsFilter.nvue'
  import AreaStatisticsComp from '@/subPackages/accountGroup/pages/store-analysis/area-statistics/components/AreaStatisticsComp.vue'
  import {
    getStageObj
  } from '../../utils'

  const params = ref({})
  const flag = ref(false) // 是否初始化完成

  const handlStoreChange = (e) => {
    params.value = {
      ...params.value,
      ...e
    }
    if(!params.value.storeId){
      const store = getStageObj('store')
      params.value.storeId = store.id
      nextTick(()=>{
        areaStatisticRef.value?.initData(params.value)
      })
    }
  }
  const handleDateChange = (e) => {
    const [startDate, endDate] = e.range
    params.value = {
      ...params.value,
      startDate,
      endDate,
      ...e
    }
    // 日期更改时直接加载数据
    if (!flag.value) {
      nextTick(()=>{
        areaStatisticRef.value?.initData(params.value)
      })
    }
  }
  // 组件ref
  const areaStatisticRef = ref(null)
</script>
<style lang="scss" scoped>
  .fixed-date {
    width: 750rpx;
    height: 100rpx;
    background-color: #f2f3f6;
    position: sticky;
    left: 0;
    top: 0;
    padding: 20rpx;
    z-index: 100;
  }

  .h-page {
    padding: 0 20rpx;
  }
</style>