<template>
<view class="app-content">
	<view class="ex-page">
		<view class="input-wrap_box">
		<view>
			<AppSearchModule placeholder="输入拼音首字母搜索" @input="searchFn"/>
		</view>
		</view>
		<view class="top-bar">
			<DateSelect class="bar" top="0" @selectDateFn="selectDateFn" />
		</view>
		<view class="main-view">
			<view class="space-view ex-table">
				<block>
					<t-table :headerBackgroundColor="'#F0F2F6'">
						<t-tr header><t-th>供货商</t-th><t-th>订单数</t-th><t-th>金额</t-th><t-th>操作</t-th></t-tr>
						<view style="font-size:30upx;margin:10upx 0 10upx 10upx;">总金额：{{ totalActPrice }}</view>
						<view v-for="(item, index) in storageData" :key="index">
							<t-tr>
								<t-td><view>{{item.name}}</view></t-td>
								<t-td><view>{{parseFloat(item.num)}}</view></t-td>
								<t-td><view>{{parseFloat(item.actPrice)}}</view></t-td>
								<t-td></t-td>
							</t-tr>
						</view>
					</t-table>
				</block>
			</view>
		</view>
	</view>
</view>
</template>
<script>
import AppWrapperEmpty from "@/components/app-wrapper-empty";
import SelectList from "@/components/plugin/selectList";
import { getStatCgGhsProfile } from "@/api/stat/index";
import { list } from "@/mixins";
import ShopSelect from "@/components/module/shopSelect";
import DateSelect from "@/components/module/dateSelect";
import AppSearchModule from "@/components/module/app-search";
import {mapActions, mapGetters} from "vuex";
export default {
	components: { SelectList, AppWrapperEmpty,ShopSelect,AppSearchModule,DateSelect },
	mixins: [list],
	computed: {		
		...mapGetters(["getDictionariesInfo","getLoginInfo"])
	},
	data() {
		return {
			isShow:false,
			customizationTime:[],
			shopId:'',
			itemId:'',
			nowTime: "",
			showTimeDropdown: false,
			nowShop: "",
			showShopDropdown: false,
			columns: [
				{ name: "姓名", dataIndex: "name", color: "info" },
				{ name: "开单额", dataIndex: "amount", color: "info", width: 120, align: "center" },
				{ name: "开单数", dataIndex: "num", color: "info", align: "center" }
			],
			dataList: [],
			params:{ itemId: '', searchTime:'', startTime: "", endTime: "", shopId: "", },
			storageData:[],
			searchContent:'',
			totalActPrice:0
		};
	},
	onPullDownRefresh() {
		this.resetList();
		this.getList().then(res => {
			uni.stopPullDownRefresh();
		});
	},
	onLoad(e) {
		this.itemId = e.id;
		this.params.itemId = e.id;
		this.shopId = this.getLoginInfo.shopId;
	},
	methods: {
		...mapActions(['setUserShopAll']),
		searchFn(e){
			this.searchContent = e;
			this.filterStat()
		},
		selectShopFn(val){
			this.params.shopId = val.id;
			this.init();
		},
		//选择时间
		selectDateFn(val) {
			this.params = {...this.params,...val}
			this.init();			
		},
		async init() {
			this.getList();
		},
		getList() {
			let that = this
			uni.showLoading()
			getStatCgGhsProfile(this.params).then(res => {
				uni.hideLoading()
				if (!this.$util.isEmpty(res.data.list)) {
					that.storageData = res.data.list
					that.totalActPrice = res.data.totalActPrice?parseFloat(res.data.totalActPrice):0
				}else{
					that.storageData = []
				}
			})
		}
	}
};
</script>
<style lang="scss" scoped>
.ex-page {
	background: white;
	padding-top:20upx;
	height: 100%;
	display: flex;
	flex-direction: column;
	.top-bar {
		position: absolute;
		left: 0;
		top:130upx;
		display: flex;
		width: 100%;
		z-index: 20;
		.bar{
			width: 50%;
			height: 100%;
			text-align: center;
			&:nth-child(1){
				border-right: 1upx solid #eeeeec;
			}
		}
	}
	.main-view {
		margin-top: 90upx;
		flex: 1;
		background-color: #f9fbfc;
		.space-view {
			background-color: #fff;
			.change-level{
				font-size:22upx;
				padding:10upx 15upx;
			}
		}
		.ex-info {
			padding: 30upx;
			.info-cell {
				display: flex;
				align-items: center;
				font-size: 28upx;
				&:not(:first-child) {
					margin-top: 20upx;
				}
				.cell-label {
					width: 110upx;
					color: #666666;
				}
				.cell-value {
					margin-left: 40upx;
					color: #333;
					&.warning {
						color: #ffaf1d;
					}
					&.success {
						color: #27c325;
					}
				}
			}
		}
		.ex-table {
			::v-deep.icon-info {
				color: #333333;
			}
		}
	}
	.bar-view {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 30upx;
		width: 100%;
		height: 100upx;

		box-shadow: 0upx -1upx 6upx 0upx rgba(4, 0, 0, 0.06);
		.info-view {
			font-size: 26upx;
		}
		.btn-view {
			display: flex;
			.admin-button-com {
				margin: 0 10upx;
			}
		}
	}
}
</style>