🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 列表操作 ~~~html <!-- PAGE CONTENT BEGINS --> <div class="row"> <div class="well well-sm"> <a onclick="addFunction(2,1)" class="btn btn-sm btn-success"> <i class="icon-plus bigger-110"></i> <span class="bigger-110 no-text-shadow">添加控制器</span> </a> </div> </div> <div class="row"> <div class="col-sm-12"> <volist name="list" id="item"> <div class="row"> <div class="widget-box"> <div class="widget-header"> <h4 class="widget-title"> <label> <span class="hd2y_tips" data-id="{$item.id}">{$item.title}[{$item.name}]</span> </label> </h4> <div class="widget-toolbar"> <a onclick="addFunction(3,'{$item.id}')" class="btn btn-xs btn-info"> <i class="icon-plus bigger-120"></i> 添加方法 </a> </div> </div> <div class="widget-body"> <div class="widget-main row"> <volist name="item.son" id="son"> <label class="col-xs-2" style="width:160px;"> <span class="hd2y_tips" data-id="{$son.id}">{$son.title}[{$son.name}]</span> </label> </volist> </div> </div> </div> </div> </volist> </div> </div> <!--弹窗---> <div id="alert" style="display: none"> <form id="node_form" action="{:U('Rbac/node')}" method="post"> <div class="form_content" style="padding: 20px;text-align: center"> <input type="hidden" name="id" class="node_input_id" value="" /> <input type="hidden" name="level" class="node_input_level" value="" /> <input type="hidden" name="pid" class="node_input_pid" value="" /> <table width="100%"> <tr><td class="label_name"></td> <td> <input type="text" name="name" class="col-xs-10 node_input_name" value=""/> </td> </tr> <tr><td class="label_title"></td> <td> <input type="text" name="title" class="col-xs-10 node_input_title" value=""/> </td> </tr> <tr><td>排序</td> <td> <input type="number" name="sort" class="col-xs-10 node_input_sort" value="0" /> </td> </tr> </table> <div class="space-10"></div> <a class="btn btn-success subBtn">提交</a> </div> </form> </div> <script type="text/javascript"> $(function () { $(".widget-box .hd2y_tips").hover(function(){ var _this = this; var id = $(_this).attr('data-id'); layer.tips('请选择操作', this, { time: 0, //0表示不自动关闭 tips: [3, '#78BA32'], btn: ['编辑', '删除'], yes:function (index) { editNode(index,id); }, btn2:function (index) { deleteNode(index,id); } }); },function(){ //layer.closeAll('tips'); }) }) /** * 编辑节点操作 */ function editNode(index,id) { layer.close(index); util.get("{:U('rbac/look')}",{id:id},function (data) { if(data){ $('.node_input_id').val(data.id); $('.node_input_pid').val(data.pid); $('.node_input_level').val(data.level); showNode(data.level,data.pid,function (form_id) { $('#'+form_id+' #node_form .node_input_name').val(data.name); $('#'+form_id+' #node_form .node_input_title').val(data.title); $('#'+form_id+' #node_form .node_input_sort').val(data.sort); $('#'+form_id+' .subBtn').on('click',function () { util.submit('#'+form_id+' #node_form',function (data) { if(data.status){ layer.msg(data.message, function(){ location.reload(); }); }else { layer.msg(data.message); } }) }) }) }else { layer.msg('不存在这个节点') } }) } /** * 删除节点操作 */ function deleteNode(index,id) { layer.close(index); layer.confirm('您要删除这个节点码?', { btn: ['删除','取消'] //按钮 }, function(){ util.post("{:U('rbac/deleted')}",{id:id},function (data) { if(data.status){ layer.msg(data.message, function(){ location.reload(); }); }else { layer.msg(data.message); } }) }); } /** * 添加节点 */ function addFunction(level,pid) { showNode(level,pid,function (form_id) { $('#'+form_id+' .subBtn').on('click',function () { util.submit('#'+form_id+' #node_form',function (data) { if(data.status){ layer.msg(data.message, function(){ location.reload(); }); }else { layer.msg(data.message); } }) }) }) } /** * 显示弹框 * @param level 2:控制器,3:方法 * @param pid 父及id * @param callback 回调函数 */ function showNode(level,pid,callback) { var title = (level==2)?'控制器':'方法'; $('.node_input_pid').val(pid); $('.node_input_level').val(level); $('.label_name').html(title); $('.label_title').html(title+'中文名'); var _form_id = 'add_form_' + Math.ceil(Math.random()*1000); var _html = '<div id="'+_form_id+'" class="add_node_div">' + $('#alert').html() + '</div>'; layer.open({ type: 1, title: title, skin: 'layui-layer-rim', //加上边框 area: ['420px', '260px'], //宽高 content: _html }); callback(_form_id); } </script> ~~~