This commit is contained in:
zhuangqian 2016-11-08 09:55:16 +08:00
parent 305923ed18
commit 8615ecd049
14 changed files with 51 additions and 89 deletions

View File

@ -9,10 +9,10 @@ PS:因为喜欢刀锋战士所以取名了SpringBlade当中有一个类也命
2.[eova](http://www.oschina.net/p/eova)
3.[hutool](http://www.oschina.net/p/hutool)
4.[beetl](http://www.oschina.net/p/beetl)
4.[beetlsql](http://www.oschina.net/p/beetlsql)
5.[dreamlu](http://www.oschina.net/p/dreamlu)
6.[kisso](http://www.oschina.net/p/kisso)
7.[spring-shiro-training](https://git.oschina.net/wangzhixuan/spring-shiro-training)
5.[beetlsql](http://www.oschina.net/p/beetlsql)
6.[dreamlu](http://www.oschina.net/p/dreamlu)
7.[kisso](http://www.oschina.net/p/kisso)
8.[spring-shiro-training](https://git.oschina.net/wangzhixuan/spring-shiro-training)
## 内置功能
@ -211,7 +211,7 @@ public class Notice extends BaseModel {
BladePage<Map<String, Object>> page = (BladePage<Map<String, Object>>) ac.getObject();
List<Map<String, Object>> list = page.getRows();
for (Map<String, Object> map : list) {
map.put("createrName", Func.getDictName(102, map.get("creater")));
map.put("createrName", SysCache.getDictName(102, map.get("creater")));
}
}
});

View File

@ -402,21 +402,12 @@ public class BeetlExt {
}
/**
* 获取YYYY-MM-DD HH:mm:ss格式
* 获取YYYY-MM-DD格式
*
* @return
*/
public String getTime(Date date) {
return DateKit.getTime(date);
}
/**
* 格式化日期
*
* @return
*/
public Date parseTime(String date) {
return DateKit.parseTime(date);
public String getDay() {
return DateKit.getDay();
}
/**
@ -424,37 +415,19 @@ public class BeetlExt {
*
* @return
*/
public Date parse(String date, String pattern) {
return DateKit.parse(date, pattern);
}
/**
* 格式化日期
*
* @return
*/
public String format(String pattern) {
public String formatTime(String pattern) {
return DateKit.format(new Date(), pattern);
}
/**
* 格式化日期
*
* @return
*/
public String format(Date date, String pattern) {
return DateKit.format(date, pattern);
public String formatTime(String dateStr, String pattern) {
return DateKit.format(DateTimeKit.parse(dateStr).toDate(), pattern);
}
/**
* 自行判断日期型字符串进行转换
* @param dateStr
* @return Date
*/
public static Date parse(String dateStr) {
return DateTimeKit.parse(dateStr).toDate();
}
/**
* 获取grid右键菜单
*
@ -462,7 +435,8 @@ public class BeetlExt {
* @param code
* @return String
*/
public String getRightMenu(final Object userId, Object roleId,final String code) {
@SuppressWarnings("rawtypes")
public String getRightMenu(final Object userId, Object roleId, final String code, boolean isExport) {
Map<String, Object> userRole = CacheKit.get(ConstCache.MENU_CACHE, ConstCacheKey.ROLE_EXT + userId,
new ILoader() {
public Object load() {
@ -484,21 +458,19 @@ public class BeetlExt {
sql.append(" and (icon is not null and (icon like '%btn%' or icon like '%icon%' ) ) ");
sql.append(" and (url like '%add%' or url like '%edit%' or url like '%remove%' or url like '%del%' or url like '%view%' ) ");
sql.append(" and (pCode=#{code})");
sql.append(" and (id in (select menuId from TFW_RELATION where roleId in ("
+ roleId + ")) or id in (" + roleIn + "))");
sql.append(" and id not in(" + roleOut + ")");
sql.append(" and (id in (select menuId from TFW_RELATION where roleId in (#{join(roleId)})) or id in (#{join(roleIn)}))");
sql.append(" and id not in(#{join(roleOut)})");
sql.append(" )");
sql.append(" order by num");
List<Map<String, Object>> btnList = CacheKit.get(ConstCache.MENU_CACHE, ConstCacheKey.RIGHT_MENU + code + "_" + userId, new ILoader() {
public Object load() {
return Db.selectList(sql.toString(), Paras.create().set("code", code));
}
});
List<Map> btnList = Db.selectListByCache(ConstCache.MENU_CACHE, ConstCacheKey.RIGHT_MENU + code + "_" + userId, sql.toString(), Paras.create().set("code", code)
.set("roleId", roleId.toString().split(","))
.set("roleIn", roleIn.split(","))
.set("roleOut", roleOut.split(",")));
StringBuilder rightsb = new StringBuilder();
rightsb.append("<ul style=\"width: 200px;\">");
for (Map<String, Object> btn : btnList) {
for (Map btn : btnList) {
rightsb.append(" <li id=\"rightMenu_" + Func.toStr(btn.get("CODE")).split("_")[1] + "\"> ");
rightsb.append(" <i class=\"ace-icon " + Func.toStr(btn.get("ICON")).split("\\|")[1].replace("bigger-120", "") + "\" style=\"width:15px;\"></i> ");
rightsb.append(" <span style=\"font-size:12px; font-family:Verdana;color:#777;padding-left:5px; \">" + Func.toStr(btn.get("NAME")) + "</span>");
@ -509,10 +481,12 @@ public class BeetlExt {
rightsb.append(" <i class=\"ace-icon fa fa-refresh\" style=\"width:15px;\"></i> ");
rightsb.append(" <span style=\"font-size:12px; font-family:Verdana;color:#777;padding-left:5px; \">刷新</span>");
rightsb.append(" </li>");
rightsb.append(" <li id=\"rightMenu_excel\"> ");
rightsb.append(" <i class=\"ace-icon fa fa-file-excel-o\" style=\"width:15px;\"></i> ");
rightsb.append(" <span style=\"font-size:12px; font-family:Verdana;color:#777;padding-left:5px; \">导出 excel</span>");
rightsb.append(" </li>");
if (isExport) {
rightsb.append(" <li id=\"rightMenu_excel\"> ");
rightsb.append(" <i class=\"ace-icon fa fa-file-excel-o\" style=\"width:15px;\"></i> ");
rightsb.append(" <span style=\"font-size:12px; font-family:Verdana;color:#777;padding-left:5px; \">导出 excel</span>");
rightsb.append(" </li>");
}
rightsb.append("</ul>");
return rightsb.toString();
}

View File

@ -7,14 +7,15 @@ public class HotBlogsTag extends GeneralVarTagBinding{
@Override
public void render() {
//Map<String, Object> paras= (Map<String, Object>) this.args[1];
/*List<Notice> notices=Notice.dao.findAll();
/*Map<String, Object> paras= (Map<String, Object>) this.args[1];
List<Notice> notices= Blade.create(Notice.class).findAll();
if(null!=notices){
for(Notice notice:notices){
this.binds(notice);
this.doBodyRender();
}
}*/
}
}

View File

@ -39,6 +39,7 @@ public class ZTreeController extends BladeController {
view.addObject("where", getParameter("where"));
view.addObject("intercept", getParameter("intercept"));
view.addObject("ext", getParameter("ext"));
view.addObject("treeId", getParameter("treeId"));
view.addObject("val", getParameter("val"));
return view;
}
@ -46,7 +47,7 @@ public class ZTreeController extends BladeController {
@ResponseBody
@SuppressWarnings({ "unchecked", "rawtypes" })
@RequestMapping("/getTreeList")
public AjaxResult getTreeList(@RequestParam String type, @RequestParam String source, @RequestParam String where, @RequestParam String intercept, @RequestParam String ext, @RequestParam String val) {
public AjaxResult getTreeList(@RequestParam String type, @RequestParam String source, @RequestParam String where, @RequestParam String intercept, @RequestParam String ext, @RequestParam String val, @RequestParam String treeId) {
final String sqlSource = getSql(type, source);
Map<String, Object> params = Paras.createHashMap();
@ -67,10 +68,8 @@ public class ZTreeController extends BladeController {
List<Map> list = Db.selectList(sqlSource, modelOrMap, ac, _intercept);
String key = "id";
if(type.indexOf("dict") >= 0){
key = "num";
}
String key = (StrKit.notBlank(treeId) && !Func.equals(treeId, "0")) ? treeId : ((type.indexOf("dict") >= 0) ? "num" : "id");
String [] arr = val.split(",");
for(Map<String, Object> map : list){
for(String v : arr){
@ -86,7 +85,7 @@ public class ZTreeController extends BladeController {
@ResponseBody
@RequestMapping("/getTreeListName")
@SuppressWarnings("unchecked")
public AjaxResult getTreeListName(@RequestParam String type, @RequestParam String source, @RequestParam String where, @RequestParam String val){
public AjaxResult getTreeListName(@RequestParam String type, @RequestParam String source, @RequestParam String where, @RequestParam String val, @RequestParam String treeId){
type = getTypeName(type, source);
final String sqlSource = getSql(type, source);
@ -106,10 +105,9 @@ public class ZTreeController extends BladeController {
});
String name = "";
String key = "id";
if(type.indexOf("dict") >= 0){
key = "num";
}
String key = (StrKit.notBlank(treeId) && !Func.equals(treeId, "0")) ? treeId : ((type.indexOf("dict") >= 0) ? "num" : "id");
String [] arr = val.split(",");
for(Map<String, Object> map : list){
for(String v : arr){
@ -118,17 +116,7 @@ public class ZTreeController extends BladeController {
}
}
}
//数据库设计导致自定义数据源的时候不知道是字典表还是其他表,所以需要再找一次id,后期可能会重新设计字典表结构
if (StrKit.isBlank(name)) {
key = (key.equals("num")) ? "id" : "num";
for(Map<String, Object> map : list){
for(String v : arr){
if(Func.toStr(map.get(key)).equals(v)){
name += Func.toStr(map.get("name")) + ",";
}
}
}
}
name = StrKit.removeSuffix(name, ",");
return json(name);

View File

@ -4,6 +4,6 @@ select d.*,(select name from tfw_dict where id=d.pId) PNAME from tfw_dict d
diy
===
select 0 as "id",0 as "pId",'top' as "name" from dual
select 0 as "id", 0 as "pId",'top' as "name" from dual
union
select ID as "id",pId as "pId",name as "name" from TFW_DICT
select ID as "id", pId as "pId",name as "name" from TFW_DICT

View File

@ -4,6 +4,6 @@ select d.*,(select name from tfw_dict where id=d.pId) PNAME from tfw_dict d
diy
===
select 0 as "id",0 as "pId",'top' as "name" from dual
select 0 as "id", 0 as "pId",'top' as "name" from dual
union
select ID as "id",pId as "pId",name as "name" from TFW_DICT
select ID as "id", pId as "pId",name as "name" from TFW_DICT

View File

@ -1,4 +1,4 @@
<script type="text/javascript">
var rightMenuHtml='${func.getRightMenu(shiro.getUser().id,shiro.getUser().roles,code)}';
var rightMenuHtml='${func.getRightMenu(shiro.getUser().id, shiro.getUser().roles, code, isExport!true)}';
$.contextMenuInit(grid_selector,rightMenuHtml,'${code}');
</script>

View File

@ -65,7 +65,7 @@
$.post("${ctxPath}/ztree/getTreeList",{source:"${source!}", type:"${type!}", where:"${where!}", intercept:"${x.intercept!}", ext:"${x.ext!}", val:"${val!}"},function(data){
$.post("${ctxPath}/ztree/getTreeList",{source:"${source!}", type:"${type!}", where:"${where!}", intercept:"${intercept!}", treeId:"${treeId!}", ext:"${ext!}", val:"${val!}"},function(data){
if(data.code===0){
$.fn.zTree.init($("#zTree"), setting, data.data);
/* var val = "${val!0}";

View File

@ -15,7 +15,7 @@
area: ["250", "420px"],
fix: false, //不固定
maxmin: true,
content: "${ctxPath}/ztree/open/?type=${x.type!0}&index=_${x.index!0}&name=${x.name!0}&source=${x.source!0}&check=${x.check!0}&where=${x.where!0}&intercept=${x.intercept!0}&ext=${x.ext!0}&val=" + val
content: "${ctxPath}/ztree/open/?type=${x.type!0}&index=_${x.index!0}&name=${x.name!0}&source=${x.source!0}&check=${x.check!0}&where=${x.where!0}&intercept=${x.intercept!0}&ext=${x.ext!0}&treeId=${x.treeId!0}&val=" + val
});
});
@ -27,7 +27,7 @@
});
function initOpenTree(val){
$.post("${ctxPath}/ztree/getTreeListName",{source:"${x.source!}", type:"${x.type!}", where:"${x.where!}", intercept:"${x.intercept!}", val:val},function(data){
$.post("${ctxPath}/ztree/getTreeListName",{source:"${x.source!}", type:"${x.type!}", where:"${x.where!}", intercept:"${x.intercept!}", treeId:"${x.treeId!}", val:val},function(data){
if(data.code === 0){
$("#_${x.index!}_INPUT").val(data.data);
}

View File

@ -3,7 +3,6 @@
var ctx="${ctxPath}";
var grid_selector = "#grid-table";
var pager_selector = "#grid-pager";
$(function(){
initGrid();
initMenuBtn("btns","${code}");

View File

@ -6,7 +6,7 @@
@ var _key="F_IT_XL";
@ var _col=[
@ {name:"通知标题",index:"F_VC_BT",type:"text",newline:true,length:8,required:"required"},
@ {name:"公告类型",index:"F_IT_LX", type:"opentreeDiy",source:"notice.diy",check:"radio",newline:true,length:3,required:"required"},
@ {name:"公告类型",index:"F_IT_LX", type:"opentreeDiy",source:"notice.diy",treeId:"num",check:"radio",newline:true,length:3,required:"required"},
@ {name:"通知时间",index:"F_DT_FBSJ", type:"laydate",format:"YYYY-MM-DD hh:mm:ss",newline:false,length:3,required:"required"},
@ {name:"通知内容",index:"F_TX_NR", type:"kindeditor",newline:true,length:8,required:"required"}
@ ];

View File

@ -6,7 +6,7 @@
@ var _col=[
@ {name:"字典编号",index:"code", type:"text",newline:true,length:8,required:"required"},
@ {name:"字典序号",index:"num", type:"text",newline:true,length:3,required:"required"},
@ {name:"上级字典",index:"pid",type:"opentreeDiy",source:"dict.diy",check:"radio",newline:false,length:3},
@ {name:"上级字典",index:"pid",type:"opentreeDiy",source:"dict.diy",treeId:"id",check:"radio",newline:false,length:3},
@ {name:"字典名称",index:"name", type:"text",newline:true,length:8,required:"required"},
@ {name:"备注",index:"tips", type:"text",newline:true,length:8}
@ ];

View File

@ -7,7 +7,7 @@
@ var _col=[
@ {name:"字典编号",index:"code", type:"text",newline:true,length:8,required:"required"},
@ {name:"字典序号",index:"num", type:"text",newline:true,length:3,required:"required"},
@ {name:"上级字典",index:"pid",type:"opentreeDiy",source:"dict.diy",check:"radio",newline:false,length:3},
@ {name:"上级字典",index:"pid",type:"opentreeDiy",source:"dict.diy",treeId:"id",check:"radio",newline:false,length:3},
@ {name:"字典名称",index:"name", type:"text",newline:true,length:8,required:"required"},
@ {name:"备注",index:"tips", type:"text",newline:true,length:8}
@ ];

View File

@ -87,5 +87,5 @@
</div>
<!-- 引入列表页所需js -->
@include("/common/_listscript.html"){}
@include("/common/_listscript.html", {isExport : false}) {}
@}