AreaStatisticTable.vue 2.6 KB
<template>
	<CardNvue :title="t('PreMenu.regionalStatistics')" :auto-height="true">
		<template #content>
			<view class="table">
				<view class="table-head">
					<view class="table-head-item">
						<text class="table-head-item-text">{{ t('table.areaName') }}</text>
					</view>
					<view class="table-head-item">
						<text class="table-head-item-text">{{ t('PreMallIndex.CustomerNum') }}</text>
					</view>
					<view class="table-head-item">
						<text class="table-head-item-text">{{ t('PreGateIndex.attentionVisitors') }}</text>
					</view>
					<view class="table-head-item last-table">
						<text class="table-head-item-text">{{ t('PreGateIndex.avgValidDwellTime') }}</text>
					</view>
				</view>
				<view class="table-body" v-if="tableList.length >0">
					<view class="table-body-item" v-for="(item,index) in tableList" :key="index">
						<view class="table-body-item-value table-body-item-name">
							<text class="table-body-item-value-text" lines="1">{{item.gateName}}</text>
						</view>
						<view class="table-body-item-value">
							<text class="table-body-item-value-text">{{item.customerCount}}</text>
						</view>
						<view class="table-body-item-value">
							<text class="table-body-item-value-text">{{item.attentionVisitors}}</text>
						</view>
						<view class="table-body-item-value">
							<text class="table-body-item-value-text">{{formatSeconds(item.avgValidDwellTime)}}</text>
						</view>
					</view>
				</view>
        <view class="p-empty" v-else style="margin-top: 40rpx;">
          <image class="p-empty-img" src="/static/common/empty.png" mode=""></image>
          <text class="p-empty-text chart-text">{{ t('maintenance.monitor.project.empty.text') }}</text>
        </view>
			</view>
		</template>
	</CardNvue>
</template>

<script setup>
	import {
		ref,
		onMounted
	} from 'vue'
	import CardNvue from './Card.nvue';
	import {
		getGateStatisticsApi
	} from '@/api'
	import {
		formatSeconds
	} from '@/utils'
  import {
    t
  } from '@/plugins/index.js'

	const tableList = ref([])
	onMounted(() => {
		// initTableList()
	})

	const options = ref({})
	const initData = (params)=>{
		options.value = params
		initTableList()
	}
	defineExpose({
		initData
	})

	const initTableList = async () => {
		try {
			const params = {
				accountIds: options.value.accountId,
				endDate: options.value.endDate,
				startDate: options.value.startDate,
				mallId: options.value.storeId
			}
			const {
				data
			} = await getGateStatisticsApi(params)
			tableList.value = data
		} catch (e) {
			console.log(e)
		}
	}
</script>

<style lang="scss">
@import '../../../styles/table.scss'
</style>