{
 "hidden": false,
 "children": [{
  "configs": {"itemId": "module"},
  "expanded": true,
  "children": [
   {
    "configs": {
     "layout": "border",
     "itemId": "select_win",
     "dialog": "true",
     "resizable": "false",
     "autoReset": "true",
     "width": "320",
     "title": "切换用户",
     "height": "240"
    },
    "expanded": true,
    "children": [
     {
      "configs": {
       "itemId": "loginDialog",
       "file": "login-dialog"
      },
      "expanded": false,
      "children": [],
      "type": "xwl"
     },
     {
      "configs": {
       "itemId": "toolbar1",
       "region": "north"
      },
      "expanded": true,
      "children": [
       {
        "configs": {
         "itemId": "newBtn",
         "text": "添加",
         "iconCls": "record_add_icon"
        },
        "expanded": false,
        "children": [],
        "type": "item",
        "events": {"click": "var win=new Ext.window.Window(app._editwin);\
win.show();\
\
"}
       },
       {
        "configs": {
         "itemId": "delBtn",
         "text": "删除",
         "iconCls": "record_delete_icon"
        },
        "expanded": false,
        "children": [],
        "type": "item",
        "events": {"click": "var recs = app.dataviewuser.getSelection();\
if (recs.length) {\
  Wb.confirm('是否确认删除关联？', function() {\
   if(recs[0].data.USER_ID == '{#sys.username#}'){\
     Wb.info(\"不允许删除主关联用户！\");\
     return;\
   }\
    Wb.request({\
      url: 'm?xwl=sys/portal/linkman/delete',\
      params: {\
        USER_ID: recs[0].data.USER_ID\
      },\
      success: function(resp) {\
        app.store.remove(recs);\
      }\
    });\
\
  });\
} else\
  Wb.info('请选择至少一项。');"}
       }
      ],
      "type": "toolbar"
     },
     {
      "configs": {
       "tpl": "<tpl for='.'>\
<div class='wb_item' style='width:80px;text-align:center;'>\
<img src='wb/images/icon/{ICON}.png'>\
<p>{USER_ID}<\/p>\
<\/div>\
<\/tpl>",
       "itemId": "dataviewuser",
       "overItemCls": "wb_hover",
       "itemSelector": "div.wb_item",
       "style": "background:white;",
       "selectedItemCls": "wb_selected",
       "dragSelector": "true",
       "region": "center",
       "autoScroll": "true",
       "multiSelect": "true"
      },
      "expanded": true,
      "children": [{
       "configs": {
        "itemId": "store",
        "autoLoad": "true",
        "url": "m?xwl=sys/portal/linkman/linkSelect"
       },
       "expanded": false,
       "children": [],
       "type": "store"
      }],
      "type": "dataview",
      "events": {"itemdblclick": "var username = record.data.USER_ID; \
app.loginDialog.username.setValue(username);\
app.loginDialog.password.setValue('00');\
app.loginDialog.login();"}
     }
    ],
    "type": "window",
    "events": {"ok": "// var rec = app.select_grid.getSelection()[0];\
// if (!rec) {\
//   Wb.warn('请选择用户。');\
//   return;\
// }\
\
var recs = app.dataviewuser.getSelection();\
if (recs.length === 0){\
   Wb.warn('请选择用户。');\
  return;\
}\
    var username = Wb.pluck(recs, 'USER_ID');\
// var username = app.select_grid.getSelection()[0].data.USER_ID;\
// // alert(username);\
app.loginDialog.username.setValue(username);\
app.loginDialog.password.setValue('00');\
app.loginDialog.login();"}
   },
   {
    "configs": {
     "layout": "absolute",
     "itemId": "editwin",
     "dialog": "true",
     "closeAction": "destroy",
     "autoReset": "true",
     "width": "272",
     "height": "128"
    },
    "expanded": true,
    "children": [
     {
      "configs": {
       "itemId": "userid",
       "allowBlank": "false",
       "labelAlign": "right",
       "fieldLabel": "用户名",
       "x": "8",
       "width": "240",
       "keyName": "WB_USER",
       "y": "8",
       "labelWidth": "60",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "combo",
      "events": {"change": "  newValue.toUpperCase();"}
     },
     {
      "configs": {
       "allowBlank": "false",
       "itemId": "password",
       "labelAlign": "right",
       "fieldLabel": "密码",
       "width": "240",
       "x": "8",
       "y": "40",
       "inputType": "password",
       "labelWidth": "60",
       "maxLength": "10",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     }
    ],
    "type": "window",
    "events": {"ok": "// //点击添加按钮的处理过程\
if (!Wb.verify(app.editwin))\
  return;\
//校验密码\
Wb.request({\
  url: 'm?xwl=sys/portal/linkman/verifyPass',\
  params: {\
    username: app.userid.getRawValue(),\
    password: app.password.getValue()\
  },\
  success: function(resp) {\
    var res = resp.responseText;\
    if (res == 'OK') {\
      //插入关联记录\
      Wb.request({\
        url: 'm?xwl=sys/portal/linkman/insert',\
        params: {\
          USER_ID: app.userid.getRawValue()\
        },\
        success: function(resp) {\
          //增加关联用户显示\
          app.store.add({\
            USER_ID: app.userid.getRawValue(),\
            ICON: 'user'\
          })[0].commit();\
\
          app.editwin.close();\
        }\
      });\
    }else{\
      Wb.info('密码错误，无法绑定用户！');\
    }\
  }\
});"}
   }
  ],
  "type": "module",
  "events": {"finalize": "app.loginDialog.main.hide();\
app.loginDialog.linkflag.setValue('1');\
app.loginDialog.username.setValue('2');\
app.loginDialog.password.setValue('2');"}
 }],
 "roles": {"default": 1},
 "title": "关联用户",
 "iconCls": "",
 "inframe": false,
 "pageLink": ""
}