<style lang="scss" scoped>
.layout-pr5 {
    padding-right: 5px;
}

.layout_card {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    margin: 10px 0;
    width: 100%;
    border: 1px solid #91d5ff;
    border-radius: 15px;
    background: #e6f7ff;

    .card_item {
        margin-right: 20px;
        font-size: 14px;
        cursor: pointer;

        .card_item_color {
            color: #1890ff;
            padding-left: 10px;
        }
    }
}

.upload-demo {
    display: flex;
    padding: 0 10px;
}

.color_red { 
    color: red;
    font-weight: 700;
}

.color_green { 
    color: #67c23a;
    font-weight: 700;
}
</style>
<template>
    <div class="overall-container">
        <div class="search-container">
            <el-form class="search-container-from">
                <el-input type="hidden" />
                <el-form-item label="项目" class="layout-pr10" >
                    <el-select v-model="projectState" placeholder="请选择项目" filterable class="layout-w200">
                        <el-option v-for="i in projectList" :key="i.Id" :label="i.AC002" :value="i.Id"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="标段" class="layout-pr10">
                    <el-select v-model="sectionState" placeholder="请选择标段" filterable class="layout-w200">
                        <el-option v-for="i in sectionList" :key="i.Id" :label="i.BC02" :value="i.Id"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="劳务队" class="layout-pr10">
                        <el-select v-model="laborTeamState" placeholder="请选择劳务队" filterable class="layout-w200">
                            <el-option v-for="i in laborTeamList" :key="i.Id" :label="i.DC01" :value="i.Id"></el-option>
                        </el-select>
                    </el-form-item>
                <el-form-item label="查询内容" class="no-required-star layout-pr10">
                    <el-input v-model="input" clearable class="layout-w200" placeholder="请输入姓名" />
                </el-form-item>
                <el-form-item class="layout-pr10">
                    <el-button type="primary" icon="Search" @click="onSearch">查询</el-button>
                </el-form-item>
                <el-form-item class="layout-pr10">
                    <el-button type="primary" icon="ArrowUp" @click="onExport">导出</el-button>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="Printer" @click="onPrint">打印</el-button>
                </el-form-item>
            </el-form>
            <el-table class="table-container" v-loading="tableLoading" ref="tableRef" :data="tableData" border
                :height="tableHeight" width="100%">
                <el-table-column label="序号" type="index" align="center" max-width="120" fixed="left" />
                <el-table-column prop="A1" label="项目名称" fixed="left" sortable align="left" min-width="180"
                    show-overflow-tooltip />
                <el-table-column prop="A2" label="标段名称" fixed="left" sortable align="left" min-width="180"
                    show-overflow-tooltip />
                <el-table-column prop="A14" label="劳务队名称" fixed="left" sortable align="left" min-width="180"
                    show-overflow-tooltip />
                <el-table-column prop="A3" label="姓名" fixed="left" sortable align="center" min-width="120"
                    show-overflow-tooltip />
                <el-table-column prop="A4" label="性别" sortable align="center" min-width="60" show-overflow-tooltip />
                <el-table-column prop="A5" label="年龄" sortable align="center" min-width="60" show-overflow-tooltip />
                <el-table-column prop="A6" label="工种" sortable align="center" min-width="120" show-overflow-tooltip />
                <el-table-column prop="A7" label="入场时间" sortable align="center" min-width="110" show-overflow-tooltip />
                <el-table-column prop="A8" label="体检时间" sortable align="center" min-width="110" show-overflow-tooltip />
                <el-table-column prop="A9" label="血压(MMHG)" sortable align="center" min-width="90" show-overflow-tooltip>
                    <template #default="scope">
                        <span v-if="isBloodPressureNormal(scope.row.A9)" class="color_green">{{ scope.row.A9 }}</span>
                        <span v-else class="color_red">{{ scope.row.A9 }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="A10" label="血氧(%)" sortable align="center" min-width="60" show-overflow-tooltip>
                    <template #default="scope">
                        <span v-if="scope.row.A10 >= 85" class="color_green">{{ scope.row.A10 }}</span>
                        <span v-else class="color_red">{{ scope.row.A10 }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="A11" label="心率(BPM)" sortable align="center" min-width="80" show-overflow-tooltip>
                    <template #default="scope">
                        <span v-if="scope.row.A11 <= 100 && scope.row.A11 >= 60" class="color_green">{{ scope.row.A11 }}</span>
                        <span v-else class="color_red">{{ scope.row.A11 }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="A12" label="体温(℃)" sortable align="center" min-width="60" show-overflow-tooltip>
                    <template #default="scope">
                         <span v-if="scope.row.A12 >= 36.1 && scope.row.A12 <= 37.2" class="color_green">{{ scope.row.A12 }}</span>
                         <span v-else class="color_red">{{ scope.row.A12 }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="A13" label="健康状态" sortable align="center" min-width="60" show-overflow-tooltip>
                    <template #default="scope">
                        <span v-if="scope.row.A13 === '正常'" class="color_green">{{ scope.row.A13 }}</span>
                        <span v-else class="color_red">{{ scope.row.A13 }}</span>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination class="layout-pagination" :current-page="currentPage" :page-size="pageSize"
                :page-sizes="pageSizes" :size="size" :disabled="disabled" :background="background"
                layout="total, sizes, prev, pager, next, jumper" :total="tableData.length"
                @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        </div>
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'

const projectList = ref([])
const sectionList = ref([])
const projectState = ref('')
const sectionState = ref('')
const laborTeamList = ref([])
const laborTeamState = ref('')
const input = ref('')
const tableLoading = ref(false)
const tableHeight = ref('60vh')
const tableRef = ref(null)
const currentPage = ref(1)
const pageSize = ref(30)
const pageSizes = ref([30, 50, 100])
// const total = ref(0)
const background = ref(true)
const disabled = ref(false)
const size = ref('default')
const tableData = ref([
    { A1: '项目1', A2: '标段1', A14: '劳务队1', A3: '张三', A4: '男', A5: '20', A6: '电工', A7: '2025-06-01', A8: '2025-06-02', A9: '145/95', A10: '80', A11: '101', A12: '37.5', A13: '异常' },
    { A1: '项目2', A2: '标段2', A14: '劳务队2', A3: '张三', A4: '男', A5: '20', A6: '电工', A7: '2025-06-01', A8: '2025-06-02', A9: '120/80', A10: '95', A11: '70', A12: '36.5', A13: '正常' },
    { A1: '项目3', A2: '标段3', A14: '劳务队3', A3: '张三', A4: '男', A5: '20', A6: '电工', A7: '2025-06-01', A8: '2025-06-02', A9: '120/80', A10: '95', A11: '59', A12: '36.5', A13: '正常' },
])
const isBloodPressureNormal = (pressure) => {
    if (!pressure) return false;

    const [systolic, diastolic] = pressure.split('/').map(Number);
    return systolic >= 90 && systolic <= 139 &&
        diastolic >= 60 && diastolic <= 89;
};
const handleCurrentChange = () => { }
const handleSizeChange = () => { }
const onSearch = () => { }
const onExport = () => { }
const onPrint = () => { }

onMounted(() => {
    
})
</script>
