<template>
    <div>
        <el-card class="!border-none" v-loading="pager.loading" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>
                <!-- <el-form-item label="编号" prop="inspection_code">
                    <el-input class="w-[280px]" v-model="queryParams.inspection_code" clearable placeholder="请输入编号" />
                </el-form-item> -->
                <!-- <el-form-item label="节点类型" prop="node_type">
                    <el-select class="flex-1" v-model="queryParams.node_type" clearable placeholder="请选择节点类型">
                        <el-option v-for="(item, index) in dictData.check_item_node_type" :key="index" :label="item.name"
                            :value="parseInt(item.value)" />
                    </el-select>
                </el-form-item> -->
                <!-- <el-form-item>
                    <el-button type="primary" @click="resetPage">查询</el-button>
                    <el-button @click="resetParams">重置</el-button>
                </el-form-item> -->
            </el-form>
            <div class="mt-4">
                <el-table :data="pager.lists" @cell-click="handleCurrentChange" @selection-change="handleSelectionChange">
                    <el-table-column type="selection" width="55" />
                    <el-table-column label="检查类别" prop="check_type" show-overflow-tooltip />
                    <el-table-column label="检查类容" prop="check_content" show-overflow-tooltip />
                    <el-table-column label="是否必填" prop="must_check_text" show-overflow-tooltip />

                </el-table>
            </div>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
            <div class="flex justify-end mt-4">
                <el-button type="primary" @click="confirm">确定</el-button>
            </div>
        </el-card>
    </div>
</template>
  
<script lang="ts" setup>
import { usePaging } from "@/hooks/usePaging"
import { apisupervision_check_item_detailLists } from '@/api/supervision_check_item'
import { defineEmits } from "vue"
import { useDictData } from '@/hooks/useDictOptions'

const props = defineProps({
    node_id: Number | String
})
// 查询条件
// 查询条件
const queryParams = reactive({
    node_id: props.node_id
})
const { dictData } = useDictData('check_item_node_type')
const multipleSelection = ref([])
// 选中数据
const emits = defineEmits(["customEvent"]);

// 选中数据子父传递
const handleCurrentChange = (value: any) => {
    emits("customEvent", [value]);
};

const handleSelectionChange = (val) => {
    multipleSelection.value = val
}
const confirm = () => {
    console.log(1)
    emits("customEvent", multipleSelection.value);
}

// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
    fetchFun: apisupervision_check_item_detailLists,
    params: queryParams,
});

getLists();
</script>