<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>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
        <td width="50" align="center" align="center" class="bg_tr" nowrap>排序</td>
        <td align="center" align="center" class="bg_tr">辅料名</td>
        <td align="center" align="center" class="bg_tr">辅料编号</td>
        <td align="center" align="center" class="bg_tr">数量</td>
        <td align="center" align="center" class="bg_tr">价格</td>
        <td align="center" align="center" class="bg_tr">备注</td>
        <td width="30" align="center" class="bg_tr">操作</td>
    </tr>
    <?php if (count($items) > 0): ?>
        <?php foreach ($items as $index=>$item): ?>
            <?php $store = \common\models\StoreRoom::findOne(['id'=>$item->fk_id]); ?>
            <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
                <td align="center" class="td_bg" nowrap><?= $index +1 ?></td>
                <td align="center" class="td_bg" nowrap><?= $store->name ?><?= (0 == $item->status) ? '<sup style="color:red;">new</sup>' : '' ?></td>
                <td align="center" class="td_bg" nowrap>--</td>
                <td align="center" class="td_bg" nowrap><?= $item->count ?></td>
                <td align="center" class="td_bg" nowrap><?= $store->selling_price ?>元</td>
                <!--            <td align="left" class="td_bg" nowrap></td>-->
                <td align="center" class="td_bg" nowrap>--</td>
                <td align="center" class="td_bg" nowrap>
                    [<a href="javascript:void(0);" onclick="del(<?= $item->id ?>,<?= $item->fix_group ?>,$(this))">删除</a>]
                </td>
            </tr>
        <?php endforeach; ?>
    <?php endif; ?>
    <tr>
        <td height="25" colspan="12" align="center" class="td_bg"></td>
    </tr>
</table>
<script type="text/javascript" language="javascript">
    //编辑
    function edit(id) {
        window.location.href = '/store-room/put-in-store-info?id=' + id;
    }
    //删除
    function del(id,gid,obj){
        if(!confirm("确定要删除吗？")) return false;
        obj.parents('tr').addClass('js-rm-'+id);
        $.post('/fix-car-item/delete',{id:id,gid:gid},function(data){
            if(data.success){
                $('.js-rm-'+id).remove();
            }
        },'json')
    }
</script>
