{
 "hidden": false,
 "children": [{
  "configs": {"itemId": "module"},
  "expanded": true,
  "children": [
   {
    "configs": {
     "layout": "border",
     "itemId": "viewport1"
    },
    "expanded": true,
    "children": [
     {
      "configs": {
       "itemId": "tree1",
       "root": "{\
  text: '全部',\
  MENU_ID: '-1',\
  expanded: true\
}",
       "width": "300",
       "viewConfig": "app.treeViewConfig",
       "region": "west",
       "multiSelect": "true"
      },
      "expanded": true,
      "children": [{
       "configs": {
        "itemId": "store",
        "fields": "['text', 'DEPT_NAME', 'DEPT_ID', 'PARENT_DEPT', 'ORDER_INDEX','GROUP_CODE']",
        "url": "m?xwl=admin/dept/select"
       },
       "expanded": false,
       "children": [],
       "type": "treestore"
      }],
      "type": "tree",
      "events": {
       "itemclick": "app.deptId.setValue(record.data.DEPT_ID);\
//app.tenancyId.setValue(record.data.TENANCY_ID);\
app.gridChild.store.load({\
    params:{deptId:record.data.DEPT_ID}\
});",
       "selectionchange": "app.selNodes = selected;\
app.selNode = selected[0];",
       "itemdblclick": "\
"
      }
     },
     {
      "configs": {
       "layout": "border",
       "itemId": "panel1",
       "region": "center"
      },
      "expanded": true,
      "children": [
       {
        "configs": {
         "itemId": "mainToolbar",
         "region": "north"
        },
        "expanded": true,
        "children": [
         {
          "configs": {
           "itemId": "newBtn",
           "tooltip": "添加新的权限 (Ctrl+E)",
           "text": "添加",
           "iconCls": "record_add_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "if (!app.selNode) {\
  Wb.warn('请选择 1 个部门。');\
  return;\
}\
var win = new Ext.window.Window(app._DeptWin);\
win.show();\
app.deptGrid.store.load({\
  params: {\
    deptId: app.deptId.getValue()\
  }\
});"}
         },
         {
          "configs": {
           "itemId": "delBtn",
           "tooltip": "删除选择的记录",
           "text": "删除",
           "iconCls": "record_delete_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "var sel = app.gridChild.getSelection()[0];\
if (!sel) {\
  Wb.warn(\"请选择要删除的记录\");\
  return;\
}\
Wb.confirm(\"确定要删除该记录吗？\", function() {\
  Wb.request({\
    url: 'm?xwl=admin/dataPerm/delete',\
    params: {\
      ID: sel.data.ID\
    },\
    async: false,\
    success: function(resp) {\
      app.gridChild.store.load({\
        params: {\
          deptId: app.deptId.getValue()\
        }\
      });\
    }\
  });\
});"}
         },
         {
          "configs": {
           "itemId": "findCombo",
           "labelAlign": "right",
           "fieldLabel": "部门",
           "labelWidth": "40"
          },
          "expanded": false,
          "children": [],
          "type": "text"
         },
         {
          "configs": {
           "itemId": "findBtn",
           "text": "查询",
           "iconCls": "seek_icon"
          },
          "expanded": false,
          "children": [],
          "type": "button",
          "events": {"click": "app.gridChild.store.load({\
  params: {deptId:app.deptId.getValue(), findCombo:app.findCombo.getValue()}\
});\
"}
         },
         {
          "configs": {
           "itemId": "deptId",
           "hidden": "true",
           "fieldLabel": "部门id"
          },
          "expanded": false,
          "children": [],
          "type": "text"
         },
         {
          "configs": {
           "itemId": "GROUP_CODE",
           "hidden": "true",
           "fieldLabel": "部门编码"
          },
          "expanded": false,
          "children": [],
          "type": "text"
         }
        ],
        "type": "toolbar"
       },
       {
        "configs": {
         "itemId": "gridChild",
         "region": "center"
        },
        "expanded": true,
        "children": [
         {
          "configs": {
           "itemId": "store",
           "remoteSort": "true",
           "autoLoad": "true",
           "url": "m?xwl=admin/dataPerm/select"
          },
          "expanded": false,
          "children": [],
          "type": "store"
         },
         {
          "configs": {"itemId": "columns"},
          "expanded": true,
          "children": [
           {
            "configs": {
             "itemId": "username",
             "dataIndex": "DATA_DEPT_NAME",
             "width": "200",
             "text": "部门名称",
             "titleAlign": "center"
            },
            "expanded": false,
            "children": [],
            "type": "column"
           },
           {
            "configs": {
             "itemId": "displayName",
             "dataIndex": "DATA_GROUP_CODE",
             "width": "200",
             "text": "部门编码",
             "titleAlign": "center"
            },
            "expanded": false,
            "children": [],
            "type": "column"
           }
          ],
          "type": "array"
         }
        ],
        "type": "grid"
       }
      ],
      "type": "panel"
     }
    ],
    "type": "viewport",
    "events": {"afterrender": "app.navKey = new Ext.KeyNav({\
  viewport: app.viewport1,\
  E: {\
    ctrl: true,\
    fn: function() {\
      app.newBtn.fireEvent('click');\
    }\
  }\
});"}
   },
   {
    "configs": {
     "layout": "absolute",
     "itemId": "DeptWin",
     "dialog": "true",
     "closeAction": "destroy",
     "width": "384",
     "height": "424"
    },
    "expanded": true,
    "children": [{
     "configs": {
      "itemId": "deptGrid",
      "barNavigateButtons": "false",
      "barPageButton": "false",
      "selType": "checkboxmodel",
      "barExportAllButtons": "false",
      "barInfoLabel": "false",
      "x": "0",
      "width": "368",
      "y": "0",
      "barExportButtons": "false",
      "height": "365"
     },
     "expanded": true,
     "children": [
      {
       "configs": {
        "itemId": "store",
        "autoLoad": "false",
        "url": "m?xwl=admin/dataPerm/selectDept"
       },
       "expanded": false,
       "children": [],
       "type": "store"
      },
      {
       "configs": {"itemId": "columns"},
       "expanded": true,
       "children": [
        {
         "configs": {
          "itemId": "col_DEPT_ID",
          "hidden": "true",
          "dataIndex": "DEPT_ID"
         },
         "expanded": false,
         "children": [],
         "type": "column"
        },
        {
         "configs": {
          "itemId": "deptNameCol",
          "dataIndex": "DEPT_NAME",
          "text": "部门名称"
         },
         "expanded": false,
         "children": [],
         "type": "column"
        },
        {
         "configs": {
          "itemId": "DATA_GROUP_CODE_COL",
          "dataIndex": "DATA_GROUP_CODE",
          "text": "部门编号"
         },
         "expanded": false,
         "children": [],
         "type": "column"
        }
       ],
       "type": "array"
      }
     ],
     "type": "grid"
    }],
    "type": "window",
    "events": {"ok": "var sels = app.deptGrid.getSelection(),\
  dataList = [];\
if (sels.length === 0) {\
  Wb.warn(\"请选择要添加的记录\");\
  return;\
}\
Wb.each(sels, function(row) {\
  dataList.push({\
    DEPT_ID: app.deptId.getValue(),\
    DATA_DEPT_ID: row.data.DEPT_ID,\
    DATA_DEPT_NAME: row.data.DEPT_NAME,\
    DATA_GROUP_CODE: row.data.GROUP_CODE\
  });\
});\
Wb.requestAg({\
  params: {\
    bean:'wbDataPermService',\
    method:'save',\
    data: dataList\
  },\
  success: function(resp) {\
    app.DeptWin.close();\
    app.findBtn.fireEvent('click');\
  }\
});"}
   }
  ],
  "type": "module",
  "events": {"initialize": "// Wb.apply(app, {\
//   /**\
//    * 获取所有模块的权限数据。\
//    */\
//   getPerms: function() {\
//     Wb.request({\
//       url: 'm?xwl=admin/user/get-perm',\
//       success: function(resp) {\
//         app.rolesList = Wb.decode(resp.responseText);\
//       }\
//     });\
//   },\
//   //更新当前选择用户的模块权限列表\
//   setModules: function(baseNode) {\
//     var hasPerm, roles, checked, allChecked = true,\
//       allUnchecked = true,\
//       hasAdmin = Wb.indexOf(app.currentRoles, 'admin') != -1,\
//       rolesList = app.rolesList;\
//     Ext.suspendLayouts();\
//     baseNode.eachChild(function(node) {\
//       if (!node.data.depth)\
//         return;\
//       if (node.isLeaf()) {\
//         if (hasAdmin)\
//           hasPerm = true;\
//         else {\
//            hasPerm = true;\
//           /*roles = rolesList[node.data.path];\
//           hasPerm = false;\
//           if (roles && app.currentRoles) {\
//             Wb.each(app.currentRoles, function(role) {\
//               if (roles[role]) {\
//                 hasPerm = true;\
//                 return false;\
//               }\
//             });\
//           }*/\
          \
//         }\
//         Wb.setChecked(node, hasPerm, app.modules, true);\
//         if (hasPerm)\
//           allUnchecked = false;\
//         else\
//           allChecked = false;\
//       } else {\
//         checked = app.setModules(node);\
//         if (checked === null) {\
//           allChecked = false;\
//           allUnchecked = false;\
//         } else if (checked)\
//           allUnchecked = false;\
//         else\
//           allChecked = false;\
//       }\
//     });\
//     if (allChecked)\
//       checked = true;\
//     else if (allUnchecked)\
//       checked = false;\
//     else\
//       checked = null;\
//     Wb.setChecked(baseNode, checked, app.modules, true);\
//     Ext.resumeLayouts(true);\
//     return checked;\
//   },\
//   changeUser: function(rec) {\
//     if (!rec)\
//       rec = app.grid1.getSelection()[0];\
//     if (!app.modules.isVisible())\
//       return;\
//     if (!rec) {\
//       app.currentRoles = null;\
//       app.rolesText.setValue('');\
//       Wb.setTitle(app.modules, '(未选择用户)');\
//       app.setModules(app.modules.getRootNode());\
//       return;\
//     }\
//     if (app.request && app.request.xhr) {\
//       app.noGetRoleError = true;\
//       app.request.xhr.abort();\
//       app.noGetRoleError = false;\
//     }\
//     app.request = Wb.request({\
//       url: 'm?xwl=admin/user/get-role-names',\
//       mask: app.modules,\
//       showError: false,\
//       params: {\
//         USER_ID: rec.data.USER_ID\
//       },\
//       failure: function(resp) {\
//         if (!app.noGetRoleError)\
//           Wb.except(resp);\
//       },\
//       success: function(resp) {\
//         Wb.setTitle(app.modules, rec.data.DISPLAY_NAME);\
//         var rows = Wb.decode(resp.responseText).rows;\
//         app.currentRoles = Ext.Array.pluck(rows, 'ROLE_ID');\
//         app.currentRoles.push('default');\
//         app.rolesText.setValue(Ext.Array.pluck(rows, 'ROLE_NAME').join(', '));\
//         app.setModules(app.modules.getRootNode());\
//       }\
//     });\
//   }\
// });\
// app.getPerms();"}
 }],
 "roles": {"demo": 1},
 "title": "数据权限",
 "iconCls": "aim_icon",
 "inframe": false,
 "pageLink": ""
}