//新增方法
addRecord : function() {
var me =this;
var height = 500; //取得当前屏幕高度
var width = 500; //取得当前屏幕宽度
var content = Ext.create("BeidaSoft.SFJCGL.rcjwgl.bdgl.BdglAddPanel", {
});
var win = new Ext.Window({
layout:'fit',
width:width,
height:height,
closable : false,
modal: true,
closeAction:'destroy',
items:[content],
buttons: []
});
win.show();
win.on("destroy",function(){
me.Reload();
});
},
Ext.define('BeidaSoft.SFJCGL.rcjwgl.bdgl.BdglAddPanel', {
extend : 'Ext.Panel',
autoScroll : true,
border : false,
PKValue : null,
canEdit : true,
parentGrid : null,
category : null,
organizaType : null,
JBID : null,
Currdate : null,
CLDX : null,
PzjgjbCombo : null,
PzjgxzCombo : null,
SfysxCombo : null,
canClose : true,
onPanelSuccessClose : null,
initComponent : function() {
var me = this;
this.addEvents(
// 后台处理事件
'load', 'beforeload',
'save', 'beforesave',
'delete', 'beforedelete',
// 按钮事件
'clickDelete', 'clickSave', 'clickCannel', 'cancel',
'loadform', 'loaddata', 'showdata',
'ready');
this.btnFn = {
"save" : function() {
var table2PanelValues = Ext.getCmp('table2').getForm()
.getValues();
var jgmcValue = table2PanelValues["机构名称"]; // 机构名称
var jgclsjValue = Ext.getCmp("jgclsj").getValue(); // 机构成立时间
var jglsdwValue = table2PanelValues["机构隶属单位"]; // 机构隶属单位
var fgldValue = table2PanelValues["分管领导"]; // 分管领导
var zrsValue = table2PanelValues["总人数"]; // 总人数
var jzbdrsValue = table2PanelValues["集中编队人数"]; // 集中编队人数
var pjbdrsValue = table2PanelValues["派警编队人数"]; // 派警编队人数
var qtrsValue = table2PanelValues["其他人数"]; // 其他人数
if (jgmcValue == '' || jgmcValue == null || jgclsjValue == ''
|| jgclsjValue == null || jglsdwValue == ''
|| jglsdwValue == null || fgldValue == ''
|| fgldValue == null) {
Ext.Msg.show({
title : '提示',
msg : '请将内容添加完整!',
buttons : Ext.Msg.OK,
icon : Ext.window.MessageBox.ERROR
});
return false;
}
if (jgmcValue != '' && jgmcValue.length > 15) {
Ext.Msg.show({
title : '提示',
msg : '机构名称不能超过15字!',
buttons : Ext.Msg.OK,
icon : Ext.window.MessageBox.ERROR
});
return false;
}
if (jglsdwValue != '' && jglsdwValue.length > 33) {
Ext.Msg.show({
title : '提示',
msg : '机构隶属单位不能超过33字!',
buttons : Ext.Msg.OK,
icon : Ext.window.MessageBox.ERROR
});
return false;
}
if (fgldValue != '' && fgldValue.length > 12) {
Ext.Msg.show({
title : '提示',
msg : '分管领导不能超过12字!',
buttons : Ext.Msg.OK,
icon : Ext.window.MessageBox.ERROR
});
return false;
}
var params;
params = {
// 机构名称
SFJC2101 : jgmcValue,
// 机构成立时间
SFJC2107 : jgclsjValue,
// 机构隶属单位
SFJC2106 : jglsdwValue,
// 分管领导
SFJC2105 : fgldValue
}, Ext.Ajax.request({
url : '/sfjcgl/rcjwgl/bdgl/savedata?theme=none',
params : params,
success : function(r) {
var data = Ext.decode(r.responseText);
Ext.Msg.show({
title : '添加',
msg : '操作成功!',
buttons : Ext.Msg.OK,
icon : Ext.window.MessageBox.ERROR
});
me.up("window").close();
Ext.getCmp('table2').form.reset();
me.cleanJBID();
},
failure : function(response) {
Ext.Msg.show({
title : '提示',
msg : '操作失败!',
buttons : Ext.Msg.OK,
icon : Ext.window.MessageBox.ERROR
});
},
strnull : function(response) {
Ext.Msg.show({
title : '提示',
msg : '信息不完善!',
buttons : Ext.Msg.OK,
icon : Ext.window.MessageBox.ERROR
});
}
});
},
"close" : function() {
me.up("window").close();
}
};
// 工具栏
var toolbar1 = Ext.create("Ext.Panel", {
height : 35,
border : false,
width : "100%",
layout : "column",
items : [{
xtype : "panel",
border : 0,
height : 30,
width : 66,
margin : '5 0 0 5',
html : '<div style="color: #ff6600;font-family: 微软雅黑;font-size: 16px;">新增</div>'
}]
});
this.tbar = ['->', {
id : 'formbtSave' + this.id,
text : '确定',
iconCls : "kscp_c_icon_add",
disabled : !this.canEdit,
handler : this.btnFn['save']
}, {
id : 'formbtclose' + this.id,
iconCls : "kscp_c_icon_close",
text : "取消",
disabled : !this.canEdit,
handler : this.btnFn['close']
}];
// 新增
var table3 = Ext.create("Ext.form.FormPanel", {
id : "table3",
width : "100%",
border : false,
layout : "column",
items : [toolbar1]
});
var table2 = Ext.create("Ext.form.FormPanel", {
id : "table2",
width : "100%",
border : false,
layout : {
type : 'table',
columns : 2,
tableAttrs : { // 在这儿控制table标签中的Attrs属性
border : 1,
cellpadding : 0,
cellspacing : 0,
width : '100%',
align : 'center',
style : "border:1px solid #CECECE;border-collapse:collapse;margin:0 auto;text-align:center;"
},
tdAttrs : { // 控制td标签的属性,以上用法都是在ext的api中查到,同样的方式可以给tr添加属性
height : '40px',
style: "border:1px solid #CECECE; border-width:0px 1px 1px 0px;border-collapse:collapse;margin:0 auto;text-align:center;"
}
},
items : [{
text : '机构名称',
xtype : 'label',
colspan : 1,
width : '240',
allowBlank : true,
enableKeyEvents : true,
cellCls : 'labelLeft'
}, {
colspan : 1,
name : "机构名称",
id : 'jgmc',
margin : 10,
height : 24,
width : 200,
xtype : 'textfield',
cellCls : 'label'
}, {
text : '机构成立时间',
xtype : 'label',
colspan : 1,
allowBlank : true,
enableKeyEvents : true,
cellCls : 'labelLeft'
}, {
colspan : 1,
name : "机构成立时间",
allowBlank : false,
format : 'Y-m-d',
margin : 10,
height : 24,
width : 200,
editable : false,
filename : "机构成立时间",
id : 'jgclsj',
xtype : 'datefield',
cellCls : 'label'
}, {
text : '机构隶属单位',
xtype : 'label',
colspan : 1,
allowBlank : true,
enableKeyEvents : true,
cellCls : 'labelLeft'
}, {
colspan : 1,
margin : 10,
name : "机构隶属单位",
height : 24,
width : 200,
id : 'jglsdw',
xtype : 'textfield',
cellCls : 'label'
}, {
text : '分管领导',
xtype : 'label',
colspan : 1,
allowBlank : true,
enableKeyEvents : true,
cellCls : 'labelLeft'
}, {
colspan : 1,
margin : 10,
name : "分管领导",
height : 24,
width : 200,
id : 'fgld',
xtype : 'textfield',
cellCls : 'label'
}, {
text : '总人数',
xtype : 'label',
colspan : 1,
allowBlank : true,
enableKeyEvents : true,
cellCls : 'labelLeft'
}, {
colspan : 1,
margin : 10,
name : "总人数",
height : 24,
width : 200,
id : 'zrs',
value : '0',
xtype : 'textfield',
cellCls : 'label'
}, {
text : '集中编队人数',
xtype : 'label',
colspan : 1,
allowBlank : true,
enableKeyEvents : true,
cellCls : 'labelLeft'
}, {
colspan : 1,
margin : 10,
name : "集中编队人数",
height : 24,
width : 200,
id : 'jzbdrs',
xtype : 'textfield',
value : '0',
cellCls : 'label'
}, {
text : '派警编队人数',
xtype : 'label',
colspan : 1,
allowBlank : true,
enableKeyEvents : true,
cellCls : 'labelLeft'
}, {
colspan : 1,
margin : 10,
name : "派警编队人数",
height : 24,
width : 200,
id : 'pjbdrs',
value : '0',
xtype : 'textfield',
cellCls : 'label'
}, {
text : '其他人数',
xtype : 'label',
colspan : 1,
allowBlank : true,
enableKeyEvents : true,
cellCls : 'labelLeft'
}, {
colspan : 1,
margin : 10,
name : "其他人数",
height : 24,
width : 200,
id : 'qtrs',
value : '0',
xtype : 'textfield',
cellCls : 'label'
}]
});
this.items = [table3, table2];
this.callParent();
},
cleanJBID : function() {
var me = this;
me.JBID = null;
}
});
java文件
//保存处理
@Action public String savedata() {
HttpServletRequest request = ActionContext.getActionContext().getHttpServletRequest();
String jgmcValue = request.getParameter("SFJC2101"); //机构名称
String jgclsjValue = null; //结束时间--
if ("".equals(request.getParameter("SFJC2107")) || request.getParameter("SFJC2107").equals(null)) {
jgclsjValue = request.getParameter("SFJC2107");
} else {
jgclsjValue = request.getParameter("SFJC2107").substring(0, 10);
}
//画面控件值为空处理
if (jgclsjValue == null) {
jgclsjValue = "";
}
String jglsdwValue = request.getParameter("SFJC2106"); //机构隶属单位
String fgldValue = request.getParameter("SFJC2105"); //分管领导
String sql = "";
String idstr = java.util.UUID.randomUUID().toString();
Object[] args = null;
sql = "insert into SFJC21 " + "(SFJC2100,SFJC2101,SFJC2107," + "SFJC2106,SFJC2105,DELETEFLAG)" + " values(?,?,to_date(?, 'yyyy-MM-dd'),?, ?,'0')";
args = new Object[] {
idstr,
jgmcValue,
jgclsjValue,
jglsdwValue,
fgldValue
};
jdbcOperations.update(sql, args);
Map < String,
Object > map = new HashMap < String,
Object > ();
map.put("uuid", idstr);
return Json.encode(map);
}