<script setup lang="ts">
import { onMounted } from "vue";
import { useData } from "./hook";
import { PureTableBar } from "@/components/RePureTableBar";
import { deviceDetection } from "@pureadmin/utils";
const {
	onSearch,
	isShow,
	tableList,
	pagination,
	tableLabel,
	handleSizeChange,
	handleCurrentChange,
	handleDelete,
	downloadData,
	loading
} = useData();
onMounted(() => {
	onSearch();
});
defineOptions({
	name: "giftRecord"
});
</script>

<template>
	<div class="main">
		<div ref="contentRef" :class="['flex', deviceDetection() ? 'flex-wrap' : '']">
			<PureTableBar title="安卓日志记录表" :class="[isShow && !deviceDetection() ? '!w-[60vw]' : 'w-full']"
				:columns="tableLabel" @refresh="onSearch">
				<template v-slot="{ size, dynamicColumns }">
					<pure-table ref="tableRef" align-whole="center" showOverflowTooltip table-layout="auto" default-expand-all
						:loading="loading" :size="size" row-key="id" adaptive :adaptiveConfig="{ offsetBottom: 108 }"
						:data="tableList" :columns="dynamicColumns" :pagination="{ ...pagination, size }" :header-cell-style="{
							background: 'var(--el-fill-color-light)',
							color: 'var(--el-text-color-primary)'
						}" @page-current-change="handleCurrentChange" @page-size-change="handleSizeChange">
						<template #operation="{ row }">
							<el-button link type="primary" :size="size" @click="downloadData(row)">
								下载
							</el-button>
							<el-popconfirm :title="`是否确认删除这条数据`" @confirm="handleDelete(row)">
								<template #reference>
									<el-button link type="primary" :size="size"> 删除 </el-button>
								</template>
							</el-popconfirm>
						</template>
					</pure-table>
				</template>
			</PureTableBar>
		</div>
	</div>
</template>
<style scoped lang="scss"></style>