更新依赖
This commit is contained in:
parent
70f36c03e1
commit
33f205244b
8
pom.xml
8
pom.xml
|
|
@ -15,10 +15,10 @@
|
||||||
<!-- 编译jdk版本 -->
|
<!-- 编译jdk版本 -->
|
||||||
<jdk.version>1.7</jdk.version>
|
<jdk.version>1.7</jdk.version>
|
||||||
<!-- 依赖版本 -->
|
<!-- 依赖版本 -->
|
||||||
<spring.version>4.3.7.RELEASE</spring.version>
|
<spring.version>4.3.9.RELEASE</spring.version>
|
||||||
<shiro.version>1.3.2</shiro.version>
|
<shiro.version>1.3.2</shiro.version>
|
||||||
<log4j2.version>2.7</log4j2.version>
|
<log4j2.version>2.7</log4j2.version>
|
||||||
<beetlsql.version>2.8.6</beetlsql.version>
|
<beetlsql.version>2.8.18</beetlsql.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
@ -154,7 +154,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid</artifactId>
|
<artifactId>druid</artifactId>
|
||||||
<version>1.0.29</version>
|
<version>1.0.31</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--shiro插件 -->
|
<!--shiro插件 -->
|
||||||
|
|
@ -183,7 +183,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.28</version>
|
<version>1.2.33</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- qrcode -->
|
<!-- qrcode -->
|
||||||
|
|
|
||||||
|
|
@ -15,16 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package com.smallchill.system.controller;
|
package com.smallchill.system.controller;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.ModelMap;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
|
|
||||||
import com.smallchill.common.base.BaseController;
|
import com.smallchill.common.base.BaseController;
|
||||||
import com.smallchill.common.tool.SysCache;
|
import com.smallchill.common.tool.SysCache;
|
||||||
import com.smallchill.core.annotation.Before;
|
import com.smallchill.core.annotation.Before;
|
||||||
|
|
@ -49,6 +39,15 @@ import com.smallchill.system.meta.intercept.UserIntercept;
|
||||||
import com.smallchill.system.meta.intercept.UserValidator;
|
import com.smallchill.system.meta.intercept.UserValidator;
|
||||||
import com.smallchill.system.model.RoleExt;
|
import com.smallchill.system.model.RoleExt;
|
||||||
import com.smallchill.system.model.User;
|
import com.smallchill.system.model.User;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
|
|
@ -187,6 +186,7 @@ public class UserController extends BaseController implements ConstShiro{
|
||||||
boolean temp = Blade.create(User.class).update(user);
|
boolean temp = Blade.create(User.class).update(user);
|
||||||
if (temp) {
|
if (temp) {
|
||||||
CacheKit.removeAll(SYS_CACHE);
|
CacheKit.removeAll(SYS_CACHE);
|
||||||
|
ShiroKit.clearCachedAuthenticationInfo(user.getAccount());
|
||||||
return success(UPDATE_SUCCESS_MSG);
|
return success(UPDATE_SUCCESS_MSG);
|
||||||
} else {
|
} else {
|
||||||
return error(UPDATE_FAIL_MSG);
|
return error(UPDATE_FAIL_MSG);
|
||||||
|
|
|
||||||
397
src/main/webapp/static/blade/js/blade-combotree.js
Normal file
397
src/main/webapp/static/blade/js/blade-combotree.js
Normal file
|
|
@ -0,0 +1,397 @@
|
||||||
|
(function () {
|
||||||
|
var BladeComboTree = function () {
|
||||||
|
this.id = "";
|
||||||
|
this.search = "";
|
||||||
|
this.type = "combotree";
|
||||||
|
this.source = "";
|
||||||
|
this.where = "";
|
||||||
|
this.val = "";
|
||||||
|
this.treeId = "id";
|
||||||
|
this.intercept = "";
|
||||||
|
this.check = "";
|
||||||
|
this.width = "180px";
|
||||||
|
this.height = "250px";
|
||||||
|
this.fix = true;
|
||||||
|
this.ext = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
BladeComboTree.prototype = {
|
||||||
|
setId : function (id) {
|
||||||
|
this.id = id;
|
||||||
|
},
|
||||||
|
setType : function (type) {
|
||||||
|
this.type = type;
|
||||||
|
},
|
||||||
|
setSource : function (source) {
|
||||||
|
this.source = source;
|
||||||
|
},
|
||||||
|
setWhere : function (where) {
|
||||||
|
this.where = where;
|
||||||
|
},
|
||||||
|
setVal : function (val) {
|
||||||
|
this.val = val;
|
||||||
|
},
|
||||||
|
setTreeId : function (treeId) {
|
||||||
|
this.treeId = treeId;
|
||||||
|
},
|
||||||
|
setIntercept : function (intercept) {
|
||||||
|
this.intercept = intercept;
|
||||||
|
},
|
||||||
|
setCheck : function (check) {
|
||||||
|
this.check = check;
|
||||||
|
},
|
||||||
|
setWidth : function (width) {
|
||||||
|
this.width = width;
|
||||||
|
},
|
||||||
|
setHeight : function (height) {
|
||||||
|
this.height = height;
|
||||||
|
},
|
||||||
|
setExt : function (ext) {
|
||||||
|
this.ext = ext;
|
||||||
|
},
|
||||||
|
beforeClick : function (treeId, treeNode) {
|
||||||
|
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
||||||
|
zTree.checkNode(treeNode, !treeNode.checked, null, true);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
onCheck : function (e, treeId, treeNode) {
|
||||||
|
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
||||||
|
nodes = zTree.getCheckedNodes(true),
|
||||||
|
ids = "",
|
||||||
|
v = "";
|
||||||
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
||||||
|
ids += nodes[i].id + ",";
|
||||||
|
v += nodes[i].name + ",";
|
||||||
|
}
|
||||||
|
if (v.length > 0 ) v = v.substring(0, v.length - 1);
|
||||||
|
if (ids.length > 0 ) ids = ids.substring(0, ids.length - 1);
|
||||||
|
var _id = treeId.replace("tree_", "").replace("_ipt", "");
|
||||||
|
var treeInput = $("#" + _id + "_ipt");
|
||||||
|
var treeHidden = $("#" + _id + "");
|
||||||
|
treeInput.val(v);
|
||||||
|
treeHidden.val(ids);
|
||||||
|
$("#form_token").val(1);
|
||||||
|
|
||||||
|
//用于点击后的回调
|
||||||
|
if (typeof comboTreeCallBack == 'function') {
|
||||||
|
comboTreeCallBack(_id, ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
showMenu : function () {
|
||||||
|
var _id = this.id;
|
||||||
|
var _me = this;
|
||||||
|
var $ipt = $("#" + _id + "_ipt");
|
||||||
|
$("#tree_" + _id + "_ipt").css({"width": $ipt.css("width")});
|
||||||
|
var top = $ipt.outerHeight();
|
||||||
|
if (this.fix) {
|
||||||
|
top = top + $ipt.offset().top - 1;
|
||||||
|
}
|
||||||
|
$("#treeContent_" + _id + "_ipt").css({top:top + "px"}).slideDown("fast");
|
||||||
|
$("body").bind("mousedown", function (event) {
|
||||||
|
if (!(event.target.id == "menuBtn" || event.target.id == ""+_id+"_ipt" || event.target.id == "treeContent_"+_id+"_ipt" || $(event.target).parents("#treeContent_"+_id+"_ipt").length>0)) {
|
||||||
|
_me.hideMenu();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
hideMenu : function () {
|
||||||
|
var _id = this.id;
|
||||||
|
var _me = this;
|
||||||
|
$("#treeContent_" + _id + "_ipt").fadeOut("fast");
|
||||||
|
$("body").unbind("mousedown", function (event) {
|
||||||
|
if (!(event.target.id == "menuBtn" || event.target.id == ""+id+"_ipt" || event.target.id == "treeContent_"+id+"_ipt" || $(event.target).parents("#treeContent_"+id+"_ipt").length>0)) {
|
||||||
|
_me.showMenu();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchMenu : function () {
|
||||||
|
var setting;
|
||||||
|
|
||||||
|
if (this.check == "radio") {
|
||||||
|
setting = {
|
||||||
|
check: {
|
||||||
|
enable: true,
|
||||||
|
chkStyle: "radio",
|
||||||
|
radioType : "all"
|
||||||
|
},
|
||||||
|
view: {
|
||||||
|
dblClickExpand: false,
|
||||||
|
fontCss: getFont,
|
||||||
|
nameIsHTML: true
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
simpleData: {
|
||||||
|
enable: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
beforeClick: this.beforeClick,
|
||||||
|
onCheck: this.onCheck
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setting = {
|
||||||
|
check: {
|
||||||
|
enable: true,
|
||||||
|
chkboxType :{ "Y" : "", "N" : "" }
|
||||||
|
},
|
||||||
|
view: {
|
||||||
|
dblClickExpand: false,
|
||||||
|
fontCss: getFont,
|
||||||
|
nameIsHTML: true
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
simpleData: {
|
||||||
|
enable: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
beforeClick: this.beforeClick,
|
||||||
|
onCheck: this.onCheck
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFont(treeId, node) {
|
||||||
|
return node.font ? node.font : {};
|
||||||
|
}
|
||||||
|
|
||||||
|
var _id = this.id;
|
||||||
|
var _node_data;
|
||||||
|
var treeList = new Ajax(BladeApp.getCtx() + "/combotree/getTreeList", function(data){
|
||||||
|
if (data.code === 0) {
|
||||||
|
_node_data = data.data;
|
||||||
|
$.fn.zTree.init($("#tree_" + _id + "_ipt"), setting, _node_data);
|
||||||
|
match();
|
||||||
|
} else {
|
||||||
|
layer.alert(data.message, {icon: 2,title:"发生错误"});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
treeList.set("search", $("#" + _id + "_ipt").val());
|
||||||
|
treeList.set("type", this.type);
|
||||||
|
treeList.set("source", this.source);
|
||||||
|
treeList.set("where", this.where);
|
||||||
|
treeList.set("intercept", this.intercept);
|
||||||
|
treeList.set("ext", this.ext);
|
||||||
|
treeList.set("val", 0);
|
||||||
|
treeList.set("treeId", this.treeId);
|
||||||
|
treeList.start();
|
||||||
|
|
||||||
|
|
||||||
|
function match() {
|
||||||
|
var search = $("#" + _id + "_ipt").val();
|
||||||
|
if (BladeTool.isEmpty(search)) {
|
||||||
|
//layer.msg("请输入关键字", {shift: 6,time:2000});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var zTree = $.fn.zTree.getZTreeObj("tree_" + _id + "_ipt");
|
||||||
|
for (var i = 0; i < _node_data.length; i++) {
|
||||||
|
var name = _node_data[i].name;
|
||||||
|
if (name.contains(search)) {
|
||||||
|
var node = zTree.getNodeByParam("name", name);
|
||||||
|
node.font = {'font-weight':'bold', 'color':'#009688'};
|
||||||
|
zTree.updateNode(node);
|
||||||
|
zTree.expandNode(node, true, false);//指定选中ID节点展开
|
||||||
|
expandParentNode(node, zTree);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//递归打开ztree节点
|
||||||
|
function expandParentNode(_node, zTree) {
|
||||||
|
var _pNode = _node.getParentNode();//获得父节点
|
||||||
|
if (null != _pNode) {
|
||||||
|
if (!_pNode.open) {
|
||||||
|
zTree.expandNode(_pNode, true, false);//指定选中ID节点展开
|
||||||
|
}
|
||||||
|
expandParentNode(_pNode, zTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
initComboTree : function () {
|
||||||
|
var setting;
|
||||||
|
|
||||||
|
if (this.check == "radio") {
|
||||||
|
setting = {
|
||||||
|
check: {
|
||||||
|
enable: true,
|
||||||
|
chkStyle: "radio",
|
||||||
|
radioType : "all"
|
||||||
|
},
|
||||||
|
view: {
|
||||||
|
dblClickExpand: false
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
simpleData: {
|
||||||
|
enable: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
beforeClick: this.beforeClick,
|
||||||
|
onCheck: this.onCheck
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setting = {
|
||||||
|
check: {
|
||||||
|
enable: true,
|
||||||
|
chkboxType :{ "Y" : "", "N" : "" }
|
||||||
|
},
|
||||||
|
view: {
|
||||||
|
dblClickExpand: false
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
simpleData: {
|
||||||
|
enable: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
beforeClick: this.beforeClick,
|
||||||
|
onCheck: this.onCheck
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var _id = this.id;
|
||||||
|
var _val = $("#" + this.id).val();
|
||||||
|
|
||||||
|
var treeList = new Ajax(BladeApp.getCtx() + "/combotree/getTreeList", function(data){
|
||||||
|
if (data.code === 0) {
|
||||||
|
$.fn.zTree.init($("#tree_" + _id + "_ipt"), setting, data.data);
|
||||||
|
} else {
|
||||||
|
layer.alert(data.message, {icon: 2,title:"发生错误"});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
treeList.set("search", "");
|
||||||
|
treeList.set("val", _val);
|
||||||
|
treeList.set("type", this.type);
|
||||||
|
treeList.set("source", this.source);
|
||||||
|
treeList.set("where", this.where);
|
||||||
|
treeList.set("intercept", this.intercept);
|
||||||
|
treeList.set("ext", this.ext);
|
||||||
|
treeList.set("treeId", this.treeId);
|
||||||
|
treeList.start();
|
||||||
|
|
||||||
|
|
||||||
|
var treeName = new Ajax(BladeApp.getCtx() + "/combotree/getTreeListName", function(data){
|
||||||
|
if (data.code === 0) {
|
||||||
|
$("#" + _id + "_ipt").val(data.data);
|
||||||
|
} else {
|
||||||
|
layer.alert(data.message, {icon: 2,title:"发生错误"});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
treeName.set("type", this.type);
|
||||||
|
treeName.set("source", this.source);
|
||||||
|
treeName.set("where", this.where);
|
||||||
|
treeName.set("val", _val);
|
||||||
|
treeName.set("treeId", this.treeId);
|
||||||
|
treeName.start();
|
||||||
|
|
||||||
|
},
|
||||||
|
reset: function () {
|
||||||
|
var setting;
|
||||||
|
|
||||||
|
if (this.check == "radio") {
|
||||||
|
setting = {
|
||||||
|
check: {
|
||||||
|
enable: true,
|
||||||
|
chkStyle: "radio",
|
||||||
|
radioType : "all"
|
||||||
|
},
|
||||||
|
view: {
|
||||||
|
dblClickExpand: false
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
simpleData: {
|
||||||
|
enable: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
beforeClick: this.beforeClick,
|
||||||
|
onCheck: this.onCheck
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setting = {
|
||||||
|
check: {
|
||||||
|
enable: true,
|
||||||
|
chkboxType :{ "Y" : "", "N" : "" }
|
||||||
|
},
|
||||||
|
view: {
|
||||||
|
dblClickExpand: false
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
simpleData: {
|
||||||
|
enable: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
beforeClick: this.beforeClick,
|
||||||
|
onCheck: this.onCheck
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var _id = this.id;
|
||||||
|
var _val = $("#" + this.id).val();
|
||||||
|
|
||||||
|
var treeList = new Ajax(BladeApp.getCtx() + "/combotree/getTreeList", function(data){
|
||||||
|
if (data.code === 0) {
|
||||||
|
$.fn.zTree.init($("#tree_" + _id + "_ipt"), setting, data.data);
|
||||||
|
} else {
|
||||||
|
layer.alert(data.message, {icon: 2,title:"发生错误"});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
treeList.set("search", "");
|
||||||
|
treeList.set("val", _val);
|
||||||
|
treeList.set("type", this.type);
|
||||||
|
treeList.set("source", this.source);
|
||||||
|
treeList.set("where", this.where);
|
||||||
|
treeList.set("intercept", this.intercept);
|
||||||
|
treeList.set("ext", this.ext);
|
||||||
|
treeList.set("treeId", this.treeId);
|
||||||
|
treeList.start();
|
||||||
|
},
|
||||||
|
init : function () {
|
||||||
|
|
||||||
|
var _me = this;
|
||||||
|
|
||||||
|
var $ipt = $("#" + this.id);
|
||||||
|
|
||||||
|
var _val = $ipt.val();
|
||||||
|
|
||||||
|
$ipt.attr("id", this.id + "_ipt");
|
||||||
|
|
||||||
|
var html = [];
|
||||||
|
html.push('<input id="' + this.id + '" name="' + this.id + '" value="'+_val+'" class="form-control" data-type="combotree" type="hidden" />');
|
||||||
|
html.push('<div id="treeContent_' + this.id + '_ipt" class="menuContent" style="display:none; position: absolute;z-index:2333333333;">');
|
||||||
|
html.push('<ul id="tree_' + this.id + '_ipt" class="ztree" style="border-radius: 0 !important;-webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);background: #fafafa;border: 1px solid rgba(0, 0, 0, 0.15);border: 1px solid #cccccc;overflow-y: scroll;overflow-x: auto;margin-top:0; width:'+this.width+'; max-height: '+this.height+';"></ul>');
|
||||||
|
html.push('</div>');
|
||||||
|
$ipt.after(html.join(""));
|
||||||
|
|
||||||
|
if (BladeTool.isEmpty(this.val)) {
|
||||||
|
this.val = _val;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.initComboTree();
|
||||||
|
|
||||||
|
$ipt.bind("click", function(){
|
||||||
|
_me.showMenu();
|
||||||
|
});
|
||||||
|
$ipt.bind("keydown", function(e){
|
||||||
|
if (e.keyCode == 13) {
|
||||||
|
_me.searchMenu();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.BladeComboTree = BladeComboTree;
|
||||||
|
|
||||||
|
document.write('<link rel="stylesheet" href="' + BladeApp.getCtx() + '/static/zTree/css/zTreeStyle/zTreeStyle.css" />');
|
||||||
|
document.write('<script src="' + BladeApp.getCtx() + '/static/zTree/js/jquery.ztree.core.js" type="text/javascript" ></script>');
|
||||||
|
document.write('<script src="' + BladeApp.getCtx() + '/static/zTree/js/jquery.ztree.excheck.js" type="text/javascript"></script>');
|
||||||
|
|
||||||
|
}());
|
||||||
328
src/main/webapp/static/blade/js/blade-grid.js
Normal file
328
src/main/webapp/static/blade/js/blade-grid.js
Normal file
|
|
@ -0,0 +1,328 @@
|
||||||
|
(function () {
|
||||||
|
var CacheGrid = function () {
|
||||||
|
this.title = [];
|
||||||
|
this.field = [];
|
||||||
|
this.pk = "id";
|
||||||
|
this.table = "";
|
||||||
|
this.data = new JMap();
|
||||||
|
this.keys = new Array();
|
||||||
|
this.checkBox = true;
|
||||||
|
this.count = 0;
|
||||||
|
this.noWidth = 3.5;
|
||||||
|
this.pageDetail = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
CacheGrid.prototype = {
|
||||||
|
setPk: function (pk) {
|
||||||
|
this.pk = pk;
|
||||||
|
},
|
||||||
|
setNoWidth: function (width) {
|
||||||
|
this.noWidth = width;
|
||||||
|
},
|
||||||
|
setCheckBox: function (checkBox) {
|
||||||
|
this.checkBox = checkBox;
|
||||||
|
},
|
||||||
|
setTable: function (table) {
|
||||||
|
this.table = table;
|
||||||
|
},
|
||||||
|
setTitle: function (title) {
|
||||||
|
this.title = title;
|
||||||
|
},
|
||||||
|
setField: function (field) {
|
||||||
|
this.field = field;
|
||||||
|
},
|
||||||
|
setData: function (data) {
|
||||||
|
this.count = 0;
|
||||||
|
this.data = new JMap();
|
||||||
|
var keys = data.keys().sortNumber();
|
||||||
|
for (var k = 0; k < keys.length; k++) {
|
||||||
|
var _key = keys[k];
|
||||||
|
var _map = data.get(_key);
|
||||||
|
this.count++;
|
||||||
|
this.data.put(this.count, _map);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setDataByKey: function (data) {
|
||||||
|
this.count = 0;
|
||||||
|
this.data = new JMap();
|
||||||
|
var keys = data.keys().sortNumber();
|
||||||
|
for (var k = 0; k < keys.length; k++) {
|
||||||
|
var _key = keys[k];
|
||||||
|
var _map = data.get(_key);
|
||||||
|
this.count = _key;
|
||||||
|
this.data.put(_key, _map);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setPageDetail:function (pageDetail) {
|
||||||
|
this.pageDetail = pageDetail;
|
||||||
|
},
|
||||||
|
getData: function () {
|
||||||
|
return this.data;
|
||||||
|
},
|
||||||
|
getSelectKey: function () {
|
||||||
|
return this.keys[0];
|
||||||
|
},
|
||||||
|
getSelectKeys: function () {
|
||||||
|
return this.keys.unique();
|
||||||
|
},
|
||||||
|
getSelectRow: function () {
|
||||||
|
var selectKey = this.keys[0];
|
||||||
|
return this.data.get(selectKey);
|
||||||
|
},
|
||||||
|
getSelectRows: function () {
|
||||||
|
var selectRows = new JMap();
|
||||||
|
var selectKeys = this.keys.unique();
|
||||||
|
for (var i = 0; i < selectKeys.length; i++) {
|
||||||
|
var key = selectKeys[i];
|
||||||
|
selectRows.put(key, this.data.get(key));
|
||||||
|
}
|
||||||
|
return selectRows;
|
||||||
|
},
|
||||||
|
zero: function () {
|
||||||
|
return (this.getSelectKeys().length == 0);
|
||||||
|
},
|
||||||
|
one: function () {
|
||||||
|
return (this.getSelectKeys().length == 1);
|
||||||
|
},
|
||||||
|
multi: function () {
|
||||||
|
return (this.getSelectKeys().length > 1);
|
||||||
|
},
|
||||||
|
rowId: function () {
|
||||||
|
return this.count;
|
||||||
|
},
|
||||||
|
select: function (key) {
|
||||||
|
debugger;
|
||||||
|
$("#" + this.table + "_body_tr_" + key).click();
|
||||||
|
},
|
||||||
|
add: function (_map) {
|
||||||
|
var me = this;
|
||||||
|
//如果没有数据则清空
|
||||||
|
if (this.data.size() == 0) {
|
||||||
|
$("#" + this.table + "_body").html("");
|
||||||
|
}
|
||||||
|
this.count++;
|
||||||
|
var _key = this.count;
|
||||||
|
this.data.put(_key, _map);
|
||||||
|
clickCheckbox(me, _key, _map);
|
||||||
|
},
|
||||||
|
update: function (_key, _map) {
|
||||||
|
this.data.remove(_key);
|
||||||
|
this.data.put(_key, _map);
|
||||||
|
this.keys.remove(_key);
|
||||||
|
var field = [];
|
||||||
|
if (this.checkBox) {
|
||||||
|
field.push("<td style='vertical-align:middle;width:2%;text-align:center;'>");
|
||||||
|
field.push("<div class='cover-checkbox' style='position:relative;width: 100%; height: 100%;top: 0px; left: 0px;'>");
|
||||||
|
field.push(" <input id='" + this.table + "_grid_checkbox_" + _key + "' data-key='" + _key + "' type='checkbox' name='" + this.table + "_grid_checkbox' />");
|
||||||
|
field.push(" <div style='position:absolute;z-index: 2;width: 100%; height: 100%;top: 0px; left: 0px;opacity: 1;'></div>");
|
||||||
|
field.push("</div>");
|
||||||
|
field.push("</td>");
|
||||||
|
}
|
||||||
|
field.push("<td style='vertical-align:middle;width:" + this.noWidth + "%;text-align:right;'>");
|
||||||
|
field.push(_key);
|
||||||
|
field.push("</td>");
|
||||||
|
for (var f = 0; f < this.field.length; f++) {
|
||||||
|
var _value = _map.get(this.field[f].name);
|
||||||
|
var _style = "";
|
||||||
|
if (this.field[f].hidden) {
|
||||||
|
_style += "display: none;";
|
||||||
|
}
|
||||||
|
if (typeof this.field[f].align === "string") {
|
||||||
|
_style += "text-align: " + this.field[f].align + ";";
|
||||||
|
}
|
||||||
|
field.push("<td id='" + this.table + "_body_td_" + this.field[f].name + "_" + _key + "' style='" + _style + "vertical-align:middle;width:" + this.field[f].width + "%;' >");
|
||||||
|
if (typeof this.field[f].format === 'function') {
|
||||||
|
field.push(this.field[f].format(_map, _key));
|
||||||
|
} else {
|
||||||
|
field.push(_value);
|
||||||
|
}
|
||||||
|
field.push("</td>");
|
||||||
|
}
|
||||||
|
$("#" + this.table + "_body_tr_" + _key).html(field.join(""));
|
||||||
|
$("#" + this.table + "_body_tr_" + _key).removeAttr("style");
|
||||||
|
},
|
||||||
|
remove: function (_key) {
|
||||||
|
this.data.remove(_key);
|
||||||
|
this.keys.remove(_key);
|
||||||
|
$("#" + this.table + "_body_tr_" + _key).remove();
|
||||||
|
if (this.data.size() == 0) {
|
||||||
|
$("#" + this.table + "_body").html("<tr><td colspan='" + (this.title.length + 2) + "' style='text-align:center;'>暂无数据</td></tr>");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeMulti: function (_keys) {
|
||||||
|
for (var i = 0; i < _keys.length; i++) {
|
||||||
|
var key = _keys[i];
|
||||||
|
this.remove(key);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
init: function () {
|
||||||
|
this.keys = new Array();
|
||||||
|
var me = this;
|
||||||
|
var $table = $("#" + this.table);
|
||||||
|
$table.html("");
|
||||||
|
var thead = [];
|
||||||
|
thead.push("<thead>");
|
||||||
|
thead.push("<tr>");
|
||||||
|
if (this.checkBox) {
|
||||||
|
thead.push("<th style='vertical-align:middle;text-align:center;'><input id='" + this.table + "_chb' type='checkbox' /></th>");
|
||||||
|
}
|
||||||
|
thead.push("<th>序号</th>");
|
||||||
|
for (var i = 0; i < this.title.length; i++) {
|
||||||
|
var _display = "";
|
||||||
|
if (this.field[i].hidden) {
|
||||||
|
_display = "style='display:none;'";
|
||||||
|
}
|
||||||
|
thead.push("<th" + _display + ">");
|
||||||
|
thead.push(this.title[i]);
|
||||||
|
thead.push("</th>");
|
||||||
|
}
|
||||||
|
thead.push("</tr>");
|
||||||
|
thead.push("</thead>");
|
||||||
|
$table.append(thead.join(""));
|
||||||
|
var $tbody = $("<tbody id='" + this.table + "_body'></table>").appendTo($table);
|
||||||
|
|
||||||
|
//加载分页信息
|
||||||
|
if (BladeTool.isNotEmpty(this.pageDetail) && this.pageDetail.total > 0) {
|
||||||
|
var html = [];
|
||||||
|
html.push('<span id="sp_grid"></span>');
|
||||||
|
html.push('<span>每页显示:</span>');
|
||||||
|
html.push('<select id="sel_page" style="border:1px solid #dddddd;" onchange="changePage()">');
|
||||||
|
html.push(' <option value="8">8</option>');
|
||||||
|
html.push(' <option value="20">20</option>');
|
||||||
|
html.push(' <option value="50">50</option>');
|
||||||
|
html.push(' <option value="100000000">全部</option>');
|
||||||
|
html.push('</select>');
|
||||||
|
html.push('<span>条</span>');
|
||||||
|
$("#grid_pages").html(html.join(""));
|
||||||
|
$("#sel_page").val(this.pageDetail.pageSize);
|
||||||
|
var rowEnd = (this.pageDetail.rowEnd == 100000000) ? "∞" : this.pageDetail.rowEnd;
|
||||||
|
$("#sp_grid").html("显示第" + this.pageDetail.rowBegin + "到第" + rowEnd + "条记录,共" + this.pageDetail.records + "条记录,");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.data.size() === 0) {
|
||||||
|
$tbody.html("<tr><td colspan='" + (this.title.length + 2) + "' style='text-align:center;'>暂无数据</td></tr>");
|
||||||
|
$("#" + this.table + "_chb").bind("click", function () {
|
||||||
|
var checked = $(this).is(":checked");
|
||||||
|
$("input[name='" + me.table + "_grid_checkbox']").each(function () {
|
||||||
|
var data_key = $(this).attr("data-key");
|
||||||
|
$(this).prop("checked", checked);
|
||||||
|
if (checked) {
|
||||||
|
$(this).closest("tr").css("background-color", "#f5f5f5");
|
||||||
|
me.keys.push(data_key);
|
||||||
|
} else {
|
||||||
|
$(this).closest("tr").removeAttr("style");
|
||||||
|
me.keys.remove(data_key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
me.keys = me.keys.unique();
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//传入的data参数为一个ListMap
|
||||||
|
var keys = this.data.keys().sortNumber();
|
||||||
|
for (var k = 0; k < keys.length; k++) {
|
||||||
|
//取到每一行的map对象
|
||||||
|
var _key = keys[k];
|
||||||
|
var _map = this.data.get(_key);
|
||||||
|
clickCheckbox(me, _key, _map);
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#" + this.table + "_chb").bind("click", function () {
|
||||||
|
var checked = $(this).is(":checked");
|
||||||
|
$("input[name='" + me.table + "_grid_checkbox']").each(function () {
|
||||||
|
var data_key = $(this).attr("data-key");
|
||||||
|
$(this).prop("checked", checked);
|
||||||
|
if (checked) {
|
||||||
|
$(this).closest("tr").css("background-color", "#f5f5f5");
|
||||||
|
me.keys.push(data_key);
|
||||||
|
} else {
|
||||||
|
$(this).closest("tr").removeAttr("style");
|
||||||
|
me.keys.remove(data_key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
me.keys = me.keys.unique();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.CacheGrid = CacheGrid;
|
||||||
|
|
||||||
|
function clickCheckbox(me, _key, _map) {
|
||||||
|
var field = [];
|
||||||
|
field.push("<tr id='" + me.table + "_body_tr_" + _key + "'>");
|
||||||
|
if (me.checkBox) {
|
||||||
|
field.push("<td style='vertical-align:middle;width:2%;text-align:center;'>");
|
||||||
|
field.push("<div class='cover-checkbox' style='position:relative;width: 100%; height: 100%;top: 0px; left: 0px;'>");
|
||||||
|
field.push(" <input id='" + me.table + "_grid_checkbox_" + _key + "' data-key='" + _key + "' type='checkbox' name='" + me.table + "_grid_checkbox' />");
|
||||||
|
field.push(" <div style='position:absolute;z-index: 2;width: 100%; height: 100%;top: 0px; left: 0px;opacity: 1;'></div>");
|
||||||
|
field.push("</div>");
|
||||||
|
field.push("</td>");
|
||||||
|
}
|
||||||
|
field.push("<td style='vertical-align:middle;width:" + me.noWidth + "%;text-align:right;'>");
|
||||||
|
field.push(_key);
|
||||||
|
field.push("</td>");
|
||||||
|
for (var f = 0; f < me.field.length; f++) {
|
||||||
|
var _value = _map.get(me.field[f].name);
|
||||||
|
var _style = "";
|
||||||
|
if (me.field[f].hidden) {
|
||||||
|
_style += "display: none;";
|
||||||
|
}
|
||||||
|
if (typeof me.field[f].align === "string") {
|
||||||
|
_style += "text-align: " + me.field[f].align + ";";
|
||||||
|
}
|
||||||
|
field.push("<td id='" + me.table + "_body_td_" + me.field[f].name + "_" + _key + "' style='" + _style + "vertical-align:middle;width:" + me.field[f].width + "%;' >");
|
||||||
|
if (typeof me.field[f].format === 'function') {
|
||||||
|
field.push(me.field[f].format(_map, _key));
|
||||||
|
} else {
|
||||||
|
field.push(_value);
|
||||||
|
}
|
||||||
|
field.push("</td>");
|
||||||
|
}
|
||||||
|
field.push("</tr>");
|
||||||
|
$("#" + me.table + "_body").append(field.join(""));
|
||||||
|
if (me.checkBox) {
|
||||||
|
$("#" + me.table + "_body_tr_" + _key).bind("click", function () {
|
||||||
|
var par = $(this).parent();
|
||||||
|
var _key = $(this).find("input[type='checkbox']").attr("data-key");
|
||||||
|
var $chb = $("#" + me.table + "_grid_checkbox_" + _key);
|
||||||
|
if ($chb.hasClass('multiple-check')) {
|
||||||
|
if ($chb.is(":checked")) {
|
||||||
|
me.keys.remove(_key);
|
||||||
|
$chb.prop("checked", false);
|
||||||
|
$(this).removeAttr("style");
|
||||||
|
$("#" + me.table + "_chb").prop("checked", false);
|
||||||
|
} else {
|
||||||
|
me.keys.push(_key);
|
||||||
|
$chb.prop("checked", true);
|
||||||
|
$(this).css("background-color", "#f5f5f5");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let checkBoxes = par.find("input[name='" + me.table + "_grid_checkbox']");
|
||||||
|
for (let i = 0; i < checkBoxes.length; i++) {
|
||||||
|
let check_key = $(checkBoxes[i]).attr("data-key");
|
||||||
|
me.keys.remove(check_key);
|
||||||
|
$(checkBoxes[i]).prop("checked", false);
|
||||||
|
$(checkBoxes[i]).closest('tr').removeAttr("style");
|
||||||
|
}
|
||||||
|
$("#" + me.table + "_chb").prop("checked", false);
|
||||||
|
if ($chb.is(":checked")) {
|
||||||
|
// me.keys.remove(_key);
|
||||||
|
// $chb.prop("checked", false);
|
||||||
|
// $(this).removeAttr("style");
|
||||||
|
} else {
|
||||||
|
me.keys = [];
|
||||||
|
me.keys.push(_key);
|
||||||
|
$chb.prop("checked", true);
|
||||||
|
$(this).css("background-color", "#f5f5f5");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.cover-checkbox').on('mouseover', function () {
|
||||||
|
$(this).find("input[type='checkbox']").addClass("multiple-check");
|
||||||
|
})
|
||||||
|
$('.cover-checkbox').on('mouseout', function () {
|
||||||
|
$(this).find("input[type='checkbox']").removeClass("multiple-check");
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}());
|
||||||
Loading…
Reference in New Issue
Block a user