1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2017/3/17 0017
- * Time: 上午 10:52
- */
- use yii\helpers\Url;
- use yii\widgets\LinkPager;
- ?>
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">分类</h3>
- </div>
- <div class="panel-body">
- <a class="btn btn-primary btn-sm " href="<?=Url::toRoute(['matertype/add'])?>">创建分类</a>
- </div>
- <table class="table">
- <tr>
- <th>名称</th>
- <th>排序</th>
- <th>添加时间</th>
- <th>状态</th>
- <th>操作</th>
- </tr>
- <?php foreach ($models as $vo):?>
- <tr >
- <td><?=$vo->name;?></td>
- <td><?=$vo->sort;?></td>
- <td><?=date('Y-m-d H:i',$vo->c_time);?></td>
- <td>
- <div class="switch">
- <div class="onoffswitch">
- <input type="checkbox" data-id="<?=$vo->id?>" name="MaterType[status]" <?= $vo->status==\common\models\MaterType::STATUS_YES?"checked":"" ?> class="onoffswitch-checkbox" id="example<?=$vo->id?>">
- <label class="onoffswitch-label" for="example<?=$vo->id?>">
- <span class="onoffswitch-inner"></span>
- <span class="onoffswitch-switch"></span>
- </label>
- </div>
- </div>
- </td>
- <td>
- <a class="btn btn-info btn-sm " href="<?=Url::toRoute(['matertype/add','id'=>$vo->id])?>" ><i class="fa fa-paste"></i> 编辑</a>
- </td>
- </tr>
- <?php endforeach;?>
- </table>
- </div>
- <?=LinkPager::widget(['pagination' => $pages]); ?>
- <script type="text/javascript">
- toastr.options={ "closeButton": true};
- $('.onoffswitch-checkbox').on('click',function(){
- var id =$(this).attr('data-id');
- $.ajax({
- type:"POST",
- data:{id:id,'<?=Yii::$app->request->csrfParam;?>':"<?=Yii::$app->request->csrfToken;?>"},
- dataType:"JSON",
- url:"<?=Url::toRoute(['matertype/update-status']);?>",
- success:function(data){
- if(data.sign == 1)
- {
- toastr.success("", data.msg);
- }else{
- toastr.error("", data.msg);
- }
- }
- })
- })
- </script>
|