<template>
    <div class="default-main">
        <TableHeader datePicker></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-device-boot/cslog/queryLog',
    method: 'POST',
    column: [
        { title: '操作日期', field: 'createTime', align: 'center', sortable: true },
        { title: '操作描述', field: 'operate', align: 'center', width: '300' },
        { title: '用户名称', field: 'userName', align: 'center' },
        { title: '更新时间', field: 'updateTime', align: 'center', sortable: true },
        { title: '失败原因', field: 'failReason', align: 'center' },
        { title: '状态', field: 'result', align: 'center' },
        { title: '登录名', field: 'loginName', align: 'center' }
    ],
    
    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>
