<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>
                <el-form-item label="工序步骤" prop="process_step">
                    <el-input class="w-[280px]" v-model="queryParams.process_step" clearable placeholder="请输入工序步骤" />
                </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>
        </el-card>
        <el-card class="!border-none" v-loading="pager.loading" shadow="never">
            <div class="mt-4">
                <el-table :data="pager.lists" @cell-click="handleCurrentChange">
                    <el-table-column type="selection" width="55" />
                    <el-table-column label="作业编码" prop="zy_code" show-overflow-tooltip />
                    <el-table-column label="项目名称" prop="project_name" show-overflow-tooltip />
                    <el-table-column label="分项工程" prop="subentry_engineering" show-overflow-tooltip />
                    <el-table-column label="工序步骤号" prop="process_step_no" show-overflow-tooltip />
                    <el-table-column label="工序步骤" prop="process_step" show-overflow-tooltip />
                    <el-table-column label="质量控制点" prop="quality_control_points" show-overflow-tooltip />
                    <el-table-column label="图例说明" prop="file" show-overflow-tooltip>
                        <template #default="{ row }">
                            <div v-if="row.file && row.file.length > 0">
                                <div v-for="(item, i) in row.file " :key='i'>
                                    <el-link :href="item" target="_blank">文件{{ i + 1 }}查看</el-link>
                                </div>
                            </div>
                            <div v-else>
                                暂无文件
                            </div>

                        </template>
                    </el-table-column>

                </el-table>

            </div>
            <div class="flex mt-4 justify-end">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
    </div>
</template>
  
<script lang="ts" setup>
import { usePaging } from "@/hooks/usePaging"
import { useDictData } from "@/hooks/useDictOptions"
import { buildplanLists } from '@/api/build/build_plan'

import { defineEmits } from "vue"

// 查询条件
const queryParams = reactive({
    process_step: ''
});


// 选中数据
const emits = defineEmits(["customEvent"]);

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

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

getLists();
</script>