Merge remote-tracking branch 'origin/master'
commit
5afdee12bb
|
@ -828,6 +828,7 @@ public class ProjectController extends BaseController {
|
|||
model.put("project", projectService.getProject(projectId));
|
||||
return "admin/project_select_role_user";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前所有的角色和角色下的用户,根据项目决定是否check
|
||||
*/
|
||||
|
@ -870,6 +871,57 @@ public class ProjectController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 进入选择页面
|
||||
*/
|
||||
@RequestMapping("/selectRoleUserBatch")
|
||||
public String selectRoleUserBatch(@RequestParam("ids") String ids, Map<String, Object> model) {
|
||||
model.put("projectId", ids);
|
||||
return "admin/project_select_role_user_batch";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前所有的角色和角色下的用户,根据项目决定是否check
|
||||
*/
|
||||
@RequestMapping("/roleUsersBatch")
|
||||
@ResponseBody
|
||||
public ResponseMsg roleUsersBatch(@RequestParam String projectId) {
|
||||
/*{ id:1, pId:0, name:"随意勾选 1", open:true},
|
||||
{ id:11, pId:1, name:"随意勾选 1-1", open:true},
|
||||
{ id:12, pId:1, name:"随意勾选 1-2", open:true},
|
||||
{ id:2, pId:0, name:"随意勾选 2", checked:true, open:true},
|
||||
{ id:21, pId:2, name:"随意勾选 2-1"},
|
||||
{ id:22, pId:2, name:"随意勾选 2-2", open:true},
|
||||
{ id:23, pId:2, name:"随意勾选 2-3"}*/
|
||||
List<ZTreeNode> zTreeNodes = projectService.getZTreeNodes();
|
||||
return ResponseMsg.buildSuccessData(zTreeNodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存项目与用户的关系
|
||||
*/
|
||||
@RequestMapping("/saveSelectRoleUserBatch")
|
||||
@ResponseBody
|
||||
public ResponseMsg saveSelectRoleUserBatch(@RequestBody String body) {
|
||||
/*{ id:1, pId:0, name:"随意勾选 1", open:true},
|
||||
{ id:11, pId:1, name:"随意勾选 1-1", open:true},
|
||||
{ id:12, pId:1, name:"随意勾选 1-2", open:true},
|
||||
{ id:2, pId:0, name:"随意勾选 2", checked:true, open:true},
|
||||
{ id:21, pId:2, name:"随意勾选 2-1"},
|
||||
{ id:22, pId:2, name:"随意勾选 2-2", open:true},
|
||||
{ id:23, pId:2, name:"随意勾选 2-3"}*/
|
||||
JSONObject jsonObject = JSON.parseObject(body);
|
||||
String projectId = jsonObject.getString(PROJECT_ID);
|
||||
String[] split = projectId.split(",");
|
||||
JSONArray array = jsonObject.getJSONArray("ids");
|
||||
String[] ids = new String[array.size()];
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
ids[i] = array.getString(i);
|
||||
}
|
||||
projectService.saveProjectVisibleBatch(split, ids);
|
||||
return ResponseMsg.buildSuccessMsg("成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除草稿状态下的概算项目
|
||||
*/
|
||||
|
@ -952,4 +1004,29 @@ public class ProjectController extends BaseController {
|
|||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 收入模板下载
|
||||
*/
|
||||
@RequestMapping("/incomeTemplate")
|
||||
public void incomeTemplate(HttpServletResponse response) throws Exception{
|
||||
|
||||
String[] headers = new String[]{"类别", "名称", "单位", "数量", "单价", "税率(%)"};
|
||||
downloadHeader(response , Utils.generateExcelName("收入明细表批量导入模板"));
|
||||
ExportUtils exportUtils = new ExportUtils(headers);
|
||||
exportUtils.write(response.getOutputStream());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支出模板下载
|
||||
*/
|
||||
@RequestMapping("/costTemplate")
|
||||
public void costTemplate(HttpServletResponse response) throws Exception{
|
||||
|
||||
String[] headers = new String[]{"大类", "类别", "名称", "单位", "数量", "单价", "税率(%)", "签约方", "是否垫资", "预估垫资金额(元)", "支出时间", "支出金额(元)", "付款方式", "备注"};
|
||||
downloadHeader(response , Utils.generateExcelName("采购成本明细表批量导入模板"));
|
||||
ExportUtils exportUtils = new ExportUtils(headers);
|
||||
exportUtils.write(response.getOutputStream());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -451,6 +451,35 @@ public class ProjectService {
|
|||
return zTreeNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把所有的角色和人员按照层级返回
|
||||
*/
|
||||
public List<ZTreeNode> getZTreeNodes(){
|
||||
List<SysRole> roleList = sysRoleRepository.findAllRole();
|
||||
//过滤掉系统管理员角色
|
||||
roleList = roleList.stream().filter(sysRole -> sysRole.getType()!=SysRole.ROLE_TYPE_SYSTEM).collect(Collectors.toList());
|
||||
|
||||
|
||||
List<Admin> adminList = adminRepository.getAllEnable();
|
||||
List<ZTreeNode> zTreeNodes = new ArrayList<>(roleList.size()+adminList.size());
|
||||
|
||||
List<ProjectVisible> visibleRoleList = new ArrayList<>();
|
||||
List<ProjectVisible> visibleUserList = new ArrayList<>();
|
||||
|
||||
|
||||
for (SysRole sysRole : roleList) {
|
||||
List<ZTreeNode> filterAdmins = filterAdmins(adminList, sysRole, visibleUserList);
|
||||
if(CollectionUtil.isNotEmpty(filterAdmins)){
|
||||
//下面有人才要
|
||||
zTreeNodes.add(new ZTreeNode(PREFIX_ROLE + sysRole.getId(), "0", sysRole.getName(),
|
||||
isChecked(visibleRoleList, sysRole.getId()), false));
|
||||
zTreeNodes.addAll(filterAdmins);
|
||||
}
|
||||
}
|
||||
|
||||
return zTreeNodes;
|
||||
}
|
||||
|
||||
private List<ZTreeNode> filterAdmins(List<Admin> adminList, SysRole sysRole, List<ProjectVisible> visibleUserList) {
|
||||
List<Admin> admins = adminList.stream()
|
||||
.filter(a -> sysRole.getId() == a.getRoleId())
|
||||
|
@ -499,6 +528,32 @@ public class ProjectService {
|
|||
projectVisibleRepository.save(pvs);
|
||||
}
|
||||
|
||||
public void saveProjectVisibleBatch(String[] split, String[] idss) {
|
||||
List<ProjectVisible> pvs = new ArrayList<>();
|
||||
for (String projectIdStr : split) {
|
||||
Integer projectId = Integer.parseInt(projectIdStr);
|
||||
//1.先清除以前的
|
||||
List<ProjectVisible> projectVisibles = projectVisibleRepository.findAllByProjectIdEquals(projectId);
|
||||
if(CollectionUtil.isNotEmpty(projectVisibles)){
|
||||
projectVisibleRepository.deleteInBatch(projectVisibles);
|
||||
}
|
||||
//2.再保存
|
||||
|
||||
for (String s : idss) {
|
||||
//只要用户的,角色的不要
|
||||
if(s.startsWith(PREFIX_USER)){
|
||||
ProjectVisible pv = new ProjectVisible();
|
||||
pv.setProjectId(projectId);
|
||||
pv.setType(ProjectVisible.TYPE_USER);
|
||||
//去掉前缀
|
||||
pv.setTid(Integer.parseInt(s.substring(PREFIX_USER.length())));
|
||||
pvs.add(pv);
|
||||
}
|
||||
}
|
||||
}
|
||||
projectVisibleRepository.save(pvs);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseMsg deleteProject(int id) {
|
||||
Project one = projectRepository.findOne(id);
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
$(function () {
|
||||
|
||||
$("#save").click(function () {
|
||||
var checkedNodes = zTreeNodes.getCheckedNodes();
|
||||
var ids = [];
|
||||
checkedNodes.forEach(function (t) {
|
||||
ids.push(t.id);
|
||||
});
|
||||
var ps = {
|
||||
projectId:$("input[name='projectId']").val(),
|
||||
ids:ids
|
||||
};
|
||||
postAjax(base+"/project/saveSelectRoleUserBatch", ps, function (p,d) {
|
||||
window.location.href=base+"/project/list";
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var params = {
|
||||
projectId:$("input[name='projectId']").val()
|
||||
};
|
||||
getAjax(base+"/project/roleUsersBatch",params,function (p,d) {
|
||||
zTreeNodes = initZTree(d);
|
||||
});
|
||||
|
||||
function initZTree(data) {
|
||||
var setting = {
|
||||
check: {
|
||||
enable: true
|
||||
},
|
||||
data: {
|
||||
simpleData: {
|
||||
enable: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*var zNodes =[
|
||||
{ id:1, pId:0, name:"随意勾选 1", open:true},
|
||||
{ id:11, pId:1, name:"随意勾选 1-1", open:true},
|
||||
{ id:111, pId:11, name:"随意勾选 1-1-1"},
|
||||
{ id:112, pId:11, name:"随意勾选 1-1-2"},
|
||||
{ id:12, pId:1, name:"随意勾选 1-2", open:true},
|
||||
{ id:121, pId:12, name:"随意勾选 1-2-1"},
|
||||
{ id:122, pId:12, name:"随意勾选 1-2-2"},
|
||||
{ id:2, pId:0, name:"随意勾选 2", checked:true, open:true},
|
||||
{ id:21, pId:2, name:"随意勾选 2-1"},
|
||||
{ id:22, pId:2, name:"随意勾选 2-2", open:true},
|
||||
{ id:221, pId:22, name:"随意勾选 2-2-1", checked:true},
|
||||
{ id:222, pId:22, name:"随意勾选 2-2-2"},
|
||||
{ id:23, pId:2, name:"随意勾选 2-3"}
|
||||
];*/
|
||||
var zTreeNodes = $.fn.zTree.init($("#treeSelectRoleUser"), setting, data.data);
|
||||
return zTreeNodes;
|
||||
}
|
||||
});
|
||||
|
|
@ -623,6 +623,23 @@
|
|||
<div class="am-tabs-bd">
|
||||
<div class="am-tab-panel am-fade am-in" id="tab3">
|
||||
<div class="am-modal-bd">
|
||||
<div class="am-u-sm-12 am-u-md-12" style="padding:0 1.6rem 1.6rem 1rem;margin:0;">
|
||||
<div class="am-btn-toolbar" style="padding-left:.5rem;">
|
||||
<div class="am-btn-group am-btn-group-xs">
|
||||
<div class="am-btn-group am-btn-group-xs am-form-file">
|
||||
<button type="button" id="bt_import" class="am-btn am-btn-default">
|
||||
<span class="am-icon-archive"></span>
|
||||
批量导入
|
||||
</button>
|
||||
<input id="doc-form-file" type="file" name="file" onChange="ajaxUploadFile('doc-form-file','${base}/project/batchIncomeImport')">
|
||||
</div>
|
||||
|
||||
<button type="button" class="am-btn am-btn-default" onclick="location.href='${base}/project/incomeTemplate'">
|
||||
<span class="am-icon-archive"></span> 导入模板下载
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;" id="incomeTable">
|
||||
<tbody>
|
||||
<tr>
|
||||
|
@ -733,6 +750,23 @@
|
|||
<div class="am-tabs-bd">
|
||||
<div class="am-tab-panel am-fade am-in" id="tab4">
|
||||
<div class="am-modal-bd">
|
||||
<div class="am-u-sm-12 am-u-md-12" style="padding:0 1.6rem 1.6rem 1rem;margin:0;">
|
||||
<div class="am-btn-toolbar" style="padding-left:.5rem;">
|
||||
<div class="am-btn-group am-btn-group-xs">
|
||||
<div class="am-btn-group am-btn-group-xs am-form-file">
|
||||
<button type="button" id="bt_import" class="am-btn am-btn-default">
|
||||
<span class="am-icon-archive"></span>
|
||||
批量导入
|
||||
</button>
|
||||
<input id="doc-form-file" type="file" name="file" onChange="ajaxUploadFile('doc-form-file','${base}/project/batchCostImport')">
|
||||
</div>
|
||||
|
||||
<button type="button" class="am-btn am-btn-default" onclick="location.href='${base}/project/costTemplate'">
|
||||
<span class="am-icon-archive"></span> 导入模板下载
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;" id="costTable">
|
||||
<tbody>
|
||||
<tr>
|
||||
|
@ -1359,6 +1393,52 @@
|
|||
}
|
||||
};
|
||||
|
||||
function ajaxUploadFile(id, url) {
|
||||
// if($('#modal')){
|
||||
// $('#modal').modal('open');
|
||||
// $('#span-'+id).html(" 数据正在导入,请等待");
|
||||
// }
|
||||
$.ajaxFileUpload({
|
||||
url: url,
|
||||
secureuri: false,
|
||||
fileElementId: id,// file标签的id
|
||||
dataType: 'json',// 返回数据的类型
|
||||
success: function (data, status) {
|
||||
console.log("--------success---------" + data)
|
||||
// if($('#modal')){
|
||||
// $('#modal').modal('close');
|
||||
// $('#span-'+id).html("导入完成");
|
||||
// }
|
||||
if(data.status ==0) {
|
||||
var list = data.data;
|
||||
var content = '';
|
||||
$.each(list, function (i, r) {
|
||||
content += (i+1) + '、' + r + '<br>';
|
||||
});
|
||||
console.log('---> ' + content);
|
||||
parent.layer.open({
|
||||
title: '导入结果:' ,
|
||||
content: data.msg + '<br><br>' + content
|
||||
});
|
||||
}else{
|
||||
parent.layer.msg(data.msg);
|
||||
}
|
||||
|
||||
window.location.reload();
|
||||
$("#" + id).val("");
|
||||
},
|
||||
error: function (data, status, e) {
|
||||
console.log("--------error---------" + data)
|
||||
alert("-----------------" + data);
|
||||
// if ($('#modal')) {
|
||||
// $('#modal').modal('close');
|
||||
// }
|
||||
alert(e);
|
||||
$("#" + id).val("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var generateFileupload = function (name) {
|
||||
var progressArea = $("#progress-area-" + name);//div
|
||||
var progressText = $("#progress-text-" + name);//进度条提示
|
||||
|
|
|
@ -304,6 +304,15 @@
|
|||
<span class="am-icon-refresh"></span> 批量指定承接人
|
||||
</button>
|
||||
|
||||
<button type="button" id="authorizeButton" disabled class="am-btn am-btn-default"
|
||||
onclick="authorize('${base}/project/selectRoleUserBatch')" >
|
||||
<span class="am-icon-trash-o"></span> 批量配置项目可见性
|
||||
</button>
|
||||
|
||||
<#-- <button type="button" class="am-btn am-btn-default"-->
|
||||
<#-- onclick="location.href='${base}/project/selectRoleUser?projectId=${list.id}'">-->
|
||||
<#-- <span class="am-icon-refresh"></span> 批量配置项目可见性-->
|
||||
<#-- </button>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -315,6 +324,8 @@
|
|||
<table class="am-table am-table-striped am-table-hover table-main">
|
||||
<thead>
|
||||
<tr class="am-text-nowrap">
|
||||
<th class="table-check">
|
||||
<input type="checkbox" id="allCheck"></th>
|
||||
<th class="table-title">序号</th>
|
||||
<th class="table-title">项目编号</th>
|
||||
<th class="table-title">项目名称</th>
|
||||
|
@ -353,6 +364,8 @@
|
|||
<tbody>
|
||||
<#list pager.list as list>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" name="ids" value="${list.id!}" /></td>
|
||||
<td>${list.tempId!}</td>
|
||||
<td class="huanhang">${list.projectNo!}</td>
|
||||
<td class="huanhang"><a style="cursor: pointer;text-decoration:none" onclick="location.href='${base}/project/approve?listFrom=list&type=1&id=${list.id}'">${list.name!}</a></td>
|
||||
|
@ -737,6 +750,36 @@
|
|||
$("#listForm").submit();
|
||||
});
|
||||
|
||||
var $allCheck = $("#allCheck");// 全选复选框
|
||||
var $idsCheck = $('[name=ids]:checkbox');// ID复选框
|
||||
var $authorizeButton = $("#authorizeButton");// 批量按钮
|
||||
|
||||
// 全选
|
||||
$allCheck.click(function() {
|
||||
var isChecked = $allCheck.is(":checked");
|
||||
if (isChecked == false) {
|
||||
$authorizeButton.prop("disabled", true);
|
||||
$idsCheck.prop("checked", false);
|
||||
} else {
|
||||
$authorizeButton.prop("disabled", false);
|
||||
$idsCheck.prop("checked", true);
|
||||
}
|
||||
});
|
||||
|
||||
// 无复选框被选中时,批量按钮不可用
|
||||
$idsCheck.click(function() {
|
||||
var $idsChecked = $("[name='ids']:checked");
|
||||
if ($idsChecked.length > 0) {
|
||||
$authorizeButton.prop("disabled", false);
|
||||
} else {
|
||||
$authorizeButton.prop("disabled", true);
|
||||
}
|
||||
if($idsChecked.length == $idsCheck.length){
|
||||
$allCheck.prop("checked", true);
|
||||
}else {
|
||||
$allCheck.prop("checked", false);
|
||||
}
|
||||
});
|
||||
|
||||
function setKeywords() {
|
||||
var keywordsObj = {};
|
||||
|
@ -800,6 +843,19 @@
|
|||
generateFileupload("icon");
|
||||
});
|
||||
|
||||
// 批量可见性
|
||||
var authorize = function(url){
|
||||
// var $authorizeButton = $("#authorizeButton");// 删除按钮
|
||||
var ids = "";
|
||||
$("input[name='ids']:checked").each(function(){
|
||||
console.log("id: " + $(this).val());
|
||||
ids +=$(this).val()+",";
|
||||
console.log("ids: " + ids);
|
||||
});
|
||||
console.log("url: " + url + "?ids=" + ids);
|
||||
location.href=url + "?ids=" + ids;
|
||||
}
|
||||
|
||||
|
||||
//会签
|
||||
var huiQian = function () {
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<#assign base=request.contextPath />
|
||||
<#import "../common/defaultLayout.ftl" as defaultLayout>
|
||||
<@defaultLayout.layout>
|
||||
<link rel="stylesheet" href="${base}/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
|
||||
<style>
|
||||
/*ul.ztree {
|
||||
margin-top: 10px;
|
||||
border: 1px solid #617775;
|
||||
background: #f0f6e4;
|
||||
width:220px;
|
||||
height:360px;
|
||||
overflow-y:scroll;
|
||||
overflow-x:auto;
|
||||
}*/
|
||||
</style>
|
||||
<div class="admin-content">
|
||||
<div class="admin-content-body">
|
||||
<div class="am-cf am-padding">
|
||||
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">项目管理</strong> / <small>请批量设置项目可见性</small></div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="projectId" value="${projectId}">
|
||||
|
||||
请勾选能够看到该项目的人员或角色
|
||||
<ul id="treeSelectRoleUser" class="ztree"></ul>
|
||||
<div class="am-margin">
|
||||
<button type="button" class="am-btn am-btn-warning am-btn-xs" onclick="javascript:history.go(-1);">返回上一级</button>
|
||||
<button type="button" class="am-btn am-btn-primary am-btn-xs" id="save">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</@defaultLayout.layout>
|
||||
<script>
|
||||
var base = "${base}";
|
||||
</script>
|
||||
<script src="${base}/assets/js/project_common.js"></script>
|
||||
<script type="text/javascript" src="${base}/ztree/js/jquery.ztree.core.js"></script>
|
||||
<script type="text/javascript" src="${base}/ztree/js/jquery.ztree.excheck.js"></script>
|
||||
<script type="text/javascript" src="${base}/ztree/js/jquery.ztree.exedit.js"></script>
|
||||
<script src="${base}/assets/js/project_select_role_user_batch.js"></script>
|
Loading…
Reference in New Issue