Commit d9be71bd by fsn

添加字典页面完成

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