<template>
    <div class="default-main">
        <TableHeader>
            <template v-slot:select>
                <el-form-item label="设备类型">
                    <!-- <el-input v-model="tableStore.table.params.searchValue" placeholder="请输入设备类型" /> -->
                    <el-select v-model="tableStore.table.params.devType" clearable placeholder="请选择设备类型">
                        <el-option
                            v-for="item in devTypeOptions"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </el-form-item>
                <el-form-item label="设备型号">
                    <el-select v-model="tableStore.table.params.devModel" clearable placeholder="请选择设备型号">
                        <el-option
                            v-for="item in devModelOptionsFilter"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </el-form-item>
                <el-form-item label="通讯协议">
                    <el-select v-model="tableStore.table.params.devAccessMethod" clearable placeholder="请选择通讯协议">
                        <el-option label="MQTT" value="mqtt"></el-option>
                        <el-option label="CLD" value="cloud"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="状态">
                    <el-select v-model="tableStore.table.params.status" clearable placeholder="请选择状态">
                        <el-option label="未注册" :value="1"></el-option>
                        <el-option label="注册" :value="2"></el-option>
                        <el-option label="接入" :value="3"></el-option>
                    </el-select>
                </el-form-item>
            </template>
        </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/debug'
})

const devTypeOptions: any = ref([])
const devModelOptionsFilter: any = ref([])

const tableStore = new TableStore({
    url: '/cs-device-boot/EquipmentDelivery/list',
    method: 'POST',
    column: [
        { title: '设备名称', field: 'name', align: 'center' },
        { title: '设备类型', field: 'operatorName', align: 'center' },
        { title: '设备型号', field: 'devModel', align: 'center', width: '300' },
        { title: '通讯协议', field: 'devAccessMethod', align: 'center' },
        { title: '录入时间', field: 'createTime', align: 'center' },
        { title: '网络设备ID', field: 'ndid', align: 'center' },
        { title: '状态', field: 'status', 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)

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

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