<template>
	<xn-form-container
		title="详情"
		:width="700"
		:visible="visible"
		:destroy-on-close="true"
		@close="onClose"
	>

		<a-form ref="formRef" :model="formData" layout="vertical">
			<s-table
				ref="tableRef"
				:columns="columns"
				:data="loadData"
				:alert="false"
				:showPagination="true"
				bordered
				:row-key="(record) => record.id"
			>
				<template #bodyCell="{ column, record }">
					<template v-if="column.dataIndex === 'adjustType'">
						<a-tag
							:color="
							record.adjustType === '1'
								? 'orange'
								: record.adjustType === '2'
								  ? 'green'
								  : record.adjustType === '3'
								    ? 'cyan'
								      : 'purple'
						"
						>
							{{ $TOOL.dictTypeData('adjust_type', record.adjustType) }}
						</a-tag>
					</template>
				</template>
			</s-table>

		</a-form>
	</xn-form-container>
</template>

<script setup name="messageDetail">
	import consumptionRecordApi from '@/api/biz/consumptionRecordApi'
	import bizUserApi from "@/api/biz/bizUserApi";
	import bizActivateDetailApi from '@/api/biz/bizActivateDetailApi'
	import {cloneDeep} from "lodash-es";
	const receiveInfoList = ref([])
	const emit = defineEmits({ successful: null })

	// 默认是关闭状态
	const visible = ref(false)
	const formRef = ref()
	// 表单数据
	const formData = ref({})
	const tableRef = ref()
	const columns = [
		{
			title: '姓名',
			dataIndex: 'userName',
			align: 'center',
		},
		{
			title: '手机号',
			dataIndex: 'phone',
			align: 'center',
		},
		{
			title: '激活时间',
			dataIndex: 'createTime',
			align: 'center',
		},

	]
	// 打开抽屉
	const onOpen = (record) => {
		visible.value = true
		if (record) {
			let recordData = cloneDeep(record)
			formData.value = Object.assign({}, recordData)
		}
	}

	const loadData = () => {
		let param = {
			activateId: formData.value.id
		}
		return bizActivateDetailApi.bizActivateDetailPage(param).then((res) => {
			return res
		})
	}
	// 关闭抽屉
	const onClose = () => {
		receiveInfoList.value = []
		visible.value = false
		emit('successful')
	}
	// 调用这个函数将子组件的一些数据和方法暴露出去
	defineExpose({
		onOpen
	})
</script>
