<template>
    <my-table url="/api/v1/logger/operation" rowKey="logId" ref="table">
        <template #drawer>
            <Form :data="currentClickRow" />
        </template>

        <template #search="{query}">
            <my-form-item label="开始时间">
                <a-date-picker
                    class="tw-w-full"
                    show-time
                    v-model="query.startTime"
                    valueFormat="YYYY-MM-DD HH:mm:ss"
                />
            </my-form-item>
            <my-form-item label="结束时间">
                <a-date-picker
                    class="tw-w-full"
                    show-time
                    v-model="query.endTime"
                    valueFormat="YYYY-MM-DD HH:mm:ss"
                />
            </my-form-item>
            <my-form-item label="操作用户Id">
                <a-input v-model="query.operatorId" />
            </my-form-item>
            <my-form-item label="业务模块">
                <a-select v-model="query.loginType" allowClear>
                    <a-select-option value="LOGIN">登录系统</a-select-option>
                    <a-select-option value="LOGOUT">退出系统</a-select-option>
                </a-select>
            </my-form-item>
            <my-form-item label="操作服务">
                <a-select v-model="query.isSuccess" allowClear>
                    <a-select-option value="0">失败</a-select-option>
                    <a-select-option value="1">成功</a-select-option>
                </a-select>
            </my-form-item>
        </template>
        <a-table-column title="用户Id" data-index="operatorId" />
        <a-table-column title="用户名称" data-index="operatorName" />
        <a-table-column title="业务模块" data-index="moduleCode" />
        <a-table-column title="操作服务" data-index="serviceCode" />
        <a-table-column title="操作时间" data-index="operateTime" />
        <a-table-column title="操作">
            <template #default="row">
                <a @click="() => view(row)">详情</a>
            </template>
        </a-table-column>
    </my-table>
</template>

<script>
import Form from './form.vue';

export default {
    components: { Form },
    data() {
        return {
            currentClickRow: {},
        };
    },
    methods: {
        showDrawer(type, noFooter) {
            this.$refs['table'].show({ type, noFooter });
        },
        view(row) {
            this.currentClickRow = row;
            this.showDrawer(2, true);
        },
    },
};
</script>
