<template>
    <div class="creditsDetail_page">
		<div class="creditsDetail_table_search">
			<div class="creditsDetail_state">
				<div class="creditsDetail_state_item">
					<span>Time:</span>
						<a-range-picker
						class="range_picker"
						v-model:value="rangePickerValue"
						:placeholder="[
							$t('HistoryPage.StartDate'),
							$t('HistoryPage.EndDate'),
						]"
						valueFormat="YYYY-MM-DD"
					>
						<template #suffixIcon>
							<span
								class="icon iconfont range_picker_icon icon-rili"
							></span>
						</template>
					</a-range-picker>
				</div>
				<div class="creditsDetail_state_item">
					<span>State:</span>
					<a-select v-model:value="currentState.value" style="width:25rem" size="large" optionFilterProp="label" :options="state" placeholder="Please select" allowClear show-search></a-select>
				</div>
			</div>

			
			<div class="creditsDetail_search">
				<div
					class="creditsDetail_search_item"
					@click="searchcreditsDetailList()"
				>
					<span
						class="icon iconfont icon-sousuo"
					></span>
				</div>
			</div>
		</div>
		<div class="creditsDetail_table_content" ref="historyTable">
			<a-table
				:columns="columns"
				:data-source="collectionList"
				:scroll="{ y: historyTableHeight }"
				@change="changePage"
				:pagination="{
					showSizeChanger: true,
					current: currentPage,
					pageSize: pageSize,
					total: total,
					showQuickJumper: true,
					bordered: false,
				}"
			>
				<template
					#bodyCell="{ column, text, record, index }"
				>
					<div
						class="operate_list"
						v-if="column?.Operations"
					>
						<!-- <div
							v-if="record.orderStatus == '支付成功'"
							class="operate_item"
							@click="refund(record)"
						>
							refund
						</div> -->
						<div class="operate_item">{{ $t('HistoryPage.Delete') }}</div>
					</div>
				</template>
			</a-table>
		</div>
    </div>
</template>
<script lang="ts">
import { defineComponent, ref, createVNode, computed } from "vue";
import { Https } from "@/tool/https";
import { useI18n } from "vue-i18n";
export default defineComponent({
    components: {
    },
    setup() {
        let renameData: any = ref({}); //修改名字选中的数据
        const columns: any = computed(() => {
            return [
                {
                    title: "Serial",
                    align: "center",
                    ellipsis: true,
                    dataIndex: "orderNo",
                    key: "orderNo",
                },
                {
                    title: "Title",
                    align: "center",
                    ellipsis: true,
                    dataIndex: "title",
                    key: "title",
                },
                {
                    title: "Money",
                    align: "center",
                    ellipsis: true,
                    dataIndex: "totalFee",
                    key: "totalFee",
                },
                {
                    title: "Payment",
                    align: "center",
                    ellipsis: true,
                    dataIndex: "paymentType",
                    key: "paymentType",
                },
                {
                    title: "State",
                    align: "center",
                    ellipsis: true,
                    dataIndex: "orderStatus",
                    key: "orderStatus",
                },

                // {
                //     title: useI18n().t("HistoryPage.Operations"),
                //     key: "operation",
                //     align: "center",
                //     // slots:{customRender:'action'}
                //     Operations: true,
                // },
            ];
        });
        let dataList: any = ref([]);
        let rangePickerValue: any = ref([]);
        let collectionList: any = ref([]);
        let userInfo: any = {};
		let currentState = ref({
			value:'income',
		})
		let state:any = ref([
			{
				label:'Income',
				value:'income',
			},
			{
				label:'Expend',
				value:'expend',
			},
		])
        return {
            columns,
            dataList,
            renameData,
			rangePickerValue,
			collectionList,
            userInfo,
			currentState,
			state,
        };
    },
    data() {
        return {
            currentPage: 1,
            pageSize: 10,
            total: 0,
            historyTableHeight: 0,
            searchCollectionName: "",
        };
    },
    mounted() {
        let historyTable: any = this.$refs.historyTable;
        this.historyTableHeight = historyTable.clientHeight - 130;
		this.getCreditsDetailList()
    },
    methods: {
		init(){
			this.currentPage = 1
			this.pageSize = 10
			this.getCreditsDetailList()
		},
        //改变页码
        changePage(e: any) {
            this.currentPage = e.current
            this.pageSize = e.pageSize
            this.getCreditsDetailList();
        },
		//查询列表
		searchcreditsDetailList() {
            this.currentPage = 1;
            this.getCreditsDetailList();
        },
		//获取列表
        getCreditsDetailList() {
			let startTime = '00:00:00'
			let endTime = '00:00:00'
			let startDate: any = this.rangePickerValue[0]
                ? this.rangePickerValue[0]+' '+startTime
                : "";
            let endDate: any = this.rangePickerValue[1]
                ? this.rangePickerValue[1]+' '+endTime
                : "";
			let data = {
				endTime: endDate,
				isIncome: this.currentState.value == 'income'?true:false,
				page:this.currentPage,
                size:this.pageSize,
				startTime: startDate
			}
			console.log(data);
			// getCreditsDetail
			// orderInfoList
            Https.axiosPost(Https.httpUrls.getCreditsDetail,data).then((rv: any) => {
                this.total = rv.length;
                this.collectionList = rv
				if(this.currentPage > 1 && rv.content.length == 0){
					this.currentPage = 1
					this.getCreditsDetailList()
				}else{
					this.collectionList = rv.content
					this.total = rv.total
				}
				
            });
        },
    },
});
</script>
<style lang="less">
.creditsDetail_page {
    width: 100%;
    height: 100%;
    overflow: hidden;
    // min-width: 1440px;
    position: relative;
	display: flex;
	flex-direction: column;
	.creditsDetail_table_search {
		display: flex;
		margin-top: 2rem;
		padding: 2rem 3.5rem 5rem 2.8rem;
		background: #fff;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		
		.creditsDetail_search{
			width: 20%;
			.creditsDetail_search_item{
				background: #343579;
				border-color: #343579;
				height: 4rem;
				padding: .64rem 1.5rem;
				font-size: 1.6rem;
				border-radius: 2px;
				display: inline-block;
				color: #fff;
				cursor: pointer;
			}
		}
		.creditsDetail_state {
			position: relative;
			display: flex;
			align-items: center;
			cursor: pointer;
			width: 80%;
			.creditsDetail_state_item{
				display: flex;
				align-items: center;
				margin-right: 5rem;
				>span{
					font-size: 2rem;
					font-weight: 400;
					color: #030303;
					margin-right: 15px;
					flex-shrink: 0;
					display: block;
					min-width: 5rem;
					text-align: left;
				}
				.ant-picker-range{
					height: 5rem;
				}
				.ant-select-lg{
					font-size: 14px;
					.ant-select-selector{
						height: 5rem;
						.ant-select-selection-item{
							line-height: 5rem;
						}
						input{
							line-height: 5rem;
							height: 5rem;
						}
					}
				}
			}
			.creditsDetail_current{
				background: #fff;
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
			.header_user_content {
				position: absolute;
				border: 2px solid;
				border-radius: 1rem;
				overflow: hidden;
				top: 0;
				transform: translateY(6rem);
				z-index: 2;
				display: none;
				margin-left: -2rem;
				.username{
					padding: 0 2rem;
					color: #000;
				}
				.username:hover{
					background: #e1e1e1;
				}
				&.active{
					display: block;
				}
			}
		}
	}

	.creditsDetail_table_content {
		width: 100%;
		// height: 100%;
		flex: 1;
		padding-bottom: 3rem;
		background: #fff;
		border-radius: 2rem;
		overflow: hidden;
		.ant-table {
			background: transparent;
		}

		.ant-table-body {
			overflow-y: auto !important;
			-ms-overflow-style: none;
			overflow: -moz-scrollbars-none;

			&::-webkit-scrollbar {
				width: 0 !important;
			}
		}
		.ant-table-thead > tr > th {
			background: #ffffff00;
			border-bottom: none;
			backdrop-filter: blur(1rem);
		}

		.ant-table-tbody > tr > td {
			border: none;
			background: transparent;
			// color: #fff;
		}
		.ant-table-tbody > tr {
			&:hover > td {
				background: #ffffff3a;
			}
		}
		.ant-table-pagination-right {
			padding-right: 3.5rem;
		}
		.operate_list {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 1rem;

			.operate_item {
				font-size: 1.4rem;
				font-family: Roboto;
				font-weight: 400;
				color: #343579;
				cursor: pointer;
			}
		}
	}
}
</style>