123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779 |
- package com.extUi.form;
- import java.util.ArrayList;
- import java.util.List;
- import com.sysmodel.XFormFactory;
- import com.sysmodel.collectmodel.xmlmodel.impl.ActionImpl;
- import com.sysmodel.collectmodel.xmlmodel.impl.ContainerImpl;
- import com.sysmodel.collectmodel.xmlmodel.impl.FormCollectionImpl;
- import com.sysmodel.collectmodel.xmlmodel.impl.HiddenFieldImpl;
- import com.sysmodel.collectmodel.xmlmodel.impl.ReportFieldImpl;
- import com.sysmodel.collectmodel.xmlmodel.impl.TabItemImpl;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.MdpConstant;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- import com.sysmodel.xformmodel.able.Validate;
- import com.sysmodel.xformmodel.importcontrol.CheckBoxControl;
- import com.sysmodel.xformmodel.importcontrol.RadioControl;
- import com.sysmodel.xformmodel.importcontrol.SelectControl;
- import com.sysmodel.xformmodel.importcontrol.TextAreaControl;
- import com.sysmodel.xformmodel.importcontrol.TreeControl;
- public class FormImpl implements Formable{
- FormCollectionImpl formCollection = null;
- @SuppressWarnings("unused")
- private SysModel sysModel = ModelFactory.getSysmodel();
- /**
- * 生成表单按钮
- */
- public StringBuffer getFormButtonJs(String pageid) {
- StringBuffer sb = new StringBuffer();
- ArrayList<ActionImpl> buttons = formCollection.getPageRoot().getAllActions();
- sb.append(" buttons: [\n");
- for (int i = 0; i < buttons.size(); i++) {
- ActionImpl button = buttons.get(i);
- if (button.getType().equals("save")) {
- sb.append(" {\n");
- sb.append(" text: '保存',\n");
- sb.append(" handler:function(){\n");
- sb.append(" fsf.getForm().submit({\n");
- sb.append(" failure:function(retForm,retAction){\n");
- sb.append(" if(retAction.result&&retAction.result=='1'){\n");
- sb.append(" Ext.MessageBox.alert('提示', '保存数据成功!');\n");
- sb.append(" Win.hide();\n");
- sb.append(" document.location.reload();\n");
- sb.append(" }else if(retAction.result&&retAction.result=='error'){ \n");
- sb.append(" Ext.MessageBox.alert('提示', '保存数据失败!');\n");
- sb.append(" }else {\n");
- sb.append(" Ext.MessageBox.alert('提示', '保存数据出错!');\n");
- sb.append(" }\n");
- sb.append(" },\n");
- sb.append(" waitMsg:'保存中...'\n");
- sb.append(" });\n");
- sb.append(" }\n");
- sb.append(" },\n");
- } else if (button.getType().equals("reset")) {
- sb.append(" {\n");
- sb.append(" text: '重置',\n");
- sb.append(" handler: function(){\n");
- sb.append(" document.forms[0].reset();\n");
- sb.append(" }\n");
- sb.append(" },\n");
- } else if (button.getType().equals("close")) {
- sb.append(" {\n");
- sb.append(" text: '关闭',\n");
- sb.append(" handler: function(){\n");
- sb.append(" Win.hide();\n");
- sb.append(" }\n");
- sb.append(" },\n");
- }
- }
- sb.reverse();
- sb.deleteCharAt(1);
- sb.reverse();
- sb.append(" ]\n");
- return sb;
- }
- /**
- * 生成form表单
- */
- @SuppressWarnings({ "rawtypes", "unused" })
- public StringBuffer getFormJs(String pageid) {
- StringBuffer sb = new StringBuffer();
- formCollection = (FormCollectionImpl) XFormFactory.getXFormModel()
- .getFormCollection(pageid);
- ArrayList containers = formCollection.getPageBody().getAlContainers();
- ArrayList hiddens = formCollection.getPageBody().getAlHiddenFields();
- sb.append("// 私有方法\n");
- sb.append("\n");
- sb.append("/**\n");
- sb.append(" * 生成新增和编辑表单,\n");
- sb.append(" */\n");
- sb.append("var getEditFrom = function() {\n");
- sb.append("// if (_this.editFrom == null) {\n");
- sb.append("_this.editFrom = new Ext.form.FormPanel({\n");
- sb.append("labelWidth : 100,\n");
- sb.append("frame : true,\n");
- sb.append("autoScroll : true,\n");
- sb.append("autoHeight : true,\n");
- sb.append("bodyStyle : 'padding:5px 5px 0',\n");
- sb.append("defaultType : 'textfield',\n");
- sb.append("items : [{\n");
- sb.append("xtype : 'hidden',\n");
- sb.append("name : 'classid',\n");
- sb.append("value : '");
- sb.append(formCollection.getClassid());
- sb.append("'// 表的classid\n");
- sb.append("}, {\n");
- sb.append("xtype : 'hidden',\n");
- sb.append("name : 'FD_OBJECTID");
- sb.append(formCollection.getClassid());
- sb.append("'// 注意添加表的classid\n");
- sb.append("},\n");
- // 生成字段
- sb.append(this.getContaineJs(containers));
- sb.append("],\n");
- sb.append("\n");
- sb.append("buttons : [{\n");
- sb.append("text : '保存',\n");
- sb.append("handler : function() {\n");
- sb.append("\n");
- sb.append("if(_this.editFrom.getForm().isValid()){\n");
- sb.append("var values = _this.editFrom.getForm().getValues();\n");
- sb.append("if (values['FD_OBJECTID' + values['classid']] != '') {\n");
- sb.append("_this.edit(values);\n");
- sb.append("} else {\n");
- sb.append("_this.add(values);\n");
- sb.append("}\n");
- sb.append("}\n");
- sb.append("\n");
- sb.append("}\n");
- sb.append("}, {\n");
- sb.append("text : '重置',\n");
- sb.append("handler : function() {\n");
- sb.append("\n");
- sb.append("var values = _this.editFrom.getForm().getValues();\n");
- sb.append("if (values['FD_OBJECTID' + values['classid']] != '') {\n");
- sb.append("var id = values['FD_OBJECTID'\n");
- sb.append("+ values['classid']];\n");
- sb.append("_this.editFrom.getForm().reset();\n");
- sb.append("_this.editFrom.getForm().loadRecord(record);\n");
- sb.append("} else {\n");
- sb.append("_this.editFrom.getForm().reset();\n");
- sb.append("}\n");
- sb.append("}\n");
- sb.append("}]\n");
- sb.append("});\n");
- sb.append("// }\n");
- sb.append("\n");
- sb.append("}\n");
- return sb;
- }
- /**
- * 生成表单内的容器
- *
- * @param containers
- * @return
- */
- @SuppressWarnings("rawtypes")
- public StringBuffer getContaineJs(ArrayList containers) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < containers.size(); i++) {
- ContainerImpl container = (ContainerImpl) containers.get(i);
- if (container.getXtype().equals("fieldset")) {
- sb.append(getCollapsibleJs(container));
- } else if (container.getXtype().equals("fieldsetcheck")) {
- sb.append(getCheckboxToggleJs(container));
- } else if (container.getXtype().equals("tabpanel")) {
- sb.append(getTabpanelJs(container));
- } else if (container.getXtype().equals("no")) {
- sb.append(getCommonJs(container));
- }
- }
- sb.reverse();
- sb.deleteCharAt(1);
- sb.reverse();
- return sb;
- }
- /**
- * 生成 带checkbox 的fieldset
- *
- * @param container
- * @return
- */
- @SuppressWarnings("rawtypes")
- public StringBuffer getCheckboxToggleJs(ContainerImpl container) {
- StringBuffer sb = new StringBuffer();
- ArrayList fields = container.getObjElements();
- sb.append(" {\n");
- sb.append(" checkboxToggle:true,\n");
- sb.append(" title: '" + container.getTitle() + "',\n");
- sb.append(" autoHeight:" + container.isAutoHeight() + ",\n");
- sb.append(" collapsed: " + container.isCollapsed() + ",\n");
- sb.append(" xtype:'fieldset',\n");
- sb.append(" layout:'column',\n");
- sb.append(" width: 700,\n");
- sb.append(" border:false,\n");
- sb.append(" labelSeparator:':',\n");
- sb.append(" items:[\n");
- sb.append(getFieldJs(fields));
- sb.append(" ]\n");
- sb.append(" },\n");
- return sb;
- }
- /**
- * 生成tabPanel
- *
- * @param container
- * @return
- */
- public StringBuffer getTabpanelJs(ContainerImpl container) {
- StringBuffer sb = new StringBuffer();
- sb.append(" {\n");
- sb.append(" xtype:'tabpanel',\n");
- sb.append(" activeTab: 0,\n");
- sb.append(" deferredRender:false,//设为false,提交的时候才会提交所有tab里的field \n");
- sb.append(" defaults:" + container.getDefaults() + ", \n");
- sb.append(" items:[\n");
- sb.append(getTabJs(container));
- sb.append(" ]\n");
- sb.append(" },\n");
- return sb;
- }
- /**
- * 生成tabpanel 中的 tab
- *
- * @param container
- * @return
- */
- @SuppressWarnings("rawtypes")
- public StringBuffer getTabJs(ContainerImpl container) {
- StringBuffer sb = new StringBuffer();
- ArrayList tabitens = container.getObjElements();
- for (int i = 0; i < tabitens.size(); i++) {
- TabItemImpl tab = (TabItemImpl) tabitens.get(i);
- ArrayList fields = tab.getObjElements();
- sb.append(" {\n");
- sb.append(" title:'" + tab.getTitle() + "',\n");
- sb.append(" layout:'column',\n");
- sb.append(" border:false, \n");
- sb.append(" labelSeparator:':', \n");
- sb.append(" width: 700, \n");
- sb.append(" items:[\n");
- sb.append(getFieldJs(fields));
- sb.append(" ]\n");
- sb.append(" },\n");
- }
- if (sb.indexOf(",") > -1) {
- sb.reverse();
- sb.deleteCharAt(1);
- sb.reverse();
- }
- return sb;
- }
- /**
- * 生成普通panel
- *
- * @param container
- * @return
- */
- public StringBuffer getCommonJs(ContainerImpl container) {
- StringBuffer sb = new StringBuffer();
- ArrayList<?> fields = container.getObjElements();
- sb.append(" {\n");
- sb.append(" layout:'column',\n");
- sb.append(" xtype : 'panel',\n");
- sb.append(" items:[\n");
- sb.append(getFieldJs(fields));
- sb.append(" ]\n");
- sb.append(" },\n");
- return sb;
- }
- /**
- * 生成可收缩的fieldset
- *
- * @param container
- * @return
- */
- @SuppressWarnings("rawtypes")
- public StringBuffer getCollapsibleJs(ContainerImpl container) {
- StringBuffer sb = new StringBuffer();
- ArrayList fields = container.getObjElements();
- sb.append(" {\n");
- sb.append(" title: '" + container.getTitle() + "',\n");
- sb.append(" autoHeight:" + container.isAutoHeight() + ",\n");
- sb.append(" collapsed: " + container.isCollapsed() + ",\n");
- sb.append(" collapsible: true,\n");
- sb.append(" xtype:'fieldset',\n");
- sb.append(" width: 700,\n");
- sb.append(" layout:'column',\n");
- sb.append(" border:false,\n");
- sb.append(" labelSeparator:':',\n");
- sb.append(" items:[\n");
- sb.append(getFieldJs(fields));
- sb.append(" ]\n");
- sb.append(" },\n");
- return sb;
- }
- /**
- * 生成 hiddens
- *
- * @param hiddens
- * @return
- */
- @SuppressWarnings("rawtypes")
- public StringBuffer getHiddenJs(ArrayList hiddens) {
- StringBuffer sb = new StringBuffer();
- String classids = formCollection.getClassid();
- String[] classidStr = classids.split(",");
- for (int i = 0; i < classidStr.length; i++) {
- String classid = classidStr[i];
- sb.append(" {\n");
- sb.append(" xtype:'hidden',\n");
- sb.append(" id:'FD_OBJECTID" + classid + "',\n");
- sb.append(" name: 'FD_OBJECTID" + classid + "'\n");
- sb.append(" },\n");
- }
- for (int i = 0; i < hiddens.size(); i++) {
- HiddenFieldImpl hiddenField = (HiddenFieldImpl) hiddens.get(i);
- sb.append(" {\n");
- sb.append(" xtype:'hidden',\n");
- sb.append(" id:'" + hiddenField.getName() + "_" + hiddenField.getClassid() + "',\n");
- sb.append(" name: '" + hiddenField.getName().toUpperCase() + "_"
- + hiddenField.getClassid() + "',\n");
- sb.append(" value: '" + hiddenField.getValue() + "'\n");
- sb.append(" },\n");
- }
- return sb;
- }
- /**
- * 生成具体字段的js代码,
- *
- * @param fields
- * @return
- */
- @SuppressWarnings("rawtypes")
- public StringBuffer getFieldJs(ArrayList fields) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < fields.size(); i++) {
- ReportFieldImpl field = (ReportFieldImpl) fields.get(i);
- if (field.getControlType().equals("text")) {// 文本框-text
- sb.append(getTextJs(field));
- } else if (field.getControlType().equals("select")) {// 下拉框-commbo
- sb.append(getSelectJs(field));
- } else if (field.getControlType().equals("checkbox")) {// 复选框-checkbox
- sb.append(getCheckboxJs(field));
- } else if (field.getControlType().equals("radio")) {// 单选框-radio
- sb.append(getRadioJs(field));
- } else if (field.getControlType().equals("date")) {// 日期-date
- sb.append(getDateJs(field));
- } else if (field.getControlType().equals("textarea")) {// 文本域-textarea
- sb.append(getTextareaJs(field));
- } else if (field.getControlType().equals("tree")) {// 树形下拉框-commbotree
- sb.append(getTreeJs(field));
- } else if (field.getControlType().equals("datetime")) {// 日期时间-datetime
- sb.append(getDateTimeJs(field));
- } else if (field.getControlType().equals("upload")) {// 上传组件-upload
- // sb.append(getTreeJs(field));
- } else if (field.getControlType().equals("hidden")) {// 隐藏字段-hidden
- // sb.append(getTreeJs(field));
- } else if (field.getControlType().equals("number")) {// 数字框-number
- // sb.append(getTreeJs(field));
- }
- }
- sb.reverse();
- sb.deleteCharAt(1);
- sb.reverse();
- return sb;
- }
- /**
- * 生成文本框
- *
- * @param field
- * @return
- */
- public StringBuffer getTextJs(ReportFieldImpl field) {
- StringBuffer sb = new StringBuffer();
- Validate validate = field.getValidate();
- sb.append(" {\n");
- sb.append(" columnWidth:" + field.getColumnWidth() + ",\n");
- sb.append(" layout: 'form',\n");
- sb.append(" labelWidth:80,\n");
- sb.append(" border:false,\n");
- sb.append(" items: [{\n");
- sb.append(" xtype:'textfield',\n");
- sb.append(" fieldLabel: '" + field.getLabel() + "',\n");
- if (validate != null) {
- if (validate.isNeed()) {
- sb.append(" allowBlank:false,\n");
- } else {
- sb.append(" allowBlank:true,\n");
- }
- if (!validate.getMaxLength().equals("")) {
- sb.append(" maxLength:" + validate.getMaxLength() + ",\n");
- sb.append(" maxLengthText:'最大长度" + validate.getMaxLength() + "',\n");
- }
- // ext中的vtype
- if (validate.getvType() != "") {
- sb.append(" vtype :'" + validate.getvType() + "',\n");
- }
- }
- sb.append(" name: '" + field.getName().toUpperCase() + "_" + field.getClassid()
- + "',\n");
- sb.append(" anchor:'95%'\n");
- sb.append(" }]\n");
- sb.append(" },\n");
- return sb;
- }
- /**
- * 生成日期控件js
- *
- * @param field
- * @return
- */
- public StringBuffer getDateJs(ReportFieldImpl field) {
- StringBuffer sb = new StringBuffer();
- Validate validate = field.getValidate();
- sb.append(" {\n");
- sb.append(" columnWidth:" + field.getColumnWidth() + ",\n");
- sb.append(" layout: 'form',\n");
- sb.append(" labelWidth:80,\n");
- sb.append(" items: [\n");
- sb.append(" {\n");
- sb.append(" fieldLabel: '" + field.getLabel() + "',\n");
- sb.append(" xtype:'datefield',\n");
- sb.append(" editable:false,\n");// 不能手工编辑输入日期值
- sb.append(" name: '" + field.getName().toUpperCase() + "_" + field.getClassid()
- + "', \n");
- sb.append(" anchor:'95%',\n");
- sb.append(" altFormats: 'Y-m-d',\n");
- sb.append(" format:'Y-m-d',\n");
- if (validate != null) {
- if (validate.isNeed()) {
- sb.append(" allowBlank:false,\n");
- } else {
- sb.append(" allowBlank:true,\n");
- }
- }
- sb.append(" border:false\n");
- sb.append(" }\n");
- sb.append(" ]\n");
- sb.append(" },\n");
- return sb;
- }
- /**
- * 生成下拉选择框js
- *
- * @param field
- * @return
- */
- public StringBuffer getSelectJs(ReportFieldImpl field) {
- StringBuffer sb = new StringBuffer();
- sb.append(" {\n");
- sb.append(" columnWidth:" + field.getColumnWidth() + ",\n");
- sb.append(" layout: 'form',\n");
- sb.append(" labelWidth:80,\n");
- sb.append(" border:false,\n");
- sb.append(" items: [\n");
- sb.append(" {\n");
- sb.append(" fieldLabel: '" + field.getLabel() + "',\n");
- sb.append(" anchor:'95%',\n");
- sb.append("xtype: 'combo' , \n");
- sb.append(" hiddenName:'" + field.getName().toUpperCase() + "_" + field.getClassid()
- + "',\n");
- sb.append(" store: {\n");
- sb.append("url : '../ws/sys/constantService/getConstantByName',\n");
- sb.append("autoLoad : true,\n");
- sb.append("baseParams : {name:'");
- SelectControl selectControl = (SelectControl) field.getControl();
- sb.append(selectControl.getConstantName());
- sb.append("'},\n");
- sb.append("xtype: 'jsonstore' , \n");
- sb.append("root : 'constants',\n");
- sb.append("fields : ['name', 'value']\n");
- sb.append("},\n");
- sb.append(" valueField:'name',\n");
- sb.append(" displayField:'value',\n");
- sb.append(" typeAhead: true,\n");
- sb.append(" triggerAction: 'all',\n");
- sb.append("listeners : {\n");
- sb.append(" afterrender : function(obj) {\n");
- sb.append(" obj.getStore().on('load', function() {\n");
- sb.append(" obj.setValue(obj.getValue());\n");
- sb.append(" });\n");
- sb.append(" }\n");
- sb.append("},\n");
- sb.append(" selectOnFocus:true\n");
- sb.append(" }\n");
- sb.append(" ]\n");
- sb.append(" },\n");
- return sb;
- }
- /**
- * 生成日期时间选择控件js
- *
- * @param field
- * @return
- */
- public StringBuffer getDateTimeJs(ReportFieldImpl field) {
- StringBuffer sb = new StringBuffer();
- Validate validate = field.getValidate();
- sb.append(" {\n");
- sb.append(" columnWidth:" + field.getColumnWidth() + ",\n");
- sb.append(" layout: 'form',\n");
- sb.append(" labelWidth:80,\n");
- sb.append(" items: [\n");
- sb.append(" {\n");
- sb.append(" fieldLabel: '" + field.getLabel() + "',\n");
- sb.append(" xtype:'datetimefield',\n");
- sb.append(" editable:false,\n");// 不能手工编辑输入日期值
- sb.append(" name: '" + field.getName().toUpperCase() + "_" + field.getClassid()
- + "', \n");
- sb.append(" anchor:'95%',\n");
- // sb.append(" altFormats: 'Y-m-d',\n");
- // sb.append(" format:'Y-m-d',\n");
- if (validate != null) {
- if (validate.isNeed()) {
- sb.append(" allowBlank:false,\n");
- } else {
- sb.append(" allowBlank:true,\n");
- }
- }
- sb.append(" border:false\n");
- sb.append(" })\n");
- sb.append(" ]\n");
- sb.append(" },\n");
- return sb;
- }
- public StringBuffer getRadioGroupJs(ReportFieldImpl field) {
- StringBuffer sb = new StringBuffer();
- Validate validate = field.getValidate();
- sb.append(" {\n");
- sb.append(" columnWidth:" + field.getColumnWidth() + ",\n");
- sb.append(" layout: 'form',\n");
- sb.append(" labelWidth:80,\n");
- sb.append(" items: [\n");
- sb.append(" {\n");
- sb.append(" fieldLabel: '" + field.getLabel() + "',\n");
- sb.append(" xtype:'radiogroup',\n");
- // sb.append(" editable:false,\n");//不能手工编辑输入日期值
- // sb.append(" name: '" + field.getName() + "_" +
- // field.getClassid()
- // + "', \n");
- sb.append(" anchor:'95%',\n");
- // sb.append(" altFormats: 'Y-m-d',\n");
- // sb.append(" format:'Y-m-d',\n");
- if (validate != null) {
- if (validate.isNeed()) {
- sb.append(" allowBlank:false,\n");
- } else {
- sb.append(" allowBlank:true,\n");
- }
- }
- sb.append(" items: [\n");
- sb.append(this.getRadioJs(field));
- sb.append(" ]\n");
- sb.append(" border:false\n");
- sb.append(" })\n");
- sb.append(" ]\n");
- sb.append(" },\n");
- return sb;
- }
- public StringBuffer getRadioJs(ReportFieldImpl field) {
- RadioControl radioControl = (RadioControl) field.getControl();
- String constantName = radioControl.getConstantName();
- StringBuffer sb = new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- // 二维常量
- MdpConstant twoConstan = sysmodel.getMdpConstantByName(constantName);
- List<String[]> lis = twoConstan.getAllNode();
- for (int i = 0; i < lis.size(); i++) {
- String[] temp = lis.get(i);
- sb.append(" {boxLabel: '" + temp[0] + "', name: '" + field.getName().toUpperCase()
- + "',inputValue: '" + temp[1] + "'},\n");
- }
- sb.deleteCharAt(sb.lastIndexOf(","));
- return sb;
- }
- public StringBuffer getCheckboxGroupJs(ReportFieldImpl field) {
- StringBuffer sb = new StringBuffer();
- Validate validate = field.getValidate();
- sb.append(" {\n");
- sb.append(" columnWidth:" + field.getColumnWidth() + ",\n");
- sb.append(" layout: 'form',\n");
- sb.append(" labelWidth:80,\n");
- sb.append(" items: [\n");
- sb.append(" {\n");
- sb.append(" fieldLabel: '" + field.getLabel() + "',\n");
- sb.append(" xtype:'checkboxgroup',\n");
- // sb.append(" editable:false,\n");//不能手工编辑输入日期值
- // sb.append(" name: '" + field.getName() + "_" +
- // field.getClassid()
- // + "', \n");
- sb.append(" anchor:'95%',\n");
- // sb.append(" altFormats: 'Y-m-d',\n");
- // sb.append(" format:'Y-m-d',\n");
- if (validate != null) {
- if (validate.isNeed()) {
- sb.append(" allowBlank:false,\n");
- } else {
- sb.append(" allowBlank:true,\n");
- }
- }
- sb.append(" items: [\n");
- sb.append(this.getCheckboxJs(field));
- sb.append(" ]\n");
- sb.append(" border:false\n");
- sb.append(" })\n");
- sb.append(" ]\n");
- sb.append(" },\n");
- return sb;
- }
- public StringBuffer getCheckboxJs(ReportFieldImpl field) {
- CheckBoxControl checkBoxControl = (CheckBoxControl) field.getControl();
- String constantName = checkBoxControl.getConstantName();
- StringBuffer sb = new StringBuffer();
- SysModel sysmodel = ModelFactory.getSysmodel();
- // 二维常量
- MdpConstant twoConstan = sysmodel.getMdpConstantByName(constantName);
- List<String[]> lis = twoConstan.getAllNode();
- for (int i = 0; i < lis.size(); i++) {
- String[] temp = lis.get(i);
- sb.append(" {boxLabel: '" + temp[0] + "', name: '" + field.getName().toUpperCase()
- + "',inputValue: '" + temp[1] + "'},\n");
- }
- sb.deleteCharAt(sb.lastIndexOf(","));
- return sb;
- }
- public StringBuffer getTreeJs(ReportFieldImpl field) {
- StringBuffer sb = new StringBuffer();
- sb.append("{\n");
- sb.append(" columnWidth:" + field.getColumnWidth() + ",\n");
- sb.append(" layout : 'form',\n");
- sb.append(" labelWidth : 80,\n");
- sb.append(" border : false,\n");
- sb.append(" items : [new Ext.form.ComboBoxTree({\n");
- sb.append(" hiddenName : '" + field.getName().toLowerCase() + "',\n");
- sb.append(" //allowUnLeafClick : true,//非叶子节点是否可选,默认为falase 不可选\n");
- sb.append(" fieldLabel : '" + field.getLabel() + "',\n");
- sb.append(" tree : new Ext.tree.TreePanel({\n");
- sb.append(" root : new Ext.tree.AsyncTreeNode({\n");
- sb.append(" text : '--选择--',\n");
- sb.append(" id : '1'\n");
- sb.append(" }),\n");
- sb.append(" rootVisible : false,\n");
- sb.append(" border : false,\n");
- sb.append(" loader : new Ext.tree.TreeLoader({\n");
- sb.append(" baseParams : {\n");
- sb.append(" name : '");
- TreeControl selectControl = (TreeControl) field.getControl();
- sb.append(selectControl.getReferenceTable());
- sb.append("'\n");
- sb.append(" },\n");
- sb.append(" dataUrl : '../ws/sys/constantService/getTreeConstantByName',\n");
- sb.append(" requestMethod : 'POST'\n");
- sb.append(" })\n");
- sb.append(" })\n");
- sb.append(" })]\n");
- sb.append("}, \n");
- return sb;
- }
- public StringBuffer getTextareaJs(ReportFieldImpl field) {
- StringBuffer sb = new StringBuffer();
- TextAreaControl textarea = new TextAreaControl();
- if (field.getControl() != null) {
- textarea = (TextAreaControl) field.getControl();
- }
- sb.append(" {\n");
- sb.append(" columnWidth:.99,\n");
- sb.append(" layout: 'form',\n");
- sb.append(" labelWidth:80,\n");
- sb.append(" border:false,\n");
- sb.append(" items :[\n");
- sb.append(" new Ext.form.TextArea({\n");
- sb.append(" fieldLabel: '" + field.getLabel() + "',\n");
- sb.append(" width:" + textarea.getWidth() + ",\n");
- sb.append(" height:" + textarea.getHeight() + ",\n");
- sb.append(" anchor:'95%',\n");
- sb.append(" allowBlank:true,\n");
- sb.append(" hideLabel:false,\n");
- sb.append(" name:'" + field.getName().toUpperCase() + "_" + field.getClassid()
- + "'\n");
- sb.append(" })\n");
- sb.append(" ]\n");
- sb.append(" },\n");
- return sb;
- }
- }
|