<style>
    .sub-header {
        text-align: center;
        font-size: 14px;
        margin-bottom: 16px;
    }

    .base-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 12px;
        margin-bottom: 12px;
    }

    .base-table td, .base-table th {
        border: 1px solid #000;
        padding: 6px 8px;
        vertical-align: middle;
    }

    .label-cell {
        width: 15%;
        text-align: center;
        white-space: nowrap;
    }

    .value-cell {
        width: 35%;
        text-align: left;
    }

    .section-title {
        font-weight: bold;
        background: #f0f0f0;
        text-align: left;
        padding: 8px;
    }

    .items-cell {
        padding: 8px;
        line-height: 1.7;
    }

    .image-box {
        width: 48%;
        height: 220px;
        margin: 1%;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px solid #eee;
        box-sizing: border-box;
    }

    .image-box img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }
</style>

<div class="header">
    <h1>车辆三检检查表单</h1>
</div>
<div class="sub-header">打印时间：$!printTime</div>

<table class="base-table">
    <colgroup>
        <col style="width: 15%;"/>
        <col style="width: 35%;"/>
        <col style="width: 15%;"/>
        <col style="width: 35%;"/>
    </colgroup>
    <tr>
        <td class="label-cell">所属企业</td>
        <td class="value-cell">$!companyName</td>
        <td class="label-cell">车牌号</td>
        <td class="value-cell">$!plateNumber</td>
    </tr>
</table>

#macro(renderPhase $phaseData $title)
<table class="base-table">
    <colgroup>
        <col style="width: 15%;"/>
        <col style="width: 35%;"/>
        <col style="width: 15%;"/>
        <col style="width: 35%;"/>
    </colgroup>
    <tr>
        <td class="section-title" colspan="4">$!title</td>
    </tr>
    <tr>
        <td class="items-cell" colspan="4">
            #if($phaseData && $phaseData.items && $phaseData.items.size() > 0)
                #foreach($item in $phaseData.items)
                    $!item.index. $!item.title：$!item.result<br/>
                #end
            #else
                无
            #end
        </td>
    </tr>
    <tr>
        <td class="label-cell">检查附件</td>
        <td class="value-cell" colspan="3">
            #if($phaseData && $phaseData.attachImages && $phaseData.attachImages.size() > 0)
                <div style="display: flex; flex-wrap: wrap; justify-content: flex-start;">
                    #foreach($img in $phaseData.attachImages)
                        <div class="image-box">
                            <img src="$!{img}"/>
                        </div>
                    #end
                </div>
            #else
                暂无
            #end
        </td>
    </tr>
    <tr>
        <td class="label-cell">检查时间</td>
        <td class="value-cell">$!phaseData.inspectTime</td>
        <td class="label-cell">检查员签名</td>
        <td class="value-cell">
            #if($phaseData && $phaseData.inspectorSignUrl)
                <img src="$!{phaseData.inspectorSignUrl}" style="height:40px; display:block;"/>
            #end
        </td>
    </tr>
    <tr>
        <td class="label-cell">是否误报</td>
        <td class="value-cell">$!phaseData.isFalseReport</td>
        <td class="label-cell">是否存在隐患</td>
        <td class="value-cell">$!phaseData.hasHiddenDanger</td>
    </tr>
    <tr>
        <td class="label-cell">审核结论</td>
        <td class="value-cell">$!phaseData.auditResult</td>
        <td class="label-cell">审核人</td>
        <td class="value-cell">$!phaseData.auditorName</td>
    </tr>
    <tr>
        <td class="label-cell">审核时间</td>
        <td class="value-cell">$!phaseData.auditTime</td>
        <td class="label-cell">审核人签名</td>
        <td class="value-cell">
            #if($phaseData && $phaseData.auditorSignUrl)
                <img src="$!{phaseData.auditorSignUrl}" style="height:40px; display:block;"/>
            #end
        </td>
    </tr>
</table>
#end

#if($phase1)
    #renderPhase($phase1 "出车前检查")
#end

#if($phase2)
    #renderPhase($phase2 "行车中检查")
#end

#if($phase3)
    #renderPhase($phase3 "收车后检查")
#end
