上架下架

//html

<extend name="Public/base" />

<block name="body">
<!-- 标题栏 -->
<div class="main-title">
<h2>期刊杂志列表</h2>
</div>
<div class="cf">
<div class="fl">
<a class="btn" href="{:U('add')}">新 增</a>
<button class="btn ajax-post confirm" url="{:U('del')}" target-form="ids">删 除</button>

</div>

<!--高级搜索-->
<div class="search-form fr cf">
<div class="sleft">
<input type="text" name="nickname" class="search-input" value="{:I('nickname')}" placeholder="请输入名称">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>
</div>
</div>
</div>
<!-- 数据列表 -->
<div class="data-table table-striped">
<table class="">
<thead>
<tr>
<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
<th class="">ID</th>
<th class="">期刊名称</th>
<th class="">期</th>
<th class="">卷</th>
<th class="">总第</th>
<th class="">下载次数</th>
<th class="">状态</th>
<th class="">更新时间</th>
<th class="">操作</th>
</tr>
</thead>
<tbody>
<notempty name="_list">
<volist name="_list" id="vo">
<tr>
<td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td>
<td>{$vo.id} </td>
<td>{$vo.magazine_name} </td>
<td>{$vo.period} </td>
<td>{$vo.volume} </td>
<td>{$vo.always} </td>
<td>{$vo.download_count} </td>
<td>
<if condition="$vo.status eq 1" >
<span class="status-green">上架</span>
<else/>
<span class="status-red">下架</span>
</if>
</td>
<td>{$vo.update_time|time_format}</td>
<td>
<eq name="vo.status" value="1">
<a href="{:U('disable?method=forbid_status&id='.$vo['id'])}" class="ajax-get">下架</a>
<else/>
<a href="{:U('disable?method=resume_status&id='.$vo['id'])}" class="ajax-get">上架</a>
</eq>
<a href="{:U('edit?id='.$vo['id'])}" >编辑</a>
<eq name="vo.new" value="1" >
<a href="{:U('disable?method=notnew&id='.$vo['id'])}" class="ajax-get">notNew</a>
<else/>

<a href="{:U('disable?method=new&id='.$vo['id'])}" class="ajax-get">new</a>
</eq >
<a href="{:U('del?id='.$vo['id'])}" class="confirm ajax-get">删除</a>

</td>
</tr>
</volist>
<else/>
<td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
</notempty>
</tbody>
</table>
</div>
<div class="page">
{$_page}
</div>
</block>

//控制器


public function disable($method = null)
{
$id = array_unique((array)I('id', 0));

$id = is_array($id) ? implode(',', $id) : $id;
if (empty($id)) {
$this->error('请选择要操作的数据!');
}
$map['id'] = array('in', $id);
switch (strtolower($method)) {
case 'forbid_status':
action_log_new('Magazine',$id,'下架','magazine_name');
//下架
$this->editRow($this->model, array('status' => 0), $map,[]);
break;
case 'resume_status':
//上架
action_log_new('Magazine',$id,'上架','magazine_name');
$this->editRow($this->model,array('status' => 1), $map, []);
break;

case 'notnew':
action_log_new('Magazine',$id,'notnew','magazine_name');
$this->editRow($this->model,array('new' => 0), $map, []);
break;

case 'new':
action_log_new('Magazine',$id,'new','magazine_name');
$this->editRow($this->model,array('new' => 1), $map, []);
break;
default:
$this->error('参数非法');
}
}



posted @ 2020-01-15 15:59  php毛宏历的博客  阅读(315)  评论(0编辑  收藏  举报