<style type="text/css">
    .new_table {
        border-collapse: collapse;
        margin: 0 auto;
        text-align: center;
        width: 95%;
        font-size: 12px;
    }

    .new_table td,
    table th {
        border: 1px solid #cad9ea;
        color: #666;
        height: 2.5em;
    }

    .new_table thead th {
        background-color: #CCE8EB;
        width: 100px;
    }

    .span_show {
        float: left;
        margin-left: 15px;
        font-size: 11px;
        color: #0a84ff;
        cursor: pointer;
    }

    .span_hide {
        float: left;
        margin-left: 15px;
        font-size: 11px;
        color: #0a84ff;
        cursor: pointer;
    }
</style>
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div class="row">
        <div class="form-group col-sm-6">
            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('Sim_type')}:</label>
            <div class="col-xs-12 col-sm-7">
                <select id="c-sim_type" data-rule="required" class="form-control" name="row[sim_type]" style="width: 80%">
                    <option value="">请选择</option>
                    {foreach name="sim_sim_type" item="vo"}
                    <option value="{$key}" {if $row.sim_type eq $key}selected{/if}>{$vo}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="control-label col-xs-12 col-sm-2 addRedStar">{:__('Name')}:</label>
            <div class="col-xs-12 col-sm-8">
                <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}" style="width: 80%">
            </div>

            <button type="submit" class="btn btn-success">{:__('提交')}</button>
        </div>
    </div>
    <input class="form-control fault_ids" name="row[fault_id]" type="hidden" value="{$row.fault_id|htmlentities}" data-rule="required">
    <input class="form-control fault_names" name="row[fault_name]" type="hidden" value="{$row.fault_name|htmlentities}" data-rule="required">
    <input class="form-control pfault_ids" name="row[pfault_id]" type="hidden" value="{$row.pfault_id|htmlentities}" data-rule="required">

    <div class="col-lg-12" style="margin: 20px 10px">
        <div class="tab-content">
            <div class="tab-pane tab_log1" style="display: block">
                <span class="text-danger" style="margin-left:40px;">各模拟器类型的故障有且只允许选择3个</span>
                <table class="new_table">
                    <thead>
                    <tr style="height: 3.5rem">
                        <td style="width:25%">型号</td>
                        <td style="width:30%">故障现象</td>
                        <td style="width:30%">故障部位</td>
                        <td style="width:15%">
                        </td>
                    </tr>
                    </thead>
                    <tbody class="task_list">
                    <?php
                        $fault_id_arr = $row['fault_id_arr'];
                        if($row['sim_type']=='0001'){
                            foreach($row['selectData'] as $key=>$vo){
                                if($key == 0){
                                    echo '<tr><td rowspan="10">FZD04B型侦毒器</td>';
                                }
                                if($key < 4){
                                    echo '<td rowspan="2">'.$vo['name'].'</td>';
                                }else{
                                    echo '<td rowspan="1">'.$vo['name'].'</td>';
                                }
                                foreach($vo['children'] as $k=>$v){
                                    $id = $v['fault_id'];
                                    $name = $v['name'];
                                    if($k>0){
                                        echo '</tr><tr><td>'.$v['name'].'</td>';
                                        if(in_array($id,$fault_id_arr)){
                                            echo '<td><input type="checkbox" name="checkbox" checked value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }else{
                                            echo '<td><input type="checkbox" name="checkbox" value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }
                                    }else{
                                        echo '<td>'.$v['name'].'</td>';
                                        if(in_array($id,$fault_id_arr)){
                                        echo '<td><input type="checkbox" name="checkbox" checked value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }else{
                                        echo '<td><input type="checkbox" name="checkbox" value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }
                                    }
                                }
                                echo "</tr>";
                           }
                        }else if($row['sim_type']=='0002'){
                            foreach($row['selectData'] as $key=>$vo){
                                if($key == 0){
                                    echo '<tr><td rowspan="15">FZB006型毒剂报警器</td>';
                                }
                                if($key < 5){
                                    echo '<td rowspan="2">'.$vo['name'].'</td>';
                                }else{
                                    echo '<td rowspan="1">'.$vo['name'].'</td>';
                                }
                                foreach($vo['children'] as $k=>$v){
                                    $id = $v['fault_id'];
                                    $name = $v['name'];
                                    if($k>0){
                                        echo '</tr><tr><td>'.$v['name'].'</td>';
                                        if(in_array($id,$fault_id_arr)){
                                            echo '<td><input type="checkbox" name="checkbox" checked value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }else{
                                            echo '<td><input type="checkbox" name="checkbox" value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }
                                    }else{
                                        echo '<td>'.$v['name'].'</td>';
                                        if(in_array($id,$fault_id_arr)){
                                            echo '<td><input type="checkbox" name="checkbox" checked value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }else{
                                            echo '<td><input type="checkbox" name="checkbox" value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }
                                    }
                                }
                                echo "</tr>";
                            }
                        }else if($row['sim_type']=='0003'){
                            foreach($row['selectData'] as $key=>$vo){
                                if($key == 0){
                                    echo '<tr><td rowspan="15">防化兵用毒剂报警器</td>';
                                }
                                if($key < 4){
                                    echo '<td rowspan="2">'.$vo['name'].'</td>';
                                }else if($key==4){
                                    echo '<td rowspan="3">'.$vo['name'].'</td>';
                                }else if($key==5){
                                    echo '<td rowspan="2">'.$vo['name'].'</td>';
                                }else{
                                    echo '<td rowspan="1">'.$vo['name'].'</td>';
                                }
                                foreach($vo['children'] as $k=>$v){
                                    $id = $v['fault_id'];
                                    $name = $v['name'];
                                    if($k>0){
                                        echo '</tr><tr><td>'.$v['name'].'</td>';
                                        if(in_array($id,$fault_id_arr)){
                                            echo '<td><input type="checkbox" name="checkbox" checked value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }else{
                                            echo '<td><input type="checkbox" name="checkbox" value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }
                                    }else{
                                        echo '<td>'.$v['name'].'</td>';
                                        if(in_array($id,$fault_id_arr)){
                                            echo '<td><input type="checkbox" name="checkbox" checked value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }else{
                                            echo '<td><input type="checkbox" name="checkbox" value='.$id.' vname='.$name.' pvalue='.$vo["fault_id"].'></td>';
                                        }
                                    }
                                }
                                echo "</tr>";
                            }
                        }
                    ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</form>