jeecg 3.6 自定义表单保存问题修复

jeecg-3.6.0
zhangdaiscott 10 years ago
parent 07385b3a0a
commit a902dbd532

@ -244,7 +244,11 @@ public class AutoFormController extends BaseController {
autoForm.setFormContent(html); autoForm.setFormContent(html);
autoForm.setFormParse(autoForm.getFormContent()); autoForm.setFormParse(autoForm.getFormContent());
} }
//--update-begin-------------date:20151102---------for:check 表单编码不允许重复--------------------
//TODO 待实现 //TODO 待实现
//--update-end-------------date:20151102---------for:check 表单编码不允许重复----------------------
autoFormService.save(autoForm); autoFormService.save(autoForm);
attributes.put("id", autoForm.getId()); attributes.put("id", autoForm.getId());
j.setAttributes(attributes); j.setAttributes(attributes);
@ -277,16 +281,18 @@ public class AutoFormController extends BaseController {
map.put(name, name); map.put(name, name);
} }
} }
Elements ids = doc.select("input[name$=.id]"); //update---begin---author:zhoujf------date:20151207---------------for:大小写问题修改-------------------------------
for (Element el: ids) { // Elements ids = doc.select("input[name$=.id]");
String name = el.attr("name"); // for (Element el: ids) {
System.out.println(name); // String name = el.attr("name");
if(map.get(name)!=null){ // System.out.println(name);
throw new BusinessException("主键ID有重复【"+name+"】,编辑器进入HTML模式删除重复的主键"); // if(map.get(name)!=null){
}else{ // throw new BusinessException("主键ID有重复【"+name+"】,编辑器进入HTML模式删除重复的主键");
map.put(name, name); // }else{
} // map.put(name, name);
} // }
// }
//update---end---author:zhoujf------date:20151207---------------for:大小写问题修改-------------------------------
} }
@ -377,7 +383,9 @@ public class AutoFormController extends BaseController {
for(AutoFormDbEntity dbForm:list){ for(AutoFormDbEntity dbForm:list){
map = new HashMap<String,Object>(); map = new HashMap<String,Object>();
map.put("id", dbForm.getId()); map.put("id", dbForm.getId());
//update-begin--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("name", dbForm.getDbChName()+"("+dbForm.getDbName()+")"); map.put("name", dbForm.getDbChName()+"("+dbForm.getDbName()+")");
//update-end--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("dbCode", dbForm.getDbName()); map.put("dbCode", dbForm.getDbName());
map.put("pid", "0"); map.put("pid", "0");
//增加父节点 //增加父节点
@ -388,7 +396,9 @@ public class AutoFormController extends BaseController {
for(AutoFormDbFieldEntity field: fieldlist){ for(AutoFormDbFieldEntity field: fieldlist){
map = new HashMap<String,Object>(); map = new HashMap<String,Object>();
map.put("id", field.getId()); map.put("id", field.getId());
//update-begin--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("name", (StringUtils.isBlank(field.getFieldText())||"null".equals(field.getFieldText()))?field.getFieldName():field.getFieldText()+"("+field.getFieldName()+")"); map.put("name", (StringUtils.isBlank(field.getFieldText())||"null".equals(field.getFieldText()))?field.getFieldName():field.getFieldText()+"("+field.getFieldName()+")");
//update-end--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("pId", dbForm.getId()); map.put("pId", dbForm.getId());
map.put("nocheck",true); map.put("nocheck",true);
dateList.add(map); dateList.add(map);
@ -400,7 +410,9 @@ public class AutoFormController extends BaseController {
for(AutoFormDbFieldEntity field: fieldlist){ for(AutoFormDbFieldEntity field: fieldlist){
map = new HashMap<String,Object>(); map = new HashMap<String,Object>();
map.put("id", field.getId()); map.put("id", field.getId());
//update-begin--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("name", (StringUtils.isBlank(field.getFieldText())||"null".equals(field.getFieldText()))?field.getFieldName():field.getFieldText()+"("+field.getFieldName()+")"); map.put("name", (StringUtils.isBlank(field.getFieldText())||"null".equals(field.getFieldText()))?field.getFieldName():field.getFieldText()+"("+field.getFieldName()+")");
//update-end--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("pId", dbForm.getId()); map.put("pId", dbForm.getId());
map.put("nocheck",true); map.put("nocheck",true);
dateList.add(map); dateList.add(map);
@ -449,11 +461,15 @@ public class AutoFormController extends BaseController {
dsData.put("dsName", db.getDbName()); dsData.put("dsName", db.getDbName());
dsList.add(dsData); dsList.add(dsData);
if("table".equals(db.getDbType())){ if("table".equals(db.getDbType())){
//update-begin--Author: jg_huangxg Date:20151106 for增加字段文本的查询,当字段文本为空时,使用字段名称
String hql = "select new Map(t.fieldName as fieldName,t.fieldText as fieldText) from AutoFormDbFieldEntity t where t.autoFormDbId=?"; String hql = "select new Map(t.fieldName as fieldName,t.fieldText as fieldText) from AutoFormDbFieldEntity t where t.autoFormDbId=?";
//update-end--Author: jg_huangxg Date:20151106 for增加字段文本的查询,当字段文本为空时,使用字段名称
List<Map<String,Object>> columns = this.systemService.findHql(hql, autoFormDbId); List<Map<String,Object>> columns = this.systemService.findHql(hql, autoFormDbId);
dsData.put("columns", columns); dsData.put("columns", columns);
} else if("sql".equals(db.getDbType())){ } else if("sql".equals(db.getDbType())){
//update-begin--Author: jg_huangxg Date:20151106 for增加字段文本的查询,当字段文本为空时,使用字段名称
String hql = "select new Map(t.fieldName as fieldName,t.fieldText as fieldText) from AutoFormDbFieldEntity t where t.autoFormDbId=?"; String hql = "select new Map(t.fieldName as fieldName,t.fieldText as fieldText) from AutoFormDbFieldEntity t where t.autoFormDbId=?";
//update-end--Author: jg_huangxg Date:20151106 for增加字段文本的查询,当字段文本为空时,使用字段名称
List<Map<String,Object>> columns = this.systemService.findHql(hql, autoFormDbId); List<Map<String,Object>> columns = this.systemService.findHql(hql, autoFormDbId);
if(columns.size()>0){ if(columns.size()>0){
dsData.put("columns", columns); dsData.put("columns", columns);
@ -682,10 +698,13 @@ public class AutoFormController extends BaseController {
id = value.toString(); id = value.toString();
} }
hqlTable.append(" where ID ='").append(id).append("'"); hqlTable.append(" where ID ='").append(id).append("'");
//update-start--Author:luobaoli Date:20150701 for如果数据源为空那么以当前上下文中的DB配置为准查询出表数据
if("".equals(formDb.getDbKey())){ if("".equals(formDb.getDbKey())){
//当前上下文中的DB环境获取数据库表中的所有数据 //当前上下文中的DB环境获取数据库表中的所有数据
data = systemService.findForJdbc(hqlTable.toString()); data = systemService.findForJdbc(hqlTable.toString());
} }
//update-end--Author:luobaoli Date:20150701 for如果数据源为空那么以当前上下文中的DB配置为准查询出表数据
else{ else{
DynamicDataSourceEntity dynamicDataSourceEntity = dynamicDataSourceServiceI.getDynamicDataSourceEntityForDbKey(formDb.getDbKey()); DynamicDataSourceEntity dynamicDataSourceEntity = dynamicDataSourceServiceI.getDynamicDataSourceEntityForDbKey(formDb.getDbKey());
if(dynamicDataSourceEntity!=null){ if(dynamicDataSourceEntity!=null){
@ -786,7 +805,9 @@ public class AutoFormController extends BaseController {
if(StringUtils.isNotBlank(dbForm.getAutoFormId())){ if(StringUtils.isNotBlank(dbForm.getAutoFormId())){
List<AutoFormDbEntity> dbFormList = this.systemService.findByProperty(AutoFormDbEntity.class, "autoFormId", dbForm.getAutoFormId()); List<AutoFormDbEntity> dbFormList = this.systemService.findByProperty(AutoFormDbEntity.class, "autoFormId", dbForm.getAutoFormId());
if(dbFormList.size()>0){ if(dbFormList.size()>0){
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请选择数据源</option>"; message = "<option value='' selected='selected'>请选择数据源</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
for(AutoFormDbEntity entity:dbFormList){ for(AutoFormDbEntity entity:dbFormList){
//根据数据源名称进行匹配数据 //根据数据源名称进行匹配数据
message += "<option value='"+entity.getDbName()+"'>"+(StringUtils.isBlank(entity.getDbChName())?entity.getDbName():entity.getDbChName())+"</option>"; message += "<option value='"+entity.getDbName()+"'>"+(StringUtils.isBlank(entity.getDbChName())?entity.getDbName():entity.getDbChName())+"</option>";
@ -795,13 +816,17 @@ public class AutoFormController extends BaseController {
j.setMsg(message); j.setMsg(message);
} else{ } else{
j.setSuccess(false); j.setSuccess(false);
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请先添加数据源</option>"; message = "<option value='' selected='selected'>请先添加数据源</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
j.setMsg(message); j.setMsg(message);
} }
}else{ }else{
//2.如果ID为空则option拼接提示信息 //2.如果ID为空则option拼接提示信息
j.setSuccess(false); j.setSuccess(false);
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请先添加数据源</option>"; message = "<option value='' selected='selected'>请先添加数据源</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
j.setMsg(message); j.setMsg(message);
} }
return j; return j;
@ -821,10 +846,13 @@ public class AutoFormController extends BaseController {
//1.如果ID不为空则拼接option字符串 //1.如果ID不为空则拼接option字符串
//根据数据源名称进行匹配数据 //根据数据源名称进行匹配数据
if(StringUtils.isNotBlank(dbForm.getDbName()) && StringUtils.isNotBlank(dbForm.getAutoFormId())){ if(StringUtils.isNotBlank(dbForm.getDbName()) && StringUtils.isNotBlank(dbForm.getAutoFormId())){
//update-begin--Author:jg_renjie Date:20150723 for数据源根据autoFormId与dbName取数据
String hqlList = "from AutoFormDbEntity t where t.dbName = ? and autoFormId = ?"; String hqlList = "from AutoFormDbEntity t where t.dbName = ? and autoFormId = ?";
List<AutoFormDbEntity> list= this.systemService.findHql(hqlList, dbForm.getDbName(),dbForm.getAutoFormId()); List<AutoFormDbEntity> list= this.systemService.findHql(hqlList, dbForm.getDbName(),dbForm.getAutoFormId());
if(list.size() ==1){ if(list.size() ==1){
dbForm = list.get(0); dbForm = list.get(0);
//update-end--Author:jg_renjie Date:20150723 for数据源根据autoFormId与dbName取数据
//dbForm = this.systemService.findUniqueByProperty(AutoFormDbEntity.class, "dbName", dbForm.getDbName()); //dbForm = this.systemService.findUniqueByProperty(AutoFormDbEntity.class, "dbName", dbForm.getDbName());
List<Map<String,Object>> columns = new ArrayList<Map<String,Object>>(); List<Map<String,Object>> columns = new ArrayList<Map<String,Object>>();
if("table".equals(dbForm.getDbType())){ if("table".equals(dbForm.getDbType())){
@ -843,7 +871,9 @@ public class AutoFormController extends BaseController {
} }
} }
if(columns.size()>0){ if(columns.size()>0){
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请选择字段</option>"; message = "<option value='' selected='selected'>请选择字段</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
for(Map<String,Object> map:columns){ for(Map<String,Object> map:columns){
message += "<option value='"+map.get("fieldName")+"'>"+(StringUtils.isBlank((String)map.get("fieldText"))?map.get("fieldName"):map.get("fieldText")) +"</option>"; message += "<option value='"+map.get("fieldName")+"'>"+(StringUtils.isBlank((String)map.get("fieldText"))?map.get("fieldName"):map.get("fieldText")) +"</option>";
} }
@ -851,18 +881,23 @@ public class AutoFormController extends BaseController {
j.setMsg(message); j.setMsg(message);
} else{ } else{
j.setSuccess(false); j.setSuccess(false);
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请先添加字段</option>"; message = "<option value='' selected='selected'>请先添加字段</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
j.setMsg(message); j.setMsg(message);
} }
}else{ }else{
//2.如果ID为空则option拼接提示信息 //2.如果ID为空则option拼接提示信息
j.setSuccess(false); j.setSuccess(false);
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请先选择数据源</option>"; message = "<option value='' selected='selected'>请先选择数据源</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
j.setMsg(message); j.setMsg(message);
} }
} }
return j; return j;
} }
//add-begin--Author:jg_renjie Date:20150725 for数据源根据autoFormId与dbName取数据,并拼接成tr串
/** /**
* ,table * ,table
* @param dbForm * @param dbForm
@ -880,6 +915,8 @@ public class AutoFormController extends BaseController {
Map<String, Object> attributes = new HashMap<String, Object>(); Map<String, Object> attributes = new HashMap<String, Object>();
if(StringUtils.isNotBlank(dbForm.getDbName()) && StringUtils.isNotBlank(dbForm.getAutoFormId())){ if(StringUtils.isNotBlank(dbForm.getDbName()) && StringUtils.isNotBlank(dbForm.getAutoFormId())){
//update-begin--Author:jg_renjie Date:20150723 for数据源根据autoFormId与dbName取数据
String hqlList = "from AutoFormDbEntity t where t.dbName = ? and autoFormId = ?"; String hqlList = "from AutoFormDbEntity t where t.dbName = ? and autoFormId = ?";
List<AutoFormDbEntity> list= this.systemService.findHql(hqlList, dbForm.getDbName(),dbForm.getAutoFormId()); List<AutoFormDbEntity> list= this.systemService.findHql(hqlList, dbForm.getDbName(),dbForm.getAutoFormId());
if(list.size() ==1){ if(list.size() ==1){
@ -891,6 +928,8 @@ public class AutoFormController extends BaseController {
} else { } else {
attributes.put("dbName", dbForm.getDbName()); attributes.put("dbName", dbForm.getDbName());
} }
//update-end--Author:jg_renjie Date:20150723 for数据源根据autoFormId与dbName取数据
//dbForm = this.systemService.findUniqueByProperty(AutoFormDbEntity.class, "dbName", dbForm.getDbName()); //dbForm = this.systemService.findUniqueByProperty(AutoFormDbEntity.class, "dbName", dbForm.getDbName());
List<Map<String,Object>> columns = new ArrayList<Map<String,Object>>(); List<Map<String,Object>> columns = new ArrayList<Map<String,Object>>();
if("table".equals(dbForm.getDbType())){ if("table".equals(dbForm.getDbType())){
@ -908,6 +947,8 @@ public class AutoFormController extends BaseController {
} }
} }
} }
//update-start--Author:jg_renjie Date:20151107 for优化根据数据源生成数据列
StringBuilder options = null; StringBuilder options = null;
StringBuilder trList = new StringBuilder(); StringBuilder trList = new StringBuilder();
String headStr = ""; String headStr = "";
@ -1049,6 +1090,7 @@ public class AutoFormController extends BaseController {
} else { } else {
message = "<option value=\"\">无字段</option>"; message = "<option value=\"\">无字段</option>";
} }
//update-end--Author:jg_renjie Date:20151107 for优化根据数据源生成数据列
j.setSuccess(true); j.setSuccess(true);
//j.setMsg(message); //j.setMsg(message);
@ -1065,6 +1107,9 @@ public class AutoFormController extends BaseController {
} }
return j; return j;
} }
//add-end--Author:jg_renjie Date:20150725 for数据源根据autoFormId与dbName取数据,并拼接成tr串
//update-start--Author:jg_renjie Date:20151107 for优化根据数据源生成数据列
/** /**
* *
*/ */
@ -1093,6 +1138,7 @@ public class AutoFormController extends BaseController {
j.setMsg(message); j.setMsg(message);
return j; return j;
} }
//update-end--Author:jg_renjie Date:20151107 for优化根据数据源生成数据列
/** /**
* *
@ -1198,6 +1244,7 @@ public class AutoFormController extends BaseController {
j.setMsg(message); j.setMsg(message);
return j; return j;
} }
//update-begin--Author:zzl Date:20151102 for表单编码唯一性验证
@RequestMapping(params = "checkTbCode") @RequestMapping(params = "checkTbCode")
@ResponseBody @ResponseBody
@ -1221,6 +1268,8 @@ public class AutoFormController extends BaseController {
jsonObject.put("status", "y"); jsonObject.put("status", "y");
return jsonObject; return jsonObject;
} }
//update-end--Author:zzl Date:20151102 for表单编码唯一性验证
//update-begin--Author:zzl Date:20151110 for数据源级联删除
private void delFormDb(String autoFormId){ private void delFormDb(String autoFormId){
List<AutoFormDbEntity> list = this.systemService.findByProperty(AutoFormDbEntity.class, "autoFormId", autoFormId); List<AutoFormDbEntity> list = this.systemService.findByProperty(AutoFormDbEntity.class, "autoFormId", autoFormId);
if(list!=null&&list.size()>0) { if(list!=null&&list.size()>0) {
@ -1230,4 +1279,5 @@ public class AutoFormController extends BaseController {
} }
} }
} }
//update-end--Author:zzl Date:20151110 for数据源级联删除
} }

Loading…
Cancel
Save