From 54fb980b07edb428b65116a1a9840b2a45b5fe1e Mon Sep 17 00:00:00 2001 From: yubao Date: Sat, 3 Mar 2018 01:35:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=A6=BB=E7=94=A8=E6=88=B7JS=E4=B8=8E?= =?UTF-8?q?=E7=B3=BB=E7=BB=9FJS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.Mvc/OpenAuth.Mvc.csproj | 17 +- OpenAuth.Mvc/Views/Categories/Index.cshtml | 2 +- OpenAuth.Mvc/Views/Forms/index.cshtml | 23 +- OpenAuth.Mvc/Views/Home/Index.cshtml | 2 +- OpenAuth.Mvc/Views/Home/Main.cshtml | 2 +- OpenAuth.Mvc/Views/Login/Index.cshtml | 4 +- .../Views/ModuleManager/Assign.cshtml | 2 +- OpenAuth.Mvc/Views/ModuleManager/Index.cshtml | 2 +- OpenAuth.Mvc/Views/OrgManager/Index.cshtml | 2 +- OpenAuth.Mvc/Views/RoleManager/Index.cshtml | 2 +- OpenAuth.Mvc/Views/UserManager/Index.cshtml | 2 +- OpenAuth.Mvc/userJs/assign.js | 158 +++++++++++ OpenAuth.Mvc/userJs/categories.js | 154 +++++++++++ OpenAuth.Mvc/userJs/login.js | 92 +++++++ OpenAuth.Mvc/userJs/main.js | 89 +++++++ OpenAuth.Mvc/userJs/modules.js | 249 ++++++++++++++++++ OpenAuth.Mvc/userJs/orgs.js | 167 ++++++++++++ OpenAuth.Mvc/userJs/roles.js | 174 ++++++++++++ OpenAuth.Mvc/userJs/users.js | 174 ++++++++++++ 19 files changed, 1281 insertions(+), 36 deletions(-) create mode 100644 OpenAuth.Mvc/userJs/assign.js create mode 100644 OpenAuth.Mvc/userJs/categories.js create mode 100644 OpenAuth.Mvc/userJs/login.js create mode 100644 OpenAuth.Mvc/userJs/main.js create mode 100644 OpenAuth.Mvc/userJs/modules.js create mode 100644 OpenAuth.Mvc/userJs/orgs.js create mode 100644 OpenAuth.Mvc/userJs/roles.js create mode 100644 OpenAuth.Mvc/userJs/users.js diff --git a/OpenAuth.Mvc/OpenAuth.Mvc.csproj b/OpenAuth.Mvc/OpenAuth.Mvc.csproj index c6229040..e87c5063 100644 --- a/OpenAuth.Mvc/OpenAuth.Mvc.csproj +++ b/OpenAuth.Mvc/OpenAuth.Mvc.csproj @@ -181,9 +181,8 @@ - - - + + @@ -208,10 +207,10 @@ - + - - + + @@ -466,12 +465,12 @@ - + - - + + diff --git a/OpenAuth.Mvc/Views/Categories/Index.cshtml b/OpenAuth.Mvc/Views/Categories/Index.cshtml index b9a98dad..e4c04b40 100644 --- a/OpenAuth.Mvc/Views/Categories/Index.cshtml +++ b/OpenAuth.Mvc/Views/Categories/Index.cshtml @@ -78,4 +78,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/OpenAuth.Mvc/Views/Forms/index.cshtml b/OpenAuth.Mvc/Views/Forms/index.cshtml index 26082c5b..10d9eace 100644 --- a/OpenAuth.Mvc/Views/Forms/index.cshtml +++ b/OpenAuth.Mvc/Views/Forms/index.cshtml @@ -18,19 +18,11 @@ 表单名称 字段个数 表单中的字段数据 - 表单替换的模板 经过处理 - 表单原html模板未经处理的 - 排序码 - 删除标记 - 数据库Id + 关联的数据库 有效 备注 创建时间 - 创建用户主键 - 创建用户 修改时间 - 修改用户主键 - 修改用户 @@ -41,10 +33,11 @@ - -
版权所有 2017 李玉宝
+
版权所有 2018 李玉宝
- + \ No newline at end of file diff --git a/OpenAuth.Mvc/Views/ModuleManager/Assign.cshtml b/OpenAuth.Mvc/Views/ModuleManager/Assign.cshtml index bd96d6c8..109ec34c 100644 --- a/OpenAuth.Mvc/Views/ModuleManager/Assign.cshtml +++ b/OpenAuth.Mvc/Views/ModuleManager/Assign.cshtml @@ -10,4 +10,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/OpenAuth.Mvc/Views/ModuleManager/Index.cshtml b/OpenAuth.Mvc/Views/ModuleManager/Index.cshtml index 93e8875f..32c8e7c9 100644 --- a/OpenAuth.Mvc/Views/ModuleManager/Index.cshtml +++ b/OpenAuth.Mvc/Views/ModuleManager/Index.cshtml @@ -170,4 +170,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/OpenAuth.Mvc/Views/OrgManager/Index.cshtml b/OpenAuth.Mvc/Views/OrgManager/Index.cshtml index 6ba81d82..c3d28abc 100644 --- a/OpenAuth.Mvc/Views/OrgManager/Index.cshtml +++ b/OpenAuth.Mvc/Views/OrgManager/Index.cshtml @@ -72,4 +72,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/OpenAuth.Mvc/Views/RoleManager/Index.cshtml b/OpenAuth.Mvc/Views/RoleManager/Index.cshtml index 5a2b3894..e27873ea 100644 --- a/OpenAuth.Mvc/Views/RoleManager/Index.cshtml +++ b/OpenAuth.Mvc/Views/RoleManager/Index.cshtml @@ -65,4 +65,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/OpenAuth.Mvc/Views/UserManager/Index.cshtml b/OpenAuth.Mvc/Views/UserManager/Index.cshtml index 97896069..70670cb5 100644 --- a/OpenAuth.Mvc/Views/UserManager/Index.cshtml +++ b/OpenAuth.Mvc/Views/UserManager/Index.cshtml @@ -83,4 +83,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/OpenAuth.Mvc/userJs/assign.js b/OpenAuth.Mvc/userJs/assign.js new file mode 100644 index 00000000..ace75dd3 --- /dev/null +++ b/OpenAuth.Mvc/userJs/assign.js @@ -0,0 +1,158 @@ +layui.config({ + base: "/js/" +}).use(['form','vue', 'ztree', 'layer', 'jquery','queryString'], function () { + var //layer = (parent == undefined || parent.layer === undefined )? layui.layer : parent.layer, + layer = layui.layer, + $ = layui.jquery; + var id = $.getUrlParam("id"); //待分配的id + var type = $.getUrlParam("type"); //待分配的类型 + var menuType = $.getUrlParam("menuType"); //待分配菜单的类型 + + //菜单列表 + var menucon = {}; //table的参数,如搜索key,点击tree的id + //菜单树状列表,等lay table没问题了,可以换成table + var menutree = function () { + var url = '/ModuleManager/LoadMenus'; + var menuTree; + var setting = { + view: { selectedMulti: true }, + check: { + enable: true, + chkStyle: "checkbox", + chkboxType: { "Y": "", "N": "" } //去掉勾选时级联 + }, + data: { + key: { + name: 'Name', + title: 'Name' + }, + simpleData: { + enable: true, + idKey: 'Id', + pIdKey: 'ParentId', + rootPId: 'null' + } + }, + callback: { + onClick: function (event, treeId, treeNode) { + // + }, + onCheck: function (event, treeId, treeNode) { + var url = "/RelevanceManager/Assign"; + if (!treeNode.checked) { + url = "/RelevanceManager/UnAssign"; + } + + $.post(url, { type: menuType, firstId: id, secIds: [treeNode.Id] } + , function (data) { + layer.msg(data.Message); + } + , "json"); + } + } + }; + var load = function (options) { + if (options != undefined) { + $.extend(menucon, options); + } + + $.getJSON(url, menucon, function (json) { + menuTree = $.fn.zTree.init($("#menutree"), setting); + menuTree.addNodes(null, json.data); + //如果该用户已经分配菜单了,则设置相应的状态 + var url = "/ModuleManager/LoadMenusForUser"; + if (type.indexOf("Role") != -1) { + url = "/ModuleManager/LoadMenusForRole"; + } + $.getJSON(url, + { + firstId: id + , moduleId: options.moduleId + } + , function (data) { + $.each(data, + function (i) { + var that = this; + var node = menuTree.getNodeByParam("Id", that.Id, null); + menuTree.checkNode(node, true, false); + }); + }); + menuTree.expandAll(true); + }); + }; + return { + load: load + } + }(); + + //模块列表 + var ztree = function () { + var url = '/UserSession/QueryModuleList'; + var zTreeObj; + var setting = { + view: { selectedMulti: true }, + check: { + enable: true, + chkStyle: "checkbox", + chkboxType: { "Y": "", "N": "" } //去掉勾选时级联 + }, + data: { + key: { + name: 'Name', + title: 'Name' + }, + simpleData: { + enable: true, + idKey: 'Id', + pIdKey: 'ParentId', + rootPId: 'null' + } + }, + callback: { + onClick: function (event, treeId, treeNode) { + menutree.load({ moduleId: treeNode.Id }); + }, + onCheck: function (event, treeId, treeNode) { + var url = "/RelevanceManager/Assign"; + if (!treeNode.checked) { + url = "/RelevanceManager/UnAssign"; + } + + $.post(url, { type: type, firstId: id, secIds: [treeNode.Id] } + , function (data) { + layer.msg(data.Message); + } + , "json"); + } + } + }; + var load = function () { + $.getJSON(url, function (json) { + zTreeObj = $.fn.zTree.init($("#tree"), setting); + zTreeObj.addNodes(null, json); + //如果该用户已经分配模块了,则设置相应的状态 + var url = "/ModuleManager/LoadForUser"; + if (type.indexOf("Role") != -1) { + url = "/ModuleManager/LoadForRole"; + } + $.getJSON(url, { firstId: id } + , function (data) { + $.each(data, + function(i) { + var that = this; + var node = zTreeObj.getNodeByParam("Id", that.Id, null); + zTreeObj.checkNode(node, true, false); + }); + }); + $("#menutree").html("点击左边的模块开始分配菜单"); + // menutree.load({ moduleId: json[0].Id }); + zTreeObj.expandAll(true); + }); + }; + load(); + return { + reload: load + } + }(); + //监听页面主按钮操作 end +}) \ No newline at end of file diff --git a/OpenAuth.Mvc/userJs/categories.js b/OpenAuth.Mvc/userJs/categories.js new file mode 100644 index 00000000..987b65c0 --- /dev/null +++ b/OpenAuth.Mvc/userJs/categories.js @@ -0,0 +1,154 @@ +layui.config({ + base: "/js/" +}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth'], function () { + var form = layui.form, + //layer = (parent == undefined || parent.layer === undefined )? layui.layer : parent.layer, + layer = layui.layer, + $ = layui.jquery; + var table = layui.table; + var openauth = layui.openauth; + layui.droptree("/Categories/AllTypes", "#TypeName", "#TypeId", false); + + //主列表加载,可反复调用进行刷新 + var config= {}; //table的参数,如搜索key,点击tree的id + var mainList = function (options) { + if (options != undefined) { + $.extend(config, options); + } + table.reload('mainList', { + url: '/Categories/All', + where: config + }); + } + //左边树状机构列表 + var ztree = function () { + var url = '/Categories/AllTypes'; + var zTreeObj; + var setting = { + view: { selectedMulti: false }, + data: { + key: { + name: 'Name', + title: 'Name' + }, + simpleData: { + enable: true, + idKey: 'Id', + pIdKey: 'ParentId', + rootPId: 'null' + } + }, + callback: { + onClick: function (event, treeId, treeNode) { + mainList({ typeId: treeNode.Id }); + } + } + }; + var load = function () { + $.getJSON(url, function (json) { + zTreeObj = $.fn.zTree.init($("#tree"), setting); + zTreeObj.addNodes(null, json); + mainList({ typeId: "" }); + zTreeObj.expandAll(true); + }); + }; + load(); + return { + reload: load + } + }(); + + //添加(编辑)对话框 + var editDlg = function() { + var vm = new Vue({ + el: "#formEdit" + }); + var update = false; //是否为更新 + var show = function (data) { + var title = update ? "编辑信息" : "添加"; + layer.open({ + title: title, + area: ["500px", "400px"], + type: 1, + content: $('#divEdit'), + success: function() { + vm.$set('$data', data); + }, + end: mainList + }); + var url = "/Categories/Add"; + if (update) { + url = "/Categories/Update"; //暂时和添加一个地址 + } + //提交数据 + form.on('submit(formSubmit)', + function(data) { + $.post(url, + data.field, + function(data) { + layer.msg(data.Message); + }, + "json"); + return false; + }); + } + return { + add: function() { //弹出添加 + update = false; + show({ + Id: '' + }); + }, + update: function(data) { //弹出编辑框 + update = true; + show(data); + } + }; + }(); + + //监听表格内部按钮 + table.on('tool(list)', function (obj) { + var data = obj.data; + if (obj.event === 'detail') { //查看 + layer.msg('ID:' + data.Id + ' 的查看操作'); + } + }); + + + //监听页面主按钮操作 + var active = { + btnDel: function () { //批量删除 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + openauth.del("/Categories/Delete", + data.map(function (e) { return e.Id; }), + mainList); + } + , btnAdd: function () { //添加 + editDlg.add(); + } + , btnEdit: function () { //编辑 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + if (data.length != 1) { + layer.msg("请选择编辑的行,且同时只能编辑一行"); + return; + } + editDlg.update(data[0]); + } + + , search: function () { //搜索 + mainList({ key: $('#key').val() }); + } + , btnRefresh: function() { + mainList(); + } + }; + + $('.toolList .layui-btn').on('click', function () { + var type = $(this).data('type'); + active[type] ? active[type].call(this) : ''; + }); + + //监听页面主按钮操作 end +}) \ No newline at end of file diff --git a/OpenAuth.Mvc/userJs/login.js b/OpenAuth.Mvc/userJs/login.js new file mode 100644 index 00000000..a25151ae --- /dev/null +++ b/OpenAuth.Mvc/userJs/login.js @@ -0,0 +1,92 @@ +layui.config({ + base: "/js/" +}).use(['form', 'layer'], function () { + var form = layui.form, + layer = parent.layer === undefined ? layui.layer : parent.layer, + $ = layui.jquery; + + // Cloud Float... + var $main = $cloud = mainwidth = null; + var offset1 = 450; + var offset2 = 0; + var offsetbg = 0; + + $(document).ready( + function () { + $main = $("#mainBody"); + $body = $("body"); + $cloud1 = $("#cloud1"); + $cloud2 = $("#cloud2"); + + mainwidth = $main.outerWidth(); + + } + ); + + setInterval(function flutter() { + if (offset1 >= mainwidth) { + offset1 = -580; + } + + if (offset2 >= mainwidth) { + offset2 = -580; + } + + offset1 += 1.1; + offset2 += 1; + $cloud1.css("background-position", offset1 + "px 100px") + + $cloud2.css("background-position", offset2 + "px 460px") + }, 70); + setInterval(function bg() { + if (offsetbg >= mainwidth) { + offsetbg = -580; + } + + offsetbg += 0.9; + $body.css("background-position", -offsetbg + "px 0") + }, 90); + $(function () { + //得到焦点 + $("#password").focus(function () { + $("#left_hand").animate({ + left: "150", + top: " -38" + }, { + step: function () { + if (parseInt($("#left_hand").css("left")) > 140) { + $("#left_hand").attr("class", "left_hand"); + } + } + }, 2000); + $("#right_hand").animate({ + right: "-64", + top: "-38px" + }, { + step: function () { + if (parseInt($("#right_hand").css("right")) > -70) { + $("#right_hand").attr("class", "right_hand"); + } + } + }, 2000); + }); + //失去焦点 + $("#password").blur(function () { + $("#left_hand").attr("class", "initial_left_hand"); + $("#left_hand").attr("style", "left:100px;top:-12px;"); + $("#right_hand").attr("class", "initial_right_hand"); + $("#right_hand").attr("style", "right:-112px;top:-12px"); + }); + + $('.loginbox').css({ 'position': 'absolute', 'left': ($(window).width() - 692) / 2 }); + $(window).resize(function () { + $('.loginbox').css({ 'position': 'absolute', 'left': ($(window).width() - 692) / 2 }); + }) + }); + + //登录按钮事件 + form.on("submit(login)", function (data) { + window.location.href = "/Login/LoginByDev"; + return false; + }) +}) diff --git a/OpenAuth.Mvc/userJs/main.js b/OpenAuth.Mvc/userJs/main.js new file mode 100644 index 00000000..dda74505 --- /dev/null +++ b/OpenAuth.Mvc/userJs/main.js @@ -0,0 +1,89 @@ +layui.config({ + base : "/js/" +}).use(['form','element','layer','jquery'],function(){ + var form = layui.form, + layer = parent.layer === undefined ? layui.layer : parent.layer, + element = layui.element, + $ = layui.jquery; + + $(".panel a").on("click",function(){ + window.parent.addTab($(this)); + }) + + //动态获取文章总数和待审核文章数量,最新文章 + $.get("/json/newsList.json", + function(data){ + var waitNews = []; + $(".allNews span").text(data.length); //文章总数 + for(var i=0;i9999 ? ($(this).text()/10000).toFixed(2) + "" : $(this).text()); + }) + + //系统基本参数 + if(window.sessionStorage.getItem("systemParameter")){ + var systemParameter = JSON.parse(window.sessionStorage.getItem("systemParameter")); + fillParameter(systemParameter); + }else{ + $.ajax({ + url : "/json/systemParameter.json", + type : "get", + dataType : "json", + success : function(data){ + fillParameter(data); + } + }) + } + + //填充数据方法 + function fillParameter(data){ + //判断字段数据是否存在 + function nullData(data){ + if(data == '' || data == "undefined"){ + return "未定义"; + }else{ + return data; + } + } + $(".version").text(nullData(data.version)); //当前版本 + $(".author").text(nullData(data.author)); //开发作者 + $(".homePage").text(nullData(data.homePage)); //网站首页 + $(".server").text(nullData(data.server)); //服务器环境 + $(".dataBase").text(nullData(data.dataBase)); //数据库版本 + $(".maxUpload").text(nullData(data.maxUpload)); //最大上传限制 + $(".userRights").text(nullData(data.userRights));//当前用户权限 + } + +}) diff --git a/OpenAuth.Mvc/userJs/modules.js b/OpenAuth.Mvc/userJs/modules.js new file mode 100644 index 00000000..e64461af --- /dev/null +++ b/OpenAuth.Mvc/userJs/modules.js @@ -0,0 +1,249 @@ +layui.config({ + base: "/js/" +}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth'], function () { + var form = layui.form, + //layer = (parent == undefined || parent.layer === undefined )? layui.layer : parent.layer, + layer = layui.layer, + $ = layui.jquery; + var table = layui.table; + var openauth = layui.openauth; + layui.droptree("/UserSession/QueryModuleList", "#ParentName", "#ParentId", false); + + //主列表加载,可反复调用进行刷新 + var config= {}; //table的参数,如搜索key,点击tree的id + var mainList = function (options) { + if (options != undefined) { + $.extend(config, options); + } + table.reload('mainList', { + url: '/UserSession/GetModules', + where: config + }); + } + + //菜单列表 + var menucon = {}; //table的参数,如搜索key,点击tree的id + var menuList = function (options) { + if (options != undefined) { + $.extend(menucon, options); + } + table.reload('menuList', { + url: '/ModuleManager/LoadMenus', + where: menucon + }); + } + + //左边树状机构列表 + var ztree = function () { + var url = '/UserSession/QueryModuleList'; + var zTreeObj; + var setting = { + view: { selectedMulti: false }, + data: { + key: { + name: 'Name', + title: 'Name' + }, + simpleData: { + enable: true, + idKey: 'Id', + pIdKey: 'ParentId', + rootPId: 'null' + } + }, + callback: { + onClick: function (event, treeId, treeNode) { + mainList({ pId: treeNode.Id }); + } + } + }; + var load = function () { + $.getJSON(url, function (json) { + zTreeObj = $.fn.zTree.init($("#tree"), setting); + var newNode = { Name: "根节点", Id: null, ParentId: "" }; + json.push(newNode); + zTreeObj.addNodes(null, json); + mainList({ pId: "" }); + zTreeObj.expandAll(true); + }); + }; + load(); + return { + reload: load + } + }(); + + //添加(编辑)模块对话框 + var editDlg = function() { + var vm = new Vue({ + el: "#formEdit" + }); + var update = false; //是否为更新 + var show = function (data) { + var title = update ? "编辑信息" : "添加"; + layer.open({ + title: title, + area: ["500px", "400px"], + type: 1, + content: $('#divEdit'), + success: function() { + vm.$set('$data', data); + }, + end: mainList + }); + var url = "/moduleManager/Add"; + if (update) { + url = "/moduleManager/Update"; + } + //提交数据 + form.on('submit(formSubmit)', + function(data) { + $.post(url, + data.field, + function(data) { + layer.msg(data.Message); + }, + "json"); + return false; + }); + } + return { + add: function() { //弹出添加 + update = false; + show({ + Id: "", + SortNo:1 + }); + }, + update: function(data) { //弹出编辑框 + update = true; + show(data); + } + }; + }(); + + //添加菜单对话框 + var meditDlg = function () { + var vm = new Vue({ + el: "#mfromEdit" + }); + var update = false; //是否为更新 + var show = function (data) { + var title = update ? "编辑信息" : "添加"; + layer.open({ + title: title, + area: ["500px", "400px"], + type: 1, + content: $('#divMenuEdit'), + success: function () { + vm.$set('$data', data); + }, + end: menuList + }); + var url = "/moduleManager/AddMenu"; + if (update) { + url = "/moduleManager/UpdateMenu"; + } + //提交数据 + form.on('submit(mformSubmit)', + function (data) { + $.post(url, + data.field, + function (data) { + layer.msg(data.Message); + }, + "json"); + return false; + }); + } + return { + add: function (moduleId) { //弹出添加 + update = false; + show({ + Id: "", + ModuleId:moduleId, + SortNo: 1 + }); + }, + update: function (data) { //弹出编辑框 + update = true; + show(data); + } + }; + }(); + + //监听模块表格内部按钮 + table.on('tool(list)', function (obj) { + var data = obj.data; + if (obj.event === 'detail') { //查看 + //layer.msg('ID:' + data.Id + ' 的查看操作'); + menuList({moduleId:data.Id}); + } + }); + + //监听菜单表格内部按钮 + table.on('tool(menulist)', function (obj) { + var data = obj.data; + if (obj.event === 'del') { //删除菜单 + openauth.del("/moduleManager/delMenu", + data.Id,menuList); + } + }); + + + //监听页面主按钮操作 + var active = { + btnDel: function () { //批量删除 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + openauth.del("/moduleManager/Delete", + data.map(function (e) { return e.Id; }), + mainList); + } + , btnAdd: function () { //添加模块 + editDlg.add(); + } + , btnAddMenu: function () { //添加菜单 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + if (data.length != 1) { + layer.msg("请选择一个要添加菜单的模块"); + return; + } + meditDlg.add(data[0].Id); + } + , btnEdit: function () { //编辑 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + if (data.length != 1) { + layer.msg("请选择编辑的行,且同时只能编辑一行"); + return; + } + editDlg.update(data[0]); + } + + , search: function () { //搜索 + mainList({ key: $('#key').val() }); + } + , btnRefresh: function() { + mainList(); + } + , btnAccessModule: function () { + var index = layer.open({ + title: "为用户分配模块", + type: 2, + content: "newsAdd.html", + success: function(layero, index) { + + } + }); + } + }; + + $('.toolList .layui-btn').on('click', function () { + var type = $(this).data('type'); + active[type] ? active[type].call(this) : ''; + }); + + //监听页面主按钮操作 end +}) \ No newline at end of file diff --git a/OpenAuth.Mvc/userJs/orgs.js b/OpenAuth.Mvc/userJs/orgs.js new file mode 100644 index 00000000..5a98329c --- /dev/null +++ b/OpenAuth.Mvc/userJs/orgs.js @@ -0,0 +1,167 @@ +layui.config({ + base: "/js/" +}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth'], function () { + var form = layui.form, + //layer = (parent == undefined || parent.layer === undefined )? layui.layer : parent.layer, + layer = layui.layer, + $ = layui.jquery; + var table = layui.table; + var openauth = layui.openauth; + layui.droptree("/UserSession/GetOrgs", "#ParentName", "#ParentId", false); + + //主列表加载,可反复调用进行刷新 + var config= {}; //table的参数,如搜索key,点击tree的id + var mainList = function (options) { + if (options != undefined) { + $.extend(config, options); + } + table.reload('mainList', { + url: '/UserSession/GetSubOrgs', + where: config + }); + } + //左边树状机构列表 + var ztree = function () { + var url = '/UserSession/GetOrgs'; + var zTreeObj; + var setting = { + view: { selectedMulti: false }, + data: { + key: { + name: 'Name', + title: 'Name' + }, + simpleData: { + enable: true, + idKey: 'Id', + pIdKey: 'ParentId', + rootPId: 'null' + } + }, + callback: { + onClick: function (event, treeId, treeNode) { + mainList({ orgId: treeNode.Id }); + } + } + }; + var load = function () { + $.getJSON(url, function (json) { + zTreeObj = $.fn.zTree.init($("#tree"), setting); + var newNode = { Name: "根节点", Id: null, ParentId: "" }; + json.push(newNode); + zTreeObj.addNodes(null, json); + mainList({ orgId: "" }); + zTreeObj.expandAll(true); + }); + }; + load(); + return { + reload: load + } + }(); + + //添加(编辑)对话框 + var editDlg = function() { + var vm = new Vue({ + el: "#formEdit" + }); + var update = false; //是否为更新 + var show = function (data) { + var title = update ? "编辑信息" : "添加"; + layer.open({ + title: title, + area: ["500px", "400px"], + type: 1, + content: $('#divEdit'), + success: function() { + vm.$set('$data', data); + }, + end: mainList + }); + var url = "/OrgManager/Add"; + if (update) { + url = "/OrgManager/Update"; //暂时和添加一个地址 + } + //提交数据 + form.on('submit(formSubmit)', + function(data) { + $.post(url, + data.field, + function(data) { + layer.msg(data.Message); + }, + "json"); + return false; + }); + } + return { + add: function() { //弹出添加 + update = false; + show({ + Id: '', + SortNo:1 + }); + }, + update: function(data) { //弹出编辑框 + update = true; + show(data); + } + }; + }(); + + //监听表格内部按钮 + table.on('tool(list)', function (obj) { + var data = obj.data; + if (obj.event === 'detail') { //查看 + layer.msg('ID:' + data.Id + ' 的查看操作'); + } + }); + + + //监听页面主按钮操作 + var active = { + btnDel: function () { //批量删除 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + openauth.del("/OrgManager/Delete", + data.map(function (e) { return e.Id; }), + mainList); + } + , btnAdd: function () { //添加 + editDlg.add(); + } + , btnEdit: function () { //编辑 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + if (data.length != 1) { + layer.msg("请选择编辑的行,且同时只能编辑一行"); + return; + } + editDlg.update(data[0]); + } + + , search: function () { //搜索 + mainList({ key: $('#key').val() }); + } + , btnRefresh: function() { + mainList(); + } + , btnAccessModule: function () { + var index = layer.open({ + title: "为用户分配模块", + type: 2, + content: "newsAdd.html", + success: function(layero, index) { + + } + }); + } + }; + + $('.toolList .layui-btn').on('click', function () { + var type = $(this).data('type'); + active[type] ? active[type].call(this) : ''; + }); + + //监听页面主按钮操作 end +}) \ No newline at end of file diff --git a/OpenAuth.Mvc/userJs/roles.js b/OpenAuth.Mvc/userJs/roles.js new file mode 100644 index 00000000..a8e5df68 --- /dev/null +++ b/OpenAuth.Mvc/userJs/roles.js @@ -0,0 +1,174 @@ +layui.config({ + base: "/js/" +}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth'], function () { + var form = layui.form, + //layer = (parent == undefined || parent.layer === undefined )? layui.layer : parent.layer, + layer = layui.layer, + $ = layui.jquery; + var table = layui.table; + var openauth = layui.openauth; + layui.droptree("/UserSession/GetOrgs", "#Organizations", "#OrganizationIds"); + + //主列表加载,可反复调用进行刷新 + var config= {}; //table的参数,如搜索key,点击tree的id + var mainList = function (options) { + if (options != undefined) { + $.extend(config, options); + } + table.reload('mainList', { + url: '/RoleManager/Load', + where: config + }); + } + //左边树状机构列表 + var ztree = function () { + var url = '/UserSession/GetOrgs'; + 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($("#tree"), setting); + var newNode = { Name: "根节点", Id: null,ParentId:"" }; + json.push(newNode); + zTreeObj.addNodes(null, json); + mainList({ orgId: "" }); + zTreeObj.expandAll(true); + }); + }; + load(); + return { + reload: load + } + }(); + + //添加(编辑)对话框 + var editDlg = function() { + var vm = new Vue({ + el: "#formEdit" + }); + var update = false; //是否为更新 + var show = function (data) { + var title = update ? "编辑信息" : "添加"; + layer.open({ + title: title, + area: ["500px", "400px"], + type: 1, + content: $('#divEdit'), + success: function() { + vm.$set('$data', data); + }, + end: mainList + }); + var url = "/RoleManager/Add"; + if (update) { + url = "/RoleManager/Update"; + } + //提交数据 + form.on('submit(formSubmit)', + function(data) { + $.post(url, + data.field, + function(data) { + layer.msg(data.Message); + }, + "json"); + return false; + }); + } + return { + add: function() { //弹出添加 + update = false; + show({ + Id: '' + }); + }, + update: function(data) { //弹出编辑框 + update = true; + show(data); + } + }; + }(); + + //监听表格内部按钮 + table.on('tool(list)', function (obj) { + var data = obj.data; + if (obj.event === 'detail') { //查看 + layer.msg('ID:' + data.Id + ' 的查看操作'); + } + }); + + + //监听页面主按钮操作 + var active = { + btnDel: function () { //批量删除 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + openauth.del("/RoleManager/Delete", + data.map(function (e) { return e.Id; }), + mainList); + } + , btnAdd: function () { //添加 + editDlg.add(); + } + , btnEdit: function () { //编辑 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + if (data.length != 1) { + layer.msg("请选择编辑的行,且同时只能编辑一行"); + return; + } + editDlg.update(data[0]); + } + + , search: function () { //搜索 + mainList({ key: $('#key').val() }); + } + , btnRefresh: function() { + mainList(); + } + , btnAccessModule: function () { + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + if (data.length != 1) { + layer.msg("请选择要分配的角色"); + return; + } + + var index = layer.open({ + title: "为用角色配模块", + type: 2, + area: ['450px', '400px'], + content: "/ModuleManager/Assign?type=RoleModule&menuType=RoleElement&id=" + data[0].Id, + success: function (layero, index) { + + } + }); + } + }; + + $('.toolList .layui-btn').on('click', function () { + var type = $(this).data('type'); + active[type] ? active[type].call(this) : ''; + }); + + //监听页面主按钮操作 end +}) \ No newline at end of file diff --git a/OpenAuth.Mvc/userJs/users.js b/OpenAuth.Mvc/userJs/users.js new file mode 100644 index 00000000..1bbbb60e --- /dev/null +++ b/OpenAuth.Mvc/userJs/users.js @@ -0,0 +1,174 @@ +layui.config({ + base: "/js/" +}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth'], function () { + var form = layui.form, + //layer = (parent == undefined || parent.layer === undefined )? layui.layer : parent.layer, + layer = layui.layer, + $ = layui.jquery; + var table = layui.table; + var openauth = layui.openauth; + layui.droptree("/UserSession/GetOrgs", "#Organizations", "#OrganizationIds"); + + //主列表加载,可反复调用进行刷新 + var config= {}; //table的参数,如搜索key,点击tree的id + var mainList = function (options) { + if (options != undefined) { + $.extend(config, options); + } + table.reload('mainList', { + url: '/UserManager/Load', + where: config + }); + } + //左边树状机构列表 + var ztree = function () { + var url = '/UserSession/GetOrgs'; + 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($("#tree"), setting); + var newNode = { Name: "根节点", Id: null,ParentId:"" }; + json.push(newNode); + zTreeObj.addNodes(null, json); + mainList({ orgId: "" }); + zTreeObj.expandAll(true); + }); + }; + load(); + return { + reload: load + } + }(); + + //添加(编辑)对话框 + var editDlg = function() { + var vm = new Vue({ + el: "#formEdit" + }); + var update = false; //是否为更新 + var show = function (data) { + var title = update ? "编辑信息" : "添加"; + layer.open({ + title: title, + area: ["500px", "400px"], + type: 1, + content: $('#divEdit'), + success: function() { + vm.$set('$data', data); + }, + end: mainList + }); + var url = "/UserManager/AddOrUpdate"; + if (update) { + url = "/UserManager/AddOrUpdate"; //暂时和添加一个地址 + } + //提交数据 + form.on('submit(formSubmit)', + function(data) { + $.post(url, + data.field, + function(data) { + layer.msg(data.Message); + }, + "json"); + return false; + }); + } + return { + add: function() { //弹出添加 + update = false; + show({ + Id: '' + }); + }, + update: function(data) { //弹出编辑框 + update = true; + show(data); + } + }; + }(); + + //监听表格内部按钮 + table.on('tool(list)', function (obj) { + var data = obj.data; + if (obj.event === 'detail') { //查看 + layer.msg('ID:' + data.Id + ' 的查看操作'); + } + }); + + + //监听页面主按钮操作 + var active = { + btnDel: function () { //批量删除 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + openauth.del("/UserManager/Delete", + data.map(function (e) { return e.Id; }), + mainList); + } + , btnAdd: function () { //添加 + editDlg.add(); + } + , btnEdit: function () { //编辑 + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + if (data.length != 1) { + layer.msg("请选择编辑的行,且同时只能编辑一行"); + return; + } + editDlg.update(data[0]); + } + + , search: function () { //搜索 + mainList({ key: $('#key').val() }); + } + , btnRefresh: function() { + mainList(); + } + , btnAccessModule: function () { + var checkStatus = table.checkStatus('mainList') + , data = checkStatus.data; + if (data.length != 1) { + layer.msg("请选择要分配的用户"); + return; + } + + var index = layer.open({ + title: "为用户分配模块", + type: 2, + area: ['450px', '400px'], + content: "/ModuleManager/Assign?type=UserModule&menuType=UserElement&id=" + data[0].Id, + success: function(layero, index) { + + } + }); + } + }; + + $('.toolList .layui-btn').on('click', function () { + var type = $(this).data('type'); + active[type] ? active[type].call(this) : ''; + }); + + //监听页面主按钮操作 end +}) \ No newline at end of file