You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
simple-yewu/frontend/views/menu/index.php

92 lines
3.7 KiB

5 years ago
<?php
use \common\libs\MyLib;
?>
<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>
<script type="text/javascript" language="javascript">
//修改
function edit(id) {
window.location.href = '/menu/edit?id=' + id;
}
function del(id) {
if(confirm('是否确认删除?')) {
$.post('/menu/delete',{id:id},function(obj){
if(obj.success) {
window.location.reload();
} else {
alert(obj.msg);
}
},'json');
}
}
$(function(){
$('#add-btn').click(function(){
edit(0);
});
$('#order-btn').click(function(){
if(confirm('是否批量保存排序?')) {
var params = $('#theFrm').serialize();
$.post('/menu/order-save',params,function(obj){
alert(obj.msg);
if(obj.success) {
window.location.reload();
}
},'json');
}
});
});
</script>
<table style="width:98%;" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<form id="searchForm">
<tr>
<td class="td_bg">
<input type="button" class="act_btn" id="add-btn" name="search-btn" value="添加">
<input type="button" class="act_btn" id="order-btn" name="order-btn" value="保存排序">
</td>
</tr>
</form>
</table>
<table width="98%" align="center" cellpadding="3" cellspacing="1" class="table">
<tr>
<td width="300" align="center" class="bg_tr">菜单名称</td>
<td width="60%" align="center" class="bg_tr">路径</td>
<td width="50" align="center" class="bg_tr">排序</td>
<td width="50" align="center" class="bg_tr">操作</td>
</tr>
<form id="theFrm">
<?php
foreach($menu_items as $item) {
?>
<tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
<td class="td_bg" nowrap><?= $item['name'] ?></td>
<td class="td_bg" nowrap><?= $item['path'] ?></td>
<td class="td_bg" nowrap>
<input type="text" name="order_ids[<?=$item['id']?>]" value="<?=$item['order_id']?>" style="width:50px;">
</td>
<td align="center" class="td_bg" nowrap>
[<a href="javascript:void(0);" onclick="edit(<?= $item['id'] ?>)">修改</a>]
[<a href="javascript:void(0);" onclick="del(<?= $item['id'] ?>)">删除</a>]
</td>
</tr>
<?php
if (isset($item['children'])) foreach ($item['children'] as $sub_item) {
?>
<tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
<td class="td_bg" nowrap>&nbsp;&nbsp;&nbsp;&nbsp;<?= $sub_item['name'] ?></td>
<td class="td_bg" nowrap><?= $sub_item['path'] ?></td>
<td class="td_bg" nowrap>
<input type="text" name="order_ids[<?=$sub_item['id']?>]" value="<?=$sub_item['order_id']?>" style="width:50px;">
</td>
<td align="center" class="td_bg" nowrap>
[<a href="javascript:void(0);" onclick="edit(<?= $sub_item['id'] ?>)">修改</a>]
[<a href="javascript:void(0);" onclick="del(<?= $sub_item['id'] ?>)">删除</a>]
</td>
</tr>
<?php
}
}
?>
</form>
</table>