<link href="/css/tabs.css" rel="stylesheet" type="text/css">
<script type="text/javascript" language="javascript" src="/js/artDialog/artDialog.js?skin=default"></script>
<script type="text/javascript" language="javascript" src="/js/artDialog/plugins/iframeTools.source.js"></script>
<style>
    #img-area li, #img-area img {
        width: 200px;
        height: 100px;
    }

    #img-area li {
        list-style: none;
        float: left;
        padding: 2px;
        position: relative;
    }

    #img-area li i {
        cursor: pointer;
        position: absolute;
        right: 20px;
    }

    .active-border {
        border: 1px solid #333333;
    }

    .add-title > h3 {
        float: left;
        cursor: pointer;
    }

    #dialog {
        position: fixed;
        left: 33%;
        top: 28%;
        background: #FFFFFF;
        border: 1px solid #333333;
        padding: 10px;
        width: 500px;
        z-index: 1000;
    }

    .mask-layer {
        position: absolute;
        top: 0px;
        filter: alpha(opacity=60);
        background-color: #777;
        z-index: 10;
        left: 0px;
        opacity: 0.5;
        -moz-opacity: 0.5;
        width: 100%;
        height: 3000px;
    }
</style>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
    <tr>
        <td colspan="13" height="22" class="td_bg">
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                <TBODY>
                <TR>
                    <TD height="30" align="center" class=tab-on id=navcell onclick=switchCell(1) name="navcell">
                        钣金
                    </TD>
                    <TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(2) name="navcell">
                        底子工
                    </TD>
                    <TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(3) name="navcell">
                        喷漆工
                    </TD>
                    <TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(4) name="navcell">
                        钣金安装
                    </TD>
                    <TD height="30" align="center" class=tab-off id=navcell onclick=switchCell(5) name="navcell">
                        抛光
                    </TD>
                    <TD height="30" class=tab-none>&nbsp;</TD>
                </TR>
                </TBODY>
            </TABLE>
        </td>
    </tr>
    <tr>
        <td height="22" colspan="2" class="td_bg">
            <table width="100%" align="center" height="120" border="0" cellpadding="0" cellspacing="0" id="mainTable">
                <tr>
                    <td height="120" valign="top" class="td_bg">
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb">
                            <TR>
                                <TD valign="top">
                                    <form id="theFrm">
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                               class="table">
                                            <input type="hidden" id="id" name="id" value="<?= $info->id ?>">
                                            <input type="hidden" name="car_id" value="<?= $info->car_id ?>">
                                            <tr>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 车牌号
                                                </td>
                                                <td height="25" class="td_bg" nowrap>
                                                    <input name="car_no" type="text" id="car_no"
                                                           value="<?= $info->car_no ?>" style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">发动机号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="engine_no" type="text" id="engine_no"
                                                           value="<?= $info->engine_no ?>"
                                                           style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">车架号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="car_frame_no" type="text" id="car_frame_no"
                                                           value="<?= $info->car_frame_no ?>"
                                                           style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 新车购置价
                                                </td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" name="new_price" value="<?= $info->new_price ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 品牌
                                                </td>
                                                <td height="25" class="td_bg">
                                                    <select id="brand_id" name="brand_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($brand_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->brand_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">车系</td>
                                                <td height="25" class="td_bg">
                                                    <select name="series_id" id="series_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($series_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->series_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">排量</td>
                                                <td height="25" class="td_bg">
                                                    <select name="displacement_id" id="displacement_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($displacement_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->displacement_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">年份</td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" name="car_year" value="<?= $info->car_year ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">预计出厂时间</td>
                                                <td height="25" class="td_bg" colspan="7">
                                                    <input name="finish_date" type="text" id="finish_date"
                                                           value="<?= $info->finish_date ?>"
                                                           style="width:100px;" readonly onClick="WdatePicker()"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">备注</td>
                                                <td colspan="7" height="25" class="td_bg" align="left">
                                                    <textarea name="remark" id="remark"
                                                              style="width: 600px;"><?= $info->remark ?></textarea>
                                                </td>
                                            </tr>
                                        </table>
                                        <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                               class="table"
                                               style="table-layout: fixed;">
                                            <tr>
                                                <td class="td_bg">
                                                    <input type="file" id="fileUploadBtn" value="上传图片"><span
                                                            style="color:#ff0000">1M/每张 | 最多上传6张</span>
                                                    <!--                <input type="button" id="fileDownBtn" value="下载图片" onclick="downloadImg()"><span style="color:#ff0000">请先选择需要下载的图片</span>-->
                                                </td>
                                            </tr>

                                            <tr id="showImg" style="display: <?= $info->fixCarImg ? 'block' : 'none' ?>"
                                                class="td_bg">
                                                <td class="td_bg">
                                                    <textarea name="result" id="result" cols="30" rows="10"
                                                              style="display:none"></textarea>
                                                    <ul id="img-area">
                                                        <?php if ($fixCarImg = \common\models\FixCarImg::find()->where('fix_id=' . $info->id . ' AND type=6')->all()): ?>
                                                            <?php foreach ($fixCarImg as $img): ?>
                                                                <li>
                                                                    <i data-fix-img="<?= $img->id ?>"
                                                                       onclick="rmImg(event,$(this))">删除</i>
                                                                    <img src="\<?= $img->name ?>" alt="">
                                                                </li>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                    </ul>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="22" align="center" class="td_bg">
                                                    <textarea name="result" id="result" cols="30" rows="10"
                                                              style="display: none"></textarea>
                                                    <input type="button" class="ACT_btn js-insert-btn" value="提交">
                                                    <input type="button" class="ACT_btn js-update-btn" value="保存">
                                                    <input id="back-btn" type="button" class="ACT_btn" value="返回">
                                                </td>
                                            </tr>
                                        </table>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list3')">保险理赔<span id="list3_title">▼</span></h3>
                                            <h3 onclick="dialogBox('保险理赔',1,<?= $info->id ?>)">清单添加</h3>
                                        </div>
                                        <div id="list3">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list4')">自费维修<span id="list4_title">▼</span></h3>
                                            <h3 onclick="dialogBox('自费维修',2,<?= $info->id ?>)">清单添加</h3>
                                        </div>
                                        <div id="list4">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list5')">汽车保养<span id="list5_title">▼</span></h3>
                                        </div>
                                        <div id="list5">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list6')">汽车美容<span id="list6_title">▼</span></h3>
                                        </div>
                                        <div id="list6">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;">
                                            <h3 onclick="show('list7')">操作记录<span id="list7_title">▲</span></h3>
                                        </div>
                                        <div id="list7" style="display: none;">
                                            <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                                   class="table">
                                                <tr>
                                                    <td width="120" align="center" class="bg_tr" nowrap>姓名</td>
                                                    <td width="200" align="center" class="bg_tr" nowrap>操作时间</td>
                                                    <td width="50%" align="center" class="bg_tr" nowrap>意见</td>
                                                    <td width="30%" align="center" class="bg_tr" nowrap>意见说明</td>
                                                </tr>
                                                <?php
                                                foreach ($log_items as $item) {
                                                    ?>
                                                    <tr>
                                                        <td align="center" class="td_bg"
                                                            nowrap><?= $item->op_man ?></td>
                                                        <td class="td_bg"
                                                            style="word-break: break-all"><?= date('Y-m-d H:i:s', $item->op_time) ?></td>
                                                        <td class="td_bg" nowrap><?= $item->info ?></td>
                                                        <td class="td_bg"
                                                            style="word-break: break-all"><?= $item->remark ?></td>
                                                    </tr>
                                                    <?php
                                                }
                                                ?>
                                            </table>
                                        </div>
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                               class="table">
                                            <tr>
                                                <td colspan="8" height="22" colspan="2" align="center" class="td_bg">
                                                    <input id="back-btn" type="button" class="ACT_btn" name="Submit2"
                                                           value=" 返回 ">
                                                </td>
                                            </tr>
                                        </table>
                                    </form>
                                </TD>
                            </TR>
                        </TABLE>
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
                            <TR>
                                <TD valign="top">
                                    <form id="theFrm">
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                               class="table">
                                            <input type="hidden" id="id" name="id" value="<?= $info->id ?>">
                                            <input type="hidden" name="car_id" value="<?= $info->car_id ?>">
                                            <tr>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 车牌号
                                                </td>
                                                <td height="25" class="td_bg" nowrap>
                                                    <input name="car_no" type="text" id="car_no"
                                                           value="<?= $info->car_no ?>" style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">发动机号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="engine_no" type="text" id="engine_no"
                                                           value="<?= $info->engine_no ?>"
                                                           style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">车架号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="car_frame_no" type="text" id="car_frame_no"
                                                           value="<?= $info->car_frame_no ?>"
                                                           style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 新车购置价
                                                </td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" name="new_price" value="<?= $info->new_price ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 品牌
                                                </td>
                                                <td height="25" class="td_bg">
                                                    <select id="brand_id" name="brand_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($brand_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->brand_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">车系</td>
                                                <td height="25" class="td_bg">
                                                    <select name="series_id" id="series_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($series_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->series_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">排量</td>
                                                <td height="25" class="td_bg">
                                                    <select name="displacement_id" id="displacement_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($displacement_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->displacement_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">年份</td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" name="car_year" value="<?= $info->car_year ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">预计出厂时间</td>
                                                <td height="25" class="td_bg" colspan="7">
                                                    <input name="finish_date" type="text" id="finish_date"
                                                           value="<?= $info->finish_date ?>"
                                                           style="width:100px;" readonly onClick="WdatePicker()"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">备注</td>
                                                <td colspan="7" height="25" class="td_bg" align="left">
                                                    <textarea name="remark" id="remark"
                                                              style="width: 600px;"><?= $info->remark ?></textarea>
                                                </td>
                                            </tr>
                                        </table>
                                        <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                               class="table"
                                               style="table-layout: fixed;">
                                            <tr>
                                                <td class="td_bg">
                                                    <input type="file" id="fileUploadBtn" value="上传图片"><span
                                                            style="color:#ff0000">1M/每张 | 最多上传6张</span>
                                                    <!--                <input type="button" id="fileDownBtn" value="下载图片" onclick="downloadImg()"><span style="color:#ff0000">请先选择需要下载的图片</span>-->
                                                </td>
                                            </tr>

                                            <tr id="showImg" style="display: <?= $info->fixCarImg ? 'block' : 'none' ?>"
                                                class="td_bg">
                                                <td class="td_bg">
                                                    <textarea name="result" id="result" cols="30" rows="10"
                                                              style="display:none"></textarea>
                                                    <ul id="img-area">
                                                        <?php if ($fixCarImg = \common\models\FixCarImg::find()->where('fix_id=' . $info->id . ' AND type=6')->all()): ?>
                                                            <?php foreach ($fixCarImg as $img): ?>
                                                                <li>
                                                                    <i data-fix-img="<?= $img->id ?>"
                                                                       onclick="rmImg(event,$(this))">删除</i>
                                                                    <img src="\<?= $img->name ?>" alt="">
                                                                </li>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                    </ul>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="22" align="center" class="td_bg">
                                                    <textarea name="result" id="result" cols="30" rows="10"
                                                              style="display: none"></textarea>
                                                    <input type="button" class="ACT_btn js-insert-btn" value="提交">
                                                    <input type="button" class="ACT_btn js-update-btn" value="保存">
                                                    <input id="back-btn" type="button" class="ACT_btn" value="返回">
                                                </td>
                                            </tr>
                                        </table>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list3')">保险理赔<span id="list3_title">▼</span></h3>
                                            <h3 onclick="dialogBox('保险理赔',1,<?= $info->id ?>)">清单添加</h3>
                                        </div>
                                        <div id="list3">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list4')">自费维修<span id="list4_title">▼</span></h3>
                                            <h3 onclick="dialogBox('自费维修',2,<?= $info->id ?>)">清单添加</h3>
                                        </div>
                                        <div id="list4">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list5')">汽车保养<span id="list5_title">▼</span></h3>
                                        </div>
                                        <div id="list5">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list6')">汽车美容<span id="list6_title">▼</span></h3>
                                        </div>
                                        <div id="list6">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;">
                                            <h3 onclick="show('list7')">操作记录<span id="list7_title">▲</span></h3>
                                        </div>
                                        <div id="list7" style="display: none;">
                                            <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                                   class="table">
                                                <tr>
                                                    <td width="120" align="center" class="bg_tr" nowrap>姓名</td>
                                                    <td width="200" align="center" class="bg_tr" nowrap>操作时间</td>
                                                    <td width="50%" align="center" class="bg_tr" nowrap>意见</td>
                                                    <td width="30%" align="center" class="bg_tr" nowrap>意见说明</td>
                                                </tr>
                                                <?php
                                                foreach ($log_items as $item) {
                                                    ?>
                                                    <tr>
                                                        <td align="center" class="td_bg"
                                                            nowrap><?= $item->op_man ?></td>
                                                        <td class="td_bg"
                                                            style="word-break: break-all"><?= date('Y-m-d H:i:s', $item->op_time) ?></td>
                                                        <td class="td_bg" nowrap><?= $item->info ?></td>
                                                        <td class="td_bg"
                                                            style="word-break: break-all"><?= $item->remark ?></td>
                                                    </tr>
                                                    <?php
                                                }
                                                ?>
                                            </table>
                                        </div>
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                               class="table">
                                            <tr>
                                                <td colspan="8" height="22" colspan="2" align="center" class="td_bg">
                                                    <input id="back-btn" type="button" class="ACT_btn" name="Submit2"
                                                           value=" 返回 ">
                                                </td>
                                            </tr>
                                        </table>
                                    </form>
                                </TD>
                            </TR>
                        </TABLE>
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
                            <TR>
                                <TD valign="top">
                                    <form id="theFrm">
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                               class="table">
                                            <input type="hidden" id="id" name="id" value="<?= $info->id ?>">
                                            <input type="hidden" name="car_id" value="<?= $info->car_id ?>">
                                            <tr>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 车牌号
                                                </td>
                                                <td height="25" class="td_bg" nowrap>
                                                    <input name="car_no" type="text" id="car_no"
                                                           value="<?= $info->car_no ?>" style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">发动机号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="engine_no" type="text" id="engine_no"
                                                           value="<?= $info->engine_no ?>"
                                                           style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">车架号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="car_frame_no" type="text" id="car_frame_no"
                                                           value="<?= $info->car_frame_no ?>"
                                                           style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 新车购置价
                                                </td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" name="new_price" value="<?= $info->new_price ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 品牌
                                                </td>
                                                <td height="25" class="td_bg">
                                                    <select id="brand_id" name="brand_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($brand_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->brand_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">车系</td>
                                                <td height="25" class="td_bg">
                                                    <select name="series_id" id="series_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($series_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->series_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">排量</td>
                                                <td height="25" class="td_bg">
                                                    <select name="displacement_id" id="displacement_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($displacement_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->displacement_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">年份</td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" name="car_year" value="<?= $info->car_year ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">预计出厂时间</td>
                                                <td height="25" class="td_bg" colspan="7">
                                                    <input name="finish_date" type="text" id="finish_date"
                                                           value="<?= $info->finish_date ?>"
                                                           style="width:100px;" readonly onClick="WdatePicker()"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">备注</td>
                                                <td colspan="7" height="25" class="td_bg" align="left">
                                                    <textarea name="remark" id="remark"
                                                              style="width: 600px;"><?= $info->remark ?></textarea>
                                                </td>
                                            </tr>
                                        </table>
                                        <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                               class="table"
                                               style="table-layout: fixed;">
                                            <tr>
                                                <td class="td_bg">
                                                    <input type="file" id="fileUploadBtn" value="上传图片"><span
                                                            style="color:#ff0000">1M/每张 | 最多上传6张</span>
                                                    <!--                <input type="button" id="fileDownBtn" value="下载图片" onclick="downloadImg()"><span style="color:#ff0000">请先选择需要下载的图片</span>-->
                                                </td>
                                            </tr>

                                            <tr id="showImg" style="display: <?= $info->fixCarImg ? 'block' : 'none' ?>"
                                                class="td_bg">
                                                <td class="td_bg">
                                                    <textarea name="result" id="result" cols="30" rows="10"
                                                              style="display:none"></textarea>
                                                    <ul id="img-area">
                                                        <?php if ($fixCarImg = \common\models\FixCarImg::find()->where('fix_id=' . $info->id . ' AND type=6')->all()): ?>
                                                            <?php foreach ($fixCarImg as $img): ?>
                                                                <li>
                                                                    <i data-fix-img="<?= $img->id ?>"
                                                                       onclick="rmImg(event,$(this))">删除</i>
                                                                    <img src="\<?= $img->name ?>" alt="">
                                                                </li>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                    </ul>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="22" align="center" class="td_bg">
                                                    <textarea name="result" id="result" cols="30" rows="10"
                                                              style="display: none"></textarea>
                                                    <input type="button" class="ACT_btn js-insert-btn" value="提交">
                                                    <input type="button" class="ACT_btn js-update-btn" value="保存">
                                                    <input id="back-btn" type="button" class="ACT_btn" value="返回">
                                                </td>
                                            </tr>
                                        </table>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list3')">保险理赔<span id="list3_title">▼</span></h3>
                                            <h3 onclick="dialogBox('保险理赔',1,<?= $info->id ?>)">清单添加</h3>
                                        </div>
                                        <div id="list3">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list4')">自费维修<span id="list4_title">▼</span></h3>
                                            <h3 onclick="dialogBox('自费维修',2,<?= $info->id ?>)">清单添加</h3>
                                        </div>
                                        <div id="list4">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list5')">汽车保养<span id="list5_title">▼</span></h3>
                                        </div>
                                        <div id="list5">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list6')">汽车美容<span id="list6_title">▼</span></h3>
                                        </div>
                                        <div id="list6">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;">
                                            <h3 onclick="show('list7')">操作记录<span id="list7_title">▲</span></h3>
                                        </div>
                                        <div id="list7" style="display: none;">
                                            <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                                   class="table">
                                                <tr>
                                                    <td width="120" align="center" class="bg_tr" nowrap>姓名</td>
                                                    <td width="200" align="center" class="bg_tr" nowrap>操作时间</td>
                                                    <td width="50%" align="center" class="bg_tr" nowrap>意见</td>
                                                    <td width="30%" align="center" class="bg_tr" nowrap>意见说明</td>
                                                </tr>
                                                <?php
                                                foreach ($log_items as $item) {
                                                    ?>
                                                    <tr>
                                                        <td align="center" class="td_bg"
                                                            nowrap><?= $item->op_man ?></td>
                                                        <td class="td_bg"
                                                            style="word-break: break-all"><?= date('Y-m-d H:i:s', $item->op_time) ?></td>
                                                        <td class="td_bg" nowrap><?= $item->info ?></td>
                                                        <td class="td_bg"
                                                            style="word-break: break-all"><?= $item->remark ?></td>
                                                    </tr>
                                                    <?php
                                                }
                                                ?>
                                            </table>
                                        </div>
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                               class="table">
                                            <tr>
                                                <td colspan="8" height="22" colspan="2" align="center" class="td_bg">
                                                    <input id="back-btn" type="button" class="ACT_btn" name="Submit2"
                                                           value=" 返回 ">
                                                </td>
                                            </tr>
                                        </table>
                                    </form>
                                </TD>
                            </TR>
                        </TABLE>
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
                            <TR>
                                <TD valign="top">
                                    <form id="theFrm">
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                               class="table">
                                            <input type="hidden" id="id" name="id" value="<?= $info->id ?>">
                                            <input type="hidden" name="car_id" value="<?= $info->car_id ?>">
                                            <tr>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 车牌号
                                                </td>
                                                <td height="25" class="td_bg" nowrap>
                                                    <input name="car_no" type="text" id="car_no"
                                                           value="<?= $info->car_no ?>" style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">发动机号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="engine_no" type="text" id="engine_no"
                                                           value="<?= $info->engine_no ?>"
                                                           style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">车架号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="car_frame_no" type="text" id="car_frame_no"
                                                           value="<?= $info->car_frame_no ?>"
                                                           style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 新车购置价
                                                </td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" name="new_price" value="<?= $info->new_price ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 品牌
                                                </td>
                                                <td height="25" class="td_bg">
                                                    <select id="brand_id" name="brand_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($brand_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->brand_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">车系</td>
                                                <td height="25" class="td_bg">
                                                    <select name="series_id" id="series_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($series_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->series_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">排量</td>
                                                <td height="25" class="td_bg">
                                                    <select name="displacement_id" id="displacement_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($displacement_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->displacement_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">年份</td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" name="car_year" value="<?= $info->car_year ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">预计出厂时间</td>
                                                <td height="25" class="td_bg" colspan="7">
                                                    <input name="finish_date" type="text" id="finish_date"
                                                           value="<?= $info->finish_date ?>"
                                                           style="width:100px;" readonly onClick="WdatePicker()"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">备注</td>
                                                <td colspan="7" height="25" class="td_bg" align="left">
                                                    <textarea name="remark" id="remark"
                                                              style="width: 600px;"><?= $info->remark ?></textarea>
                                                </td>
                                            </tr>
                                        </table>
                                        <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                               class="table"
                                               style="table-layout: fixed;">
                                            <tr>
                                                <td class="td_bg">
                                                    <input type="file" id="fileUploadBtn" value="上传图片"><span
                                                            style="color:#ff0000">1M/每张 | 最多上传6张</span>
                                                    <!--                <input type="button" id="fileDownBtn" value="下载图片" onclick="downloadImg()"><span style="color:#ff0000">请先选择需要下载的图片</span>-->
                                                </td>
                                            </tr>

                                            <tr id="showImg" style="display: <?= $info->fixCarImg ? 'block' : 'none' ?>"
                                                class="td_bg">
                                                <td class="td_bg">
                                                    <textarea name="result" id="result" cols="30" rows="10"
                                                              style="display:none"></textarea>
                                                    <ul id="img-area">
                                                        <?php if ($fixCarImg = \common\models\FixCarImg::find()->where('fix_id=' . $info->id . ' AND type=6')->all()): ?>
                                                            <?php foreach ($fixCarImg as $img): ?>
                                                                <li>
                                                                    <i data-fix-img="<?= $img->id ?>"
                                                                       onclick="rmImg(event,$(this))">删除</i>
                                                                    <img src="\<?= $img->name ?>" alt="">
                                                                </li>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                    </ul>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="22" align="center" class="td_bg">
                                                    <textarea name="result" id="result" cols="30" rows="10"
                                                              style="display: none"></textarea>
                                                    <input type="button" class="ACT_btn js-insert-btn" value="提交">
                                                    <input type="button" class="ACT_btn js-update-btn" value="保存">
                                                    <input id="back-btn" type="button" class="ACT_btn" value="返回">
                                                </td>
                                            </tr>
                                        </table>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list3')">保险理赔<span id="list3_title">▼</span></h3>
                                            <h3 onclick="dialogBox('保险理赔',1,<?= $info->id ?>)">清单添加</h3>
                                        </div>
                                        <div id="list3">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list4')">自费维修<span id="list4_title">▼</span></h3>
                                            <h3 onclick="dialogBox('自费维修',2,<?= $info->id ?>)">清单添加</h3>
                                        </div>
                                        <div id="list4">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list5')">汽车保养<span id="list5_title">▼</span></h3>
                                        </div>
                                        <div id="list5">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list6')">汽车美容<span id="list6_title">▼</span></h3>
                                        </div>
                                        <div id="list6">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;">
                                            <h3 onclick="show('list7')">操作记录<span id="list7_title">▲</span></h3>
                                        </div>
                                        <div id="list7" style="display: none;">
                                            <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                                   class="table">
                                                <tr>
                                                    <td width="120" align="center" class="bg_tr" nowrap>姓名</td>
                                                    <td width="200" align="center" class="bg_tr" nowrap>操作时间</td>
                                                    <td width="50%" align="center" class="bg_tr" nowrap>意见</td>
                                                    <td width="30%" align="center" class="bg_tr" nowrap>意见说明</td>
                                                </tr>
                                                <?php
                                                foreach ($log_items as $item) {
                                                    ?>
                                                    <tr>
                                                        <td align="center" class="td_bg"
                                                            nowrap><?= $item->op_man ?></td>
                                                        <td class="td_bg"
                                                            style="word-break: break-all"><?= date('Y-m-d H:i:s', $item->op_time) ?></td>
                                                        <td class="td_bg" nowrap><?= $item->info ?></td>
                                                        <td class="td_bg"
                                                            style="word-break: break-all"><?= $item->remark ?></td>
                                                    </tr>
                                                    <?php
                                                }
                                                ?>
                                            </table>
                                        </div>
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                               class="table">
                                            <tr>
                                                <td colspan="8" height="22" colspan="2" align="center" class="td_bg">
                                                    <input id="back-btn" type="button" class="ACT_btn" name="Submit2"
                                                           value=" 返回 ">
                                                </td>
                                            </tr>
                                        </table>
                                    </form>
                                </TD>
                            </TR>
                        </TABLE>
                        <TABLE id=tb cellSpacing=1 cellPadding=0 width="100%" border=0 name="tb" class="hide-table">
                            <TR>
                                <TD valign="top">
                                    <form id="theFrm">
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                               class="table">
                                            <input type="hidden" id="id" name="id" value="<?= $info->id ?>">
                                            <input type="hidden" name="car_id" value="<?= $info->car_id ?>">
                                            <tr>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 车牌号
                                                </td>
                                                <td height="25" class="td_bg" nowrap>
                                                    <input name="car_no" type="text" id="car_no"
                                                           value="<?= $info->car_no ?>" style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">发动机号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="engine_no" type="text" id="engine_no"
                                                           value="<?= $info->engine_no ?>"
                                                           style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">车架号</td>
                                                <td height="25" class="td_bg">
                                                    <input name="car_frame_no" type="text" id="car_frame_no"
                                                           value="<?= $info->car_frame_no ?>"
                                                           style="width:100px;"/>
                                                </td>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 新车购置价
                                                </td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" name="new_price" value="<?= $info->new_price ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr"><span
                                                            style="color:#ff0000">*</span> 品牌
                                                </td>
                                                <td height="25" class="td_bg">
                                                    <select id="brand_id" name="brand_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($brand_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->brand_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">车系</td>
                                                <td height="25" class="td_bg">
                                                    <select name="series_id" id="series_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($series_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->series_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">排量</td>
                                                <td height="25" class="td_bg">
                                                    <select name="displacement_id" id="displacement_id">
                                                        <option value="0">---请选择---</option>
                                                        <?php
                                                        foreach ($displacement_items as $item) {
                                                            echo '<option value="' . $item->id . '"';
                                                            if ($info->displacement_id == $item->id)
                                                                echo ' selected ';
                                                            echo '>' . $item->name . '</option>';
                                                        }
                                                        ?>
                                                    </select>
                                                </td>
                                                <td width="100" height="25" class="bg_tr">年份</td>
                                                <td height="25" class="td_bg">
                                                    <input type="text" name="car_year" value="<?= $info->car_year ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">预计出厂时间</td>
                                                <td height="25" class="td_bg" colspan="7">
                                                    <input name="finish_date" type="text" id="finish_date"
                                                           value="<?= $info->finish_date ?>"
                                                           style="width:100px;" readonly onClick="WdatePicker()"/>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td width="100" height="25" class="bg_tr">备注</td>
                                                <td colspan="7" height="25" class="td_bg" align="left">
                                                    <textarea name="remark" id="remark"
                                                              style="width: 600px;"><?= $info->remark ?></textarea>
                                                </td>
                                            </tr>
                                        </table>
                                        <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                               class="table"
                                               style="table-layout: fixed;">
                                            <tr>
                                                <td class="td_bg">
                                                    <input type="file" id="fileUploadBtn" value="上传图片"><span
                                                            style="color:#ff0000">1M/每张 | 最多上传6张</span>
                                                    <!--                <input type="button" id="fileDownBtn" value="下载图片" onclick="downloadImg()"><span style="color:#ff0000">请先选择需要下载的图片</span>-->
                                                </td>
                                            </tr>

                                            <tr id="showImg" style="display: <?= $info->fixCarImg ? 'block' : 'none' ?>"
                                                class="td_bg">
                                                <td class="td_bg">
                                                    <textarea name="result" id="result" cols="30" rows="10"
                                                              style="display:none"></textarea>
                                                    <ul id="img-area">
                                                        <?php if ($fixCarImg = \common\models\FixCarImg::find()->where('fix_id=' . $info->id . ' AND type=6')->all()): ?>
                                                            <?php foreach ($fixCarImg as $img): ?>
                                                                <li>
                                                                    <i data-fix-img="<?= $img->id ?>"
                                                                       onclick="rmImg(event,$(this))">删除</i>
                                                                    <img src="\<?= $img->name ?>" alt="">
                                                                </li>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                    </ul>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="22" align="center" class="td_bg">
                                                    <textarea name="result" id="result" cols="30" rows="10"
                                                              style="display: none"></textarea>
                                                    <input type="button" class="ACT_btn js-insert-btn" value="提交">
                                                    <input type="button" class="ACT_btn js-update-btn" value="保存">
                                                    <input id="back-btn" type="button" class="ACT_btn" value="返回">
                                                </td>
                                            </tr>
                                        </table>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list3')">保险理赔<span id="list3_title">▼</span></h3>
                                            <h3 onclick="dialogBox('保险理赔',1,<?= $info->id ?>)">清单添加</h3>
                                        </div>
                                        <div id="list3">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list4')">自费维修<span id="list4_title">▼</span></h3>
                                            <h3 onclick="dialogBox('自费维修',2,<?= $info->id ?>)">清单添加</h3>
                                        </div>
                                        <div id="list4">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list5')">汽车保养<span id="list5_title">▼</span></h3>
                                        </div>
                                        <div id="list5">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;" class="add-title">
                                            <h3 onclick="show('list6')">汽车美容<span id="list6_title">▼</span></h3>
                                        </div>
                                        <div id="list6">
                                        </div>
                                        <div style="clear: both"></div>
                                        <div style="width:98%; margin: 0 auto;">
                                            <h3 onclick="show('list7')">操作记录<span id="list7_title">▲</span></h3>
                                        </div>
                                        <div id="list7" style="display: none;">
                                            <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1"
                                                   class="table">
                                                <tr>
                                                    <td width="120" align="center" class="bg_tr" nowrap>姓名</td>
                                                    <td width="200" align="center" class="bg_tr" nowrap>操作时间</td>
                                                    <td width="50%" align="center" class="bg_tr" nowrap>意见</td>
                                                    <td width="30%" align="center" class="bg_tr" nowrap>意见说明</td>
                                                </tr>
                                                <?php
                                                foreach ($log_items as $item) {
                                                    ?>
                                                    <tr>
                                                        <td align="center" class="td_bg"
                                                            nowrap><?= $item->op_man ?></td>
                                                        <td class="td_bg"
                                                            style="word-break: break-all"><?= date('Y-m-d H:i:s', $item->op_time) ?></td>
                                                        <td class="td_bg" nowrap><?= $item->info ?></td>
                                                        <td class="td_bg"
                                                            style="word-break: break-all"><?= $item->remark ?></td>
                                                    </tr>
                                                    <?php
                                                }
                                                ?>
                                            </table>
                                        </div>
                                        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1"
                                               class="table">
                                            <tr>
                                                <td colspan="8" height="22" colspan="2" align="center" class="td_bg">
                                                    <input id="back-btn" type="button" class="ACT_btn" name="Submit2"
                                                           value=" 返回 ">
                                                </td>
                                            </tr>
                                        </table>
                                    </form>
                                </TD>
                            </TR>
                        </TABLE>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<!--对话框begin-->
<div id="dialog" style="display: none">
</div>
<!--end-->
<!--遮罩层 begin-->
<div class="mask-layer" style="display: none">
</div>
<!--end-->
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script>
<script type="text/javascript" language="javascript" src="/js/datepicker/WdatePicker.js"></script>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script>
<script type="text/javascript" language="javascript" src="/js/func.js"></script>
<script type="text/javascript" language="javascript">
    function reloadItems() {
        var id = $('#id').val();
        if (id > 0) {
            gotoPage('/fix-car/ajax-item-list?fix_id=' + id + '&pay_type=1', 'list3');
            gotoPage('/fix-car/ajax-item-list?fix_id=' + id + '&pay_type=2', 'list4');
            gotoPage('/fix-car/ajax-item-list?fix_id=' + id + '&small_type_id=5', 'list5');
            gotoPage('/fix-car/ajax-item-list?fix_id=' + id + '&small_type_id=6', 'list6');
        }
    }

    function show(id_str) {
        var obj = $('#' + id_str);
        var obj_title = $('#' + id_str + '_title');
        obj.toggle();
        if (obj_title.html() == '▼')
            obj_title.html('▲');
        else
            obj_title.html('▼');
    }

    //退回处理
    $('#return-btn').click(function () {
        var r = prompt('退回原因', '');
        if (r != null && r != '') {
            $.post('/fix-car/return-op', {
                id:<?=$info->id > 0 ? $info->id : 0?>,
                return_remark: r,
                return_status_id:<?=$info->status?>
            }, function (obj) {
                alert(obj.msg);
                if (obj.success) {
                    $('#back-btn').click();
                }
            }, 'json');
        } else {
            alert('不填写原因,无法退回');
        }
    });
    //保存按钮
    $(".js-update-btn").click(function () {
        if (confirm('是否确认提交?')) {
            if (fileCollect.length > 0) {
                $('#result').val(fileCollect);
            }
            var params = $("#theFrm").serialize();
            params += '&status=<?=$info->status?>';

            $.post('/business-order/fix-car-save', params, function (obj) {
                alert(obj.msg);
                if (obj.success) {
                    $('#id').val(obj.fix_id);
                    toDoClearBase64();
                    window.location.reload();
                }
            }, 'json');
        }
    });

    //提交按钮
    $(".js-insert-btn").click(function () {
        var id = $('#id').val();
        var sys_remark = $('#sys_remark').val();
        if (sys_remark == '') {
            alert('请先输入审核意见');
            return;
        }
        if (id > 0) {
            if (confirm('是否确认提交?')) {
                if (fileCollect.length > 0) {
                    $('#result').val(fileCollect);
                }
                var params = $("#theFrm").serialize();
                params = params + '&status=<?=$info->status + 1?>' + '&sys_remark=' + sys_remark;
                $.post('/business-order/fix-car-save', params, function (obj) {
                    alert(obj.msg);
                    if (obj.success) {
                        $('#id').val(obj.fix_id);
                        toDoClearBase64();
                        $('#back-btn').click();
                    }
                }, 'json');
            }
        } else {
            alert('请先保存维修信息');
        }
    });

    //返回按钮
    $('#back-btn').click(function () {
        window.location.href="/business-order/metal-plate-list";
    });
    //打印接车单
    $('#print-btn').click(function () {
        window.open('/fix-car/print-receive?id=<?=$info->id?>');
    });
    //刷新明细
    reloadItems();

    $('#brand_id').change(function () {
        var brand_id = $(this).val();
        $('#series_id').html('<option value="0">---请选择---</option>');
        $('#displacement_id').html('<option value="0">---请选择---</option>');
        if (brand_id > 0) {
            $.get('/car/series', {brand_id: brand_id}, function (obj) {
                if (obj.success) {
                    $('#series_id').html(obj.html);
                }
            }, 'json');
        }
    });
    $('#series_id').change(function () {
        var series_id = $(this).val();
        $('#displacement_id').html('<option value="0">---请选择---</option>');
        if (series_id > 0) {
            $.get('/car/displacement', {series_id: series_id}, function (obj) {
                if (obj.success) {
                    $('#displacement_id').html(obj.html);
                }
            }, 'json');
        }
    });
    //图片点击加边框
    $('#img-area > li').on('click', function () {
        $(this).addClass('active-border');
        $(this).siblings().removeClass('active-border');
    });
    //base64图片上传
    var result = img_area = null,
        input = document.getElementById("fileUploadBtn"),
        result = document.getElementById("result"),
        img_area = document.getElementById("img-area");
    if (typeof(FileReader) === 'undefined') {
        alert("抱歉，你的浏览器不支持 FileReader，请使用现代浏览器操作！");
        input.setAttribute('disabled', 'disabled');
    } else {
        input.addEventListener('change', readFile, false);
    }

    var fileCollect = []; //图片上传base64集合

    function readFile() {
        var liLen = img_area.getElementsByTagName('li').length;
        if (liLen >= 6) {
            alert("最多上传6张图片");
            return false;
        }

        var file = this.files[0];
        //这里我们判断下类型如果不是图片就返回 去掉就可以上传任意文件
        if (!/image\/\w+/.test(file.type)) {
            alert("请确保文件为图像类型");
            return false;
        }
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function (e) {
            fileCollect.push(this.result+'^#@#$');
            img_area.innerHTML += '<li><i onclick="rmImg(event,$(this))">删除</i><img src="' + this.result + '" alt=""/></li>';
            $('#showImg').show();
        }
    }


    //图片删除
    function rmImg(event, obj) {
        event.stopPropagation();
        var id = obj.data('fix-img');
        if (id > 0) {
            $.post('/fix-car/rm-img', 'id=' + id, function (msg) {
                if (msg.success) {
                    obj.parent().remove();
                }
            }, 'json');
        } else {
            var index = obj.next().attr('src')+'^#@#$';
            fileCollect.splice($.inArray(index,fileCollect), 1);
            obj.parent().remove();
        }
    }

    //下载图片
    function downloadImg() {
        var isChoice = false,
            id = 0;

        $('#img-area > li ').each(function (i) {
            if ($(this).hasClass('active-border')) {
                isChoice = true;
                id = $(this).find('i').data('fix-img')
            }
        })
        if (!isChoice) {
            alert('请先选择要下载的图片!');
            return false;
        }

        if (id == 0) {
            alert('下载失败！');
            return false;
        }
        window.location.href = "/fix-car/download-img?id=" + id;
    }

    //弹框
    function dialogBox(title, type, fix_id) {
        var dialog = '<form id="dialog-from"><table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">' +
            '<input type="hidden" name="fix_id" value="' + fix_id + '">' +
            '<input type="hidden" name="list_type" value="' + type + '">' +
            '<input type="hidden" name="big_type_id" value="' + type + '">' +
            '<tr><th colspan="4" id="dialog-title">' + title + '</th></tr>' +
            '<tr class="bg_tr"><td colspan="4"><select name="small_type_id">';
        if (1 == type || 2 == type) {
            dialog += '<option value="1">更换清单</option>' +
                '<option value="2">维修清单</option>' +
                '<option value="3">辅料清单</option>' +
                '<option value="4">待定清单</option>' +
                '<option value="5">汽车保养</option>' +
                '<option value="6">美容装饰</option>';
        } else if (3 == type || 4 == type) {
            dialog += '<option value="1">更换清单</option>' +
                '<option value="2">维修清单</option>' +
                '<option value="3">辅料清单</option>' +
                '<option value="4">待定清单</option>';
        }

        dialog += '</select></td></tr>' +
            '        <tr>' +
            '            <td class="bg_tr">项目名称</td>' +
            '            <td class="td_bg"><input type="text" name="name" class="js-name"></td>' +
            '            <td class="bg_tr">数量</td>' +
            '            <td class="td_bg"><input name="count" type="text"></td>' +
            '        </tr>' +
            '        <tr>' +
            '            <td class="bg_tr">保险定价</td>' +
            '            <td class="td_bg"><input name="insurance_price" type="text"></td>' +
            '            <td class="bg_tr">自费单价</td>' +
            '            <td class="td_bg"><input name="price" type="text"></td>' +
            '</select></td>' +
            '        </tr>' +
            '        <tr>' +
            '            <td class="bg_tr">类型</td>' +
            '            <td class="td_bg"><select name="type" onchange="typeChange($(this))">' +
            '<option value="">--请选择--</option>' +
            '<option value="68">机修</option>' +
            '<option value="69">美容</option>' +
            '<option value="70">喷漆</option>' +
            '</select></td>' +
            '            <td class="bg_tr">维修人</td>' +
            '            <td class="td_bg"><select name="fix_user" id="fix-user">' +
            '<option value="">--请选择--</option>' +
            '</select></td>' +
            '        </tr>' +
            '<tr>' +
            '            <td class="bg_tr">结算方式</td>' +
            '            <td class="td_bg"><select name="pay_type" id="">';
        if (1 == type) {
            dialog += '<option value="1">保险理赔</option>';
        } else if (2 == type) {
            dialog += '<option value="2">自费维修</option>';
        }
        dialog += '</select>' +
            '</tr>' +
            '        <tr>' +
            '            <td class="bg_tr">备注</td>' +
            '            <td class="td_bg" colspan="3"><textarea name="fix_remark" id="" cols="40" rows="2"></textarea></td>' +
            '        </tr>' +
            '        <tr>' +
            '            <td colspan="4" align="center" class="td_bg"><input type="button" class="act_btn" value="提交" onclick="detailedListAdd()"></td>' +
            '        </tr>' +
            '    </table></form>';
        $('#dialog').html($(dialog));
        $('#dialog').show();
        $('.js-name').focus();
        maskOpen();
    }

    //类型联动
    function typeChange(obj) {
        var options = '<option value="">--请选择--</option>';
        if (obj.val()) {
            $.post('/fix-car/ajax-fix-user', {gid: obj.val()}, function (msg) {
                if (msg.success) {
                    for (var i = 0; i < msg.content.length; i++) {
                        options += '<option value="' + msg.content[i].id + '">' + msg.content[i].name + '</option>';
                    }
                    $('#fix-user').html(options);
                    return false;
                }
            }, 'json');
        }
        $('#fix-user').html(options);
    }
    function toDoClearBase64(){
        $('#result').val('');
        fileCollect = [];
    }

    //清单添加
    function detailedListAdd() {
        var param = $('#dialog-from').serialize();
        $.post('/fix-car/fix-item-save', param, function (msg) {
            maskClose();
            alert(msg.msg);
            if (msg.success) {
                if (3 == msg.list_type || 4 == msg.list_type) {
                    gotoPage('/fix-car/ajax-item-list?fix_id=' + msg.fix_id + '&pay_type=' + msg.pay_type, 'list' + msg.list_type);
                } else if (5 == msg.list_type) {
                    gotoPage('/fix-car/ajax-item-list?fix_id=' + msg.fix_id + '&small_type_id=5', 'list' + msg.list_type);
                } else if (6 == msg.list_type) {
                    gotoPage('/fix-car/ajax-item-list?fix_id=' + msg.fix_id + '&small_type_id=6', 'list' + msg.list_type);
                }
            }
        });
    }

    $('.mask-layer').on('click', function () {
        maskClose();
    });

    function maskOpen() {
        $('.mask-layer').show();
        $(document.body).css({
            "overflow-x": "hidden",
            "overflow-y": "hidden"
        });
    }

    function maskClose() {
        $('.mask-layer').hide();
        $('#dialog').hide();
        $(document.body).css({
            "overflow-x": "auto",
            "overflow-y": "auto"
        });
    }
</script>
