{
 "hidden": false,
 "children": [{
  "configs": {"itemId": "sys.util.wbMenu"},
  "expanded": true,
  "children": [{
   "configs": {
    "layout": "border",
    "itemId": "win",
    "dialog": "false",
    "createInstance": "false",
    "resizable": "true",
    "closeAction": "destroy",
    "width": "800",
    "modal": "true",
    "height": "450",
    "maximizable": "true"
   },
   "expanded": true,
   "children": [
    {
     "configs": {
      "border": "false",
      "itemId": "tree",
      "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', 'MENU_URL','MENU_TYPE']",
       "url": "m?xwl=admin/wbMenu/select"
      },
      "expanded": false,
      "children": [],
      "type": "treestore",
      "events": {"success": "app.setAllNodes(app.tree.getRootNode(), app.MENU_URL.getValue());"}
     }],
     "type": "tree",
     "events": {
      "itemclick": "if(app.editFlag){\
  app.MENU_ID.setValue(record.data.MENU_ID);\
  app.PARENT_MENU.setValue(record.data.PARENT_MENU);\
  app.MENU_NAME.setValue(record.data.MENU_NAME);\
  app.MENU_URL.setValue(record.data.MENU_URL);\
  app.MENU_TYPE.setValue(record.data.MENU_TYPE);\
  app.ORDER_INDEX.setValue(record.data.ORDER_INDEX);\
}else{\
  app.PARENT_MENU.setValue(record.data.MENU_ID);\
  var orderIndex = app.selNode.lastChild ? app.selNode.lastChild.data.ORDER_INDEX + 1 : 1;\
  app.ORDER_INDEX.setValue(orderIndex);\
}\
//app.MENU_NAME.setValue(record.data.MENU_NAME);",
      "selectionchange": "app.selNodes = selected;\
app.selNode = selected[0];"
     }
    },
    {
     "configs": {
      "border": "false",
      "layout": "absolute",
      "itemId": "panelright",
      "width": "464",
      "height": "400"
     },
     "expanded": true,
     "children": [
      {
       "configs": {
        "itemId": "MENU_ID",
        "labelAlign": "right",
        "fieldLabel": "菜单ID",
        "width": "368",
        "x": "48",
        "y": "72",
        "readOnly": "true",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "text"
      },
      {
       "configs": {
        "itemId": "MENU_NAME",
        "allowBlank": "false",
        "labelAlign": "right",
        "fieldLabel": "菜单名称",
        "width": "334",
        "x": "72",
        "y": "104",
        "labelWidth": "60",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "text"
      },
      {
       "configs": {
        "itemId": "PARENT_MENU",
        "labelAlign": "right",
        "fieldLabel": "上级菜单",
        "width": "368",
        "x": "48",
        "y": "40",
        "readOnly": "true",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "text"
      },
      {
       "configs": {
        "itemId": "MENU_URL",
        "labelAlign": "right",
        "fieldLabel": "菜单url",
        "width": "334",
        "x": "72",
        "y": "166",
        "labelWidth": "60",
        "height": "22"
       },
       "expanded": false,
       "children": [],
       "type": "text"
      },
      {
       "configs": {
        "itemId": "MENU_TYPE",
        "labelAlign": "right",
        "pickList": "[\
  ['0','菜单'],['1','功能'],['2','子系统']\
]",
        "fieldLabel": "菜单类型",
        "width": "334",
        "x": "72",
        "y": "134",
        "labelWidth": "60",
        "height": "26"
       },
       "expanded": false,
       "children": [],
       "type": "combo"
      },
      {
       "configs": {
        "itemId": "ORDER_INDEX",
        "labelAlign": "right",
        "fieldLabel": "序号",
        "width": "334",
        "x": "72",
        "y": "198",
        "labelWidth": "60",
        "height": "26"
       },
       "expanded": false,
       "children": [],
       "type": "number"
      },
      {
       "configs": {
        "itemId": "delButton",
        "x": "136",
        "width": "88",
        "y": "328",
        "text": "删除树节点",
        "iconCls": "record_delete_icon",
        "height": "26"
       },
       "expanded": false,
       "children": [],
       "type": "button",
       "events": {"click": " if (app.tree.selModel.isSelected(app.tree.getRootNode())) {\
  Wb.warn('不能删除根节点。');\
  return;\
}\
Wb.confirm('确定要删除选择的部门及其所属的所有子部门吗？', function() {\
  var deptIds = {};\
  Wb.each(app.tree.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.tree);\
    }\
  });\
});\
"}
      },
      {
       "configs": {
        "itemId": "saveBtn",
        "x": "232",
        "width": "88",
        "y": "328",
        "text": "保存",
        "height": "26"
       },
       "expanded": false,
       "children": [],
       "type": "button",
       "events": {"click": "if(Wb.isEmpty(app.PARENT_MENU.getValue())){\
  Wb.warn('请选择树节点！');\
  return;\
}\
if(Wb.isEmpty(app.MENU_NAME.getValue())){\
  Wb.warn('菜单名称不能为空！');\
  return;\
}\
var url = \"m?xwl=admin/wbMenu/insertWbMenu\";\
if(!Wb.isEmpty(app.MENU_ID.getValue())){\
  url = \"m?xwl=admin/wbMenu/updateWbMenu\";\
}\
Wb.request({\
  url: url,\
  params: {\
    MENU_ID : app.MENU_ID.getValue(),\
    MENU_NAME: app.MENU_NAME.getValue(),\
    MENU_URL: app.MENU_URL.getValue(),\
    MENU_TYPE: app.MENU_TYPE.getValue(),\
    PARENT_MENU: app.PARENT_MENU.getValue(),\
    ORDER_INDEX: app.ORDER_INDEX.getValue()\
  },\
  success: function(resp) {\
    app.win.close();\
  }\
});"}
      },
      {
       "configs": {
        "itemId": "closeBtn",
        "x": "328",
        "width": "88",
        "y": "328",
        "text": "关闭",
        "height": "26"
       },
       "expanded": false,
       "children": [],
       "type": "button",
       "events": {"click": "app.win.close();"}
      }
     ],
     "type": "panel"
    }
   ],
   "type": "window",
   "events": {"ok": "// var orderIndex = app.selNode.lastChild ? app.selNode.lastChild.data.ORDER_INDEX + 1 : 1;\
// app.ORDER_INDEX.setValue(orderIndex);\
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.MENU_ID.getValue(),\
    ORDER_INDEX: app.ORDER_INDEX.getValue()\
  },\
  success: function(resp) {\
    win.close();\
  }\
});"}
  }],
  "type": "module",
  "events": {"initialize": "Wb.apply(app, {\
  openFunc: function(raw, path) {\
    showWin();\
    app.MENU_URL.setValue(path.substring(6));\
    app.MENU_NAME.setValue(raw.title);\
    //console.info(Wb.getNode(app.tree.getRootNode()));\
    app.tree.getSelectionModel().select(0);\
    app.MENU_TYPE.setValue('1');\
  },\
  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();\
            }\
          }\
        });\
      }\
    }\
  },\
  setAllNodes:function(node, str){\
    if(!app.editFlag){\
      return;\
    }\
    app.setNodeChecked(node, str);\
    var nodes=node.childNodes;\
    for(var i=0;i<nodes.length;i++){\
      var nodechild = nodes[i];\
      app.setAllNodes(nodechild, str);\
    }\
},\
/**\
 * 设置此节点选中\
 */\
   setNodeChecked:function(child, str){\
      if(child.raw.MENU_URL !==undefined && (child.raw.MENU_URL+\".xwl\").indexOf(str)>-1){\
         app.tree.getSelectionModel().select(child);\
        app.PARENT_MENU.setValue(child.raw.PARENT_MENU);\
        app.MENU_ID.setValue(child.raw.MENU_ID);\
        console.info(child.raw);\
      }\
     \
   }\
});\
\
function showWin() {\
  function doShow() {\
    var sqlWin = new Ext.window.Window(app._win);\
    sqlWin.show();\
  }\
  if (window.CodeMirror)\
    doShow();\
  else {\
    Wb.addLink(['wb/libs/cm/cmirror.css', 'wb/libs/cm/cmirror.js'],\
      doShow\
    );\
  }\
}\
\
 \
\
\
\
"}
 }],
 "roles": {"default": 1},
 "title": "菜单维护(右键弹窗)",
 "iconCls": "menu_icon",
 "inframe": true,
 "pageLink": ""
}