<!--html-->
<form action="{:url('cate/csort')}" method="post">
<div class="layui-collapse" lay-filter="test">
<button type="submit" class="layui-btn layui-btn-xs">更新排序</button>
<table class="layui-table" lay-size="sm">
<thead>
<tr>
<th style="text-align: center;" width="5%">id</th>
<th style="text-align: center;" width="5%">排序</th>
<th style="text-align: center;">名称</th>
<th style="text-align: center;" width="10%">图片</th>
<th style="text-align: center;" width="10%">类型</th>
<th style="text-align: center;" width="10%">模型</th>
<th style="text-align: center;" width="10%">状态</th>
<th style="text-align: center;" width="10%">操作</th>
</tr>
</thead>
<tbody>
{volist name="cate" id="c"}
<tr>
<td style="text-align: center;">{$c.id}</td>
<th style="text-align: center;" width="5%">
<!--排序inpunt输入框-->
<input type="text" name="cate_sort[{$c.id}]" value="{$c.cate_sort}" style="width: 20px;height: 20px;text-align: center;color: #333333;"/>
</th>
<td><?php echo str_repeat('———',$c['level']*1); ?>{$c.name}</td>
<td style="text-align: center;"><img src="{$c.image}" style="height: 40px;"/></td>
<td style="text-align: center;">
{if condition="$c.cate_type eq 1 "}列表页面{/if}
{if condition="$c.cate_type eq 2 "}频道页面{/if}
{if condition="$c.cate_type eq 3 "}单独页面{/if}
</td>
<td style="text-align: center;">{$c.cate_model}</td>
<td style="text-align: center;"> <button spanid="{$c.id}" onclick="status(this)" type="button" class="{if condition=" $c.status eq 1 "}layui-btn layui-btn-xs layui-btn-normal {else /} layui-btn layui-btn-xs layui-btn-danger {/if}">
{if condition="$c.status eq 1 "}启用{else /}禁用{/if}
</button></td>
<td style="text-align: center;">
<a title="编辑" onclick="MT_open('编辑','edit?id={$c.id}')" href="javascript:;" class="layui-btn layui-btn-xs">编辑</a>
<a title="删除" onclick="member_del(this,'{$c.id}')" href="javascript:;" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
</td>
</tr>
{/volist}
</tbody>
</table>
</div>
</form>// 排序PHP
public function csort(){
if (request()->isPost()){
$data = input('post.');
foreach ($data as $k=>$v){
foreach ($v as $i=>$s){
$res = db('cate')->where('id',$i)->update([$k=>$s]);
}
}
if ($res){
$this->redirect('cate_list');
}else{
$this->redirect('cate_list');
}
}
}记录一下ThinkPHP实现排序功能代码……
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号