main
tamguo 7 years ago
parent 1a371dc003
commit 656ff71f93

@ -12,4 +12,6 @@ public interface ISysOfficeService {
JSONArray treeData(String excludeId); JSONArray treeData(String excludeId);
void save(SysOfficeEntity office);
} }

@ -1,8 +1,11 @@
package com.tamguo.modules.sys.service.impl; package com.tamguo.modules.sys.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
@ -12,6 +15,7 @@ import com.tamguo.modules.sys.dao.SysOfficeMapper;
import com.tamguo.modules.sys.model.SysOfficeEntity; import com.tamguo.modules.sys.model.SysOfficeEntity;
import com.tamguo.modules.sys.model.condition.SysOfficeCondition; import com.tamguo.modules.sys.model.condition.SysOfficeCondition;
import com.tamguo.modules.sys.service.ISysOfficeService; import com.tamguo.modules.sys.service.ISysOfficeService;
import com.tamguo.modules.sys.utils.ShiroUtils;
@Service @Service
public class SysOfficeServiceImpl implements ISysOfficeService { public class SysOfficeServiceImpl implements ISysOfficeService {
@ -54,4 +58,21 @@ public class SysOfficeServiceImpl implements ISysOfficeService {
return null; return null;
} }
@Transactional(readOnly=false)
@Override
public void save(SysOfficeEntity office) {
office.setCreateBy(ShiroUtils.getUserCode());
office.setCreateDate(new Date());
office.setUpdateBy(ShiroUtils.getUserCode());
office.setUpdateDate(new Date());
office.setOfficeCode(office.getViewCode());
office.setParentCode("0");
office.setParentCodes("0,");
office.setTreeSorts(office.getTreeSort() + ",");
office.setTreeLeaf(false);
office.setTreeLevel(BigDecimal.valueOf(0));
office.setTreeNames(office.getOfficeName() + ",");
sysOfficeMapper.insert(office);
}
} }

@ -11,6 +11,8 @@ import com.alibaba.fastjson.JSONArray;
import com.tamguo.modules.sys.model.SysOfficeEntity; import com.tamguo.modules.sys.model.SysOfficeEntity;
import com.tamguo.modules.sys.model.condition.SysOfficeCondition; import com.tamguo.modules.sys.model.condition.SysOfficeCondition;
import com.tamguo.modules.sys.service.ISysOfficeService; import com.tamguo.modules.sys.service.ISysOfficeService;
import com.tamguo.modules.sys.utils.ExceptionSupport;
import com.tamguo.modules.sys.utils.Result;
/** /**
* Controller - * Controller -
@ -36,6 +38,17 @@ public class SysOfficeController {
public JSONArray treeData(String excludeId) { public JSONArray treeData(String excludeId) {
return iSysOfficeService.treeData(excludeId); return iSysOfficeService.treeData(excludeId);
} }
@RequestMapping(path="save")
@ResponseBody
public Result save(SysOfficeEntity office) {
try {
iSysOfficeService.save(office);
return Result.result(0, null, "新增机构【"+office.getOfficeName()+"】成功!");
} catch (Exception e) {
return ExceptionSupport.resolverResult("新增机构", this.getClass(), e);
}
}
} }

@ -0,0 +1,291 @@
<!DOCTYPE html><html><head><meta charset="utf-8"><meta content="webkit" name="renderer"/><meta http-equiv="X-UA-Compatible"
content="IE=edge"><meta name="keywords" content="PoweredByJeeSiteV4.0"/><meta http-equiv="Cache-Control"
content="no-cache, no-store, must-revalidate"/><meta name="description" content="PoweredByJeeSiteV4.0"/><meta
content="no-cache" http-equiv="Pragma"/><meta http-equiv="Expires" content="0"/><meta
content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
<title>机构管理 - JeeSite Demo</title>
<script th:src="${setting.domain + 'global.min.js'}"></script>
<script th:src="${setting.domain + 'jquery/jquery-1.12.4.min.js'}"></script>
<script th:src="${setting.domain + 'jquery/jquery-migrate-1.4.1.min.js'}"></script>
<!--[if lt IE 9]><script src="/js/static/common/h5fix.min.js"></script><![endif]-->
<link rel="stylesheet" th:href="${setting.domain + 'fonts/font-icons.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'bootstrap/css/bootstrap.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'select2/4.0/select2.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'icheck/1.0/minimal/grey.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'adminlte/css/AdminLTE.min.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'common/jeesite.css'}">
<link rel="stylesheet" th:href="${setting.domain + 'common/common.css'}">
</head><body class="hold-transition ">
<div class="wrapper"><div class="main-content">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-grid"></i> 新增机构
</div>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
</div>
<form id="inputForm" th:action="${setting.domain + 'sys/office/save'}" method="post" class="form-horizontal">
<div class="box-body">
<div class="form-unit">基本信息</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4">上级机构:</label>
<div class="col-sm-8">
<div class="input-group treeselect" id="parentDiv" data-url="sys/office/treeData?excludeCode='">
<input id="parentCode" type="hidden" name="parent.id" value="" class="isReset"/>
<input id="parentName" type="text" name="parent.officeName" value=""
class="form-control " readonly="readonly"
/><span class="input-group-btn"><a id="parentButton" href="javascript:"
class="btn btn-default "><i class="fa fa-search"></i></a>
</span>
</div>
<script>
$("#parentButton,#parentName").click(function(){
if ($("#parentButton").hasClass("disabled")){
return true;
}
var options = {
type: 2,
maxmin: true,
shadeClose: true,
title: '上级机构',
area: ['300px', '400px'],
content: 'sys/treeselect',
contentFormData: {
url: $('#parentDiv').attr('data-url'),
checkbox: 'false',
expandLevel: '-1',
selectCodes: $("#parentCode").val(),
isReturnValue: 'false'
},
success: function(layero, index){
if ($(js.layer.window).width() < 300
|| $(js.layer.window).height() < 400){
js.layer.full(index);
}
},
btn: ['<i class="fa fa-check"></i> 确定'],
btn1: function(index, layero){
var win = js.layer.iframeWindow(index);
win.$('#keyword').val('').change(); var codes = [], names = [], nodes;
if ("false" == "true"){
nodes = win.tree.getCheckedNodes(true);
}else{
nodes = win.tree.getSelectedNodes();
}
for(var i=0; i<nodes.length; i++) {
var code = nodes[i]['false'=='true'?'value':'id'], name = nodes[i]['name'];
codes.push(code.replace(/^u_/g,''));
names.push(name.replace(/\([0-9]*\)/g,''));
break;
}
if(typeof treeselectCheck == 'function'){
if (!treeselectCheck('parent', nodes)){
return false;
}
}
$("#parentCode").val(codes.join(',')).change();
$("#parentName").val(names.join(',')).change();
try { $('#parentCode,#parentName').valid(); }catch(e){}
if(typeof treeselectCallback == 'function'){
treeselectCallback('parent', 'ok', index, layero, nodes);
}
}
};
options.btn.push('<i class="fa fa-eraser"></i> 清除');
options['btn'+options.btn.length] = function(index, layero){
$("#parentCode").val('').change();
$("#parentName").val('').change();
if(typeof treeselectCallback == 'function'){
treeselectCallback('parent', 'clear', index, layero);
}
};
options.btn.push('<i class="fa fa-close"></i> 关闭');
options['btn'+options.btn.length] = function(index, layero){
if(typeof treeselectCallback == 'function'){
treeselectCallback('parent', 'cancel', index, layero);
}
};
js.layer.open(options);
});
</script> </div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required ">*</span> 机构名称:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="officeName" name="officeName" value="" maxlength="100" class="form-control required "/>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required ">*</span> 机构代码:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="hidden" id="isNewRecord" name="isNewRecord" value="true"/>
<input type="hidden" id="officeCode" name="officeCode" value=""/>
<input type="text" id="viewCode" name="viewCode" value="SD1" maxlength="64" class="form-control required abc"/>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required ">*</span> 机构全称:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="fullName" name="fullName" value="" maxlength="200" class="form-control required "/>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required ">*</span> 排序号:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="treeSort" name="treeSort" value="70" maxlength="10" class="form-control required digits"/>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required ">*</span> 机构类型:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<select id="officeType" name="officeType" class="form-control required ">
<option value="1">省级公司</option>
<option value="2">市级公司</option>
<option value="3">部门</option>
</select>
</div>
</div>
</div>
</div>
<div class="form-unit">详细信息</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required hide">*</span> 负责人:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="leader" name="leader" value="" maxlength="100" class="form-control "/>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required hide">*</span> 办公电话:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="phone" name="phone" value="" maxlength="100" class="form-control phone"/>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required hide">*</span> 联系地址:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="address" name="address" value="" maxlength="255" class="form-control "/>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required hide">*</span> 邮政编码:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="zipCode" name="zipCode" value="" maxlength="100" class="form-control zipCode"/>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label col-sm-4" title="">
<span class="required hide">*</span> 电子邮箱:<i class="fa icon-question hide"></i></label>
<div class="col-sm-8">
<input type="text" id="email" name="email" value="" maxlength="300" class="form-control email"/>
</div>
</div>
</div>
<div class="col-xs-12">
<div class="form-group">
<label class="control-label col-sm-2" title="">
<span class="required hide">*</span> 备注信息:<i class="fa icon-question hide"></i></label>
<div class="col-sm-10">
<textarea id="remarks" name="remarks" rows="4" maxlength="500" class="form-control "></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="box-footer">
<div class="row">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>&nbsp;
<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> 关 闭</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<a id="scroll-up" href="#" class="btn btn-sm"><i class="fa fa-angle-double-up"></i></a>
<script th:src="${setting.domain + 'bootstrap/js/bootstrap.min.js'}"></script>
<script th:src="${setting.domain + 'select2/4.0/select2.js'}"></script>
<script th:src="${setting.domain + 'select2/4.0/i18n/zh_CN.js'}"></script>
<script th:src="${setting.domain + 'layer/3.1/layer.js'}"></script>
<script th:src="${setting.domain + 'my97/WdatePicker.js'}"></script>
<script th:src="${setting.domain + 'jquery-validation/1.16/jquery.validate.js'}"></script>
<script th:src="${setting.domain + 'jquery-validation/1.16/localization/messages_zh_CN.js'}"></script>
<script th:src="${setting.domain + 'jquery-validation/1.16/jquery.validate.extend.js'}"></script>
<script th:src="${setting.domain + 'common/jeesite.js'}"></script>
<script th:src="${setting.domain + 'common/i18n/jeesite_zh_CN.js'}"></script>
<script th:src="${setting.domain + 'common/common.js'}"></script>
<script>
$("#inputForm").validate({
submitHandler: function(form){
js.ajaxSubmitForm($(form), function(data){
js.showMessage(data.message);
if(data.result == Global.TRUE){
js.closeCurrentTabPage(function(contentWindow){
contentWindow.$('#dataGrid').dataGrid('refreshTreeChildren',
$('#parentCode').val(), '');
});
}
}, "json");
}
});
$('#officeName').change(function(){
if ($('#fullName').val()==''){
$('#fullName').val($(this).val());
}
});
// 选择父级菜单回调方法
function treeselectCallback(id, act, index, layero){
if (id == 'parent' && (act == 'ok' || act == 'clear')){
// 创建并初始化下一个节点信息,如:排序号、默认值
$.get('sys/office/createNextNode?parentCode='
+$('#parentCode').val(), function(data){
$('#treeSort').val(data.treeSort);
});
}
}
</script>

@ -32,7 +32,7 @@ content="width=device-width, initial-scale=1, user-scalable=1" name="viewport"/>
<a href="#" class="btn btn-default" id="btnRefreshTree" title="刷新"><i class="fa fa-refresh"></i> 刷新</a> <a href="#" class="btn btn-default" id="btnRefreshTree" title="刷新"><i class="fa fa-refresh"></i> 刷新</a>
<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="展开一级"><i class="fa fa-angle-double-down"></i> 展开</a> <a href="#" class="btn btn-default" id="btnExpandTreeNode" title="展开一级"><i class="fa fa-angle-double-down"></i> 展开</a>
<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="折叠全部"><i class="fa fa-angle-double-up"></i> 折叠</a> <a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="折叠全部"><i class="fa fa-angle-double-up"></i> 折叠</a>
<a href="/js/a/sys/office/form" class="btn btn-default btnTool" title="新增机构"><i class="fa fa-plus"></i> 新增</a> <a th:href="${setting.domain + 'sys/office/add'}" class="btn btn-default btnTool" title="新增机构"><i class="fa fa-plus"></i> 新增</a>
</div> </div>
</div> </div>
<div class="box-body"> <div class="box-body">

Loading…
Cancel
Save