123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
- <jsp:include page="../../common/include.jsp" />
- <% String basePath = request.getScheme()+ "://" + request.getServerName() + ":" +request.getServerPort() + request.getContextPath(); %>
- <script type="text/javascript">
- /**菜单显示区*/
- $(function() {
- $('#menuDataGrid').datagrid({
- rownumbers:true,
- fit:true,
- pageSize:10,
- pageList : [ 10, 20, 30, 40, 50 ],
- fitColumns:false,
- border:false,
- sortOrder:'desc',
- pagination:true,
- idField:'id',
- url:whzl.basePath + '/menuAction_listMenu',
- toolbar:'#searchtool',
- checkOnSelect:true,
- selectOnCheck:true,
- nowrap:true,
- loadFilter:function(result){
- if(result.success){
- return result.obj;
- }else{
- $.messager.alert('出错了',result.message,'error');
- return ;
- }
- }
- }
- );
- });
-
- /**查询*/
- function searchFun(){
- $("#menuDataGrid").datagrid("load", {
- "menu.text":$("#tblQuery").find("input[id='text']").val(),
- "menu.href":$("#tblQuery").find("input[id='href']").val()
- });
- }
-
- /*清除查询条件**/
- function ClearQuery() {
- $("#tblQuery").find("input").val("");
- $("#tblQuery").find("select").val("-1");
- }
-
-
- /**详细*/
- var parentNameFormatter = function(value , row , index){
- if("parent" in row){
- return row.parent.text;
- }else{
- return "";
- }
-
- };
-
- /**详细*/
- var detailsFormatter = function(value , row , index){
- return "<img src='<%=basePath%>/images/details.png' title='查看详情' onclick=btsqDetails(" + row.id + ") style='cursor:pointer' />";
- };
-
- var iconFormatter = function(value , row , index){
- return "<div class='iconImg " +value + "'/>";
- };
-
- /**详细页面对话框*/
- var btsqDetails = function(id){
- $("#detailMenuDialog").dialog(
- {
- buttons : [
- {
- text : '确定',
- iconCls : 'icon-ok',
- handler : function(){
- $("#detailMenuDialog").dialog("close");
- }
- }
- ],
- onLoad : function(){
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "menuAction_findById",//要访问的后台地址
- data: "menu.id="+id,//要发送的数据
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- $("#id_detail").text(msg.obj.id);
- $("#text_detail").text(msg.obj.text);
- $("#parent_detail").text(msg.obj.parent.text);
- $("#href_detail").text(msg.obj.href);
- }
- });
- }
- }
- );
- };
-
- /**更新*/
- var updateFormatter = function(value , row , index){
- return "<img src='<%=basePath%>/js/easyui/themes/itemicon/update.png' title='修改' onclick=updateRow(" + row.id + ") style='cursor:pointer' />";
- };
-
- /**更新事件*/
- function updateRow(id){
- var updateIndex = $('#menuDataGrid').datagrid('getRowIndex', id);
- $('#updateMenuDialog').dialog(
- {
- buttons : [
- {
- text : '提交',
- iconCls : 'icon-ok',
- handler : function(){
- var menuId = $('#id_update').val();
- var updateId = $("input[name='menu.parent.id']").val()
- if(menuId == updateId){
- $.messager.alert("提示","不能选择自身节点作为父节点!");
- return;
- }
- $('#updateMenuForm').form('submit',
- {
- url : whzl.basePath+'/menuAction_updateMenu',
- success : function(result){
- var parseResult = $.parseJSON(result);
- if(parseResult.success){
- //修改完数据,更新对应行的数据
- $('#menuDataGrid').datagrid('updateRow',
- {
- index : updateIndex,
- row : parseResult.obj
- }
- );
- $('#allMenuTree').tree('reload');
- $("#updateMenuDialog").dialog("close");
- $('#iconDialog').dialog("destroy");
- }else{
- $.messager.alert('出错了',parseResult.message,'error');
- }
- }
- }
- );
- }
- },
- {
- text : '取消',
- iconCls : 'icon-cancel',
- handler : function(){
- $("#updateMenuDialog").dialog("close");
- }
- }
- ],
- onLoad : function(){
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "menuAction_findById",//要访问的后台地址
- data: "menu.id="+id,//要发送的数据
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- $("#id_update").val(msg.obj.id);
- $("#text_update").val(msg.obj.text);
- $("#href_update").val(msg.obj.href);
- $("#iconCls").val(msg.obj.iconCls);
- $("#iconCls").attr('class',"iconImg " + msg.obj.iconCls);
- //$("#p_id_add").val(msg.obj.parentId);
- if(msg.obj.parentId >0){
- $('#p_id_update').combotree('setValue',msg.obj.parentId);
- }
- }
- });
- }
- }
- );
- }
-
- /**删除*/
- var delFormatter = function(value , row , index){
- return "<img src='<%=basePath%>/js/easyui/themes/itemicon/delete.png' title='删除' onclick=deleteRow(" + row.id + ") style='cursor:pointer' />";
- };
-
- /**删除功能*/
- function deleteRow(id){
- $.messager.confirm('删除提示', '确定删除这条记录吗?', function(r){
- if (r){
- $.ajax({
- type: "post",//使用get方法访问后台
- dataType: "json",//返回json格式的数据
- url: "menuAction_deleteMenu",//要访问的后台地址
- data: "menu.id="+id,//要发送的数据
- complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
- success: function(msg){//msg为返回的数据,在这里做数据绑定
- if(msg.success){
- $.messager.alert('提示','删除成功!');
- $('#menuDataGrid').datagrid('reload');
- $('#allMenuTree').tree('reload');
- }else{
- $.messager.alert('提示','删除失败!');
- }
- }
- });
- }
- });
- }
-
- /**增加菜单*/
- function menuAdd(){
- $('#addMenuDialog').dialog(
- {
- buttons : [
- {
- text : '提交',
- iconCls : 'icon-ok',
- handler : function(){
- $('#addMenuForm').form('submit',
- {
- url : whzl.basePath+'/menuAction_addMenu',
- success : function(result){
- var parseResult = $.parseJSON(result);
- if(parseResult.success){
- $("#addMenuDialog").dialog("close");
- $('#menuDataGrid').datagrid('reload');
- $('#allMenuTree').tree('reload');
- $('#iconAddDialog').dialog("destroy");
- }else{
- $.messager.alert('提示',parseResult.message);
- }
- }
- }
- );
- }
- },
- {
- text : '取消',
- iconCls : 'icon-cancel',
- handler : function(){
- $("#addMenuDialog").dialog("close");
- }
- }
- ]
- }
- );
- }
- $(function(){
- $('#allMenuTree').tree({
- url:whzl.basePath+'/menuAction_menu',
- loadFilter: function(result){
- if(result.success){
- return result.obj;
- }else{
- $.messager.alert('提示',result.message);
- }
- }
- });
- });
- </script>
- <div style="width: 63%;height: 100%;boreder:1px solid red;float: left;background-color: #E0ECFF;">
- <div class="easyui-layout" data-options="fit:true,border:false" style="margin: 0px;padding: 0px;">
- <div data-options="region:'center',border:false">
- <div id="searchtool" data-options="region:'north' , border:false">
- <table id="tblQuery" style="width:100%;">
- <tr>
- <td align="right"><span>名称</span></td><td style="width: 200px;"><input id="text" name="menu.text" type="text"/></td>
- <td align="right"><span>地址</span></td><td style="width: 200px;"><input id="href" name="menu.href" type="text"/></td>
- <td align="center" colspan="2">
- <a href="javascript:searchFun();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">查询</a>
- <a href="javascript:ClearQuery();" class="easyui-linkbutton" data-options="iconCls:'icon-emptied',plain:true">清空</a>
- <a href="javascript:menuAdd();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加</a>
- </td>
- </tr>
- </table>
- </div>
-
- <table id="menuDataGrid">
- <thead frozen="true">
- <tr>
- <th data-options="field:'id',checkbox:true,width:50">ID</th>
- <th data-options="field:'text',sortable:true,width:150">名称</th>
- </tr>
- </thead>
- <thead>
- <tr>
- <th data-options="field:'iconCls',sortable:true,formatter:iconFormatter,width:40">图标</th>
- <th data-options="field:'href',sortable:true,width:200">地址</th>
- <!-- <th data-options="field:'parentId',sortable:false">父节点ID</th> -->
- <th data-options="field:'parentName',sortable:false,width:150,formatter:parentNameFormatter">父节点名称</th>
- <!-- <th data-options="field:'details',align:'center',formatter:detailsFormatter">查看详情</th> -->
- <th data-options="field:'update',align:'center',formatter:updateFormatter,width:50">修改</th>
- <th data-options="field:'delete',align:'center',formatter:delFormatter,width:50">删除</th>
- </tr>
- </thead>
- </table>
- </div>
- </div>
- </div>
- <div style="width: 37%;height: 100%;boreder:1px solid red;float: left;background-color: #E0ECFF;">
- <div class="easyui-accordion" data-options="fit:true,border:false">
- <div title="菜单" data-options="iconCls:'icon-menu'">
- <ul id="allMenuTree" class="easyui-tree" data-options="lines:true" style="margin-top:5px;margin-left: 20px;">
- </ul>
- </div>
- </div>
- </div>
- <div id="detailMenuDialog" data-options="title:' 菜单详细信息',iconCls:'icon-details',width:400,height:185,modal:true,href:'<%=basePath %>/menuAction_toDetail'">
- </div>
- <div id="updateMenuDialog" data-options="title:' 修改菜单信息',iconCls:'icon-edit',width:400,height:250,modal:true,href:'<%=basePath %>/menuAction_toUpdate'">
- </div>
- <div id="addMenuDialog" data-options="title:' 增加菜单信息',iconCls:'icon-add',width:400,height:250,modal:true,href:'<%=basePath %>/menuAction_toAdd'">
- </div>
- <script type="text/javascript">
- <!--
- parent.$.messager.progress('close');
- //-->
- </script>
|