mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
120 lines
3.6 KiB
JavaScript
120 lines
3.6 KiB
JavaScript
layui.config({
|
|
base: "/js/"
|
|
}).use(['form','ztree', 'layer', 'jquery', 'table','droptree','openauth','utils','cookie'], function () {
|
|
var form = layui.form,
|
|
layer = layui.layer,
|
|
$ = layui.jquery;
|
|
var table = layui.table;
|
|
var openauth = layui.openauth;
|
|
var toplayer = (top == undefined || top.layer === undefined) ? layer : top.layer; //顶层的LAYER
|
|
|
|
//左边树状机构列表
|
|
var ztree = function () {
|
|
var url = '/UserSession/GetOrgs';
|
|
var zTreeObj;
|
|
var setting = {
|
|
view: {
|
|
selectedMulti: false ,
|
|
nameIsHTML: true
|
|
},
|
|
data: {
|
|
key: {
|
|
name: 'Name',
|
|
title: 'Name'
|
|
},
|
|
simpleData: {
|
|
enable: true,
|
|
idKey: 'Id',
|
|
pIdKey: 'ParentId',
|
|
rootPId: ""
|
|
}
|
|
},
|
|
callback: {
|
|
onClick: function (event, treeId, treeNode) {
|
|
$.cookie('defaultorgid', treeNode.Id, {path: '/'});
|
|
load();
|
|
}
|
|
}
|
|
};
|
|
var load = function () {
|
|
$.getJSON(url, function (json) {
|
|
zTreeObj = $.fn.zTree.init($("#tree"), setting);
|
|
var defaultorgid = $.cookie('defaultorgid');
|
|
if(defaultorgid != undefined) {
|
|
$.each(json.Result, function () {
|
|
var element = this;
|
|
if (element.Id == defaultorgid) {
|
|
element.Name = "<font color='red'>"+element.Name + "(当前默认)"+"</font>"
|
|
}
|
|
});
|
|
}
|
|
zTreeObj.addNodes(null, json.Result);
|
|
zTreeObj.expandAll(true);
|
|
});
|
|
};
|
|
load();
|
|
return {
|
|
reload: load
|
|
}
|
|
}();
|
|
|
|
$("#tree").height( $("div.layui-table-view").height());
|
|
|
|
|
|
//模块列表
|
|
var ztreeModule = function () {
|
|
var url = '/UserSession/GetModules';
|
|
var zTreeObj;
|
|
var setting = {
|
|
view: { selectedMulti: false },
|
|
data: {
|
|
key: {
|
|
name: 'Name',
|
|
title: 'Name'
|
|
},
|
|
simpleData: {
|
|
enable: true,
|
|
idKey: 'Id',
|
|
pIdKey: 'ParentId',
|
|
rootPId: ""
|
|
}
|
|
},
|
|
callback: {
|
|
onClick: function (event, treeId, treeNode) {
|
|
//mainList({ orgId: treeNode.Id });
|
|
}
|
|
}
|
|
};
|
|
var load = function () {
|
|
$.getJSON(url, function (json) {
|
|
zTreeObj = $.fn.zTree.init($("#treeModule"), setting);
|
|
zTreeObj.addNodes(null, json.Result);
|
|
zTreeObj.expandAll(true);
|
|
});
|
|
};
|
|
load();
|
|
return {
|
|
reload: load
|
|
}
|
|
}();
|
|
|
|
$.get('/UserSession/GetUserProfile',
|
|
function (data) {
|
|
var obj = JSON.parse(data);
|
|
form.val("formEdit", obj.Result);
|
|
});
|
|
|
|
var url = "/UserManager/ChangeProfile";
|
|
//提交数据
|
|
form.on('submit(formSubmit)',
|
|
function (data) {
|
|
$.post(url,
|
|
data.field,
|
|
function (data) {
|
|
layer.msg(data.Message);
|
|
},
|
|
"json");
|
|
return false;
|
|
});
|
|
//监听页面主按钮操作 end
|
|
}) |