<template>
    <div class="default-main">
        <TableHeader datePicker showExport showCustomColumn></TableHeader>
        <Table ref="tableRef" :isGroup="true" />
    </div>
</template>
<script setup lang="ts">
import { Plus } from '@element-plus/icons-vue'
import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'

defineOptions({
    name: 'govern/log/operation'
})
const tableStore = new TableStore({
    url: '/cs-system-boot/cslog/queryLog',
    method: 'POST',
    column: [
        {
            field: 'index',
            title: '序号',
            width: '80',
            formatter: (row: any) => {
                return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
            }
        },
        { title: '操作日期', field: 'createTime', align: 'center', sortable: true, minWidth: '180' },
        { title: '用户名称', field: 'userName', align: 'center', minWidth: '180'  },
        { title: '操作描述', field: 'operate', align: 'center', minWidth: '300' },

        {
            title: '状态',
            field: 'result',
            align: 'center',
            minWidth: '100',
            render: 'tag',
            custom: {
                0: 'danger',
                1: 'success',
                null:'info'
            },
            replaceValue: {
                0: '失败',
                1: '成功',
                null: '/'
            }
        },
        {
            title: '失败原因',
            field: 'failReason',
            align: 'center',
            minWidth: '200',
            formatter: (row: any) => {
                return row.cellValue || '/'
            }
        },
        // {
        //     title: '登录名称',
        //     field: 'loginName',
        //     align: 'center',
        //     minWidth: '120',
        //     formatter: (row: any) => {
        //         return row.cellValue || '/'
        //     }
        // }
    ],

    loadCallback: () => {
        // tableStore.table.data.forEach((item: any) => {
        //     item.failReason = item.failReason || '/'
        //     item.result = item.result === 1 ? '成功' : '失败'
        //     item.loginName = item.loginName || '/'
        // })
    }
})

provide('tableStore', tableStore)
tableStore.table.params.searchState = 0
tableStore.table.params.sortBy = ''
tableStore.table.params.orderBy = ''
onMounted(() => {
    tableStore.index()
})

const addMenu = () => { }
</script>
