<template>
    <div>
        <!--终端运维日志 -->

        <Table ref="tableRef"></Table>
    </div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch } from 'vue'

import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ledgerChangePush } from '@/api/device-boot/terminalTree'
import { getTimeOfTheMonth } from '@/utils/formatTime'
const prop = defineProps({
    width: { type: String },
    height: { type: String },
    timeKey: { type: String }
})
const dictData = useDictData()
const fontdveoption = dictData.getBasicData('Dev_Ops')

const tableStore:any = new TableStore({
    url: '/device-boot/pqsTerminalLogs/getList',
    method: 'POST',
    column: [
        {
            field: 'index',
            title: '序号',
            width: '60',
            formatter: (row: any) => {
                return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
            }
        },
        // { title: '名称', field: 'name', width: '200' },
        {
            title: '日志类型',
            field: 'logsType',
            width: '100',
            formatter: (row: any) => {
                return fontdveoption.find((item: any) => item.id == row.cellValue)?.name
            }
        },

        {
            title: '更改人员',
            field: 'createBy',
            width: '100'
        },
        {
            title: '更改时间',
            field: 'updateTime',
            width: '140'
        },

        { title: '描述', field: 'terminalDescribe' }
    ],
    beforeSearchFun: () => {
        tableStore.table.params.searchBeginTime = getTimeOfTheMonth(prop.timeKey)[0]
        tableStore.table.params.searchEndTime = getTimeOfTheMonth(prop.timeKey)[1]
    },
    loadCallback: () => {
        tableStore.table.height = `calc(${prop.height} - 80px)`
    }
})

const tableRef = ref()
provide('tableRef', tableRef)
tableStore.table.params.type = ''
tableStore.table.params.searchValue = ''
provide('tableStore', tableStore)

onMounted(() => {
    tableStore.index()
})
watch(
    () => prop.timeKey,
    val => {
        tableStore.index()
    }
)

const addMenu = () => {}
</script>
<style lang="scss" scoped></style>
