1.员工职位jsp
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme() + "://" 5 + request.getServerName() + ":" + request.getServerPort() 6 + path + "/"; 7 %> 8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 9 <html> 10 <head> 11 <base href="<%=basePath%>"> 12 <title>员工调动</title> 13 <script type="text/javascript"> 14 var jobChange = new JobChangeInfoPanel(); 15 tabId = Ext.getCmp('mainTab').getActiveTab().id.split('_')[1]; 16 juage(tabId, "jobch", jobChange, "jobChangeDiv"); 17 </script> 18 </head> 19 <body> 20 <div id="jobChangeDiv"></div> 21 </body> 22 </html>
2.员工职位信息js
1 /** 2 * @author sux 3 * @desc 职员调动信息 4 * @date 2011-02-13 5 */ 6 Ext.namespace("hrmsys.jobChange"); 7 8 var JobChangeInfoPanel = Ext.extend(Ext.grid.GridPanel,{ 9 id: 'jobChangeInfo', 10 constructor: function(){ 11 Ext.QuickTips.init(); 12 13 var sm = new Ext.grid.CheckboxSelectionModel(); 14 var number = new Ext.grid.RowNumberer(); 15 //该类用于定义表格的列模型 16 var cm = new Ext.grid.ColumnModel([ 17 number, sm, 18 { 19 header: '员工', 20 dataIndex: 'employee', 21 align: 'center' 22 },{ 23 header: '原部门', 24 dataIndex: 'departmentByJcOldDept', 25 align: 'center' 26 },{ 27 header: '原职位', 28 dataIndex: 'jobByJcOldJob', 29 align: 'center' 30 },{ 31 header: '新部门', 32 dataIndex: 'departmentByJcNewDept', 33 align: 'center' 34 },{ 35 header: '新职位', 36 dataIndex: 'jobByJcNewJob', 37 align: 'center' 38 }]); 39 40 41 jobChangeStore = new Ext.data.JsonStore({ 42 url:'jobChange_list.action', 43 root:'root', 44 totalProperty:'totalProperty', 45 fields: ['jcId',{name: 'employee', convert: function(v){return v.empName}}, 46 {name: 'departmentByJcNewDept', convert: function(v){return v.deptName}}, 47 {name: 'departmentByJcOldDept', convert: function(v){return v.deptName}}, 48 {name: 'jobByJcNewJob', convert: function(v){return v.jobName}}, 49 {name: 'jobByJcOldJob', convert: function(v){return v.jobName}}] 50 }); 51 52 JobChangeInfoPanel.superclass.constructor.call(this,{ 53 Ext.getCmp('mainTab').getActiveTab().getInnerWidth(), 54 height: Ext.getCmp('mainTab').getActiveTab().getInnerHeight(), 55 /**表格高度自适应 document.body.clientHeight浏览器页面高度 start**/ 56 monitorResize: true, 57 doLayout: function() { 58 this.setWidth(document.body.clientWidth-205); 59 this.setHeight(document.body.clientHeight-140); 60 Ext.grid.GridPanel.prototype.doLayout.call(this); 61 } , 62 viewConfig:{ 63 forceFit: true, 64 enableRowBody:true//是否包含行体 65 }, 66 //columns:[{header: 'kk',dataIndex: 'jcId'}], 67 cm: cm, 68 sm: sm, 69 store: jobChangeStore, 70 tbar: new Ext.Toolbar({ 71 items:['条目:',{ 72 80, 73 xtype: 'combo', 74 mode: 'local', 75 store: new Ext.data.SimpleStore({ 76 fields: ['name', 'value'], 77 data: [['empId','员工工号'],['empName','员工姓名']] 78 }), 79 displayField: 'value', 80 valueField: 'name', 81 id: 'jc_condition', 82 triggerAction: 'all', 83 editable: false 84 85 },' 内容:',{ 86 xtype: 'textfield', 87 id: 'jc_conditionValue', 88 80 89 },{ 90 text: '删除', 91 id: 'jobch_delete', 92 handler: this.jobChangeDelFn 93 },{ 94 text: '添加', 95 id: 'jobch_add', 96 handler: this.jobChangeAddFn 97 },{ 98 text: '修改', 99 id: 'jobch_update', 100 handler: this.jobChangeUpdateFn 101 },{ 102 text: '详情', 103 id: 'jobch_detail', 104 handler: this.jobChangeDetailFn 105 }] 106 }), 107 bbar: new PagingToolbar(jobChangeStore, 20) 108 }); 109 jobChangeStore.load({ 110 params: { 111 start: 0, 112 limit: 20 113 } 114 }); 115 }, 116 //查询 117 jobChangeQueryFn:function(){ 118 var condition = Ext.getCmp('jc_condition').getValue(); 119 var conditionValue = Ext.getCmp('jc_conditionValue').getValue(); 120 jobChangeStore.load({ 121 params: { 122 condition: condition, 123 conditionValue: conditionValue, 124 start: 0, 125 limit: 20 126 } 127 }); 128 }, 129 //添加 130 jobChangeAddFn:function(){ 131 var jobChangeAddWin = new JobChangeAddWin(); 132 jobChangeAddWin.show(); 133 }, 134 //删除 135 jobChangeDelFn: function(){ 136 gridDel('jobChangeInfo','jcId','jobChange_delete.action'); 137 }, 138 //修改 139 jobChangeUpdateFn:function(){ 140 var jobChangeAddWin = new JobChangeAddWin(); 141 jobChangeAddWin.title = '员工职位变动修改'; 142 var selectionModel = Ext.getCmp('jobChangeInfo').getSelectionModel(); 143 //多条记录 144 var record = selectionModel.getSelections(); 145 if(record.length!=1){ 146 Ext.Msg.alert('提示','请选择一个'); 147 return; 148 } 149 var jcId = record[0].get('jcId'); 150 Ext.getCmp('jobChangeaAdd').getForm().load({ 151 url: 'jobChange_edit.action', 152 params: { 153 jcId: jcId 154 }, 155 success: function(form, action){ 156 var obj = Ext.util.JSON.decode(action.response.responseText); 157 //Ext.getCmp("jobValue旧职位").setRawValue(obj[0].jobByJcOldJob.jobName); 158 //Ext.getCmp("deptValue旧部门").setRawValue(obj[0].departmentByJcOldDept.deptName); 159 //方法获取的是中选中项的文本text值, 160 Ext.get('jc_oldDept').dom.value = obj[0].jobByJcOldJob.jobName; 161 Ext.get('jc_oldJob').dom.value = obj[0].departmentByJcOldDept.deptName; 162 //,则getValue()返回的是valueFiled的值,getRawValue()返回的则是displayField的值 163 Ext.getCmp("deptValue新部门").setRawValue(obj[0].departmentByJcNewDept.deptName); 164 Ext.getCmp("jobValue新职位").setRawValue(obj[0].jobByJcNewJob.jobName); 165 } 166 }) 167 jobChangeAddWin.show(); 168 }, 169 //详情 170 jobChangeDetailFn:function(){ 171 var jobChangeDetailWin = new JobChangeDetailWin(); 172 var selectionModel = Ext.getCmp('jobChangeInfo').getSelectionModel(); 173 var record = selectionModel.getSelections(); 174 if(record.length != 1){ 175 Ext.Msg.alert('提示','请选择一个'); 176 return; 177 } 178 var jcId = record[0].get('jcId'); 179 Ext.getCmp('jobChangeaDetail').getForm().load({ 180 url: 'jobChange_edit.action', 181 params: { 182 jcId: jcId 183 } 184 }) 185 jobChangeDetailWin.show(); 186 } 187 });
3.员工添加页面
1 Ext.namespace("hrmsys.jobChange.add"); 2 3 /** 4 * @author sux 5 * @desc 职员调动录入 6 * @date 2011-02-13 7 */ 8 // 新建窗口 9 JobChangeAddWin = Ext.extend(Ext.Window, { 10 id : 'jobChangeAddWinId', 11 title : '员工职位添加', 12 constructor : function() { 13 var jobChangeAddPanel = new JobChangeAddPanel(); 14 JobChangeAddWin.superclass.constructor.call(this, { 15 resizable : false, 16 modal : true, 17 width : 850, 18 height : 340, 19 items : [ jobChangeAddPanel ] 20 }) 21 } 22 }); 23 // 子面板 24 var JobChangeAddPanel = Ext.extend(Ext.form.FormPanel, { 25 id : 'jobChangeaAdd', 26 constructor : function() { 27 Ext.QuickTips.init(); 28 var reader = new Ext.data.JsonReader({}, [ { 29 name : 'jobChange.jcId', 30 mapping : 'jcId' 31 }, { 32 name : 'jobChange.employee.empId', 33 mapping : 'employee.empId' 34 }, { 35 name : 'jobChange.employee.empName', 36 mapping : 'employee.empName' 37 }, { 38 name : 'jobChange.jcReason', 39 mapping : 'jcReason' 40 }, { 41 name : 'jobChange.jcRemark', 42 mapping : 'jcRemark' 43 }, { 44 name : 'jobChange.departmentByJcOldDept.deptId', 45 mapping : 'departmentByJcOldDept.deptId' 46 }, { 47 name : 'jobChange.jobByJcOldJob.jobId', 48 mapping : 'jobByJcOldJob.jobId' 49 }, { 50 name : 'jobChange.departmentByJcNewDept.deptId', 51 mapping : 'departmentByJcNewDept.deptId' 52 }, { 53 name : 'jobChange.jobByJcNewJob.jobId', 54 mapping : 'jobByJcNewJob.jobId' 55 } ]); 56 57 var oldDeptJC = new DepartJob("旧部门", 58 "jobChange.departmentByJcOldDept.deptId"); 59 var oldJobJC = new Job("旧职位", "jobChange.jobByJcOldJob.jobId", 60 oldDeptJC); 61 62 oldJobJC.on('expand', function(comboBox) { 63 var deptId = Ext.getCmp('deptValue旧部门').getValue(); 64 this.getStore().load({ 65 params : { 66 deptId : deptId 67 } 68 }) 69 }); 70 71 var newDeptJC = new DepartJob("新部门", 72 "jobChange.departmentByJcNewDept.deptId"); 73 var newJobJC = new Job("新职位", "jobChange.jobByJcNewJob.jobId", 74 newDeptJC); 75 76 newJobJC.on('expand', function(comboBox) { 77 var deptId = Ext.getCmp("deptValue新部门").getValue(); 78 this.getStore().load({ 79 params : { 80 deptId : deptId 81 } 82 }) 83 }); 84 85 JobChangeAddPanel.superclass.constructor.call(this, { 86 // collapsible: true, 87 // collapsed: true, 88 frame : true, 89 titile : '职员调动录入', 90 labelWidth : 60, 91 labelAlign : 'right', 92 reader : reader, 93 items : [ { 94 xtype : 'fieldset', 95 title : '职员调动录入', 96 layout : 'table', 97 layoutConfig : { 98 columns : 4 99 }, 100 items : [ 101 //第一个form 102 { 103 layout : 'form', 104 defaultType : 'textfield', 105 defaults : { 106 width : 100 107 }, 108 width : 200, 109 //第一个form的元素 110 items : [ { 111 xtype : 'hidden', 112 name : 'jobChange.jcId' 113 }, { 114 fieldLabel : '员工编号', 115 allowBlank : false, 116 msgTarget : 'side', 117 emptyText : '不能为空', 118 blankText : '请填写员工号', 119 id : 'jc_empId', 120 name : 'jobChange.employee.empId', 121 listeners : { 122 'blur' : jcEmpFn 123 } 124 }, { 125 fieldLabel : '原部门', 126 readOnly : true, 127 msgTarget : 'side', 128 blankText : '不能为空', 129 allowBlank : false, 130 id : 'jc_oldDept' 131 }, { 132 xtype : 'hidden', 133 id : 'jc_oldDeptId', 134 name : 'jobChange.departmentByJcOldDept.deptId' 135 } ] 136 }, 137 //第二个form 138 { 139 layout : 'form', 140 defaultType : 'textfield', 141 defaults : { 142 width : 100 143 }, 144 width : 200, 145 //第二个form里的元素 146 items : [ { 147 fieldLabel : '员工姓名', 148 readOnly : true, 149 id : 'jc_empName', 150 name : 'jobChange.employee.empName' 151 }, { 152 fieldLabel : '原职位', 153 readOnly : true, 154 allowBlank : false, 155 msgTarget : 'side', 156 blankText : '不能为空', 157 id : 'jc_oldJob' 158 }, { 159 xtype : 'hidden', 160 id : 'jc_oldJobId', 161 name : 'jobChange.jobByJcOldJob.jobId' 162 } ] 163 }, 164 //第三个form 165 { 166 layout : 'form', 167 defaultType : 'textfield', 168 defaults : { 169 width : 100 170 }, 171 width : 200, 172 //第三个form元素 173 items : [ { 174 xtype : 'panel', 175 height : 26 176 }, newDeptJC ] 177 }, 178 //第四个form 179 { 180 layout : 'form', 181 defaultType : 'textfield', 182 defaults : { 183 width : 100 184 }, 185 width : 200, 186 //第四个form元素 187 items : [ { 188 xtype : 'panel', 189 height : 26 190 }, newJobJC ] 191 }, 192 //第五个form 193 { 194 layout : 'form', 195 colspan : 2, 196 //第五个form元素 197 items : [ { 198 xtype : 'textarea', 199 fieldLabel : '调动原因', 200 height : 150, 201 width : '100%', 202 name : 'jobChange.jcReason' 203 } ] 204 }, 205 //第六个form 206 { 207 layout : 'form', 208 colspan : 2, 209 //第六个form元素 210 items : [ { 211 xtype : 'textarea', 212 fieldLabel : '备注', 213 height : 150, 214 width : '100%', 215 name : 'jobChange.jcRemark' 216 } ] 217 }, 218 //按钮 219 { 220 colspan : 4, 221 buttonAlign : 'center', 222 buttons : [ { 223 text : '保存', 224 iconCls : 'save', 225 handler : saveJCFn 226 }, { 227 text : '关闭', 228 iconCls : 'cancel', 229 handler : cancelJCFn 230 } ] 231 } ] 232 233 } ] 234 235 }) 236 } 237 }); 238 //失去焦点 239 jcEmpFn = function() { 240 var empId = Ext.get('jc_empId').dom.value; 241 Ext.Ajax.request({ 242 url : 'emp_unique.action', 243 success : empJuageSuccessFn, 244 failure : failureFn, 245 params : { 246 empId : empId 247 } 248 }) 249 }; 250 //失去焦点请求成功 251 empJuageSuccessFn = function(response, options) { 252 if ("" != response.responseText) { 253 var obj = Ext.util.JSON.decode(response.responseText); 254 Ext.get('jc_empName').dom.value = obj[0].empName; 255 Ext.get('jc_oldDept').dom.value = obj[0].department.deptName; 256 Ext.get('jc_oldJob').dom.value = obj[0].job.jobName; 257 Ext.get('jc_oldDeptId').dom.value = obj[0].department.deptId; 258 Ext.get('jc_oldJobId').dom.value = obj[0].job.jobId; 259 } else { 260 // 成批设置表单字段为验证无效 261 Ext.getCmp('jc_empId').markInvalid('此工号不存在'); 262 } 263 }; 264 //失去焦点请求失败 265 failureFn = function(respose, options) { 266 Ext.Msg.alert('提示', '连接后台失败'); 267 }; 268 //保存成功 269 saveJCFn = function() { 270 if (!Ext.getCmp('jobChangeaAdd').getForm().isValid()) { 271 return; 272 } 273 Ext.getCmp('jobChangeaAdd').getForm().submit({ 274 url : 'jobChange_save.action', 275 method : 'post', 276 waitTitle : '提示', 277 waitMsg : '正在保存数据...', 278 success : saveJCSuccessFn, 279 failure : failureFn 280 }) 281 }; 282 //保存成功处理 283 saveJCSuccessFn = function(form, action) { 284 Ext.Msg.confirm("提示", action.result.msg, function(button, text) { 285 if (button == "yes") { 286 Ext.getCmp("jobChangeAddWinId").destory(); 287 Ext.getCmp("jobChangeInfo").getStore().load({ 288 params : { 289 start : 0, 290 limit : 20 291 } 292 }); 293 } 294 }); 295 }; 296 //关闭按钮 297 cancelJCFn = function() { 298 Ext.getCmp("jobChangeAddWinId").destroy(); 299 };
4.员工详情页面js
1 Ext.namespace("hrmsys.jobChange.detail"); 2 3 /** 4 * @author sux 5 * @desc 职员调动录入 6 * @date 2011-02-13 7 */ 8 // 新窗口 9 JobChangeDetailWin = Ext.extend(Ext.Window, { 10 id : 'jobChangeDetailWinId', 11 title : '职员变动详情', 12 constructor : function() { 13 var jobChangeDetailPanel = new JobChangeDetailPanel(); 14 15 JobChangeDetailWin.superclass.constructor.call(this, { 16 // 是否允许改变列宽 17 resizable : false, 18 modal : true, 19 width : 800, 20 height : 320, 21 items : [ jobChangeDetailPanel ] 22 }) 23 } 24 }); 25 // 面板 26 var JobChangeDetailPanel = Ext.extend(Ext.form.FormPanel, { 27 id : 'jobChangeaDetail', 28 constructor : function() { 29 Ext.QuickTips.init(); 30 var reader = new Ext.data.JsonReader({}, [ { 31 name : 'jobChange.jcId', 32 mapping : 'jcId' 33 }, { 34 name : 'jobChange.employee.empId', 35 mapping : 'employee.empId' 36 }, { 37 name : 'jobChange.employee.empName', 38 mapping : 'employee.empName' 39 }, { 40 name : 'oldDept', 41 mapping : 'departmentByJcOldDept.deptName' 42 }, { 43 name : 'oldJob', 44 mapping : 'jobByJcOldJob.jobName' 45 }, { 46 name : 'newDept', 47 mapping : 'departmentByJcNewDept.deptName' 48 }, { 49 name : 'newJob', 50 mapping : 'jobByJcNewJob.jobName' 51 }, { 52 name : 'jobChange.jcReason', 53 mapping : 'jcReason' 54 }, { 55 name : 'jobChange.jcRemark', 56 mapping : 'jcRemark' 57 }, { 58 name : 'jobChange.jcAddPerson', 59 mapping : 'jcAddPerson' 60 }, { 61 name : 'jobChange.jcDate', 62 mapping : 'jcDate.time', 63 dateFormat : 'time', 64 type : 'date' 65 } ]); 66 JobChangeAddPanel.superclass.constructor.call(this, { 67 // collapsible: true, 68 // collapsed: true, 69 frame : true, 70 titile : '职员调动', 71 labelWidth : 60, 72 labelAlign : 'right', 73 reader : reader, 74 items : [ { 75 xtype : 'fieldset', 76 title : '职员调动', 77 layout : 'table', 78 layoutConfig : { 79 columns : 4 80 }, 81 items : [ { 82 layout : 'form', 83 defaultType : 'textfield', 84 defaults : { 85 width : 100 86 }, 87 width : 200, 88 items : [ { 89 xtype : 'hidden', 90 name : 'jobChange.jcId' 91 }, { 92 fieldLabel : '员工编号', 93 allowBlank : false, 94 msgTarget : 'side', 95 blankText : '请填写员工号', 96 id : 'jc_empId', 97 name : 'jobChange.employee.empId', 98 style : 'background: #dfe8f6;', 99 readOnly : true 100 }, { 101 xtye : 'textfield', 102 style : 'background: #dfe8f6;', 103 readOnly : true, 104 fieldLabel : '原部门', 105 name : 'oldDept' 106 } ] 107 }, { 108 layout : 'form', 109 defaultType : 'textfield', 110 defaults : { 111 width : 100 112 }, 113 items : [ { 114 fieldLabel : '员工姓名', 115 readOnly : true, 116 id : 'jc_empName', 117 style : 'background: #dfe8f6;', 118 readOnly : true, 119 name : 'jobChange.employee.empName' 120 }, { 121 xtype : 'textfield', 122 style : 'background: #dfe8f6;', 123 readOnly : true, 124 fieldLabel : '原职位', 125 name : 'oldJob' 126 } ] 127 }, { 128 layout : 'form', 129 defaultType : 'textfield', 130 defaults : { 131 width : 100 132 }, 133 items : [ { 134 xtype : 'textfield', 135 fieldLabel : '添加人', 136 name : 'jobChange.jcAddPerson', 137 style : 'background: #dfe8f6;', 138 readOnly : true, 139 height : 26 140 }, { 141 xtype : 'textfield', 142 style : 'background: #dfe8f6;', 143 readOnly : true, 144 fieldLabel : '新部门', 145 name : 'newDept' 146 } ] 147 }, { 148 layout : 'form', 149 defaultType : 'textfield', 150 defaults : { 151 width : 100 152 }, 153 items : [ { 154 xtype : 'datefield', 155 style : 'background: #dfe8f6;', 156 readOnly : true, 157 format : 'Y-m-d', 158 fieldLabel : '添加时间', 159 name : 'jobChange.jcDate', 160 height : 26 161 }, { 162 xtype : 'textfield', 163 fieldLabel : '新职位', 164 style : 'background: #dfe8f6;', 165 readOnly : true, 166 name : 'newJob' 167 } ] 168 }, { 169 layout : 'form', 170 colspan : 2, 171 items : [ { 172 xtype : 'textarea', 173 fieldLabel : '调动原因', 174 height : 150, 175 width : '100%', 176 style : 'background: #dfe8f6;', 177 readOnly : true, 178 name : 'jobChange.jcReason' 179 } ] 180 }, { 181 layout : 'form', 182 colspan : 2, 183 items : [ { 184 xtype : 'textarea', 185 fieldLabel : '备注', 186 height : 150, 187 style : 'background: #dfe8f6;', 188 readOnly : true, 189 width : '100%', 190 name : 'jobChange.jcRemark' 191 } ] 192 }, { 193 colspan : 4, 194 buttonAlign : 'center', 195 buttons : [ { 196 text : '关闭', 197 iconCls : 'cancel', 198 handler : function() { 199 Ext.getCmp("jobChangeDetailWinId").destroy(); 200 } 201 } ] 202 } ] 203 204 } ] 205 206 }) 207 } 208 });