<div class="clear-float height_100p">
|
<div class="float_l left_tree_wrap">
|
<ul id="department_tree_wrap"></ul>
|
</div>
|
<div class="float_l folding_partition_line">
|
<img src="image/hide_left_tree.png" width="19" class="operation_left_tree_img">
|
</div>
|
<div class="float_l form_and_table_wrap">
|
<form class="layui-form">
|
<div class="layui-form-item">
|
<div class="layui-inline">
|
<label class="layui-form-label">机构编号:</label>
|
<div class="layui-input-inline">
|
<input type="text" name="identityCode" autocomplete="off" class="layui-input">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">机构名称:</label>
|
<div class="layui-input-inline">
|
<input type="text" name="orgName" autocomplete="off" class="layui-input">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">状态:</label>
|
<div class="layui-input-inline">
|
<select name="state">
|
<option value="">请选择</option>
|
<option value="0">启用</option>
|
<option value="1">停用</option>
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
<button class="layui-btn" lay-submit lay-filter="org_search" id="org_mgt_trigger_search_btn">搜索</button>
|
</div>
|
</div>
|
</form>
|
<button style="margin-bottom: 20px;" class="layui-btn page_add_btn" id="add_oganization"><i class="layui-icon"></i>新增机构</button>
|
<table id="oganization_management_table" lay-filter="oganization_management_table"></table>
|
</div>
|
</div>
|
|
<script>
|
window.g_org_parentCode = "";
|
|
function org_tree_render(){
|
$("#department_tree_wrap").empty();
|
layui.use('tree', function(){
|
$.ajax({
|
type : 'POST',
|
url : base_url+"/sso-manage/org/getOrgTree",
|
dataType : 'json',
|
contentType: "application/json",
|
success : function(res){
|
|
if(res.resultCode == 1){
|
layui.tree({
|
elem: '#department_tree_wrap' //传入元素选择器
|
,nodes: res.data.list
|
,click: function(node){
|
$("#department_tree_wrap a").click(function () {
|
$("#department_tree_wrap a").removeClass("text_red");
|
$(this).addClass("text_red");
|
});
|
// console.log('节点数据',node) //node即为当前点击的节点数据
|
window.g_org_parentCode = node.orgCode;
|
$("#org_mgt_trigger_search_btn").trigger("click");
|
}
|
});
|
}else{
|
layer.msg(res.errorDesc);
|
}
|
}
|
});
|
});
|
}
|
|
|
org_tree_render();
|
</script>
|
|
<script>
|
layui.use(['table', 'element', 'form'], function () {
|
var index = layer.load(0, {time: 5 * 1000});
|
var table = layui.table;
|
var form = layui.form;
|
//table渲染
|
var organization_mgt_table = table.render({
|
elem: '#oganization_management_table'
|
, id: 'oganization_management_table'
|
, url: base_url+'/sso-manage/org/search' //数据接口
|
, method: 'post'
|
,contentType: 'application/json'
|
,request: {
|
pageName: 'pageNum' //页码的参数名称,默认:page
|
,limitName: 'pageSize' //每页数据量的参数名,默认:limit
|
}
|
, page: true //开启分页
|
, limit: 10
|
, done: function (res, curr, count) {
|
var element = layui.element;
|
element.init();
|
form.render();
|
layer.close(index);
|
|
}
|
,parseData: function(res){ //res 即为原始返回的数据
|
return {
|
"code": res.resultCode, //解析接口状态
|
"msg": res.errorDesc, //解析提示文本
|
"count": res.total, //解析数据长度
|
"data": res.data.list //解析数据列表
|
};
|
}
|
, response: {
|
statusName: 'code' //数据状态的字段名称,默认:code
|
, statusCode: '1' //成功的状态码,默认:0
|
, msgName: 'msg' //状态信息的字段名称,默认:msg
|
, countName: 'count' //数据总数的字段名称,默认:count
|
, dataName: 'data' //数据列表的字段名称,默认:data
|
}
|
, cols: [[
|
{type: 'numbers', title: '序号', width: 60}
|
, {title: '机构编号',templet: '#org_view_tpl',width:150}
|
, {field: 'orgName', title: '机构名称',minWidth:150}
|
, {field: 'levelDesc', title: '级别',minWidth:120}
|
, {field: 'parentName', title: '上级机构',minWidth:150}
|
, {title: '状态',templet:'#state_tpl',width:90}
|
, {title: '机构管理', templet: '#operation_tpl',width:150}
|
]]
|
});
|
|
// 搜索
|
form.on('submit(org_search)',function (data) {
|
data.field.parentCode = window.g_org_parentCode;
|
var index = layer.load(0,{time:5*1000});
|
organization_mgt_table.reload({
|
where:{params:data.field},
|
done: function (res, curr, count) {
|
layer.close(index);
|
|
}
|
});
|
return false;
|
});
|
|
// 新增
|
$("#add_oganization").click(function () {
|
$.get('views/jurisdiction/organization_add_modal.html', function(str){
|
window.organization_add_modal_index = layer.open({
|
type: 1
|
,title :'新增机构'
|
,content: str //注意,如果str是object,那么需要字符拼接。
|
,area: '700px'
|
});
|
});
|
});
|
|
table.on('tool(oganization_management_table)',function (obj) {
|
var data = obj.data;
|
var event = obj.event;
|
if(event == 'enable'){
|
// 启用
|
$.ajax({
|
type : 'POST',
|
url : base_url+"/sso-manage/org/modifyState",
|
dataType : 'json',
|
contentType: "application/json",
|
data:JSON.stringify({
|
params:{
|
"orgCode":data.orgCode,
|
"state":0
|
}
|
}),
|
success : function(res){
|
|
if(res.resultCode == 1){
|
layer.msg("状态启用成功");
|
$("#org_mgt_trigger_search_btn").trigger("click");
|
}else{
|
layer.msg(res.errorDesc);
|
}
|
}
|
});
|
}else if(event == 'discontinue_use'){
|
// 停用
|
$.ajax({
|
type : 'POST',
|
url : base_url+"/sso-manage/org/modifyState",
|
dataType : 'json',
|
contentType: "application/json",
|
data:JSON.stringify({
|
params:{
|
"orgCode":data.orgCode,
|
"state":1
|
}
|
}),
|
success : function(res){
|
|
if(res.resultCode == 1){
|
layer.msg("状态停用成功");
|
$("#org_mgt_trigger_search_btn").trigger("click");
|
}else{
|
layer.msg(res.errorDesc);
|
}
|
}
|
});
|
}else if(event == 'edit'){
|
// 修改
|
window._organization_edit_id = data.orgCode;
|
$.get('views/jurisdiction/organization_edit_modal.html', function(str){
|
window.organization_edit_modal_index = layer.open({
|
type: 1
|
,title :'机构修改'
|
,content: str //注意,如果str是object,那么需要字符拼接。
|
,area: '700px'
|
});
|
});
|
}else if(event == 'org_view'){
|
// 查看
|
window._organization_view_id = data.orgCode;
|
$.get('views/jurisdiction/organization_view_modal.html', function(str){
|
window.organization_view_modal_index = layer.open({
|
type: 1
|
,title :'查看'
|
,content: str //注意,如果str是object,那么需要字符拼接。
|
,area: '700px'
|
});
|
});
|
}
|
});
|
|
});
|
</script>
|
|
<script type="text/html" id="state_tpl">
|
{{# if(d.state == 0){ }}
|
启用
|
{{# } else if(d.state == 1){ }}
|
停用
|
{{# } }}
|
</script>
|
|
<script type="text/html" id="operation_tpl">
|
{{# if(d.state == 1){ }}
|
<a class="tool_event_textbtn" lay-event="enable">启用</a>
|
{{# } else if(d.state == 0){ }}
|
<a class="tool_event_textbtn" lay-event="discontinue_use">停用</a>
|
{{# } }}
|
<a class="tool_event_textbtn" lay-event="edit">修改</a>
|
</script>
|
|
<script type="text/html" id="org_view_tpl">
|
<span class="tool_event_textbtn" lay-event="org_view">{{d.identityCode}}</span>
|
</script>
|
|
<script id="org_type_select_tpl" type="text/html">
|
{{each list value index}}
|
<option value="{{value.orgType}}">{{value.typeName}}</option>
|
{{/each}}
|
</script>
|
|
<script id="parent_org_select_tpl" type="text/html">
|
{{each list value index}}
|
<option value="{{value.orgCode}}">{{value.shortName}}</option>
|
{{/each}}
|
</script>
|