{
 "hidden": false,
 "children": [{
  "configs": {"itemId": "module"},
  "expanded": true,
  "children": [
   {
    "configs": {
     "layout": "absolute",
     "dialog": "true",
     "itemId": "userWin",
     "focusControl": "USER_NAME",
     "width": "648",
     "iconCls": "user_icon",
     "height": "496"
    },
    "expanded": true,
    "children": [
     {
      "configs": {
       "tagConfigs": "{\
  getValue: function() {\
    var vals = Wb.getValue(this, ['radio1', 'radio2']);\
    if (vals.radio1)\
      return 1;\
    else if (vals.radio2)\
      return 0;\
    else return null;\
  },\
  setValue: function(v) {\
    Wb.setValue(this, {\
      radio1: v == 1,\
      radio2: v === 0\
    });\
  }\
}",
       "layout": "hbox",
       "itemId": "STATUS",
       "labelAlign": "right",
       "fieldLabel": "* 状态",
       "width": "304",
       "x": "320",
       "y": "80",
       "height": "30"
      },
      "expanded": false,
      "children": [
       {
        "configs": {
         "itemId": "radio1",
         "boxLabel": "启用",
         "flex": "1",
         "name": "boolField",
         "checked": "true"
        },
        "expanded": false,
        "children": [],
        "type": "radio"
       },
       {
        "configs": {
         "itemId": "radio2",
         "boxLabel": "停用",
         "flex": "1",
         "name": "boolField"
        },
        "expanded": false,
        "children": [],
        "type": "radio"
       }
      ],
      "type": "fieldcontainer"
     },
     {
      "configs": {
       "allowBlank": "false",
       "itemId": "USER_NAME",
       "labelAlign": "right",
       "normalName": "userName",
       "fieldLabel": "* 用户名称",
       "width": "304",
       "x": "8",
       "y": "16",
       "labelWidth": "80",
       "height": "26"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "allowBlank": "false",
       "itemId": "DISPLAY_NAME",
       "labelAlign": "right",
       "fieldLabel": "* 显示名称",
       "width": "304",
       "x": "320",
       "y": "16",
       "height": "26"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "allowBlank": "false",
       "itemId": "PASSWORD",
       "labelAlign": "right",
       "minLength": "6",
       "fieldLabel": "* 密码",
       "width": "304",
       "x": "8",
       "y": "48",
       "inputType": "password",
       "labelWidth": "80",
       "height": "26"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "allowBlank": "false",
       "itemId": "RE_PASSWORD",
       "labelAlign": "right",
       "minLength": "6",
       "fieldLabel": "* 密码确认",
       "width": "304",
       "x": "320",
       "y": "48",
       "inputType": "password",
       "height": "26"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "itemId": "EMAIL",
       "vtype": "email",
       "labelAlign": "right",
       "fieldLabel": "电子邮件",
       "width": "304",
       "x": "8",
       "y": "80",
       "labelWidth": "80",
       "height": "26"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "itemId": "IC_CARD",
       "labelAlign": "right",
       "fieldLabel": "身份证号",
       "width": "284",
       "x": "344",
       "y": "112",
       "labelWidth": "60",
       "height": "26"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "itemId": "IPHONE",
       "labelAlign": "right",
       "fieldLabel": "手机号",
       "width": "304",
       "x": "8",
       "y": "112",
       "labelWidth": "80",
       "height": "26"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "itemId": "TENANCY_ID",
       "labelAlign": "right",
       "fieldLabel": "租户",
       "keyName": "WB_TENANCY",
       "x": "32",
       "width": "284",
       "y": "144",
       "labelWidth": "55",
       "height": "26"
      },
      "expanded": false,
      "children": [],
      "type": "combo"
     },
     {
      "configs": {
       "itemId": "roleGrid",
       "selType": "checkboxmodel",
       "sortableColumns": "false",
       "simpleSelect": "true",
       "pagingBar": "false",
       "x": "8",
       "width": "616",
       "y": "176",
       "multiSelect": "true",
       "height": "248"
      },
      "expanded": true,
      "children": [{
       "configs": {
        "itemId": "store",
        "remoteSort": "true",
        "autoLoad": "true",
        "pageSize": "-1",
        "url": "m?xwl=admin/user/select-valid-roles"
       },
       "expanded": false,
       "children": [],
       "type": "store"
      }],
      "type": "grid"
     },
     {
      "configs": {
       "itemId": "DEPT_ID",
       "hidden": "true",
       "x": "240",
       "width": "240",
       "y": "296",
       "height": "26"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     }
    ],
    "type": "window",
    "events": {
     "hide": "Wb.reset(win);\
app.roleGrid.selModel.deselectAll();",
     "show": "if (!win.isNew) {\
  app.PASSWORD.setValue('******');\
  app.RE_PASSWORD.setValue('******');\
}",
     "ok": "if (app.PASSWORD.getValue() != app.RE_PASSWORD.getValue()) {\
  Wb.warn('两次密码输入不一致。',\
    function() {\
      app.PASSWORD.focus(true, true);\
    }\
  );\
  return;\
}\
Wb.requestAg({\
  params:{\
    bean : 'PwdCheckService',\
    method: 'execute',\
    pwd : app.PASSWORD.getValue()\
  },\
  success : function(resp){\
    app.userName.setValue(app.userName.getValue());\
\tapp.PASSWORD .setValue( window.btoa(app.PASSWORD.getValue()));\
\tapp.RE_PASSWORD .setValue( window.btoa(app.RE_PASSWORD.getValue()));\
    win.editHandler();\
  }\
});"
    }
   },
   {
    "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','IS_TENANCY']",
        "url": "m?xwl=admin/dept/select"
       },
       "expanded": false,
       "children": [],
       "type": "treestore"
      }],
      "type": "tree",
      "events": {
       "itemclick": "app.deptId.setValue(record.data.DEPT_ID);\
if(Wb.isEmpty(app.deptId.getValue())){\
  app.deptId.setValue(\"-1\");\
}\
app.grid1.store.load({\
    params:{deptId:app.deptId.getValue()}\
});",
       "selectionchange": "app.selNodes = selected;\
app.selNode = selected[0];"
      }
     },
     {
      "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": "app.DEPT_ID.setValue(app.deptId.getValue());\
\
Wb.insert(app.grid1, {\
  win: app.userWin,\
  url: 'm?xwl=admin/user/insert'\
});\
\
\
"}
         },
         {
          "configs": {
           "itemId": "editBtn",
           "tooltip": "修改选择的用户",
           "text": "修改",
           "iconCls": "record_edit_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "var rec = app.grid1.getSelection()[0];\
app.DEPT_ID.setValue(app.deptId.getValue());\
if (rec) {\
  Wb.request({\
    url: 'm?xwl=admin/user/get-roles',\
    params: {\
      USER_ID: rec.data.USER_ID\
    },\
    success: function(resp) {\
      Wb.edit(app.grid1, {\
        win: app._userWin,\
        titleField: 'DISPLAY_NAME',\
        url: 'm?xwl=admin/user/update',\
        success: function() {\
          app.changeUser();\
        }\
      });\
      var roleRec, selRecs = [],\
        roles = Wb.decode(resp.responseText);\
      Wb.each(roles.rows, function(rec) {\
        roleRec = Wb.find(app.roleGrid.store, 'ROLE_ID', rec.ROLE_ID);\
        if (roleRec)\
          selRecs.push(roleRec);\
      });\
      app.roleGrid.setSelection(selRecs);\
      app.USER_NAME.focus(false, true);\
    }\
  });\
} else Wb.edit(app.grid1); //仅用于提示用户选择记录"}
         },
         {
          "configs": {
           "itemId": "delBtn",
           "tooltip": "删除选择的用户",
           "text": "删除",
           "iconCls": "record_delete_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "Wb.del(app.grid1, {\
  url: 'm?xwl=admin/user/delete',\
  titleField: 'DISPLAY_NAME'\
});"}
         },
         {
          "configs": {
           "itemId": "findCombo",
           "onTriggerClick": "this.collapse();\
if (app.selRoleGrid.rendered)\
  app.selRoleGrid.selModel.deselectAll();\
app.grid1.store.load({\
  out: app.mainToolbar\
});",
           "emptyText": "用户名称",
           "triggerCls": "x-form-search-trigger",
           "width": "200",
           "displayField": "USER_NAME",
           "enterKeyTriggerClick": "true"
          },
          "expanded": true,
          "children": [{
           "configs": {
            "itemId": "store",
            "url": "m?xwl=admin/user/user-list"
           },
           "expanded": false,
           "children": [],
           "type": "store"
          }],
          "type": "combo",
          "events": {"select": "app.findCombo.onTriggerClick();"}
         },
         {
          "configs": {
           "itemId": "rolesMenu",
           "hidden": "true",
           "text": "搜索角色",
           "iconCls": "user_group_icon"
          },
          "expanded": false,
          "children": [{
           "configs": {
            "itemId": "selRoleGrid",
            "selType": "checkboxmodel",
            "sortableColumns": "false",
            "simpleSelect": "true",
            "pagingBar": "false",
            "width": "500",
            "multiSelect": "true",
            "height": "230"
           },
           "expanded": true,
           "children": [{
            "configs": {
             "itemId": "store",
             "remoteSort": "true",
             "autoLoad": "true",
             "pageSize": "-1",
             "url": "m?xwl=admin/user/select-all-roles"
            },
            "expanded": false,
            "children": [],
            "type": "store"
           }],
           "type": "grid",
           "events": {"selectionchange": "app.grid1.store.load({\
  out: app.selRoleGrid\
});"}
          }],
          "type": "item"
         },
         {
          "configs": {
           "itemId": "resetFindBtn",
           "hidden": "true",
           "tooltip": "重置搜索条件",
           "text": "重置搜索",
           "iconCls": "undo_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "if (app.selRoleGrid.rendered)\
  app.selRoleGrid.selModel.deselectAll();\
Wb.reset(app.mainToolbar);\
app.grid1.store.load();"}
         },
         {
          "configs": {
           "itemId": "rolesBtn",
           "hidden": "true",
           "tooltip": "查看/隐藏选择用户的角色和权限",
           "text": "角色权限",
           "iconCls": "option_icon"
          },
          "expanded": false,
          "children": [],
          "type": "item",
          "events": {"click": "var notVisible = !app.modules.isVisible();\
app.modules.setVisible(notVisible);\
if (notVisible)\
  app.changeUser();"}
         },
         {
          "configs": {
           "itemId": "deptId",
           "hidden": "true",
           "labelAlign": "right",
           "fieldLabel": "部门ID",
           "labelWidth": "60"
          },
          "expanded": false,
          "children": [],
          "type": "text"
         }
        ],
        "type": "toolbar"
       },
       {
        "configs": {
         "itemId": "grid1",
         "region": "center",
         "multiSelect": "true"
        },
        "expanded": true,
        "children": [
         {
          "configs": {
           "itemId": "store",
           "remoteSort": "true",
           "autoLoad": "true",
           "sorters": "'USER_NAME'",
           "url": "m?xwl=admin/user/select"
          },
          "expanded": false,
          "children": [],
          "type": "store"
         },
         {
          "configs": {"itemId": "columns"},
          "expanded": true,
          "children": [
           {
            "configs": {
             "itemId": "USER_NAME",
             "dataIndex": "USER_NAME",
             "text": "用户名"
            },
            "expanded": false,
            "children": [],
            "type": "column"
           },
           {
            "configs": {
             "itemId": "DISPLAY_NAME",
             "dataIndex": "DISPLAY_NAME",
             "text": "显示名称"
            },
            "expanded": false,
            "children": [],
            "type": "column"
           },
           {
            "configs": {
             "itemId": "col_IPHONE",
             "dataIndex": "IPHONE",
             "text": "手机号"
            },
            "expanded": false,
            "children": [],
            "type": "column"
           },
           {
            "configs": {
             "itemId": "col_IC_CARD",
             "dataIndex": "IC_CARD",
             "text": "身份证号"
            },
            "expanded": false,
            "children": [],
            "type": "column"
           },
           {
            "configs": {
             "itemId": "col_OPEN_ID",
             "dataIndex": "OPEN_ID",
             "text": "OPEN_ID"
            },
            "expanded": false,
            "children": [],
            "type": "column"
           },
           {
            "configs": {
             "itemId": "col_TENANCY_ID",
             "dataIndex": "TENANCY_ID",
             "text": "租户"
            },
            "expanded": false,
            "children": [],
            "type": "column"
           }
          ],
          "type": "array"
         }
        ],
        "type": "grid",
        "events": {
         "selectionchange": "//app.changeUser(selected[0]);",
         "itemdblclick": "app.editBtn.fireEvent('click');"
        }
       }
      ],
      "type": "panel"
     }
    ],
    "type": "viewport",
    "events": {"afterrender": "app.navKey = new Ext.KeyNav({\
  viewport: app.viewport1,\
  E: {\
    ctrl: true,\
    fn: function() {\
      app.newBtn.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;\
          console.info(node.data.path);\
         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": "user_icon",
 "inframe": false,
 "pageLink": ""
}