Commit d9be71bd by fsn

添加字典页面完成

parent d6f144d2
package com.stylefeng.guns.persistence.model; package com.stylefeng.guns.persistence.model;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
...@@ -26,6 +28,8 @@ public class User extends Model<User> { ...@@ -26,6 +28,8 @@ public class User extends Model<User> {
private String password; private String password;
private String salt; private String salt;
private String name; private String name;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date birthday; private Date birthday;
private Integer sex; private Integer sex;
private String email; private String email;
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
</div> </div>
</div> </div>
<div class="hidden-xs" id="DictTableToolbar" role="group"> <div class="hidden-xs" id="DictTableToolbar" role="group">
<#button name="添加" icon="fa-plus" clickFun="Dict.openAddDept()"/> <#button name="添加" icon="fa-plus" clickFun="Dict.openAddDict()"/>
<#button name="修改" icon="fa-plus" clickFun="Dict.openDeptDetail()" space="true"/> <#button name="修改" icon="fa-plus" clickFun="Dict.openDictDetail()" space="true"/>
<#button name="删除" icon="fa-plus" clickFun="Dict.delete()" space="true"/> <#button name="删除" icon="fa-plus" clickFun="Dict.delete()" space="true"/>
</div> </div>
<#table id="DictTable"/> <#table id="DictTable"/>
......
...@@ -6,37 +6,44 @@ ...@@ -6,37 +6,44 @@
<input type="hidden" id="id" value=""> <input type="hidden" id="id" value="">
<div class="row"> <div class="row">
<div class="col-sm-6 b-r"> <div class="col-sm-12" id="itemsArea">
<#input id="simplename" name="部门名称" underline="true"/> <div class="form-group">
<label class="col-sm-2 control-label">字典名称</label>
<div class="col-sm-2">
<input class="form-control" id="dictName" type="text">
</div>
<div class="col-sm-2">
<#button btnCss="info" name="增加" icon="fa-plus" clickFun="DictInfoDlg.addItem()"/>
</div>
</div>
<div class="hr-line-dashed"></div>
<#input id="fullname" name="部门全称" underline="true"/>
<#input id="tips" name="备注" underline="true"/>
</div>
<div class="col-sm-6">
<#input id="num" name="排序" underline="true"/>
<#input id="pName" name="上级部门" readonly="readonly" hidden="pid"
clickFun="DeptInfoDlg.showDeptSelectTree(); return false;"
style="background-color: #ffffff !important;"/>
</div> </div>
</div> </div>
<!-- 父级部门的选择框 -->
<div id="parentDeptMenu" class="menuContent"
style="display: none; position: absolute; z-index: 200;">
<ul id="parentDeptMenuTree" class="ztree tree-box" style="width: 245px !important;"></ul>
</div>
<div class="row btn-group-m-t"> <div class="row btn-group-m-t">
<div class="col-sm-10"> <div class="col-sm-10">
<#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="DeptInfoDlg.addSubmit()"/> <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="DictInfoDlg.addSubmit()"/>
<#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="DeptInfoDlg.close()"/> <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="DictInfoDlg.close()"/>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<script src="${ctxPath}/static/modular/system/dict/dict_info.js"></script> <script type="text/template" id="itemTemplate">
@} <div class="form-group" name="dictItem" id="dictItem">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-2">
<input class="form-control" type="text" name="itemNum">
</div>
<label class="col-sm-2 control-label" style="width: 8%;">名称</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="itemName">
</div>
<div class="col-sm-4">
<#button btnCss="danger" name="删除" id="cancel" icon="fa-remove" clickFun="DictInfoDlg.deleteItem(event)"/>
</div>
</div>
</script>
<script src="${ctxPath}/static/modular/system/dict/dict_info.js"></script>
@}
\ No newline at end of file
...@@ -5,13 +5,13 @@ var Feng = { ...@@ -5,13 +5,13 @@ var Feng = {
this.ctxPath = ctx; this.ctxPath = ctx;
} }
}, },
confirm : function(tip,ensure){//询问框 confirm: function (tip, ensure) {//询问框
parent.layer.confirm(tip, { parent.layer.confirm(tip, {
btn: ['确定','取消'] btn: ['确定', '取消']
}, function(index){ }, function (index) {
ensure(); ensure();
parent.layer.close(index); parent.layer.close(index);
}, function(index){ }, function (index) {
parent.layer.close(index); parent.layer.close(index);
}); });
}, },
...@@ -38,10 +38,10 @@ var Feng = { ...@@ -38,10 +38,10 @@ var Feng = {
display = info; display = info;
} else { } else {
if (info instanceof Array) { if (info instanceof Array) {
for(var x in info){ for (var x in info) {
display = display + info[x] + "<br/>"; display = display + info[x] + "<br/>";
} }
}else{ } else {
display = info; display = info;
} }
} }
...@@ -101,5 +101,10 @@ var Feng = { ...@@ -101,5 +101,10 @@ var Feng = {
ids += "," + nodes[i].id; ids += "," + nodes[i].id;
} }
return ids.substring(1); return ids.substring(1);
},
eventParseObject: function (event) {//获取点击事件的源对象
event = event ? event : window.event;
var obj = event.srcElement ? event.srcElement : event.target;
return $(obj);
} }
}; };
/** /**
* 初始化部门详情对话框 * 初始化字典详情对话框
*/ */
var DeptInfoDlg = { var DictInfoDlg = {
deptInfoData : {} count: 0,
dictName: '', //字典的名称
mutiString: '', //拼接字符串内容(拼接字典条目)
itemTemplate: $("#itemTemplate").html()
}; };
/** /**
* 清除数据 * item获取新的id
*/ */
DeptInfoDlg.clearData = function() { DictInfoDlg.newId = function () {
this.deptInfoData = {}; this.count = this.count + 1;
} return "dictItem" + this.count;
};
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
DeptInfoDlg.set = function(key, val) {
this.deptInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
return this;
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
DeptInfoDlg.get = function(key) {
return $("#" + key).val();
}
/** /**
* 关闭此对话框 * 关闭此对话框
*/ */
DeptInfoDlg.close = function() { DictInfoDlg.close = function () {
parent.layer.close(window.parent.Dept.layerIndex); parent.layer.close(window.parent.Dict.layerIndex);
} };
/** /**
* 点击部门ztree列表的选项时 * 添加条目
*
* @param e
* @param treeId
* @param treeNode
* @returns
*/ */
DeptInfoDlg.onClickDept = function(e, treeId, treeNode) { DictInfoDlg.addItem = function () {
$("#pName").attr("value", instance.getSelectedVal()); $("#itemsArea").append(this.itemTemplate);
$("#pid").attr("value", treeNode.id); $("#dictItem").attr("id", this.newId());
} };
/** /**
* 显示部门选择的树 * 删除item
*
* @returns
*/ */
DeptInfoDlg.showDeptSelectTree = function() { DictInfoDlg.deleteItem = function (event) {
var pName = $("#pName"); var obj = Feng.eventParseObject(event);
var pNameOffset = $("#pName").offset(); obj.parent().parent().remove();
$("#parentDeptMenu").css({ };
left : pNameOffset.left + "px",
top : pNameOffset.top + pName.outerHeight() + "px"
}).slideDown("fast");
$("body").bind("mousedown", onBodyDown);
}
/** /**
* 隐藏部门选择的树 * 清除为空的item Dom
*/ */
DeptInfoDlg.hideDeptSelectTree = function() { DictInfoDlg.clearNullDom = function(){
$("#parentDeptMenu").fadeOut("fast"); $("[name='dictItem']").each(function(){
$("body").unbind("mousedown", onBodyDown);// mousedown当鼠标按下就可以触发,不用弹起 var num = $(this).find("[name='itemNum']").val();
} var name = $(this).find("[name='itemName']").val();
if(num == '' || name == ''){
$(this).remove();
}
});
};
/** /**
* 收集数据 * 收集添加字典的数据
*/ */
DeptInfoDlg.collectData = function() { DictInfoDlg.collectData = function () {
this.set('id').set('simplename').set('fullname').set('tips').set('num').set('pid'); this.clearNullDom();
} var mutiString = "";
$("[name='dictItem']").each(function(){
var num = $(this).find("[name='itemNum']").val();
var name = $(this).find("[name='itemName']").val();
mutiString = mutiString + (num + ":" + name + ";");
});
this.dictName = $("#dictName").val();
this.mutiString = mutiString;
};
/** /**
* 提交添加部门 * 提交添加字典
*/ */
DeptInfoDlg.addSubmit = function() { DictInfoDlg.addSubmit = function () {
this.collectData();
this.clearData(); //提交信息
this.collectData(); var ajax = new $ax(Feng.ctxPath + "/dict/add", function (data) {
Feng.success("添加成功!");
//提交信息 window.parent.Dict.table.refresh();
var ajax = new $ax(Feng.ctxPath + "/dept/add", function(data){ DictInfoDlg.close();
Feng.success("添加成功!"); }, function (data) {
window.parent.Dept.table.refresh(); Feng.error("添加失败!" + data.responseJSON.message + "!");
DeptInfoDlg.close(); });
},function(data){ ajax.set('dictName',this.dictName);
Feng.error("添加失败!" + data.responseJSON.message + "!"); ajax.set('dictValues',this.mutiString);
}); ajax.start();
ajax.set(this.deptInfoData); };
ajax.start();
}
/** /**
* 提交修改 * 提交修改
*/ */
DeptInfoDlg.editSubmit = function() { DictInfoDlg.editSubmit = function () {
this.collectData();
this.clearData(); var ajax = new $ax(Feng.ctxPath + "/dict/update", function (data) {
this.collectData(); Feng.success("修改成功!");
window.parent.Dept.table.refresh();
//提交信息 DictInfoDlg.close();
var ajax = new $ax(Feng.ctxPath + "/dept/update", function(data){ }, function (data) {
Feng.success("修改成功!"); Feng.error("修改失败!" + data.responseJSON.message + "!");
window.parent.Dept.table.refresh(); });
DeptInfoDlg.close(); ajax.set(this.dictInfoData);
},function(data){ ajax.start();
Feng.error("修改失败!" + data.responseJSON.message + "!"); };
});
ajax.set(this.deptInfoData);
ajax.start();
}
function onBodyDown(event) {
if (!(event.target.id == "menuBtn" || event.target.id == "parentDeptMenu" || $(
event.target).parents("#parentDeptMenu").length > 0)) {
DeptInfoDlg.hideDeptSelectTree();
}
}
$(function() { $(function () {
var ztree = new $ZTree("parentDeptMenuTree", "/dept/tree"); var ztree = new $ZTree("parentDeptMenuTree", "/dept/tree");
ztree.bindOnClick(DeptInfoDlg.onClickDept); ztree.bindOnClick(DictInfoDlg.onClickDept);
ztree.init(); ztree.init();
instance = ztree; instance = ztree;
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment