1.员工职位jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
2.员工职位信息js
/**
* @author sux
* @desc 职员调动信息
* @date 2011-02-13
*/
Ext.namespace("hrmsys.jobChange");
var JobChangeInfoPanel = Ext.extend(Ext.grid.GridPanel,{
id: 'jobChangeInfo',
constructor: function(){
Ext.QuickTips.init();
var sm = new Ext.grid.CheckboxSelectionModel();
var number = new Ext.grid.RowNumberer();
//该类用于定义表格的列模型
var cm = new Ext.grid.ColumnModel(\[
number, sm,
{
header: '员工',
dataIndex: 'employee',
align: 'center'
},{
header: '原部门',
dataIndex: 'departmentByJcOldDept',
align: 'center'
},{
header: '原职位',
dataIndex: 'jobByJcOldJob',
align: 'center'
},{
header: '新部门',
dataIndex: 'departmentByJcNewDept',
align: 'center'
},{
header: '新职位',
dataIndex: 'jobByJcNewJob',
align: 'center'
}\]);
jobChangeStore = new Ext.data.JsonStore({
url:'jobChange\_list.action',
root:'root',
totalProperty:'totalProperty',
fields: \['jcId',{name: 'employee', convert: function(v){return v.empName}},
{name: 'departmentByJcNewDept', convert: function(v){return v.deptName}},
{name: 'departmentByJcOldDept', convert: function(v){return v.deptName}},
{name: 'jobByJcNewJob', convert: function(v){return v.jobName}},
{name: 'jobByJcOldJob', convert: function(v){return v.jobName}}\]
});
JobChangeInfoPanel.superclass.constructor.call(this,{
width: Ext.getCmp('mainTab').getActiveTab().getInnerWidth(),
height: Ext.getCmp('mainTab').getActiveTab().getInnerHeight(),
/\*\*表格高度自适应 document.body.clientHeight浏览器页面高度 start\*\*/
monitorResize: true,
doLayout: function() {
this.setWidth(document.body.clientWidth-205);
this.setHeight(document.body.clientHeight-140);
Ext.grid.GridPanel.prototype.doLayout.call(this);
} ,
viewConfig:{
forceFit: true,
enableRowBody:true//是否包含行体
},
//columns:\[{header: 'kk',dataIndex: 'jcId'}\],
cm: cm,
sm: sm,
store: jobChangeStore,
tbar: new Ext.Toolbar({
items:\['条目:',{
width: 80,
xtype: 'combo',
mode: 'local',
store: new Ext.data.SimpleStore({
fields: \['name', 'value'\],
data: \[\['empId','员工工号'\],\['empName','员工姓名'\]\]
}),
displayField: 'value',
valueField: 'name',
id: 'jc\_condition',
triggerAction: 'all',
editable: false
},' 内容:',{
xtype: 'textfield',
id: 'jc\_conditionValue',
width: 80
},{
text: '删除',
id: 'jobch\_delete',
handler: this.jobChangeDelFn
},{
text: '添加',
id: 'jobch\_add',
handler: this.jobChangeAddFn
},{
text: '修改',
id: 'jobch\_update',
handler: this.jobChangeUpdateFn
},{
text: '详情',
id: 'jobch\_detail',
handler: this.jobChangeDetailFn
}\]
}),
bbar: new PagingToolbar(jobChangeStore, 20)
});
jobChangeStore.load({
params: {
start: 0,
limit: 20
}
});
},
//查询
jobChangeQueryFn:function(){
var condition = Ext.getCmp('jc\_condition').getValue();
var conditionValue = Ext.getCmp('jc\_conditionValue').getValue();
jobChangeStore.load({
params: {
condition: condition,
conditionValue: conditionValue,
start: 0,
limit: 20
}
});
},
//添加
jobChangeAddFn:function(){
var jobChangeAddWin = new JobChangeAddWin();
jobChangeAddWin.show();
},
//删除
jobChangeDelFn: function(){
gridDel('jobChangeInfo','jcId','jobChange\_delete.action');
},
//修改
jobChangeUpdateFn:function(){
var jobChangeAddWin = new JobChangeAddWin();
jobChangeAddWin.title = '员工职位变动修改';
var selectionModel = Ext.getCmp('jobChangeInfo').getSelectionModel();
//多条记录
var record = selectionModel.getSelections();
if(record.length!=1){
Ext.Msg.alert('提示','请选择一个');
return;
}
var jcId = record\[0\].get('jcId');
Ext.getCmp('jobChangeaAdd').getForm().load({
url: 'jobChange\_edit.action',
params: {
jcId: jcId
},
success: function(form, action){
var obj = Ext.util.JSON.decode(action.response.responseText);
//Ext.getCmp("jobValue旧职位").setRawValue(obj\[0\].jobByJcOldJob.jobName);
//Ext.getCmp("deptValue旧部门").setRawValue(obj\[0\].departmentByJcOldDept.deptName);
//方法获取的是中选中项的文本text值,
Ext.get('jc\_oldDept').dom.value = obj\[0\].jobByJcOldJob.jobName;
Ext.get('jc\_oldJob').dom.value = obj\[0\].departmentByJcOldDept.deptName;
//,则getValue()返回的是valueFiled的值,getRawValue()返回的则是displayField的值
Ext.getCmp("deptValue新部门").setRawValue(obj\[0\].departmentByJcNewDept.deptName);
Ext.getCmp("jobValue新职位").setRawValue(obj\[0\].jobByJcNewJob.jobName);
}
})
jobChangeAddWin.show();
},
//详情
jobChangeDetailFn:function(){
var jobChangeDetailWin = new JobChangeDetailWin();
var selectionModel = Ext.getCmp('jobChangeInfo').getSelectionModel();
var record = selectionModel.getSelections();
if(record.length != 1){
Ext.Msg.alert('提示','请选择一个');
return;
}
var jcId = record\[0\].get('jcId');
Ext.getCmp('jobChangeaDetail').getForm().load({
url: 'jobChange\_edit.action',
params: {
jcId: jcId
}
})
jobChangeDetailWin.show();
}
});
3.员工添加页面
Ext.namespace("hrmsys.jobChange.add");
/**
* @author sux
* @desc 职员调动录入
* @date 2011-02-13
*/
// 新建窗口
JobChangeAddWin = Ext.extend(Ext.Window, {
id : 'jobChangeAddWinId',
title : '员工职位添加',
constructor : function() {
var jobChangeAddPanel = new JobChangeAddPanel();
JobChangeAddWin.superclass.constructor.call(this, {
resizable : false,
modal : true,
width : 850,
height : 340,
items : [ jobChangeAddPanel ]
})
}
});
// 子面板
var JobChangeAddPanel = Ext.extend(Ext.form.FormPanel, {
id : 'jobChangeaAdd',
constructor : function() {
Ext.QuickTips.init();
var reader = new Ext.data.JsonReader({}, [ {
name : 'jobChange.jcId',
mapping : 'jcId'
}, {
name : 'jobChange.employee.empId',
mapping : 'employee.empId'
}, {
name : 'jobChange.employee.empName',
mapping : 'employee.empName'
}, {
name : 'jobChange.jcReason',
mapping : 'jcReason'
}, {
name : 'jobChange.jcRemark',
mapping : 'jcRemark'
}, {
name : 'jobChange.departmentByJcOldDept.deptId',
mapping : 'departmentByJcOldDept.deptId'
}, {
name : 'jobChange.jobByJcOldJob.jobId',
mapping : 'jobByJcOldJob.jobId'
}, {
name : 'jobChange.departmentByJcNewDept.deptId',
mapping : 'departmentByJcNewDept.deptId'
}, {
name : 'jobChange.jobByJcNewJob.jobId',
mapping : 'jobByJcNewJob.jobId'
} ]);
var oldDeptJC = new DepartJob("旧部门",
"jobChange.departmentByJcOldDept.deptId");
var oldJobJC = new Job("旧职位", "jobChange.jobByJcOldJob.jobId",
oldDeptJC);
oldJobJC.on('expand', function(comboBox) {
var deptId = Ext.getCmp('deptValue旧部门').getValue();
this.getStore().load({
params : {
deptId : deptId
}
})
});
var newDeptJC = new DepartJob("新部门",
"jobChange.departmentByJcNewDept.deptId");
var newJobJC = new Job("新职位", "jobChange.jobByJcNewJob.jobId",
newDeptJC);
newJobJC.on('expand', function(comboBox) {
var deptId = Ext.getCmp("deptValue新部门").getValue();
this.getStore().load({
params : {
deptId : deptId
}
})
});
JobChangeAddPanel.superclass.constructor.call(this, {
// collapsible: true,
// collapsed: true,
frame : true,
titile : '职员调动录入',
labelWidth : 60,
labelAlign : 'right',
reader : reader,
items : \[ {
xtype : 'fieldset',
title : '职员调动录入',
layout : 'table',
layoutConfig : {
columns : 4
},
items : \[
//第一个form
{
layout : 'form',
defaultType : 'textfield',
defaults : {
width : 100
},
width : 200,
//第一个form的元素
items : \[ {
xtype : 'hidden',
name : 'jobChange.jcId'
}, {
fieldLabel : '员工编号',
allowBlank : false,
msgTarget : 'side',
emptyText : '不能为空',
blankText : '请填写员工号',
id : 'jc\_empId',
name : 'jobChange.employee.empId',
listeners : {
'blur' : jcEmpFn
}
}, {
fieldLabel : '原部门',
readOnly : true,
msgTarget : 'side',
blankText : '不能为空',
allowBlank : false,
id : 'jc\_oldDept'
}, {
xtype : 'hidden',
id : 'jc\_oldDeptId',
name : 'jobChange.departmentByJcOldDept.deptId'
} \]
},
//第二个form
{
layout : 'form',
defaultType : 'textfield',
defaults : {
width : 100
},
width : 200,
//第二个form里的元素
items : \[ {
fieldLabel : '员工姓名',
readOnly : true,
id : 'jc\_empName',
name : 'jobChange.employee.empName'
}, {
fieldLabel : '原职位',
readOnly : true,
allowBlank : false,
msgTarget : 'side',
blankText : '不能为空',
id : 'jc\_oldJob'
}, {
xtype : 'hidden',
id : 'jc\_oldJobId',
name : 'jobChange.jobByJcOldJob.jobId'
} \]
},
//第三个form
{
layout : 'form',
defaultType : 'textfield',
defaults : {
width : 100
},
width : 200,
//第三个form元素
items : \[ {
xtype : 'panel',
height : 26
}, newDeptJC \]
},
//第四个form
{
layout : 'form',
defaultType : 'textfield',
defaults : {
width : 100
},
width : 200,
//第四个form元素
items : \[ {
xtype : 'panel',
height : 26
}, newJobJC \]
},
//第五个form
{
layout : 'form',
colspan : 2,
//第五个form元素
items : \[ {
xtype : 'textarea',
fieldLabel : '调动原因',
height : 150,
width : '100%',
name : 'jobChange.jcReason'
} \]
},
//第六个form
{
layout : 'form',
colspan : 2,
//第六个form元素
items : \[ {
xtype : 'textarea',
fieldLabel : '备注',
height : 150,
width : '100%',
name : 'jobChange.jcRemark'
} \]
},
//按钮
{
colspan : 4,
buttonAlign : 'center',
buttons : \[ {
text : '保存',
iconCls : 'save',
handler : saveJCFn
}, {
text : '关闭',
iconCls : 'cancel',
handler : cancelJCFn
} \]
} \]
} \]
})
}
});
//失去焦点
jcEmpFn = function() {
var empId = Ext.get('jc_empId').dom.value;
Ext.Ajax.request({
url : 'emp_unique.action',
success : empJuageSuccessFn,
failure : failureFn,
params : {
empId : empId
}
})
};
//失去焦点请求成功
empJuageSuccessFn = function(response, options) {
if ("" != response.responseText) {
var obj = Ext.util.JSON.decode(response.responseText);
Ext.get('jc_empName').dom.value = obj[0].empName;
Ext.get('jc_oldDept').dom.value = obj[0].department.deptName;
Ext.get('jc_oldJob').dom.value = obj[0].job.jobName;
Ext.get('jc_oldDeptId').dom.value = obj[0].department.deptId;
Ext.get('jc_oldJobId').dom.value = obj[0].job.jobId;
} else {
// 成批设置表单字段为验证无效
Ext.getCmp('jc_empId').markInvalid('此工号不存在');
}
};
//失去焦点请求失败
failureFn = function(respose, options) {
Ext.Msg.alert('提示', '连接后台失败');
};
//保存成功
saveJCFn = function() {
if (!Ext.getCmp('jobChangeaAdd').getForm().isValid()) {
return;
}
Ext.getCmp('jobChangeaAdd').getForm().submit({
url : 'jobChange_save.action',
method : 'post',
waitTitle : '提示',
waitMsg : '正在保存数据…',
success : saveJCSuccessFn,
failure : failureFn
})
};
//保存成功处理
saveJCSuccessFn = function(form, action) {
Ext.Msg.confirm("提示", action.result.msg, function(button, text) {
if (button == "yes") {
Ext.getCmp("jobChangeAddWinId").destory();
Ext.getCmp("jobChangeInfo").getStore().load({
params : {
start : 0,
limit : 20
}
});
}
});
};
//关闭按钮
cancelJCFn = function() {
Ext.getCmp("jobChangeAddWinId").destroy();
};
4.员工详情页面js
Ext.namespace("hrmsys.jobChange.detail");
/**
* @author sux
* @desc 职员调动录入
* @date 2011-02-13
*/
// 新窗口
JobChangeDetailWin = Ext.extend(Ext.Window, {
id : 'jobChangeDetailWinId',
title : '职员变动详情',
constructor : function() {
var jobChangeDetailPanel = new JobChangeDetailPanel();
JobChangeDetailWin.superclass.constructor.call(this, {
// 是否允许改变列宽
resizable : false,
modal : true,
width : 800,
height : 320,
items : \[ jobChangeDetailPanel \]
})
}
});
// 面板
var JobChangeDetailPanel = Ext.extend(Ext.form.FormPanel, {
id : 'jobChangeaDetail',
constructor : function() {
Ext.QuickTips.init();
var reader = new Ext.data.JsonReader({}, [ {
name : 'jobChange.jcId',
mapping : 'jcId'
}, {
name : 'jobChange.employee.empId',
mapping : 'employee.empId'
}, {
name : 'jobChange.employee.empName',
mapping : 'employee.empName'
}, {
name : 'oldDept',
mapping : 'departmentByJcOldDept.deptName'
}, {
name : 'oldJob',
mapping : 'jobByJcOldJob.jobName'
}, {
name : 'newDept',
mapping : 'departmentByJcNewDept.deptName'
}, {
name : 'newJob',
mapping : 'jobByJcNewJob.jobName'
}, {
name : 'jobChange.jcReason',
mapping : 'jcReason'
}, {
name : 'jobChange.jcRemark',
mapping : 'jcRemark'
}, {
name : 'jobChange.jcAddPerson',
mapping : 'jcAddPerson'
}, {
name : 'jobChange.jcDate',
mapping : 'jcDate.time',
dateFormat : 'time',
type : 'date'
} ]);
JobChangeAddPanel.superclass.constructor.call(this, {
// collapsible: true,
// collapsed: true,
frame : true,
titile : '职员调动',
labelWidth : 60,
labelAlign : 'right',
reader : reader,
items : [ {
xtype : 'fieldset',
title : '职员调动',
layout : 'table',
layoutConfig : {
columns : 4
},
items : [ {
layout : 'form',
defaultType : 'textfield',
defaults : {
width : 100
},
width : 200,
items : [ {
xtype : 'hidden',
name : 'jobChange.jcId'
}, {
fieldLabel : '员工编号',
allowBlank : false,
msgTarget : 'side',
blankText : '请填写员工号',
id : 'jc_empId',
name : 'jobChange.employee.empId',
style : 'background: #dfe8f6;',
readOnly : true
}, {
xtye : 'textfield',
style : 'background: #dfe8f6;',
readOnly : true,
fieldLabel : '原部门',
name : 'oldDept'
} ]
}, {
layout : 'form',
defaultType : 'textfield',
defaults : {
width : 100
},
items : [ {
fieldLabel : '员工姓名',
readOnly : true,
id : 'jc_empName',
style : 'background: #dfe8f6;',
readOnly : true,
name : 'jobChange.employee.empName'
}, {
xtype : 'textfield',
style : 'background: #dfe8f6;',
readOnly : true,
fieldLabel : '原职位',
name : 'oldJob'
} ]
}, {
layout : 'form',
defaultType : 'textfield',
defaults : {
width : 100
},
items : [ {
xtype : 'textfield',
fieldLabel : '添加人',
name : 'jobChange.jcAddPerson',
style : 'background: #dfe8f6;',
readOnly : true,
height : 26
}, {
xtype : 'textfield',
style : 'background: #dfe8f6;',
readOnly : true,
fieldLabel : '新部门',
name : 'newDept'
} ]
}, {
layout : 'form',
defaultType : 'textfield',
defaults : {
width : 100
},
items : [ {
xtype : 'datefield',
style : 'background: #dfe8f6;',
readOnly : true,
format : 'Y-m-d',
fieldLabel : '添加时间',
name : 'jobChange.jcDate',
height : 26
}, {
xtype : 'textfield',
fieldLabel : '新职位',
style : 'background: #dfe8f6;',
readOnly : true,
name : 'newJob'
} ]
}, {
layout : 'form',
colspan : 2,
items : [ {
xtype : 'textarea',
fieldLabel : '调动原因',
height : 150,
width : '100%',
style : 'background: #dfe8f6;',
readOnly : true,
name : 'jobChange.jcReason'
} ]
}, {
layout : 'form',
colspan : 2,
items : [ {
xtype : 'textarea',
fieldLabel : '备注',
height : 150,
style : 'background: #dfe8f6;',
readOnly : true,
width : '100%',
name : 'jobChange.jcRemark'
} ]
}, {
colspan : 4,
buttonAlign : 'center',
buttons : [ {
text : '关闭',
iconCls : 'cancel',
handler : function() {
Ext.getCmp("jobChangeDetailWinId").destroy();
}
} ]
} ]
} \]
})
}
});
手机扫一扫
移动阅读更方便
你可能感兴趣的文章