<template>
    <div class="default-main">
        <TableHeader datePicker showExport>
            <template v-slot:select>
                <el-form-item label="日志类型">
                    <el-select v-model="tableStore.table.params.type" clearable placeholder="请选择日志类型">
                        <el-option v-for="item in fontdveoption" :key="item.id" :label="item.name" :value="item.id" />
                    </el-select>
                </el-form-item>
                <el-form-item label="筛选数据">
                    <el-input v-model="tableStore.table.params.searchValue" placeholder="请输入筛选数据" clearable />
                </el-form-item>
            </template>
            <template #operation>
                <el-button type="primary" icon="el-icon-Sort" @click="changePush">台账变更推送</el-button>
            </template>
        </TableHeader>
        <Table ref="tableRef"></Table>
    </div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, nextTick } 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'
defineOptions({
    name: 'BusinessAdministrator/LogManagement/TerminalLog'
})
const dictData = useDictData()
const fontdveoption = dictData.getBasicData('Dev_Ops')

const tableStore = new TableStore({
    url: '/device-boot/pqsTerminalLogs/getList',
    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: 'name', width: '200' },
        {
            title: '日志类型',
            field: 'logsType',
            width: '250',
            formatter: (row: any) => {
                return fontdveoption.find((item: any) => item.id == row.cellValue)?.name
            }
        },

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

        { title: '描述', field: 'terminalDescribe' }
    ],
    beforeSearchFun: () => {}
})
// 变更推送
const changePush = () => {
    ElMessageBox.confirm('当前操作会把存在变动的装置测点推送至前置，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
    }).then(() => {
        ledgerChangePush().then(res => {
            ElMessage.success(res.message)
            tableStore.index()
        })
    })
}
const tableRef = ref()
provide('tableRef', tableRef)
tableStore.table.params.type = ''
tableStore.table.params.searchValue = ''
provide('tableStore', tableStore)

onMounted(() => {
    tableStore.index()
})

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