<template>
	<view class="w-screen h-screen flex flex-col bg-[#ededed]" :style="themeColor()">
		<!-- #ifdef MP-WEIXIN -->
		<view style="width: 100%;height: 120rpx;"></view>
		<!-- #endif -->
		<view class="statistics-title" >{{t('dataSummary')}}</view>
		<view class="sidebar-margin mt-[20rpx] bg-[#ffffff]  br-gg">
			<up-grid :border="true" col="2" align="center">
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">{{t('todayPurchaseCount')}}</text>
						<up-count-to :startVal="0" :endVal="baseInfo.purchase_count.today" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">{{t('todayPurchaseSale')}}</text>
						<up-count-to :startVal="0" :endVal="baseInfo.purchase_price.todays" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">{{t('todaySellCount')}}</text>
					<up-count-to :startVal="0" :endVal="baseInfo.sell_count.today" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">{{t('todaySellSale')}}</text>
					<up-count-to :startVal="0" :endVal="baseInfo.sell_price.today" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">入库订单总数</text>
					<up-count-to :startVal="0" :endVal="baseInfo.purchase_count.total" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">入库总额(元)</text>
					<up-count-to :startVal="0" :endVal="baseInfo.purchase_price.total" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">出库订单总数</text>
					<up-count-to :startVal="0" :endVal="baseInfo.sell_count.total" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">出库总额(元)</text>
					<up-count-to :startVal="0" :endVal="baseInfo.sell_price.total" color="#007aff"></up-count-to>
				</up-grid-item>
			</up-grid>
		</view>
		
		<view class="statistics-title" >待办事项</view>
		<view class="sidebar-margin mt-[20rpx] bg-[#ffffff]  br-gg">
			<up-grid :border="true" col="2" align="center">
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">{{t('waitApprovePurchase')}}</text>
					<up-count-to :startVal="0" :endVal="waitInfo.wait_approve_count" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">{{t('waitInventoryPurchase')}}</text>
						<up-count-to :startVal="0" :endVal="waitInfo.wait_inventory_count" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">{{t('waitReturnPurchase')}}</text>
					<up-count-to :startVal="0" :endVal="waitInfo.wait_return_count" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">{{t('waitSellOrder')}}</text>
					<up-count-to :startVal="0" :endVal="waitInfo.wait_sell_order" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">{{t('waitDeliveryOrder')}}</text>
						<up-count-to :startVal="0" :endVal="waitInfo.wait_delivery_order" color="#007aff"></up-count-to>
				</up-grid-item>
				<up-grid-item class="pt-[20rpx]">
					<text
						class="text-center color-[#909399] text-[28rpx] pt-[20rpx] pb-[20rpx]">{{t('waitReturnOrder')}}</text>
					<up-count-to :startVal="0" :endVal="waitInfo.wait_return_order" color="#007aff"></up-count-to>
				</up-grid-item>
			</up-grid>
		</view>
		<tabbar />
	</view>
</template>

<script setup lang="ts">
	import { ref } from 'vue'
	import { t } from '@/locale'
	import { getBaseInfo, getWaitInfo } from '@/addon/erp/api/statistice';
	import { onLoad } from '@dcloudio/uni-app';
	const baseInfo = ref<any>({
		purchase_count: {},
		purchase_price: {},
		sell_count: {},
		sell_price: {},
	});
	const waitInfo = ref<any>({});

	onLoad(() => {
		getBaseInfoFn();
		getWaitInfoFn();
	})

	const getBaseInfoFn = async () => {
		baseInfo.value = await (await getBaseInfo()).data;
	};

	const getWaitInfoFn = async () => {
		waitInfo.value = await (await getWaitInfo()).data;
	};
</script>

<style scoped>
	.statistics-title{
		margin: 0 auto;
		margin-top: 40rpx;
		font-size: 30rpx;
		font-weight: bold;
	}
	.br-gg{
		border-radius: 10rpx;
	}
</style>