<template>
	<div class="layout-padding">
		<div class="layout-padding-auto layout-padding-view">
			<el-row class="ml10" v-show="showSearch">
				<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
					<el-form-item :label="$t('systoken.ip')" prop="ip">
						<el-input :placeholder="$t('systoken.inputIpTip')" v-model="state.queryForm.ip"></el-input>
					</el-form-item>
                    <el-form-item :label="$t('systoken.domain')" prop="domain">
						<el-input :placeholder="$t('systoken.inputDomainTip')" v-model="state.queryForm.domain"></el-input>
					</el-form-item>
					<el-form-item>
						<el-button @click="getDataList" icon="Search" type="primary">{{ $t('common.queryBtn') }} </el-button>
						<el-button @click="resetQuery" icon="Refresh">{{ $t('common.resetBtn') }}</el-button>
					</el-form-item>
				</el-form>
			</el-row>
			<el-table
				:data="state.dataList"
				@sort-change="sortChangeHandle"
				style="width: 100%"
				v-loading="state.loading"
				border
				:cell-style="tableStyle.cellStyle"
				:header-cell-style="tableStyle.headerCellStyle"
			>
				<!-- <el-table-column align="center" type="selection" width="40" /> -->
				<el-table-column :label="$t('systoken.ip')" prop="ip" show-overflow-tooltip></el-table-column>
				<el-table-column :label="$t('systoken.domain')" prop="domain" show-overflow-tooltip ></el-table-column>
				<el-table-column :label="$t('systoken.content')" prop="content" show-overflow-tooltip></el-table-column>
				<el-table-column :label="$t('systoken.active')" prop="active" show-overflow-tooltip></el-table-column>
			</el-table>

			<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle" v-bind="state.pagination"> </pagination>
		</div>
	</div>
</template>

<script lang="ts" setup>
import { BasicTableProps, useTable } from '/@/hooks/table';
import { pageList } from '/@/api/marketing/statistics';

import { useI18n } from 'vue-i18n';
import { useMessage, useMessageBox } from '/@/hooks/message';
import { Session } from '/@/utils/storage';

const { t } = useI18n();
// 定义变量内容
const queryRef = ref();
const showSearch = ref(true);

//  table hook
const state: BasicTableProps = reactive<BasicTableProps>({
	queryForm: {
		ip: '',
        domain:''
	},
	pageList: pageList,
});
const { getDataList, currentChangeHandle, sortChangeHandle, sizeChangeHandle, tableStyle } = useTable(state);

// 清空搜索条件
const resetQuery = () => {
	queryRef.value?.resetFields();
	getDataList();
};

</script>
