{
 "hidden": false,
 "children": [{
  "configs": {"itemId": "module"},
  "expanded": true,
  "children": [
   {
    "configs": {
     "layout": "absolute",
     "itemId": "editWin",
     "focusControl": "EMPLOYEE_CODE",
     "editWin": "true",
     "width": "576",
     "height": "440"
    },
    "expanded": true,
    "children": [
     {
      "configs": {
       "allowBlank": "false",
       "itemId": "EMPLOYEE_CODE",
       "isLowerCase": "true",
       "labelAlign": "right",
       "fieldLabel": "*员工编号",
       "width": "264",
       "x": "0",
       "y": "24",
       "isUpperCase": "true",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "allowBlank": "false",
       "itemId": "REAL_NAME",
       "labelAlign": "right",
       "fieldLabel": "*姓名",
       "width": "264",
       "x": "272",
       "y": "24",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "allowBlank": "false",
       "itemId": "BIRTH_DATE",
       "labelAlign": "right",
       "fieldLabel": "*出生日期",
       "width": "264",
       "x": "0",
       "y": "56",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "date"
     },
     {
      "configs": {
       "allowBlank": "false",
       "itemId": "SEX",
       "labelAlign": "right",
       "fieldLabel": "*性别",
       "keyName": "sex",
       "width": "264",
       "x": "272",
       "y": "56",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "combo"
     },
     {
      "configs": {
       "itemId": "NATION",
       "labelAlign": "right",
       "fieldLabel": "民族",
       "keyName": "nation",
       "width": "264",
       "x": "0",
       "y": "88",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "combo"
     },
     {
      "configs": {
       "itemId": "EMAIL",
       "vtype": "email",
       "labelAlign": "right",
       "fieldLabel": "电子邮件",
       "width": "264",
       "x": "272",
       "y": "88",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "text"
     },
     {
      "configs": {
       "itemId": "VACATION_HOURS",
       "minValue": "0",
       "labelAlign": "right",
       "fieldLabel": "休假时长",
       "width": "264",
       "x": "0",
       "y": "120",
       "height": "22"
      },
      "expanded": false,
      "children": [],
      "type": "number"
     },
     {
      "configs": {
       "itemId": "COMPANY_NAME",
       "labelAlign": "right",
       "bindField": "COMPANY_ID",
       "fieldLabel": "负责公司",
       "width": "264",
       "x": "272",
       "displayField": "COMPANY_NAME",
       "y": "120",
       "height": "22"
      },
      "expanded": false,
      "children": [{
       "configs": {
        "itemId": "store",
        "url": "m?xwl=examples/employee/edit/company-list"
       },
       "expanded": false,
       "children": [],
       "type": "store"
      }],
      "type": "combo"
     },
     {
      "configs": {
       "layout": "fit",
       "itemId": "fieldset1",
       "padding": "8",
       "width": "504",
       "x": "32",
       "y": "152",
       "title": "备注：",
       "height": "208"
      },
      "expanded": false,
      "children": [{
       "configs": {"itemId": "REMARK"},
       "expanded": false,
       "children": [],
       "type": "textarea"
      }],
      "type": "fieldset"
     }
    ],
    "type": "window",
    "events": {"ok": "var values = Wb.getValue(app.editWin);\
if (app.isEdit) {\
  //点击修改按钮的处理过程\
  Wb.request({\
    url: 'm?xwl=examples/employee/dialog/update',\
    params: Wb.applyIf(values, Wb.getData(app.selRec, true)), //合并窗口和记录数据作为参数，后者为默认值\
    success: function() {\
      //把窗口数据更新到选择记录中\
      Wb.update(app.selRec, values);\
      //隐藏对话框，在模块关闭时自动销毁对话框\
      app.editWin.close();\
    }\
  });\
} else {\
  //点击添加按钮的处理过程\
  Wb.request({\
    url: 'm?xwl=examples/employee/dialog/insert',\
    out: app.editWin,\
    params: {\
      DEPT_ID: app.selDept.data.DEPT_ID\
    },\
    success: function(resp) {\
      //把服务器返回的数据合并窗口数据（公司名称等数据）添加到表格中\
      Wb.add(app.grid1, Wb.apply(Wb.decode(resp.responseText), values));\
      //隐藏对话框，在模块关闭时自动销毁对话框\
      app.editWin.close();\
    }\
  });\
}"}
   },
   {
    "configs": {
     "layout": "border",
     "itemId": "viewport1"
    },
    "expanded": true,
    "children": [
     {
      "configs": {
       "itemId": "toolbar1",
       "region": "north"
      },
      "expanded": false,
      "children": [
       {
        "configs": {"itemId": "deptid"},
        "expanded": false,
        "children": [],
        "type": "text"
       },
       {
        "configs": {
         "itemId": "newBtn",
         "tooltip": "添加新的记录 (Ctrl+E)",
         "text": "添加",
         "iconCls": "record_add_icon"
        },
        "expanded": false,
        "children": [],
        "type": "item",
        "events": {"click": "if (!app.selDept) {\
  Wb.warn('部门未选择。');\
  return;\
}\
app.editWin.setTitle('添加 - ' + app.selDept.data.DEPT_NAME);\
app.editWin.setIconCls('record_add_icon');\
app.editWin.show();\
app.isEdit = false; //标识是否为添加或修改状态，在editWin的ok事件中用到此属性"}
       },
       {
        "configs": {
         "itemId": "editBtn",
         "tooltip": "修改选择的记录",
         "text": "修改",
         "iconCls": "record_edit_icon"
        },
        "expanded": false,
        "children": [],
        "type": "item",
        "events": {"click": "var sels = app.grid1.getSelection();\
if (sels.length != 1) {\
  Wb.warn('请选择 1 条需要修改的记录。');\
  return;\
}\
app.selRec = sels[0];\
app.editWin.setTitle('修改 - ' + app.selRec.data.REAL_NAME);\
app.editWin.setIconCls('record_edit_icon');\
Wb.setValue(app.editWin, app.selRec.data);\
app.editWin.show();\
app.isEdit = true; //标识是否为添加或修改状态，在editWin的ok事件中用到此属性"}
       },
       {
        "configs": {
         "itemId": "delBtn",
         "tooltip": "删除选择的记录",
         "text": "删除",
         "iconCls": "record_delete_icon"
        },
        "expanded": false,
        "children": [],
        "type": "item",
        "events": {"click": "var sels = app.grid1.getSelection();\
Wb.confirmDo(sels, function() {\
  Wb.request({\
    url: 'm?xwl=examples/employee/dialog/delete',\
    params: {\
      destroy: Wb.getData(sels, true)\
    },\
    success: function() {\
      Wb.remove(app.grid1, sels);\
    }\
  });\
}, 'REAL_NAME');"}
       },
       {
        "configs": {
         "itemId": "item1",
         "text": "-"
        },
        "expanded": false,
        "children": [],
        "type": "item"
       },
       {
        "configs": {
         "itemId": "searchCombo",
         "onTriggerClick": "this.collapse();\
app.grid1.store.load({\
  out: app.toolbar1 //toolbar1内的所有控件值作为参数列表\
});",
         "emptyText": "姓名",
         "triggerCls": "x-form-search-trigger",
         "width": "130",
         "displayField": "REAL_NAME",
         "enterKeyTriggerClick": "true"
        },
        "expanded": true,
        "children": [{
         "configs": {
          "itemId": "store",
          "url": "m?xwl=examples/employee/edit/search"
         },
         "expanded": false,
         "children": [],
         "type": "store"
        }],
        "type": "combo",
        "events": {"select": "Ext.callback(combo.onTriggerClick, combo);"}
       },
       {
        "configs": {
         "itemId": "resetSearchBtn",
         "tooltip": "重置搜索结果",
         "text": "重置搜索",
         "iconCls": "undo_icon"
        },
        "expanded": false,
        "children": [],
        "type": "item",
        "events": {"click": "app.loadData();"}
       }
      ],
      "type": "toolbar"
     },
     {
      "configs": {
       "itemId": "deptTree",
       "file": "m?xwl=examples/employee/public/dept-tree"
      },
      "expanded": false,
      "children": [],
      "type": "xwl"
     },
     {
      "configs": {
       "itemId": "grid1",
       "remotefilter": "true",
       "plugins": "[{ptype:\"gridFilter\"}]",
       "viewConfig": "{\
  plugins: {\
    ptype: 'gridviewdragdrop',\
    ddGroup: 'dept',\
    enableDrop: false\
  }\
}",
       "region": "center",
       "multiSelect": "true"
      },
      "expanded": false,
      "children": [
       {
        "configs": {
         "itemId": "store",
         "remoteSort": "true",
         "sorters": "'EMPLOYEE_CODE'",
         "url": "m?xwl=examples/employee/edit/select"
        },
        "expanded": false,
        "children": [],
        "type": "store",
        "events": {"beforeload": "store.baseParams = {\
　 DEPT_ID:app.deptid.getValue()\
　};"}
       },
       {
        "configs": {"itemId": "columns"},
        "expanded": true,
        "children": [
         {
          "configs": {
           "itemId": "numCol",
           "xtype": "rownumberer"
          },
          "expanded": false,
          "children": [],
          "type": "column"
         },
         {
          "configs": {
           "filter": "true",
           "itemId": "employeeCodeCol",
           "dataIndex": "EMPLOYEE_CODE",
           "width": "80",
           "text": "员工编号"
          },
          "expanded": false,
          "children": [],
          "type": "column"
         },
         {
          "configs": {
           "filter": "true",
           "itemId": "realNameCol",
           "dataIndex": "REAL_NAME",
           "width": "150",
           "text": "姓名"
          },
          "expanded": false,
          "children": [],
          "type": "column"
         },
         {
          "configs": {
           "itemId": "birthDateCol",
           "dataIndex": "BIRTH_DATE",
           "width": "100",
           "text": "出生日期"
          },
          "expanded": false,
          "children": [],
          "type": "column"
         },
         {
          "configs": {
           "filter": "true",
           "itemId": "sexCol",
           "dataIndex": "SEX",
           "keyName": "sex",
           "width": "50",
           "text": "性别"
          },
          "expanded": false,
          "children": [],
          "type": "column"
         },
         {
          "configs": {
           "itemId": "nationCol",
           "dataIndex": "NATION",
           "keyName": "nation",
           "width": "90",
           "text": "民族"
          },
          "expanded": false,
          "children": [],
          "type": "column"
         },
         {
          "configs": {
           "itemId": "emailCol",
           "dataIndex": "EMAIL",
           "width": "150",
           "text": "电子邮件"
          },
          "expanded": false,
          "children": [],
          "type": "column"
         },
         {
          "configs": {
           "filter": "true",
           "itemId": "vacationHoursCol",
           "dataIndex": "VACATION_HOURS",
           "width": "70",
           "format": "#,##0",
           "text": "休假时长",
           "align": "right"
          },
          "expanded": false,
          "children": [],
          "type": "column"
         },
         {
          "configs": {
           "itemId": "companyNAMECol",
           "dataIndex": "COMPANY_NAME",
           "width": "130",
           "text": "负责公司"
          },
          "expanded": false,
          "children": [],
          "type": "column"
         },
         {
          "configs": {
           "itemId": "remarkCol",
           "dataIndex": "REMARK",
           "flex": "1",
           "text": "备注"
          },
          "expanded": false,
          "children": [],
          "type": "column"
         }
        ],
        "type": "array"
       }
      ],
      "type": "grid",
      "events": {"itemdblclick": "app.editBtn.fireEvent('click');"}
     },
     {
      "configs": {"itemId": "grid2"},
      "expanded": true,
      "children": [{
       "configs": {
        "itemId": "store",
        "remoteSort": "true",
        "sorters": "'EMPLOYEE_CODE'",
        "url": "m?xwl=dev/autogenControl/datasource"
       },
       "expanded": false,
       "children": [],
       "type": "store",
       "events": {"beforeload": "store.baseParams = {\
　 DEPT_ID:app.deptid.getValue()\
　};"}
      }],
      "type": "grid"
     },
     {
      "configs": {"itemId": "panel1"},
      "expanded": true,
      "children": [
       {
        "configs": {
         "itemId": "EMPLOYEE_ID",
         "allowBlank": "false",
         "fieldLabel": "EMPLOYEE_ID",
         "maxLength": "13"
        },
        "expanded": false,
        "children": [],
        "type": "text"
       },
       {
        "configs": {
         "itemId": "EMPLOYEE_CODE",
         "allowBlank": "false",
         "fieldLabel": "EMPLOYEE_CODE",
         "maxLength": "5"
        },
        "expanded": false,
        "children": [],
        "type": "text"
       },
       {
        "configs": {
         "itemId": "REAL_NAME",
         "allowBlank": "false",
         "fieldLabel": "REAL_NAME",
         "maxLength": "50"
        },
        "expanded": false,
        "children": [],
        "type": "text"
       },
       {
        "configs": {
         "itemId": "BIRTH_DATE",
         "allowBlank": "false",
         "fieldLabel": "BIRTH_DATE"
        },
        "expanded": false,
        "children": [],
        "type": "datetime"
       },
       {
        "configs": {
         "itemId": "SEX",
         "allowBlank": "false",
         "fieldLabel": "SEX",
         "maxLength": "1"
        },
        "expanded": false,
        "children": [],
        "type": "text"
       },
       {
        "configs": {
         "itemId": "DEPT_ID",
         "allowBlank": "false",
         "fieldLabel": "DEPT_ID",
         "maxLength": "13"
        },
        "expanded": false,
        "children": [],
        "type": "text"
       },
       {
        "configs": {
         "itemId": "NATION",
         "fieldLabel": "NATION",
         "maxLength": "2"
        },
        "expanded": false,
        "children": [],
        "type": "text"
       },
       {
        "configs": {
         "itemId": "EMAIL",
         "fieldLabel": "EMAIL",
         "maxLength": "50"
        },
        "expanded": false,
        "children": [],
        "type": "text"
       },
       {
        "configs": {
         "itemId": "VACATION_HOURS",
         "fieldLabel": "VACATION_HOURS",
         "decimalPrecision": "0"
        },
        "expanded": false,
        "children": [],
        "type": "number"
       },
       {
        "configs": {
         "itemId": "COMPANY_ID",
         "fieldLabel": "COMPANY_ID",
         "maxLength": "13"
        },
        "expanded": false,
        "children": [],
        "type": "text"
       },
       {
        "configs": {
         "itemId": "REMARK",
         "fieldLabel": "REMARK",
         "height": "120"
        },
        "expanded": false,
        "children": [],
        "type": "textarea"
       }
      ],
      "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, {\
  /**\
   * tree1配置拖放事件，允许grid数据拖动到tree以调整人员所属部门。\
   */\
  treeViewConfig: {\
    plugins: {\
      ptype: 'treeviewdragdrop',\
      ddGroup: 'dept',\
      enableDrag: false\
    },\
    listeners: {\
      beforedrop: function(node, data, om, dp, dh) {\
        dh.wait = true;\
        dh.cancelDrop();\
        Wb.request({\
          url: 'm?xwl=examples/employee/edit/change-dept',\
          params: {\
            newDeptId: om.data.DEPT_ID,\
            recs: Wb.getData(data.records)\
          },\
          success: function() {\
            Wb.remove(app.grid1);\
          }\
        });\
      },\
      nodedragover: function(node, dp, data) {\
        return dp == 'append' && app.selectDeptNode != node;\
      }\
    }\
  },\
  /**\
   * 加载指定部门的人员数据。\
   */\
  loadData: function() {\
    if (app.selDept)\
      app.grid1.store.load({\
        params: app.selDept.data\
      });\
  }\
});"}
 }],
 "roles": {"demo": 1},
 "title": "对话框",
 "iconCls": "",
 "inframe": false,
 "pageLink": ""
}