<template>
	<el-drawer v-model="visible" v-loading="loading" direction="rtl" size="70%" title="缴费记录">
		<el-table :data="paymentConfigList" :default-expand-all="defaultExpandAll || expandAll"
			@selection-change="handleSelectionChange">
			<!-- <el-table-column label="订单号" align="center" prop="orderNumer" />
			<el-table-column label="设备" align="center" prop="configId" v-if="props.configId==null" />
			<el-table-column label="支付金额" align="center" prop="paymentMoney">
				<template #default="scope">
					<span class="text-price">{{scope.row.paymentMoney}}</span>
				</template>
			</el-table-column>
			<el-table-column label="支付方式" align="center" prop="paymentType">
				<template #default="scope">
					<dict-tag :options="com_payment_type" :value="scope.row.paymentType" />
				</template>
			</el-table-column>
			<el-table-column label="支付状态" align="center" prop="paymentState">
				<template #default="scope">
					<dict-tag :options="com_payment_state" :value="scope.row.paymentState" />
				</template>
			</el-table-column>
			<el-table-column label="支付时间" align="center" prop="parmentTime">
				<template #default="scope">
					<span>{{ parseTime(scope.row.parmentTime) }}</span>
				</template>
			</el-table-column> -->
		</el-table>
	</el-drawer>
</template>

<script setup>
	import {
		listPaymentConfig,
		// getPaymentConfig,
		// delPaymentConfig,
		// addPaymentConfig,
		// updatePaymentConfig
	} from "@/api/paymentConfig/paymentConfig";

	import {
		listPaymentDetails,
		// getPaymentDetails,
		// delPaymentDetails,
		// addPaymentDetails,
		// updatePaymentDetails
	} from "@/api/PaymentDetails/PaymentDetails";

	const {
		proxy
	} = getCurrentInstance();

	const {
		com_payment_type,
		com_payment_state
	} = proxy.useDict('com_payment_type', 'com_payment_state');

	const props = defineProps({
		configId: String,
		orderNumer: String,
		defaultExpandAll: Boolean
	});

	const loading = ref(true);
	const total = ref(0);
	const visible = ref(false);
	const expandAll = ref(false);
	

	const queryParams = ref({
		pageNum: 1,
		pageSize: 9999,
		configId: null,
		orderNumer: null,
	});
	const paymentConfigList = ref([]);

	/** 查询订单详情列表 */
	function getList() {
		console.log(props)
		loading.value = true;
		// queryParams.value = {
		// 	pageNum: 1,
		// 	pageSize: 9999,
		// 	configId: null,
		// 	orderNumer: null,
		// }
		getPaymentConfigList()
		// if (props.configId != null) {
		// 	getPaymentConfigList()
		// 	// getPaymentDetailsList()
		// } else if (props.orderNumer != null) {
		// 	getPaymentDetailsList()
		// } else {
		// 	getPaymentConfigList()
		// }

	}

	function getPaymentConfigList() {
		console.log("getPaymentConfigList")
		console.log(props)
		queryParams.value.configId = props.configId
		queryParams.value.orderNumer = props.orderNumer
		console.log(queryParams.value)
		listPaymentConfig(queryParams.value).then(response => {
			paymentConfigList.value = response.rows;
			total.value = response.total;
			if(total.value == 1){
				expandAll.value = true
			}
			loading.value = false;
		});
	}

	function getPaymentDetailsList() {
		console.log("getPaymentDetailsList")
		queryParams.value.orderNumer = props.orderNumer
		console.log(queryParams.value)
		listPaymentDetails(queryParams.value).then(response => {
			paymentConfigList.value = response.rows;
			total.value = response.total;
			loading.value = false;
		});
	}

	/** 查询参数列表 */
	function show() {
		getList();
		visible.value = true;
	}

	defineExpose({
		show,
	});
</script>

<style>
</style>
