<template>
    <a-modal
        class="modal_component generalModel_modal"
        v-model:visible="showPayOrder"
        :footer="null"
        width="78%"
        :maskClosable="false"
        :centered="true"
        :closable="false"
        wrapClassName="#app"
        :keyboard="false"
    >
		<div class="generalModel_page ">
			<div class="closeIcon">
				<i class="fi fi-rr-cross-small" @click.stop="cancelDsign()"></i>
			</div>
			<div class="creditsDetail_table_search generalModel_table_search">
				<div class="creditsDetail_state generalModel_state">
					<div class="generalModel_state_item">
						<span>Time:</span>
							<a-range-picker
							class="range_picker"
							v-model:value="rangePickerValue"
							style="width:35rem"
							:placeholder="[
								$t('HistoryPage.StartDate'),
								$t('HistoryPage.EndDate'),
							]"
							:show-time="{ format: 'HH:mm:ss' }"
							format="YYYY-MM-DD HH:mm:ss"
							valueFormat="YYYY-MM-DD HH:mm:ss"
						>
							<template #suffixIcon>
								<span
									class="icon iconfont range_picker_icon icon-rili"
								></span>
							</template>
						</a-range-picker>
					</div>
					<div class="creditsDetail_state_item generalModel_state_item">
						<span>State:</span>
						<a-select style="width:25rem" v-model:value="currentState.value" size="large" optionFilterProp="label" :options="state" placeholder="Please select" allowClear show-search></a-select>
					</div>
				</div>

				
				<div class="creditsDetail_search generalModel_search">
					<div
						class="creditsDetail_search_item generalModel_search_item"
						@click="searchcreditsDetailList()"
					>
						<span
							class="icon iconfont icon-sousuo"
						></span>
					</div>
				</div>
			</div>
			<div class="generalModel_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 }">
						<template v-if="column.inputImage">
							<img :src="text.inputImage" :title="column.title">
						</template>
						<template v-else-if="column.outputImage">
							<img :src="text.outputImage" :title="column.title">
						</template>
						<template v-else-if="column.Operations">
							<div class="operate_list">
								<div class="operate_item" @click="openExport(text)">下载</div>
							</div>
							<!-- <div v-else class="operate_item">/</div> -->
						</template>
					</template>
					<!-- <template
						#bodyCell="{ column, text, record, index }"
					>
						<div
							class="operate_list"
							v-if="column?.Operations"
						>
							<div class="operate_item">{{ $t('HistoryPage.Delete') }}</div>
						</div>
					</template> -->
				</a-table>
			</div>
		</div>
      
	
    </a-modal>
	<div class="mark_loading" v-show="loadingShow">
		<a-spin size="large" />
	</div>
</template>
<script lang="ts">
import { defineComponent, ref, createVNode, computed, nextTick } from "vue";
import { Https } from "@/tool/https";
import { downloadIamge } from "@/tool/util";
import { Modal, message } from "ant-design-vue";
import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
import { useI18n } from "vue-i18n";
export default defineComponent({
    components: {
    },
    setup() {
        let presentState: any = ref('paypal');
        let showPayOrder: any = ref(false);
        let loadingShow: any = ref(false);//原因
        let { t } = useI18n();
		const columns: any = computed(() => {
            return [
                {
                    title: "Input",
                    align: "center",
                    ellipsis: true,
                    // dataIndex: "inputImage",
                    key: "inputImage",
					inputImage:true,
                },
				{
                    title: "Output",
                    align: "center",
                    ellipsis: true,
                    // dataIndex: "outputImage",
                    key: "outputImage",
					outputImage:true,

                },
                {
                    title: "Name",
                    align: "center",
                    ellipsis: true,
                    dataIndex: "imageName",
                    key: "imageName",
                },
				{
                    title: "CreateDate",
                    align: "center",
                    ellipsis: true,
                    dataIndex: "createDate",
                    key: "createDate",
                },
                {
                    title: "Scale",
                    align: "center",
                    ellipsis: true,
                    dataIndex: "otherInput",
                    key: "otherInput",
                },

                {
                    title: useI18n().t("HistoryPage.Operations"),
                    key: "operation",
                    align: "center",
                    // slots:{customRender:'action'}
                    Operations: true,
                },
            ];
		
        });
		let currentState = ref({
			value:'SR',
		})
		let state:any = ref([
			{
				label:'SR',
				value:'SR',
			},
			// {
			// 	label:'Expend',
			// 	value:'expend',
			// },
		])
        let collectionList: any = ref([]);
        let rangePickerValue: any = ref([]);
        return {
            presentState,
            showPayOrder,
			loadingShow,
            t,
			columns,
			currentState,
			state,
			collectionList,
			rangePickerValue,
        };
    },
    data() {
        return {
			currentPage: 1,
            pageSize: 10,
            total: 0,
			historyTableHeight: 0,
        };
    },
    mounted() {
		
		
	},
    methods: {
        init() {
            this.showPayOrder = true;
			this.currentPage = 1
			this.pageSize = 10
			nextTick().then(()=>{
				let historyTable: any = this.$refs.historyTable;
				this.historyTableHeight = historyTable.clientHeight - 130;
			})
			this.getTaskDetail()
        },
		 //改变页码
		 changePage(e: any) {
            this.currentPage = e.current
            this.pageSize = e.pageSize
            this.getTaskDetail();
        },
		//查询列表
		searchcreditsDetailList() {
            this.currentPage = 1;
            this.getTaskDetail();
        },
		getTaskDetail() {
			let startDate: any = this.rangePickerValue[0]?this.rangePickerValue[0] : "";
            let endDate: any = this.rangePickerValue[1]?this.rangePickerValue[1] : "";
				
			let data = {
				size:this.pageSize,
                page: this.currentPage,
				type:this.currentState.value,
				endTime: endDate,
				startTime: startDate,
			}

            Https.axiosPost(Https.httpUrls.getTasksHistory,data).then((rv: any) => {
				if(this.currentPage > 1 && rv.content.length == 0){
					this.currentPage = 1
					this.getTaskDetail()
				}else{
					this.collectionList = rv.content
					this.total = rv.total
				}
				
            });
        },
		openExport(exportObj:any){
			downloadIamge(exportObj.outputImage,exportObj.imageName)
		},
		cancelDsign(){
			this.showPayOrder = false
		}
    },
});
</script>
<style lang="less">
// .generalModel_modal {
    .closeIcon {
        z-index: 2;
    }
    .generalModel_page {
        width: 100%;
        height: 100%;
        padding: 9rem;
        overflow: hidden;
        // min-width: 1440px;
        position: relative;
		display: flex;
		flex-direction: column;
		.generalModel_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;
		
		.generalModel_search{
			width: auto;
			.generalModel_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;
			}
		}
		.generalModel_state {
			position: relative;
			display: flex;
			align-items: center;
			width: auto;
			flex-wrap: wrap;
			.generalModel_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;
						}
					}
				}
			}
			.generalModel_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;
				}
			}
		}
	}
	
	// }
}
.generalModel_table_content {
		width: 100%;
		// height: 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;
			img{
				max-width: 100%;
				max-height: 10rem;
				object-fit: contain;
			}
		}
		.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;
			justify-content: center;
			.operate_item {
				font-size: 1.4rem;
				font-family: Roboto;
				font-weight: 400;
				color: #343579;
				cursor: pointer;
			}
		}
	}
</style>