{
 "hidden": false,
 "children": [{
  "configs": {"itemId": "module"},
  "expanded": true,
  "children": [
   {
    "configs": {
     "layout": "fit",
     "dialog": "true",
     "itemId": "Win",
     "width": "310",
     "height": "210"
    },
    "expanded": true,
    "children": [{
     "configs": {
      "layout": "absolute",
      "itemId": "panelWin",
      "width": "376",
      "height": "190"
     },
     "expanded": true,
     "children": [
      {
       "configs": {
        "itemId": "MENU_NAME",
        "labelAlign": "right",
        "fieldLabel": "菜单名称",
        "width": "270",
        "x": "5",
        "y": "10",
        "labelWidth": "60",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "text"
      },
      {
       "configs": {
        "itemId": "MENU_URL",
        "labelAlign": "right",
        "fieldLabel": "菜单url",
        "width": "270",
        "x": "5",
        "y": "40",
        "labelWidth": "60",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "text"
      },
      {
       "configs": {
        "itemId": "MENU_TYPE",
        "labelAlign": "right",
        "pickList": "[\
  ['0','菜单'],['1','功能'],['2','子系统']\
]",
        "fieldLabel": "菜单类型",
        "width": "270",
        "x": "5",
        "y": "70",
        "labelWidth": "60",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "combo"
      },
      {
       "configs": {
        "hideTrigger": "true",
        "itemId": "ORDER_INDEX",
        "labelAlign": "right",
        "fieldLabel": "序号",
        "width": "270",
        "x": "5",
        "y": "100",
        "labelWidth": "60",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "number"
      },
      {
       "configs": {
        "itemId": "MENU_ID",
        "hidden": "true",
        "fieldLabel": "ID",
        "x": "296",
        "width": "240",
        "y": "24",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "text"
      }
     ],
     "type": "panel"
    }],
    "type": "window"
   },
   {
    "configs": {
     "layout": "border",
     "itemId": "viewport1"
    },
    "expanded": true,
    "children": [
     {
      "configs": {
       "border": "false",
       "itemId": "tree1",
       "root": "{\
  text: '全部',\
  MENU_ID: '-1',\
  expanded: true\
}",
       "width": "300",
       "viewConfig": "app.treeViewConfig",
       "region": "west",
       "rootVisible": "true",
       "multiSelect": "true"
      },
      "expanded": true,
      "children": [
       {
        "configs": {
         "itemId": "store",
         "fields": "['text', 'MENU_NAME', 'MENU_ID', 'PARENT_MENU', 'ORDER_INDEX']",
         "url": "m?xwl=admin/wbMenu/select"
        },
        "expanded": false,
        "children": [],
        "type": "treestore",
        "events": {"success": "//Wb.selFirst(app.tree1);"}
       },
       {
        "configs": {
         "itemId": "tbar",
         "enableOverflow": "true"
        },
        "expanded": true,
        "children": [
         {
          "configs": {
           "itemId": "combo",
           "labelAlign": "right",
           "bindField": "COD",
           "fieldLabel": "模块",
           "displayField": "NAME",
           "labelWidth": "40",
           "valueField": "COD",
           "height": "22"
          },
          "expanded": true,
          "children": [{
           "configs": {
            "itemId": "store",
            "url": "m?xwl=admin/perm/selectWbMenu"
           },
           "expanded": false,
           "children": [],
           "type": "store"
          }],
          "type": "combo",
          "events": {
           "beforequery": "\
",
           "select": "this.collapse();\
//选择任意一个节点Select any node\
Wb.request({\
  url: 'm?xwl=admin/perm/check', \
  params:{menuId:app.combo.getValue()},\
  success: function(resp) {\
    var s= Wb.decode(resp.responseText);\
    var postion = app.tree1.getRootNode();\
    for(var i=0; i<s.length;i++){\
      postion = postion.childNodes[s[i]];\
    }\
    Wb.selectAnyNode(app.tree1,postion);\
    app.parent_menu.setValue(app.combo.getValue());\
    app.findButton.fireEvent('click');\
  }\
});"
          }
         },
         {
          "configs": {
           "itemId": "deleteTree",
           "text": "删除树节点",
           "iconCls": "record_delete_icon"
          },
          "expanded": false,
          "children": [],
          "type": "button",
          "events": {"click": " if (app.tree1.selModel.isSelected(app.tree1.getRootNode())) {\
  Wb.warn('不能删除根节点。');\
  return;\
}\
Wb.confirm('确定要删除选择的部门及其所属的所有子部门吗？', function() {\
  var deptIds = {};\
  Wb.each(app.tree1.getSelection(), function(node) {\
    node.cascadeBy(function(item) {\
      deptIds[item.data.MENU_ID] = {\
        MENU_ID: item.data.MENU_ID\
      };\
    });\
  });\
  Wb.request({\
    url: 'm?xwl=admin/wbMenu/deleteTree',\
    params: {\
      deptIds: Ext.Object.getValues(deptIds)\
    },\
    success: function(resp) {\
      Wb.remove(app.tree1);\
    }\
  });\
});\
"}
         }
        ],
        "type": "toolbar"
       }
      ],
      "type": "tree",
      "events": {
       "itemclick": "app.parent_menu.setValue(record.data.MENU_ID);\
app.gridMenu.store.load({\
    params:{parentMenu:record.data.MENU_ID}\
});\
\
app.gridMenuRes.store.load();",
       "selectionchange": "app.selNodes = selected;\
app.selNode = selected[0];"
      }
     },
     {
      "configs": {
       "layout": "border",
       "border": "false",
       "itemId": "paneltoal",
       "region": "center"
      },
      "expanded": true,
      "children": [
       {
        "configs": {
         "layout": "fit",
         "border": "false",
         "itemId": "panelMenu",
         "region": "north",
         "height": "300",
         "frame": "true"
        },
        "expanded": true,
        "children": [{
         "configs": {"itemId": "gridMenu"},
         "expanded": true,
         "children": [
          {
           "configs": {
            "itemId": "store",
            "autoLoad": "true",
            "url": "m?xwl=admin/wbMenu/selectWbMenu"
           },
           "expanded": false,
           "children": [],
           "type": "store"
          },
          {
           "configs": {
            "itemId": "tbar",
            "region": "north"
           },
           "expanded": true,
           "children": [
            {
             "configs": {
              "itemId": "menu_name",
              "labelAlign": "right",
              "fieldLabel": "菜单名称",
              "labelWidth": "60"
             },
             "expanded": false,
             "children": [],
             "type": "text"
            },
            {
             "configs": {
              "itemId": "findButton",
              "text": "查询",
              "iconCls": "search_icon"
             },
             "expanded": false,
             "children": [],
             "type": "button",
             "events": {"click": "\
app.gridMenu.store.load({\
  params:{menu_name:app.menu_name.getValue(),parentMenu:app.parent_menu.getValue()}\
});"}
            },
            {
             "configs": {
              "itemId": "addButton",
              "text": "添加",
              "iconCls": "record_add_icon"
             },
             "expanded": false,
             "children": [],
             "type": "button",
             "events": {"click": "if (!app.selNode) {\
  Wb.warn('请选择 1 个部门。');\
  return;\
}\
var win = new Ext.window.Window(app._Win); //app._win指向配置对象而非实例\
win.show();\
win.setIconCls('record_add_icon');\
Wb.setTitle(win, '添加');\
\
app.MENU_NAME.setValue(\"\");\
app.MENU_URL.setValue(\"\");\
app.MENU_TYPE.setValue(\"\");\
app.MENU_ID.setValue(\"\");\
var orderIndex = app.selNode.lastChild ? app.selNode.lastChild.data.ORDER_INDEX + 1 : 1;\
app.ORDER_INDEX.setValue(orderIndex);\
\
//alert(app.selNode.data.MENU_ID);\
//窗口每次动态生成,方法在窗口销毁时自动销毁\
win.mon(win, 'ok', function() {\
  Wb.request({\
    url: 'm?xwl=admin/wbMenu/insertWbMenu', \
    params:{\
      MENU_NAME:app.MENU_NAME.getValue(),\
      MENU_URL:app.MENU_URL.getValue(),\
      MENU_TYPE:app.MENU_TYPE.getValue(),\
      PARENT_MENU: app.selNode.data.MENU_ID,\
      ORDER_INDEX:app.ORDER_INDEX.getValue()\
    },\
    success: function(resp) {\
      win.close(); //根据closeAction属性，默认为销毁\
      app.tree1.store.load();\
      Wb.request({\
        url: 'm?xwl=admin/wbMenu/select', \
        success: function(resp) {\
          Wb.request({\
            url: 'm?xwl=admin/perm/check', \
            params:{menuId:app.parent_menu.getValue()},\
            success: function(resp) {\
              var s= Wb.decode(resp.responseText);\
              var postion = app.tree1.getRootNode();\
              for(var i=0; i<s.length;i++){\
                postion = postion.childNodes[s[i]];\
              }\
              Wb.selectAnyNode(app.tree1,postion);\
              app.findButton.fireEvent('click');\
            }\
          });\
        }\
      });\
    }\
  });\
});"}
            },
            {
             "configs": {
              "itemId": "editbutton",
              "text": "修改",
              "iconCls": "record_edit_icon"
             },
             "expanded": false,
             "children": [],
             "type": "button",
             "events": {"click": "var rec = app.gridMenu.getSelection()[0];\
if (!rec) {\
  Wb.warn('请选择 1 条需要修改的记录。');\
  return;\
}\
var win = new Ext.window.Window(app._Win); //app._win指向配置对象而非实例\
win.show();\
win.setIconCls('record_edit_icon');\
Wb.setTitle(win, '修改');\
Wb.setValue(win, rec.data); //把记录数据应用到窗口\
\
\
//窗口每次动态生成,方法在窗口销毁时自动销毁\
win.mon(win, 'ok', function() {\
  var values = Wb.applyIf(Wb.getValue(win), Wb.getData(rec, true)); //Wb.getData用于获取记录中的原始值，见Wb.getData方法\
  Wb.request({\
    url: 'm?xwl=admin/wbMenu/updateWbMenu',\
    params: values,\
    success: function(resp) {\
      Wb.update(rec, values); //同步在客户端表格中更新\
      win.close(); //根据closeAction属性，默认为销毁\
      app.tree1.store.load();\
      Wb.request({\
        url: 'm?xwl=admin/wbMenu/select', \
        success: function(resp) {\
          Wb.request({\
            url: 'm?xwl=admin/perm/check', \
            params:{menuId:app.parent_menu.getValue()},\
            success: function(resp) {\
              var s= Wb.decode(resp.responseText);\
              var postion = app.tree1.getRootNode();\
              for(var i=0; i<s.length;i++){\
                postion = postion.childNodes[s[i]];\
              }\
              Wb.selectAnyNode(app.tree1,postion);\
            }\
          });\
        }\
      });\
    }\
  });\
});\
\
"}
            },
            {
             "configs": {
              "itemId": "delButton",
              "text": "删除",
              "iconCls": "record_delete_icon"
             },
             "expanded": false,
             "children": [],
             "type": "button",
             "events": {"click": "// if (app.tree1.selModel.isSelected(app.tree1.getRootNode())) {\
//   Wb.warn('不能删除根节点。');\
//   return;\
// }\
// Wb.confirm('确定要删除选择的部门及其所属的所有子部门吗？', function() {\
//   var deptIds = {};\
//   Wb.each(app.tree1.getSelection(), function(node) {\
//     node.cascadeBy(function(item) {\
//       deptIds[item.data.MENU_ID] = {\
//         MENU_ID: item.data.MENU_ID\
//       };\
//     });\
//   });\
//   Wb.request({\
//     url: 'm?xwl=admin/wbMenu/deleteWbMenu',\
//     params: {\
//       deptIds: Ext.Object.getValues(deptIds)\
//     },\
//     success: function(resp) {\
//       Wb.remove(app.tree1);\
//     }\
//   });\
// });\
\
\
var rec = app.gridMenu.getSelection()[0];\
if (!rec) {\
  Wb.warn('请选择 1 条需要删除的记录。');\
  return;\
}\
//alert(rec.data.MENU_ID);\
Wb.request({\
  url: 'm?xwl=admin/wbMenu/deleteWbMenu',\
  params: {menuId:rec.data.MENU_ID},\
  success: function() {\
     app.findButton.fireEvent('click');\
     app.tree1.store.load();\
      Wb.request({\
        url: 'm?xwl=admin/wbMenu/select', \
        success: function(resp) {\
          Wb.request({\
            url: 'm?xwl=admin/perm/check', \
            params:{menuId:app.parent_menu.getValue()},\
            success: function(resp) {\
              var s= Wb.decode(resp.responseText);\
              var postion = app.tree1.getRootNode();\
              for(var i=0; i<s.length;i++){\
                postion = postion.childNodes[s[i]];\
              }\
              Wb.selectAnyNode(app.tree1,postion);\
            }\
          });\
        }\
      });\
  }\
});"}
            },
            {
             "configs": {
              "itemId": "copyPathBtn",
              "text": "复制路径",
              "iconCls": "copy_icon"
             },
             "expanded": false,
             "children": [],
             "type": "button",
             "events": {"click": "\
var rec = app.gridMenu.getSelection()[0];\
if (!rec) {\
  Wb.warn('未选择记录。');\
  return;\
}\
if(Wb.isEmpty(rec.data.MENU_URL)){\
  Wb.warn('不存在的路径');\
  return;\
}\
app.copy(rec.data.MENU_URL);\
"}
            },
            {
             "configs": {
              "itemId": "parent_menu",
              "hidden": "true"
             },
             "expanded": false,
             "children": [],
             "type": "text"
            }
           ],
           "type": "toolbar"
          },
          {
           "configs": {"itemId": "columns"},
           "expanded": true,
           "children": [
            {
             "configs": {
              "itemId": "row",
              "xtype": "rownumberer",
              "text": "序号",
              "align": "center",
              "titleAlign": "center"
             },
             "expanded": true,
             "children": [],
             "type": "column"
            },
            {
             "configs": {
              "itemId": "id",
              "hidden": "true",
              "dataIndex": "MENU_ID",
              "titleAlign": "center"
             },
             "expanded": false,
             "children": [],
             "type": "column"
            },
            {
             "configs": {
              "itemId": "menuName",
              "dataIndex": "MENU_NAME",
              "text": "菜单名称",
              "titleAlign": "center"
             },
             "expanded": false,
             "children": [],
             "type": "column"
            },
            {
             "configs": {
              "itemId": "menuurl",
              "dataIndex": "MENU_URL",
              "width": "300",
              "text": "菜单url",
              "titleAlign": "center"
             },
             "expanded": false,
             "children": [],
             "type": "column"
            },
            {
             "configs": {
              "itemId": "menuType",
              "renderer": "if(value==0){\
  return '菜单';\
}\
if(value==1){\
  return '功能';\
}\
if(value==2){\
  return '子系统';\
}",
              "dataIndex": "MENU_TYPE",
              "text": "菜单类型",
              "titleAlign": "center"
             },
             "expanded": false,
             "children": [],
             "type": "column"
            },
            {
             "configs": {
              "itemId": "parentMenu",
              "hidden": "true",
              "dataIndex": "PARENT_MENU",
              "text": "上级节点",
              "titleAlign": "center"
             },
             "expanded": false,
             "children": [],
             "type": "column"
            },
            {
             "configs": {
              "itemId": "orderIdex",
              "dataIndex": "ORDER_INDEX",
              "text": "排序",
              "align": "right",
              "titleAlign": "center"
             },
             "expanded": false,
             "children": [],
             "type": "column"
            }
           ],
           "type": "array"
          }
         ],
         "type": "grid",
         "events": {"itemclick": "app.parent_menu_id.setValue(record.data.MENU_ID);\
app.gridMenuRes.store.load({\
  params:{parentMenuId:record.data.MENU_ID}\
});"}
        }],
        "type": "panel"
       },
       {
        "configs": {
         "layout": "fit",
         "border": "false",
         "itemId": "panelMenuRes",
         "region": "center",
         "frame": "true"
        },
        "expanded": true,
        "children": [{
         "configs": {
          "itemId": "gridMenuRes",
          "editable": "true"
         },
         "expanded": true,
         "children": [
          {
           "configs": {
            "itemId": "store",
            "autoLoad": "true",
            "url": "m?xwl=admin/wbMenu/selectWbMenuRes"
           },
           "expanded": false,
           "children": [],
           "type": "store"
          },
          {
           "configs": {
            "itemId": "tbar",
            "region": "north"
           },
           "expanded": true,
           "children": [
            {
             "configs": {
              "itemId": "menu_name_res",
              "labelAlign": "right",
              "fieldLabel": "按钮名称",
              "labelWidth": "60"
             },
             "expanded": false,
             "children": [],
             "type": "text"
            },
            {
             "configs": {
              "itemId": "findBtn",
              "text": "查询",
              "iconCls": "search_icon"
             },
             "expanded": false,
             "children": [],
             "type": "item",
             "events": {"click": "console.log(app.menu_name_res.getValue());\
app.gridMenuRes.store.load({\
    params:{parentMenuId:app.parent_menu_id.getValue(),menuNameRes:app.menu_name_res.getValue()}\
});"}
            },
            {
             "configs": {
              "itemId": "addBtn",
              "text": "添加",
              "iconCls": "record_add_icon"
             },
             "expanded": false,
             "children": [],
             "type": "item",
             "events": {"click": "var rec = app.gridMenu.getSelection()[0];\
if (!rec) {\
  Wb.warn('请选择一条菜单功能记录。');\
  return;\
}\
Wb.addEdit(app.gridMenuRes,{PARENT_MENU_ID:app.parent_menu_id.getValue()});"}
            },
            {
             "configs": {
              "itemId": "delBtn",
              "text": "删除",
              "iconCls": "record_delete_icon"
             },
             "expanded": false,
             "children": [],
             "type": "item",
             "events": {"click": "Wb.remove(app.gridMenuRes);"}
            },
            {
             "configs": {
              "itemId": "saveBtn",
              "text": "保存",
              "iconCls": "save_icon"
             },
             "expanded": false,
             "children": [],
             "type": "item",
             "events": {"click": "if (!Wb.verifyGrid(app.gridMenuRes)) //验证数据是否合法\
  return;\
Wb.sync({\
  grid: app.gridMenuRes,\
  url: 'm?xwl=admin/wbMenu/saveWbMenuRes',\
  message: '正在保存中...',\
  success: function(resp) {\
    //ID_FIELD值在后台生成，把返回的ID_FIELD值列表同步到表格中\
    Wb.syncCreate(app.gridMenuRes, Wb.decode(resp.responseText));\
  }\
});\
"}
            },
            {
             "configs": {
              "itemId": "parent_menu_id",
              "hidden": "true"
             },
             "expanded": false,
             "children": [],
             "type": "text"
            }
           ],
           "type": "toolbar"
          },
          {
           "configs": {"itemId": "columns"},
           "expanded": true,
           "children": [
            {
             "configs": {
              "itemId": "id",
              "hidden": "true",
              "dataIndex": "MENU_RES_ID",
              "align": "center",
              "titleAlign": "center"
             },
             "expanded": false,
             "children": [],
             "type": "column"
            },
            {
             "configs": {
              "itemId": "row",
              "xtype": "rownumberer",
              "text": "序号",
              "titleAlign": "center"
             },
             "expanded": true,
             "children": [],
             "type": "column"
            },
            {
             "configs": {
              "itemId": "menuResEname",
              "dataIndex": "MENU_RES_ENAME",
              "text": "英文名称",
              "titleAlign": "center"
             },
             "expanded": true,
             "children": [{
              "configs": {"itemId": "editor"},
              "expanded": false,
              "children": [],
              "type": "text"
             }],
             "type": "column"
            },
            {
             "configs": {
              "itemId": "menuResCname",
              "dataIndex": "MENU_RES_CNAME",
              "text": "中文名称",
              "titleAlign": "center"
             },
             "expanded": true,
             "children": [{
              "configs": {"itemId": "editor"},
              "expanded": false,
              "children": [],
              "type": "text"
             }],
             "type": "column"
            },
            {
             "configs": {
              "itemId": "menuResType",
              "renderer": "if(value=='tbr'){\
  return '按钮';\
}\
if(value=='panel'){\
  return '面板';\
}\
",
              "dataIndex": "MENU_RES_TYPE",
              "text": "类型",
              "titleAlign": "center"
             },
             "expanded": true,
             "children": [{
              "configs": {
               "itemId": "editor",
               "pickList": "[\
  ['tbr','按钮'],['panel','面板']\
]"
              },
              "expanded": false,
              "children": [],
              "type": "combo"
             }],
             "type": "column"
            }
           ],
           "type": "array"
          }
         ],
         "type": "grid"
        }],
        "type": "panel"
       }
      ],
      "type": "panel"
     }
    ],
    "type": "viewport",
    "events": {"afterrender": "// app.navKey = new Ext.KeyNav({\
//   viewport: app.viewport1,\
//   J: {\
//     ctrl: true,\
//     fn: function() {\
//      // app.newBtn.fireEvent('click');\
//     }\
//   }\
// });"}
   }
  ],
  "type": "module",
  "events": {"initialize": "Wb.apply(app, {\
  treeViewConfig: {\
    plugins: {\
      ptype: 'treeviewdragdrop'\
    },\
    listeners: {\
      beforedrop: function(node, data, om, dp, dh) {\
        var i, index, parentNode, parentMenu, selDepts, deptCount = data.records.length;\
        if (dp == 'append') {\
          parentNode = om;\
          index = om.lastChild ? om.lastChild.data.ORDER_INDEX + 1 : 1;\
        } else {\
          parentNode = om.parentNode;\
          index = dp == 'before' ? om.data.ORDER_INDEX : om.data.ORDER_INDEX + 1;\
        }\
        dh.wait = true;\
        parentMenu = parentNode.data.MENU_ID;\
        selDepts = Wb.getData(data.records);\
        i = 0;\
        Wb.each(selDepts, function(item) {\
          item.ORDER_INDEX = index + (i++);\
        });\
        Wb.request({\
          url: 'm?xwl=admin/wbMenu/move',\
          params: {\
            index: index,\
            deptCount: deptCount,\
            parentMenu: parentMenu,\
            selDepts: selDepts\
          },\
          callback: function(a, succ) {\
            if (succ) {\
              dh.processDrop();\
              parentNode.eachChild(function(node) {\
                i = node.data.ORDER_INDEX;\
                if (i >= index)\
                  node.set('ORDER_INDEX', i + deptCount);\
              });\
              i = 0;\
              Wb.each(data.records, function(node) {\
                node.set('PARENT_MENU', parentMenu);\
                node.set('ORDER_INDEX', index + (i++));\
              });\
              app.tree1.setSelection(data.records);\
            } else {\
              dh.cancelDrop();\
            }\
          }\
        });\
      }\
    }\
  },\
  copy: function(text) {\
    // text是复制文本\
    // 创建input元素\
    var el = document.createElement('input');\
    // 给input元素赋值需要复制的文本\
    el.setAttribute('value', text);\
    // 将input元素插入页面\
    document.body.appendChild(el);\
    // 选中input元素的文本\
    el.select();\
    // 复制内容到剪贴板\
    document.execCommand('copy');\
    // 删除input元素\
    document.body.removeChild(el);\
    Wb.tip('路径复制成功');\
  }\
  \
});"}
 }],
 "roles": {"default": 1},
 "title": "菜单维护",
 "iconCls": "menu_icon",
 "inframe": true,
 "pageLink": ""
}