<template>
	<view class="table-scroll">
		<table cellspacing="0">
			<thead>
				<tr style="background-color: #aebad2;color: #fff;" height='41'>
					<th>商品名称</th>
					<th>数量</th>
					<th>金额</th>
				</tr>
			</thead>
			<tbody>
				<tr v-for="(item,index) in tableList" :key="item.productId">
					<td style="padding-left: 16rpx;">{{item.productName}}</td>
					<td style="padding-left: 16rpx;">{{item.num}}</td>
					<td style="padding-left: 16rpx;">{{item.salesAmount}}</td>
				</tr>
			</tbody>
		</table>
	</view>
</template>

<script setup>
	import {
		onMounted,
		ref
	} from 'vue';
	import {
		summaryTrade,
		dateProduct
	} from '@/http/yskApi/requestAll.js';
	let tableList = ref([])
	let props = defineProps({
		day: {
			type: Number
		}
	})
	onMounted(() => {
		gettableData()
	})
	// 获取表格数据
	function gettableData() {
		dateProduct({
			shopId: uni.getStorageSync('shopId'),
			day: props.day,
			page: 0,
			size: 50
		}).then((res) => {
			tableList.value = res.productList.content
		})

	}
</script>

<style>
	.table-scroll {
		overflow-x: scroll;
		white-space: nowrap;
		margin: 32rpx 28rpx;
		margin-right: 30rpx;
		border-radius: 30rpx 30rpx 0 0;
	
	}
	
	.table-scroll table {
		table-layout: fixed;
	}
	
	.table-scroll thead {
		display: table-row;
		background-color: bisque;
		font-size: 24rpx;
	}
	
	.table-scroll tbody {
		overflow-y: scroll;
		overflow-x: hidden;
		display: block;
		width: 100%;
	}
	
	.table-scroll th,
	td {
		height: 82rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		width: 250rpx;
		border: 0.7rpx solid rgba(126, 155, 212, 0.27);
	}
</style>