<template>
	<view class="content">
		<view class="contentList" v-for="item,index in tableList" :key="index">
			<view class="linebox">
				<view class="line_title">{{$t('MY_ORD_56')}}</view>
				<view class="line_content thesuccess">{{$t('MY_ORD_57')}}</view>
			</view>
			<view class="linebox">
				<view class="line_title">{{$t('w_0296')}}</view>
				<view class="line_content">{{item.tradeCode}}</view>
			</view>
			<view class="linebox">
				<view class="line_title">{{$t('w_0294')}}</view>
				<view class="line_content">{{item.pkAccountVal}}</view>
			</view>
			<view class="linebox">
				<view class="line_title">{{$t('N_I_163')}}</view>
				<view class="line_content">{{item.tradeTypeVal}}</view>
			</view>
			<view class="linebox">
				<view class="line_title">{{$t('N_I_162')}}</view>
				<view class="line_content">{{item.tradeAmount}}</view>
			</view>
			<view class="linebox">
				<view class="line_title">{{$t('w_0298')}}</view>
				<view class="line_content">{{item.tradeBalance |numberToCurrency}}</view>
			</view>
			<view class="linebox">
				<view class="line_title">{{$t('N_I_160')}}</view>
				<view class="line_content">{{item.creationTime}}</view>
			</view>
			<view class="linebox">
				<view class="line_title">{{$t('MY_WAL_22')}}</view>
				<view class="line_content">{{item.remarks}}</view>
			</view>
		</view>
		<u-popup :show="sxShow" mode="right" @close="sxShow = false" :closeOnClickOverlay="false">
			<view class="rightPopup">
				<view class="popup_top">
					<view @click="getSearch">{{$t('MY_ORD_50')}}</view>
					<view class="top_red" @click="sxShow = false">{{$t('N_I_241')}}</view>
				</view>
				<view class="typesBox">
					<view class="typeTitle">
						{{$t('N_I_163')}}
					</view>
					<view class="choiceBox">
						<view class="flex_btn" @click="clickTransType(item)" v-for="(item,index) in tradeTypeList"
							:key="index" :class="queryParams.tradeType==item.value?'selectbtn':''">
							{{item.label}}
						</view>

					</view>
				</view>
				<view class="typesBox">
					<view class="typeTitle">
						{{$t('w_0294')}}
					</view>
					<view class="choiceBox">
						<view class="flex_btn" @click="clickAccountType(item)" v-for="(item,index) in pkAccountList"
							:key="index" :class="queryParams.pkAccount==item.pkId?'selectbtn':''">
							{{item.accountName}}
						</view>

					</view>
				</view>
				<view class="typesBox">
					<view class="typeTitle">
						{{$t('N_I_160')}}
					</view>
					<view class="choiceBox">
						<view class="flex_btn" @click="openDate(0)">
							{{queryParams.startDate?queryParams.startDate:$t('CK_KS_3')}}
						</view>
						<view style="color: #666;">
							——
						</view>
						<view class="flex_btn" @click="openDate(1)">
							{{queryParams.endDate?queryParams.endDate:$t('CK_KS_9')}}
						</view>
					</view>
				</view>
				<u-datetime-picker :closeOnClickOverlay="true" @close="dataShow = false" @cancel="dataShow = false"
					@confirm="getDate" :show="dataShow" v-model="value1" mode="date"></u-datetime-picker>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import * as bal from "@/config/balance.js"
	import {
		formatMsToDate
	} from '@/util/index'
	export default {
		data() {
			return {
				sxShow: false,
				queryParams: {
					pageNum: 1,
					pageSize: 50,
					tradeType: "", //交易类型
					pkAccount: "", //账户类型
					startDate: "",
					endDate: ""
				},
				tradeTypeList: [], //交易类型
				pkAccountList: [], //账户类型
				tableList: [],
				timeIndex: 0,
				dataShow: false,
				value1: ""
			}
		},
		onLoad() {
			this.getOthers()
			this.getSearch()
		},
		onNavigationBarButtonTap() {
			this.sxShow = true
		},
		methods: {
			getDate(e) {
				if (this.timeIndex == 1) {
					this.queryParams.endDate = formatMsToDate(e.value)
				} else {
					this.queryParams.startDate = formatMsToDate(e.value)
				}
				this.dataShow = false
			},
			openDate(index) {
				this.timeIndex = index
				this.dataShow = true
			},

			clickTransType(item) {
				this.queryParams.tradeType = item.value
			},
			clickAccountType(item) {
				this.queryParams.pkAccount = item.pkId
			},
			getOthers() {
				bal.getTradeTypeList().then((res) => {
					this.tradeTypeList = res.data;
				});
				bal.getEnumsAccountList().then((res) => {
					this.pkAccountList = res.data;
				});
			},
			getSearch() {
				bal.getTransactionDetails(this.queryParams).then(res => {
					this.tableList = res.rows
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	::v-deep .u-popup__content {
		overflow: auto;
	}

	.content {
		background: #F2F2F2;

		.contentList {
			background-color: #fff;
			margin-top: 8rpx;
			padding: 10rpx 23rpx;

			.linebox {
				display: flex;
				align-items: center;
				font-size: 26rpx;
				margin: 14rpx 0;

				.line_title {
					min-width: 150rpx;
					color: #999999;
				}

				.line_content {
					color: #333;
				}

				.thesuccess {
					color: #45C242;
				}
			}
		}

		.rightPopup {
			width: 645rpx;

			.popup_top {
				padding: 25rpx;
				background-color: rgba(255, 234, 233, 0.65);
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;

				.top_red {
					color: #FB3024;
				}
			}

			.typesBox {
				margin-top: 40rpx;

				.typeTitle {
					padding: 0 24rpx;
					font-size: 30rpx;
					font-family: Source Han Sans CN;
					font-weight: bold;
					color: #333333;
				}

				.choiceBox {
					padding: 0 12rpx;
					display: flex;
					margin-top: 17rpx;
					align-items: center;
					flex-wrap: wrap;

					.flex_btn {
						background-color: rgba(255, 234, 233, 0.65);
						display: flex;
						align-items: center;
						justify-content: center;
						padding: 14rpx 48rpx;
						border-radius: 26rpx;
						font-size: 24rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #333333;
						margin: 17rpx 5rpx;
					}

					.selectbtn {
						background-color: #C8161D;
						color: #ffffff;
					}

				}
			}
		}
	}
</style>