<template>
    <Table url="/api/v1/logger/login" rowKey="logId">
        <template #search="{ query }">
            <MoreItem :label="$t('select.startTime')">
                <a-date-picker
                    class="tw-w-full"
                    show-time
                    v-model="query.startTime"
                    valueFormat="YYYY-MM-DD HH:mm:ss"
                />
            </MoreItem>
            <MoreItem :label="$t('select.endTime')">
                <a-date-picker
                    class="tw-w-full"
                    show-time
                    v-model="query.endTime"
                    valueFormat="YYYY-MM-DD HH:mm:ss"
                />
            </MoreItem>
            <MoreItem :label="$t('log.loginUser')">
                <a-input v-model="query.userId" />
            </MoreItem>
            <MoreItem :label="$t('log.loginIp')">
                <a-input v-model="query.loginIp" />
            </MoreItem>
        </template>
        <template #moreSearch="{ query }">
            <MoreItem :label="$t('log.eventType')">
                <a-select v-model="query.loginType" allowClear>
                    <a-select-option value="LOGIN">{{ $t('log.login') }}</a-select-option>
                    <a-select-option value="LOGOUT">{{ $t('log.logout') }}</a-select-option>
                </a-select>
            </MoreItem>
            <MoreItem :label="$t('log.eventStatus')">
                <a-select v-model="query.isSuccess" allowClear>
                    <a-select-option value="0">{{ $t('fail') }}</a-select-option>
                    <a-select-option value="1">{{ $t('success') }}</a-select-option>
                </a-select>
            </MoreItem>
        </template>

        <a-table-column :title="$t('log.userId')" data-index="userId" />
        <a-table-column :title="$t('log.loginUser')" data-index="userName" />
        <a-table-column :title="$t('log.loginIp')" data-index="loginIp" />
        <a-table-column :title="$t('log.eventType')" data-index="loginTypeName" />
        <a-table-column :title="$t('log.eventStatus')" data-index="isSuccessName" />
        <a-table-column :title="$t('log.loginTime')" data-index="loginTime" />
        <a-table-column :title="$t('table.remark')" data-index="logResultContent" />
    </Table>
</template>

<script>
import { Table, MoreItem } from '@/components/table';

export default {
    components: { Table, MoreItem },
};
</script>
