<?php if (count($stores) > 0): ?> <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> <style> .color1{ background-color: #299AD6; color:white; } </style> <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table"> <form id="searchForm"> <tr> <td class="td_bg"> 辅料名:<input id="name" name="name" type="text" value=""> <input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索"> </td> </tr> </form> </table> <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"> <tr> <td width="5%" class="td_bg" nowrap></td> <td width="5%" class="td_bg" align="center"><input type="checkbox" class="js-all-choice-box"></td> <td width="10%" class="td_bg" align="center"><input type="button" value="批量添加" class="color1 js-all-choice-btn" onclick="batchChoiceBox()"></td> <td colspan="7" class="td_bg"></td> </tr> <tr> <td width="5%" align="center" align="center" class="bg_tr" nowrap>序号</td> <td width="5%" align="center" align="center" class="bg_tr">选</td> <td width="10%" align="center" align="center" class="bg_tr">快速</td> <td width="20%" align="center" align="center" class="bg_tr">辅料名</td> <td width="20%" align="center" align="center" class="bg_tr">辅料编码</td> <td width="50%" align="center" align="center" class="bg_tr">辅料价格</td> </tr> <?php foreach ($stores as $index => $content): ?> <tr onMouseOver=overColor(this) onMouseOut=outColor(this)> <td align="center" class="td_bg" nowrap><?= $index + 1 ?></td> <td align="center" class="td_bg" nowrap><input type="checkbox" class="js-one-choice-box" value="<?= $content->id ?>" data-price="<?= number_format($content->price * ($content->category->fixCarScale->scale/100 +1),2) ?>"></td> <td align="center" class="td_bg" nowrap><input type="button" value="+" class="color1" onclick="oneChoiceBox($(this),'<?= $content->id ?>','<?= number_format($content->price * ($content->category->fixCarScale->scale/100 +1),2) ?>')"></td> <td align="center" class="td_bg" nowrap><?= $content->category->name ?></td> <td align="center" class="td_bg" nowrap>--</td> <td align="center" class="td_bg" nowrap><?= number_format($content->price * ($content->category->fixCarScale->scale/100 +1),2) ?>元</td> </tr> <?php endforeach; ?> <tr> <td width="5%" class="td_bg" nowrap></td> <td width="5%" class="td_bg" align="center"><input type="checkbox" class="js-all-choice-box"></td> <td width="10%" class="td_bg" align="center"><input type="button" value="批量添加" class="color1 js-all-choice-btn" onclick="batchChoiceBox()"></td> <td colspan="7" class="td_bg"></td> </tr> <tr> <td height="25" colspan="12" align="center" class="td_bg"><?= $page_info ?></td> </tr> </table> <script type="text/javascript" language="javascript"> $('.js-all-choice-box').on('click',function(){ $('.js-one-choice-box').attr('checked',($(this).attr('checked') ? true : false)); $('.js-all-choice-box').attr('checked',($(this).attr('checked') ? true : false)); }); //单选 function oneChoiceBox(obj,id,price){ obj.parent('td').prev('td').find('.js-one-choice-box').attr('checked',true); obj.css('background-color','gray'); $.post('/fix-car-item/add',{id:id,fix_id:<?= $fix_id ?>,t:3,pay_type:2,price:price},function(data){ if(data.success){ var url = '/fix-car-item/index?fix_id='+'<?= $fix_id ?>'+'&t=3'; parent.openBottom(url); } },'json') } //批量添加 function batchChoiceBox() { var idArr = [],priceArr = []; $('.js-one-choice-box:checked').each(function () { idArr.push($(this).val()); priceArr.push($(this).data('price')); }) if (0 == idArr.length) return false; $.post('/fix-car-item/batch-add', {ids: idArr, fix_id:<?= $fix_id ?>, t: 3,pay_type:2,price:priceArr}, function (data) { if (data.success) { $('.js-one-choice-box:checked').each(function () { $(this).parent('td').next('td').find('input').css('background-color','gray'); }) var url = '/fix-car-item/index?fix_id=' + '<?= $fix_id ?>' + '&t=3'; parent.openBottom(url); } }) } //搜索 $('#search-btn').on('click',function(){ var $name = $('#name').val(); if(!$name) return false; location.href="<?= $url ?>&name="+$name }) </script> <?php endif; ?>