<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.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" src="/js/common.js"></script>
<?php if(count($lists) > 0 ): ?>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
        <td width="5%" align="center" align="center" class="bg_tr" nowrap>排序</td>
        <td align="center" class="bg_tr">修理项目</td>
        <td align="center" class="bg_tr">报案号</td>
        <td align="center" class="bg_tr">修理分组</td>
        <td align="center" class="bg_tr">损伤程度</td>
        <td align="center" class="bg_tr">单价</td>
        <td align="center" class="bg_tr">数量</td>
        <td align="center" class="bg_tr">结算方式</td>
        <td width="5%" align="center" class="bg_tr">操作</td>
    </tr>
    <?php $group_name =[1=>'微伤',2=>'轻度',3=>'中度',4=>'重度'] ?>
    <?php foreach ($lists as $index => $list): ?>
        <?php if(2 == $list->type || 6 == $list->type): ?>
            <?php $project = \common\models\FixCarProject::findOne($list->fk_id) ?>
            <tr onMouseOver=overColor(this) onMouseOut=outColor(this) class="js-a">
                <td align="center" class="td_bg" nowrap><?= $index + 1 ?></td>
                <td align="left" class="td_bg" nowrap><?= $project->category->name ?></td>
                <td align="center" class="td_bg" nowrap><?= $list->report_id > 0 ? $list->report->report_no :'--' ?></td>
                <td align="left" class="td_bg" nowrap><?= $project->group->name ?></td>
                <td align="left" class="td_bg" nowrap><?= 7 == $project->group_id ? $group_name[$project->car_price] : '--' ?></td>
                <td align="left" class="td_bg" nowrap><?= $project->price ?>元</td>
                <td align="left" class="td_bg" nowrap><?= $list->count ?></td>
                <td align="left" class="td_bg" nowrap><?= 1 == $list->pay_type ? '保险理赔' : '自费维修' ?></td>
                <td align="center" class="td_bg" nowrap>
                    [<a href="javascript:void(0);" onclick="getItem($(this),<?= $list->id ?>)">领取</a>]
                </td>
            </tr>
        <?php elseif(1 == $list->type): ?>
            <?php $store = \common\models\StoreRoom::findOne($list->fk_id) ?>
            <tr onMouseOver=overColor(this) onMouseOut=outColor(this) class="js-a">
                <td align="center" class="td_bg" nowrap><?= $index + 1 ?></td>
                <td align="left" class="td_bg" nowrap><?= $store->category->name ?></td>
                <td align="center" class="td_bg" nowrap><?= $list->report_id > 0 ? $list->report->report_no :'--' ?></td>
                <td align="left" class="td_bg" nowrap>更换</td>
                <td align="left" class="td_bg" nowrap>--</td>
                <td align="left" class="td_bg" nowrap><?= $store->price ?>元</td>
                <td align="left" class="td_bg" nowrap><?= $list->count ?></td>
                <td align="left" class="td_bg" nowrap><?= 1 == $list->pay_type ? '保险理赔' : '自费维修' ?></td>
                <td align="center" class="td_bg" nowrap>
                    [<a href="javascript:void(0);" onclick="getItem($(this),<?= $list->id ?>)">领取</a>]
                </td>
            </tr>
        <?php endif; ?>
    <?php endforeach; ?>
</table>
<?php endif; ?>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
        <td height="25" colspan="9" align="center" class="td_bg"><input type="button" onclick="backBtn()" class="act_btn" value="返回"></td>
    </tr>
</table>
<script type="text/javascript" language="javascript">
    //编辑
    function edit(fixId, typeName) {
        window.location.href = '/fix-car-item/item-list-info?fix_id=' + fixId + '&type_name=' + typeName;
    }
   //领取操作
    function getItem(obj,itemId){
        if(itemId <= 0 || !confirm('确认要领取吗？领取以后不可退回!!')) return false;
        obj.parents('tr').addClass('success-mark-'+itemId);
        $.post('/fix-car-item/get-item',{item_id:itemId},function(data){
            alert(data.msg);
            if(data.success){
                $('.success-mark-'+itemId).remove();
                if($('.js-a').length <= 0) backBtn();
            }
        },'json');
    }
    //返回
    function backBtn(){
        window.location.href = '<?= $redirect ?>';
    }
</script>
