-
-
+
+
\ No newline at end of file
diff --git a/CodeSmith/Util.cs b/CodeSmith/Util.cs
new file mode 100644
index 00000000..0ebb0882
--- /dev/null
+++ b/CodeSmith/Util.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using CodeSmith.Engine;
+using SchemaExplorer;
+
+namespace Util{
+ public class Tools{
+ public static String GetDescription(ColumnSchema column) { //得到字段的描述
+ if(string.IsNullOrEmpty(column.Description))
+ return column.Name;
+ else
+ return column.Description;
+ }
+
+ public static bool NeedCascade(TableSchema SourceTable){ //判断表中是否需要下拉选择树
+ return SourceTable.Columns.Contains("ParentId")
+ || SourceTable.Columns.Contains("CascadeId") ;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CodeSmith/editDlg.js.cst b/CodeSmith/editDlg.js.cst
new file mode 100644
index 00000000..02a99e16
--- /dev/null
+++ b/CodeSmith/editDlg.js.cst
@@ -0,0 +1,250 @@
+<%--
+Name: 编辑修改JS
+Author: yubaolee
+Description: 编辑修改JS
+--%>
+<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Encoding="utf-8" Description="添加模块" %>
+<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context"
+Description="连接的数据库" %>
+<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
+<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
+<%@ Assembly Name="SchemaExplorer" %>
+<%@ Import Namespace="SchemaExplorer" %>
+<%@ Assembly Src="Util.cs" %>
+<%@ Import Namespace="Util" %>
+
+
+//grid列表模块
+function MainGrid() {
+ var url = '/<%=ModuleName%>/Load?parentId=';
+ var selectedId = 0; //ztree选中的模块
+ this.maingrid = $('#maingrid').datagrid({
+ showToolbar: false,
+ filterThead: false,
+ target: $(this),
+ columns: [
+ <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
+ {
+ name: '<%=column.Name%>',
+ label: '<%=Tools.GetDescription(column)%>',
+ width: 100
+ <%if(column.IsPrimaryKeyMember){ %>
+ , hide: true
+ <%} %>
+ <%else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
+ ,type: 'select',
+ align: 'center',
+ items: [{ '0': '否' }, { '1': '是' }],
+ <%} %>
+ <%else if(CSharpAlias[column.SystemType.FullName] == "int") {%>
+ ,type: 'select',
+ align: 'center',
+ items: [{ '0': '默认' }, { '1': '状态1' }],
+ <%} %>
+ },
+ <% } %>
+ ],
+ dataUrl: url + selectedId,
+ fullGrid: true,
+ showLinenumber: true,
+ showCheckboxcol: true,
+ paging: true,
+ filterMult: false,
+ showTfoot: false,
+ height: '100%'
+ });
+ this.reload = function (id) {
+ if (id != undefined) selectedId = id;
+ this.maingrid.datagrid('reload', { dataUrl: url+ selectedId });
+ };
+};
+MainGrid.prototype = new Grid();
+var list = new MainGrid();
+
+//左边分类导航树
+var ztree = function () {
+ var url = '/<%=ModuleName%>/LoadForTree';
+ var setting = {
+ view: { selectedMulti: false },
+ data: {
+ key: {
+ name: 'Name',
+ title: 'Name'
+ },
+ simpleData: {
+ enable: true,
+ idKey: 'Id',
+ pIdKey: 'ParentId',
+ rootPId: 'null'
+ }
+ },
+ callback: { onClick: zTreeOnClick }
+ };
+ $.getJSON(url, function (json) {
+ $.fn.zTree.init($("#tree"), setting, json).expandAll(true);
+ });
+ function zTreeOnClick(event, treeId, treeNode) {
+ list.reload(treeNode.Id);
+ }
+
+ return {
+ reload:function() {
+ $.getJSON(url, function (json) {
+ $.fn.zTree.init($("#tree"), setting, json).expandAll(true);
+ });
+ }
+ }
+}();
+
+<%if(Tools.NeedCascade(SourceTable)){ %>
+//编辑时,选择上级弹出的树
+var parentTree = function () {
+ var nameDom = "#ParentName";
+ var idDom = "#ParentId";
+ var zTreeObj;
+ var setting = {
+ view: {
+ selectedMulti: false
+ },
+ check: {
+ enable: true,
+ chkStyle: "radio", //单选
+ radioType: "all"
+ },
+ data: {
+ key: {
+ name: 'Name',
+ title: 'Name'
+ },
+ simpleData: {
+ enable: true,
+ idKey: 'Id',
+ pIdKey: 'ParentId',
+ rootPId: 'null'
+ }
+ },
+ callback: {
+ onClick: zTreeOnClick,
+ onCheck: zTreeCheck
+ }
+ };
+
+ function zTreeCheck(event, treeId, treeNode) {
+ var nodes = zTreeObj.getCheckedNodes(true);
+ var ids = nodes.map(function (e) { return e.Id; }).join(",");
+ var names = nodes.map(function (e) { return e.Name; }).join(",");
+
+ $(nameDom).val(names);
+ $(idDom).val(ids);
+ }
+ function zTreeOnClick(event, treeId, treeNode) {
+ zTreeObj.checkNode(treeNode, !treeNode.checked, true, true);
+ event.preventDefault();
+ }
+
+ return {
+ show:function() {
+ $.getJSON('/<%=ModuleName%>/LoadForTree', function (json) {
+ zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
+ var orgstr = $(idDom).val();
+ var name = '';
+ if (orgstr != '') {
+ var nodeIds = orgstr.split(',');
+ $.each(nodeIds, function () {
+ var node = zTreeObj.getNodeByParam("Id", this, null);
+ name += ',' + node.Name;
+ zTreeObj.checkNode(node, true, true);
+ });
+ $(nameDom).val(name.substr(1)); //显示名称
+ }
+ zTreeObj.expandAll(true);
+ });
+ }
+ };
+}();
+<%} %>
+
+//添加(编辑)对话框
+var editDlg = function () {
+ var update = false;
+ var show = function () {
+ BJUI.dialog({ id: 'editDlg', title: '编辑对话框', target: '#editDlg' });
+ $("#btnSave").on("click", function() {
+ editDlg.save();
+ });
+ }
+ return {
+ add: function () { //弹出添加
+ update = false;
+ show();
+ $.CurrentDialog.find("form")[0].reset(); //reset方法只能通过dom调用
+ $("#Id").val(0);
+
+ <%if(Tools.NeedCascade(SourceTable)){
+ Response.WriteLine("parentTree.show()");
+ }%>
+ },
+ update: function (ret) { //弹出编辑框
+ update = true;
+ show();
+ <% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
+ <%if(CSharpAlias[column.SystemType.FullName] == "bool"
+ ||(CSharpAlias[column.SystemType.FullName] == "int" && Tools.GetDescription(column).Contains("下拉选择"))) {%>
+ $('#<%=column.Name%>').selectpicker('val', ret.<%=column.Name%>);
+ <%} else{ %>
+ $('#<%=column.Name%>').val(ret.<%=column.Name%>);
+ <%} %>
+ <% } %>
+ <%if(Tools.NeedCascade(SourceTable)){
+ Response.WriteLine("parentTree.show()");
+ }%>
+ },
+ save: function() { //编辑-->保存
+ $('#editForm').isValid(function (v) {
+ if (!v) return; //验证没通过
+ $("#editForm").bjuiajax('ajaxForm', {
+ reload: false,
+ callback:function(json) {
+ list.reload();
+ ztree.reload();
+ }
+ });
+ });
+ }
+ };
+}();
+
+//删除
+function del() {
+ var selected = list.getSelectedObj();
+ if (selected == null) return;
+
+ $.getJSON('/moduleManager/Delete?Id=' + selected.Id, function (data) {
+ if (data.statusCode == "200") {
+ list.reload();
+ ztree.reload();
+ }
+ else {
+ $(this).alertmsg('warn', data.message);
+ }
+ });
+}
+
+//自定义的编辑按钮
+function edit() {
+ var selected = list.getSelectedObj();
+ if (selected == null) {
+ return;
+ }
+ editDlg.update(selected);
+}
+
+function add() {
+ editDlg.add();
+}
+
+function refresh() {
+ list.reload();
+}
+
+//@@ sourceURL=<%=ModuleName%>.js
\ No newline at end of file
diff --git a/OpenAuth.App/CategoryManagerApp.cs b/OpenAuth.App/CategoryManagerApp.cs
index efa3917d..e869f652 100644
--- a/OpenAuth.App/CategoryManagerApp.cs
+++ b/OpenAuth.App/CategoryManagerApp.cs
@@ -27,7 +27,7 @@ namespace OpenAuth.App
}
else
{
- return _repository.GetCategoryCntInOrgs(GetSubOrgIds(orgId));
+ return _repository.GetCategoryCntInOrgs(GetSubCategories(orgId));
}
}
@@ -39,19 +39,19 @@ namespace OpenAuth.App
///
/// 加载一个部门及子部门全部Categorys
///
- public dynamic Load(int orgId, int pageindex, int pagesize)
+ public dynamic Load(int parentId, int pageindex, int pagesize)
{
IEnumerable
Categorys;
int total = 0;
- if (orgId == 0)
+ if (parentId == 0)
{
Categorys = _repository.LoadCategorys(pageindex, pagesize);
total = _repository.GetCount();
}
else
{
- Categorys = _repository.LoadInOrgs(pageindex, pagesize, GetSubOrgIds(orgId));
- total = _repository.GetCategoryCntInOrgs(orgId);
+ Categorys = _repository.LoadInOrgs(pageindex, pagesize, GetSubCategories(parentId));
+ total = _repository.GetCategoryCntInOrgs(parentId);
}
return new
@@ -65,11 +65,11 @@ namespace OpenAuth.App
///
/// 获取当前组织的所有下级组织
///
- private int[] GetSubOrgIds(int orgId)
+ private int[] GetSubCategories(int orgId)
{
- var org = _orgRepository.FindSingle(u => u.Id == orgId);
- var orgs = _orgRepository.Find(u => u.CascadeId.Contains(org.CascadeId)).Select(u => u.Id).ToArray();
- return orgs;
+ var category = Find(orgId);
+ var categories = _repository.Find(u => u.CascadeId.Contains(category.CascadeId)).Select(u => u.Id).ToArray();
+ return categories;
}
public Category Find(int id)
@@ -89,9 +89,10 @@ namespace OpenAuth.App
{
Category category = new Category();
model.CopyTo(category);
+ ChangeModuleCascade(category);
+
if (category.Id == 0)
{
- ChangeModuleCascade(category);
_repository.Add(category);
}
else
diff --git a/OpenAuth.App/ModuleElementManagerApp.cs b/OpenAuth.App/ModuleElementManagerApp.cs
index f0a628ca..08b3d419 100644
--- a/OpenAuth.App/ModuleElementManagerApp.cs
+++ b/OpenAuth.App/ModuleElementManagerApp.cs
@@ -97,18 +97,24 @@ namespace OpenAuth.App
_repository.Delete(u =>delIds.Contains(u.Id));
}
- public void AssignForRole(int roleId,int moduleId, int[] menuIds)
+ public void AssignForRole(int roleId, int[] menuIds)
{
- var elements = _repository.Find(u => u.ModuleId == moduleId).Select(u =>u.Id).ToArray();
- _relevanceRepository.Delete(u =>elements.Contains(u.SecondId) &&u.Key =="RoleElement" && u.FirstId == roleId);
_relevanceRepository.AddRelevance("RoleElement", menuIds.ToLookup(u => roleId));
}
- public void AssignForUser(int userId, int moduleId, int[] ids)
+ public void CancelForRole(int roleId, int[] ids)
+ {
+ _relevanceRepository.Delete(u => ids.Contains(u.SecondId) && u.Key == "RoleElement" && u.FirstId == roleId);
+ }
+
+ public void AssignForUser(int userId, int[] ids)
{
- var elements = _repository.Find(u => u.ModuleId == moduleId).Select(u => u.Id).ToArray();
- _relevanceRepository.Delete(u => elements.Contains(u.SecondId) && u.Key == "UserElement" && u.FirstId == userId);
_relevanceRepository.AddRelevance("UserElement", ids.ToLookup(u => userId));
}
+
+ public void CancelForUser(int userId, int[] ids)
+ {
+ _relevanceRepository.Delete(u => ids.Contains(u.SecondId) && u.Key == "UserElement" && u.FirstId == userId);
+ }
}
}
diff --git a/OpenAuth.App/ModuleManagerApp.cs b/OpenAuth.App/ModuleManagerApp.cs
index 1c2d73a1..5f588e59 100644
--- a/OpenAuth.App/ModuleManagerApp.cs
+++ b/OpenAuth.App/ModuleManagerApp.cs
@@ -92,9 +92,9 @@ namespace OpenAuth.App
{
Module model = new Module();
vm.CopyTo(model); //copy一次,防止成员为null的情况
+ ChangeModuleCascade(model);
if (model.Id == 0)
{
- ChangeModuleCascade(model);
_repository.Add(model);
}
else
diff --git a/OpenAuth.Mvc/BllScripts/moduleElementMan.js b/OpenAuth.Mvc/BllScripts/moduleElementMan.js
index ad0f0cd7..d3a9783c 100644
--- a/OpenAuth.Mvc/BllScripts/moduleElementMan.js
+++ b/OpenAuth.Mvc/BllScripts/moduleElementMan.js
@@ -16,7 +16,7 @@ var moduleId = $.CurrentDialog.find("#selectedModuleId").val(); //外部传递
$(document).ready(function () {
$.CurrentDialog.find('#btnAddElement').on('click', function () {
- editDlg.add();
+ editEleDlg.add();
});
$.CurrentDialog.find('#btnEditElement').on('click', function () {
@@ -24,7 +24,7 @@ $(document).ready(function () {
if (selected == null) {
return;
}
- editDlg.update(selected);
+ editEleDlg.update(selected);
});
$.CurrentDialog.find('#btnDelElement').on('click', function () {
@@ -48,32 +48,67 @@ $(document).ready(function () {
//本对话框
var thisDlg = function () {
- var maingrid = $.CurrentDialog.find('#maingrid').datagrid({
+ var maingrid = $('#moduleEleList').datagrid({
showToolbar: false,
filterThead: false,
target: $(this),
columns: [
- {
- name: 'Id',
- label: '功能模块流水号',
- hide: true
- },
- {
- name: 'DomId',
- label: 'DOM标识',
- },
- {
- name: 'Name',
- label: '功能模块名称',
- },
- {
- name: 'Icon',
- label: '图标',
- },
- {
- name: 'SortNo',
- label: '排序号'
- }
+ {
+ name: 'Id',
+ label: '流水号',
+ width: 100
+ , hide: true
+ },
+ {
+ name: 'DomId',
+ label: 'DOM ID',
+ width: 100
+ },
+ {
+ name: 'Name',
+ label: '名称',
+ width: 100
+ },
+ {
+ name: 'Type',
+ label: '类型',
+ width: 100
+ },
+ {
+ name: 'ModuleId',
+ label: '功能模块Id',
+ width: 100
+ },
+ {
+ name: 'Attr',
+ label: '元素附加属性',
+ width: 100
+ },
+ {
+ name: 'Script',
+ label: '元素调用脚本',
+ width: 100
+ },
+ {
+ name: 'Icon',
+ label: '元素图标',
+ width: 100
+ },
+ {
+ name: 'Class',
+ label: '元素样式',
+ width: 100
+ },
+ {
+ name: 'Remark',
+ label: '备注',
+ width: 100
+ },
+ {
+ name: 'Sort',
+ label: '排序字段',
+ width: 100
+ }
],
dataUrl: '/ModuleElementManager/Get?moduleId=' + moduleId,
fullGrid: true,
@@ -82,7 +117,7 @@ var thisDlg = function () {
paging: false,
filterMult: false,
showTfoot: false,
- height: 'auto'
+ height: '100%'
});
var getSelectDatas = function () {
@@ -110,36 +145,50 @@ var thisDlg = function () {
};
}();
-var editDlg = function () {
+//添加(编辑)对话框
+var editEleDlg = function () {
var update = false;
- //在B-JUI中,不能在这里获取DOM,否则下面赋值会不成功
- //只能直接 $("#Id").val(ret.Id);
- // Id = $("#Id");
var show = function () {
- BJUI.dialog({ id: 'editDlg', title: '菜单编辑', target: '#editDlg' });
+ BJUI.dialog({ id: 'editEleDlg', title: '菜单编辑', target: '#editEleDlg' });
+ $("#btnEleChange").on("click", function () {
+ editEleDlg.save();
+ });
}
return {
- add: function () {
+ add: function () { //弹出添加
+ update = false;
show();
$("#editElementForm")[0].reset(); //reset方法只能通过dom调用
- $("#Id").val(0);
- $("#Sort").val('0');
- $("#ModuleId").val(moduleId);
+ $.CurrentDialog.find("#Id").val(0);
+ $.CurrentDialog.find("#Sort").val('0');
+ $.CurrentDialog.find("#ModuleId").val(moduleId);
+
},
- update: function (ret) {
+ update: function (ret) { //弹出编辑框
update = true;
show();
- $("#Id").val(ret.Id);
- $("#DomId").val(ret.DomId);
- $("#Name").val(ret.Name);
- $("#Type").val(ret.Type);
- $("#ModuleId").val(ret.ModuleId);
- $("#Attr").val(ret.Attr);
- $("#Script").val(ret.Script);
- $("#Icon").val(ret.Icon);
- $("#Class").val(ret.Class);
- $("#Remark").val(ret.Remark);
- $("#Sort").val(ret.Sort);
+ $.CurrentDialog.find('#Id').val(ret.Id);
+ $.CurrentDialog.find('#DomId').val(ret.DomId);
+ $.CurrentDialog.find('#Name').val(ret.Name);
+ $.CurrentDialog.find('#Type').selectpicker('val', ret.Type);
+ $.CurrentDialog.find('#ModuleId').val(ret.ModuleId);
+ $.CurrentDialog.find('#Attr').val(ret.Attr);
+ $.CurrentDialog.find('#Script').val(ret.Script);
+ $.CurrentDialog.find('#Icon').selectpicker('val', ret.Icon);
+ $.CurrentDialog.find('#Class').selectpicker('val', ret.Class);
+ $.CurrentDialog.find('#Remark').val(ret.Remark);
+ $.CurrentDialog.find('#Sort').val(ret.Sort);
+ },
+ save: function () { //编辑-->保存
+ $('#editElementForm').isValid(function (v) {
+ if (!v) return; //验证没通过
+ $("#editElementForm").bjuiajax('ajaxForm', {
+ reload: false,
+ callback: function (json) {
+ thisDlg.reload();
+ }
+ });
+ });
}
};
}();
diff --git a/OpenAuth.Mvc/BllScripts/modulemanager.js b/OpenAuth.Mvc/BllScripts/modulemanager.js
index 26955c98..90674d13 100644
--- a/OpenAuth.Mvc/BllScripts/modulemanager.js
+++ b/OpenAuth.Mvc/BllScripts/modulemanager.js
@@ -12,12 +12,114 @@
// 模块管理脚本
// ***********************************************************************
-$(document).ready(function () {
-});
+//grid列表模块
+function MainGrid() {
+ var url = '/ModuleManager/Load?orgId=';
+ var selectedId = 0; //ztree选中的模块
+ this.maingrid = $('#maingrid').datagrid({
+ showToolbar: false,
+ filterThead: false,
+ target: $(this),
+ columns: [
+ {
+ name: 'Id',
+ label: '功能模块流水号',
+ width: 100
+ , hide: true
+ },
+ {
+ name: 'CascadeId',
+ label: '节点语义ID',
+ width: 100
+ },
+ {
+ name: 'Name',
+ label: '功能模块名称',
+ width: 100
+ },
+ {
+ name: 'Url',
+ label: '主页面URL',
+ width: 100
+ },
+ {
+ name: 'HotKey',
+ label: '热键',
+ width: 100
+ },
+ {
+ name: 'ParentId',
+ label: '父节点流水号',
+ width: 100
+ , type: 'select',
+ align: 'center',
+ items: [{ '0': '默认' }, { '1': '状态1' }],
+ },
+ {
+ name: 'IsLeaf',
+ label: '是否叶子节点',
+ width: 100
+ , type: 'select',
+ align: 'center',
+ items: [{ 'false': '否' }, { 'true': '是' }],
+ },
+ {
+ name: 'IsAutoExpand',
+ label: '是否自动展开',
+ width: 100
+ , type: 'select',
+ align: 'center',
+ items: [{ 'false': '否' }, { 'true': '是' }],
+ },
+ {
+ name: 'IconName',
+ label: '节点图标文件名称',
+ width: 100
+ },
+ {
+ name: 'Status',
+ label: '当前状态',
+ width: 100
+ , type: 'select',
+ align: 'center',
+ items: [{ '0': '默认' }, { '1': '状态1' }],
+ },
+ {
+ name: 'ParentName',
+ label: '父节点名称',
+ width: 100
+ },
+ {
+ name: 'Vector',
+ label: '矢量图标',
+ width: 100
+ },
+ {
+ name: 'SortNo',
+ label: '排序号',
+ width: 100
+ },
+ ],
+ dataUrl: url + selectedId,
+ fullGrid: true,
+ showLinenumber: true,
+ showCheckboxcol: true,
+ paging: true,
+ filterMult: false,
+ showTfoot: false,
+ height: '100%'
+ });
+ this.reload = function (id) {
+ if (id != undefined) selectedId = id;
+ this.maingrid.datagrid('reload', { dataUrl: url + selectedId });
+ };
+};
+MainGrid.prototype = new Grid();
+var list = new MainGrid();
-//ztree模块
+//左边分类导航树
var ztree = function () {
- var zTreeObj = undefined;
+ var url = '/ModuleManager/LoadModuleWithRoot';
var setting = {
view: { selectedMulti: false },
data: {
@@ -34,115 +136,150 @@ var ztree = function () {
},
callback: { onClick: zTreeOnClick }
};
- $.getJSON('/ModuleManager/LoadModuleWithRoot', function (json) {
- zTreeObj = $.fn.zTree.init($('#maintree'), setting, json);
- zTreeObj.expandAll(true);
- });
-}();
-
-//grid列表模块
-var grid = function () {
- var selectedId = 0; //选中的ID
- var maingrid = $('#maingrid', '#detail').datagrid({
- showToolbar: false,
- filterThead: false,
- target: $(this),
- columns: [
- {
- name: 'Id',
- label: '功能模块流水号',
- hide: true
- },
- {
- name: 'CascadeId',
- label: '节点语义ID',
- width: 80
- },
- {
- name: 'Name',
- label: '功能模块名称',
- width: 80
- },
- {
- name: 'Url',
- label: '主页面URL',
- width: 80
- },
- {
- name: 'ParentId',
- label: '父节点流水号',
- hide: true
- },
- {
- name: 'IconName',
- width: 80,
- label: '节点图标文件名称'
- },
- {
- name: 'Status',
- width: 80,
- label: '当前状态'
- },
- {
- name: 'ParentName',
- width: 80,
- label: '父节点名称'
- },
- {
- name: 'Vector',
- width: 80,
- label: '矢量图标'
- },
- {
- name: 'SortNo',
- width: 80,
- label: '排序号'
- },
- ],
- dataUrl: '/ModuleManager/Load?orgId=' + selectedId,
- fullGrid: true,
- showLinenumber: true,
- showCheckboxcol: true,
- paging: true,
- filterMult: false,
- showTfoot: false,
- height: 'auto'
+ $.getJSON(url, function (json) {
+ $.fn.zTree.init($("#tree"), setting, json).expandAll(true);
});
+ function zTreeOnClick(event, treeId, treeNode) {
+ list.reload(treeNode.Id);
+ }
return {
- reload: function (id) {
- if (id != undefined) selectedId = id;
- maingrid.datagrid('reload', { dataUrl: '/ModuleManager/Load?orgId=' + selectedId });
+ reload: function () {
+ $.getJSON(url, function (json) {
+ $.fn.zTree.init($("#tree"), setting, json).expandAll(true);
+ });
+ }
+ }
+}();
+
+//编辑时,选择上级弹出的树
+var parentTree = function () {
+ var nameDom = "#ParentName";
+ var idDom = "#ParentId";
+ var zTreeObj;
+ var setting = {
+ view: {
+ selectedMulti: false
},
- getSelectedObj: function () { //选择单行
- var selectedDatas = maingrid.data('selectedDatas');
- if (selectedDatas == undefined || selectedDatas.length == 0) {
- $(this).alertmsg('warn', '至少选择一个对象', {
- displayMode: 'slide',
- title: '重要提示'
- });
- return null;
+ check: {
+ enable: true,
+ chkStyle: "radio", //单选
+ radioType: "all"
+ },
+ data: {
+ key: {
+ name: 'Name',
+ title: 'Name'
+ },
+ simpleData: {
+ enable: true,
+ idKey: 'Id',
+ pIdKey: 'ParentId',
+ rootPId: 'null'
}
- return selectedDatas[0];
- },
- getSelectedMany: function () { //选择多行
- return maingrid.data('selectedDatas');
},
+ callback: {
+ onClick: zTreeOnClick,
+ onCheck: zTreeCheck
+ }
+ };
+
+ function zTreeCheck(event, treeId, treeNode) {
+ var nodes = zTreeObj.getCheckedNodes(true);
+ var ids = nodes.map(function (e) { return e.Id; }).join(",");
+ var names = nodes.map(function (e) { return e.Name; }).join(",");
+
+ $(nameDom).val(names);
+ $(idDom).val(ids);
+ }
+ function zTreeOnClick(event, treeId, treeNode) {
+ zTreeObj.checkNode(treeNode, !treeNode.checked, true, true);
+ event.preventDefault();
+ }
+
+ return {
+ show: function () {
+ $.getJSON('/moduleManager/LoadForTree', function (json) {
+ zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
+ var orgstr = $(idDom).val();
+ var name = '';
+ if (orgstr != '') {
+ var nodeIds = orgstr.split(',');
+ $.each(nodeIds, function () {
+ var node = zTreeObj.getNodeByParam("Id", this, null);
+ name += ',' + node.Name;
+ zTreeObj.checkNode(node, true, true);
+ });
+ $(nameDom).val(name.substr(1)); //显示名称
+ }
+ zTreeObj.expandAll(true);
+ });
+ }
+ };
+}();
+
+//添加(编辑)对话框
+var editDlg = function () {
+ var update = false;
+ var show = function () {
+ BJUI.dialog({ id: 'editDlg', title: '编辑', target: '#editDlg' });
+ $("#btnSave").on("click", function () {
+ editDlg.save();
+ });
+ }
+ return {
+ add: function () { //弹出添加
+ update = false;
+ show();
+ $.CurrentDialog.find("form")[0].reset(); //reset方法只能通过dom调用
+ $("#Id").val(0);
+
+ parentTree.show()
+ },
+ update: function (ret) { //弹出编辑框
+ update = true;
+ show();
+ $('#Id').val(ret.Id);
+ $('#CascadeId').val(ret.CascadeId);
+ $('#Name').val(ret.Name);
+ $('#Url').val(ret.Url);
+ $('#HotKey').val(ret.HotKey);
+ $('#ParentId').val(ret.ParentId);
+ $('#IsLeaf').selectpicker('val', ret.IsLeaf?"true":"false");
+ $('#IsAutoExpand').selectpicker('val', ret.IsAutoExpand?"true":"false");
+ $('#IconName').val(ret.IconName);
+ $('#Status').val(ret.Status);
+ $('#ParentName').val(ret.ParentName);
+ $('#Vector').val(ret.Vector);
+ $('#SortNo').val(ret.SortNo);
+ parentTree.show()
+ },
+ save: function () { //编辑-->保存
+ $('#editForm').isValid(function (v) {
+ if (!v) return; //验证没通过
+ $("#editForm").bjuiajax('ajaxForm', {
+ reload: false,
+ callback: function (json) {
+ list.reload();
+ ztree.reload();
+ }
+ });
+ });
+ }
};
}();
-function zTreeOnClick(event, treeId, treeNode) {
- grid.reload(treeNode.Id);
-}
//删除
-function delModule() {
- var selected = grid.getSelectedObj();
+function del() {
+ var selected = list.getSelectedObj();
if (selected == null) return;
- $.getJSON('/ModuleManager/Delete?Id=' + selected.Id, function (data) {
- if (data.statusCode == "200")
- grid.reload();
+ $.getJSON('/moduleManager/Delete?Id=' + selected.Id, function (data) {
+ if (data.statusCode == "200") {
+ list.reload();
+ ztree.reload();
+ }
else {
$(this).alertmsg('warn', data.message);
}
@@ -150,23 +287,25 @@ function delModule() {
}
//自定义的编辑按钮
-function editModule() {
- var selected = grid.getSelectedObj();
- if (selected == null) return;
+function edit() {
+ var selected = list.getSelectedObj();
+ if (selected == null) {
+ return;
+ }
+ editDlg.update(selected);
+}
- $(this).dialog({
- id: 'editDialog',
- url: '/ModuleManager/Add?id=' + selected.Id,
- title: '编辑',
- onClose: function () {
- grid.reload();
- }
- });
+function add() {
+ editDlg.add();
+}
+
+function refresh() {
+ list.reload();
}
//为模块分配按钮
function assignButton() {
- var selected = grid.getSelectedObj();
+ var selected = list.getSelectedObj();
if (selected == null) return;
//BJUI.dialog({ id: 'assignDialog', title: '菜单编辑', target: '#moduleElementManager' });
@@ -175,10 +314,10 @@ function assignButton() {
id: 'assignDialog',
mask: true,
url: '/ModuleElementManager/Index?id=' + selected.Id,
- title: '为模块分配按钮'
+ title: '为模块分配按钮',
+ width: '800',
+ height:'600'
});
}
-function refreshModuleGrid() {
- grid.reload();
-}
\ No newline at end of file
+//@@ sourceURL=moduleManager.js
\ No newline at end of file
diff --git a/OpenAuth.Mvc/BllScripts/userModuleElement.js b/OpenAuth.Mvc/BllScripts/userModuleElement.js
new file mode 100644
index 00000000..2a148d39
--- /dev/null
+++ b/OpenAuth.Mvc/BllScripts/userModuleElement.js
@@ -0,0 +1,116 @@
+// ***********************************************************************
+// Assembly : OpenAuth.Mvc
+// Author : yubaolee
+// Created : 04-13-2016
+//
+// Last Modified By : yubaolee
+// Last Modified On : 04-13-2016
+// ***********************************************************************
+//
+// 版权所有(C) 2015
+//
+// 为用户分配模块菜单
+// ***********************************************************************
+
+
+$(document).ready(function () {
+ $.CurrentDialog.find("#btnAccess").on("click", function () {
+ var ids = list.getSelectedProperties('Id');
+ if (ids == null) return;
+
+ $.post("/ModuleElementManager/AssignForUser",
+ {
+ userId: $('#userId').val(),
+ menuIds: ids,
+ }, function (json) {
+ list.reload();
+ });
+ });
+ $.CurrentDialog.find("#btnDelAccess").on("click", function () {
+ var ids = list.getSelectedProperties('Id');
+ if (ids == null) return;
+
+ $.post("/ModuleElementManager/CancelForUser",{
+ userId: $('#userId').val(),
+ menuIds: ids,
+ }, function (json) {
+ list.reload();
+ });
+ });
+});
+
+//grid列表模块
+function UserMEGrid() {
+ var selectedId = 0; //ztree选中的模块
+ this.maingrid = $.CurrentDialog.find('#maingrid').datagrid({
+ showToolbar: false,
+ filterThead: false,
+ target: $(this),
+ columns: [
+ {
+ name: 'Id',
+ label: '元素名称',
+ hide: true
+ },
+ {
+ name: 'Name',
+ label: '元素名称',
+ width: 80
+ },
+ {
+ name: 'ModuleName',
+ label: '所属模块',
+ width: 80
+ },
+ {
+ name: 'Accessed',
+ label: '是否已经授权',
+ type: 'select',
+ align: 'center',
+ items: [{ 'false': '未授权', 'true': '已授权' }],
+ width: 80
+ }
+ ],
+ dataUrl: '/ModuleElementManager/LoadForUser?moduleId=' + selectedId + '&userId=' + $('#userId').val(),
+ fullGrid: true,
+ showLinenumber: true,
+ showCheckboxcol: true,
+ paging: true,
+ filterMult: false,
+ showTfoot: false,
+ height: '100%'
+ });
+ this.reload = function(id) {
+ if (id != undefined) selectedId = id;
+ this.maingrid.datagrid('reload', { dataUrl: '/ModuleElementManager/LoadForUser?moduleId=' + selectedId + '&userId=' + $('#userId').val() });
+ };
+};
+UserMEGrid.prototype = new Grid();
+var list = new UserMEGrid();
+
+var ztree = function () {
+ var setting = {
+ view: { selectedMulti: false },
+ data: {
+ key: {
+ name: 'Name',
+ title: 'Name'
+ },
+ simpleData: {
+ enable: true,
+ idKey: 'Id',
+ pIdKey: 'ParentId',
+ rootPId: 'null'
+ }
+ },
+ callback: { onClick: zTreeOnClick }
+ };
+ $.getJSON('/ModuleManager/LoadForUser?userId=' + $('#userId').val(), function (json) {
+ var zTreeObj = $.fn.zTree.init($.CurrentDialog.find("#tree"), setting, json);
+ zTreeObj.expandAll(true);
+ });
+}();
+function zTreeOnClick(event, treeId, treeNode) {
+ list.reload(treeNode.Id);
+}
+//@@ sourceURL=userModuleElement.js
diff --git a/OpenAuth.Mvc/BllScripts/userRoleManager.js b/OpenAuth.Mvc/BllScripts/userRoleManager.js
index d6795619..56800756 100644
--- a/OpenAuth.Mvc/BllScripts/userRoleManager.js
+++ b/OpenAuth.Mvc/BllScripts/userRoleManager.js
@@ -1,4 +1,19 @@
-$(document).ready(function () {
+// ***********************************************************************
+// Assembly : OpenAuth.Mvc
+// Author : yubaolee
+// Created : 04-13-2016
+//
+// Last Modified By : yubaolee
+// Last Modified On : 04-13-2016
+// ***********************************************************************
+//
+// 版权所有(C) 2015
+//
+// 用户分配角色模块
+// ***********************************************************************
+
+
+$(document).ready(function () {
$.CurrentDialog.find("#btnAccess").on("click", function () {
var ids = userRolesList.getSelectedProperties('Id');
if (ids == null) return;
@@ -62,7 +77,7 @@ function UserRolesList() {
paging: true,
filterMult: false,
showTfoot: false,
- height: 'auto'
+ height: '100%'
});
this.reload = function (id) {
if (id != undefined) selectedId = id;
@@ -97,4 +112,4 @@ var ztree = function () {
function zTreeOnClick(event, treeId, treeNode) {
userRolesList.reload(treeNode.Id);
}
-//@@ sourceURL=RoleLookup.js
+//@@ sourceURL=userRoleManager.js
diff --git a/OpenAuth.Mvc/BllScripts/usermanager.js b/OpenAuth.Mvc/BllScripts/usermanager.js
index 22b6f4da..3646d921 100644
--- a/OpenAuth.Mvc/BllScripts/usermanager.js
+++ b/OpenAuth.Mvc/BllScripts/usermanager.js
@@ -104,7 +104,7 @@ var grid = function () {
paging: true,
filterMult: false,
showTfoot: false,
- height: 'auto'
+ height: '100%'
});
return {
diff --git a/OpenAuth.Mvc/Content/BJUI/themes/css/style.css b/OpenAuth.Mvc/Content/BJUI/themes/css/style.css
index 8353fe5d..b8e4ad9d 100644
--- a/OpenAuth.Mvc/Content/BJUI/themes/css/style.css
+++ b/OpenAuth.Mvc/Content/BJUI/themes/css/style.css
@@ -675,12 +675,12 @@ span.tmpzTreeMove_arrow,.ztree .tree_add, .ztree .tree_del,
.ztree li span.button.chk{margin:0 3px 0 0; width:18px; height:20px; cursor:auto;}
.ztree li span.button.chk.checkbox_false_full{background-position:0 -2px;}
.ztree li span.button.chk.checkbox_false_full_focus{background-position:0 -24px;}
-.ztree li span.button.chk.checkbox_false_part{background-position:-19px -46px;}
-.ztree li span.button.chk.checkbox_false_part_focus{background-position:-19px -24px;}
+.ztree li span.button.chk.checkbox_false_part{background-position: 0px -46px;}
+.ztree li span.button.chk.checkbox_false_part_focus{background-position:0px -46px;}
.ztree li span.button.chk.checkbox_false_disable{background-position:0 -68px;}
.ztree li span.button.chk.checkbox_true_full{background-position:-19px -2px;}
.ztree li span.button.chk.checkbox_true_full_focus{background-position:-19px -24px;}
-.ztree li span.button.chk.checkbox_true_part{background-position:-19px -46px;}
+.ztree li span.button.chk.checkbox_true_part{background-position: -19px -24px;}
.ztree li span.button.chk.checkbox_true_part_focus{background-position:-19px -24px;}
.ztree li span.button.chk.checkbox_true_disable{background-position:-19px -68px;}
.ztree li span.button.chk.radio_false_full{background-position:-40px -2px;}
diff --git a/OpenAuth.Mvc/Controllers/CategoryManagerController.cs b/OpenAuth.Mvc/Controllers/CategoryManagerController.cs
index e45e9a57..22de51dd 100644
--- a/OpenAuth.Mvc/Controllers/CategoryManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/CategoryManagerController.cs
@@ -24,11 +24,11 @@ namespace OpenAuth.Mvc.Controllers
}
///
- /// 加载组织下面的所有用户
+ /// 加载分类下面的所有分类
///
- public string Load(int orgId, int pageCurrent = 1, int pageSize = 30)
+ public string Load(int parentId, int pageCurrent = 1, int pageSize = 30)
{
- return JsonHelper.Instance.Serialize(_app.Load(orgId, pageCurrent, pageSize));
+ return JsonHelper.Instance.Serialize(_app.Load(parentId, pageCurrent, pageSize));
}
public string LoadForTree()
diff --git a/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs b/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs
index f44ce44b..a423b840 100644
--- a/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs
@@ -92,12 +92,12 @@ namespace OpenAuth.Mvc.Controllers
/// 菜单ID列表
///
[HttpPost]
- public string AssignForRole(int roleId,int moduleId, string menuIds)
+ public string AssignForRole(int roleId, string menuIds)
{
try
{
- var ids = menuIds.Split(',').Select(id => int.Parse(id)).ToArray();
- _app.AssignForRole(roleId,moduleId, ids);
+ var ids = JsonHelper.Instance.Deserialize(menuIds);
+ _app.AssignForRole(roleId, ids);
}
catch (Exception e)
{
@@ -107,9 +107,25 @@ namespace OpenAuth.Mvc.Controllers
return JsonHelper.Instance.Serialize(_bjuiResponse);
}
- public string LoadForRole(int roleId, int orgId)
+ [HttpPost]
+ public string CancelForRole(int roleId, string menuIds)
{
- return JsonHelper.Instance.Serialize(_app.LoadWithAccess("RoleElement", roleId, orgId));
+ try
+ {
+ var ids = JsonHelper.Instance.Deserialize(menuIds);
+ _app.CancelForRole(roleId, ids);
+ }
+ catch (Exception e)
+ {
+ _bjuiResponse.statusCode = "300";
+ _bjuiResponse.message = e.Message;
+ }
+ return JsonHelper.Instance.Serialize(_bjuiResponse);
+ }
+
+ public string LoadForRole(int roleId, int moduleId)
+ {
+ return JsonHelper.Instance.Serialize(_app.LoadWithAccess("RoleElement", roleId, moduleId));
}
#endregion
@@ -124,16 +140,30 @@ namespace OpenAuth.Mvc.Controllers
/// 为用户分配菜单
///
/// 用户ID
- /// 模块ID
/// 菜单ID列表
///
[HttpPost]
- public string AssignForUser(int userId,int moduleId, string menuIds)
+ public string AssignForUser(int userId, string menuIds)
{
try
{
- var ids = menuIds.Split(',').Select(id => int.Parse(id)).ToArray();
- _app.AssignForUser(userId,moduleId, ids);
+ var ids = JsonHelper.Instance.Deserialize(menuIds);
+ _app.AssignForUser(userId, ids);
+ }
+ catch (Exception e)
+ {
+ _bjuiResponse.statusCode = "300";
+ _bjuiResponse.message = e.Message;
+ }
+ return JsonHelper.Instance.Serialize(_bjuiResponse);
+ }
+ [HttpPost]
+ public string CancelForUser(int userId, string menuIds)
+ {
+ try
+ {
+ var ids = JsonHelper.Instance.Deserialize(menuIds);
+ _app.CancelForUser(userId, ids);
}
catch (Exception e)
{
@@ -143,9 +173,9 @@ namespace OpenAuth.Mvc.Controllers
return JsonHelper.Instance.Serialize(_bjuiResponse);
}
- public string LoadForUser(int userId, int orgId)
+ public string LoadForUser(int userId, int moduleId)
{
- return JsonHelper.Instance.Serialize(_app.LoadWithAccess("UserElement", userId, orgId));
+ return JsonHelper.Instance.Serialize(_app.LoadWithAccess("UserElement", userId, moduleId));
}
#endregion
}
diff --git a/OpenAuth.Mvc/OpenAuth.Mvc.csproj b/OpenAuth.Mvc/OpenAuth.Mvc.csproj
index 9565d881..d6ac9255 100644
--- a/OpenAuth.Mvc/OpenAuth.Mvc.csproj
+++ b/OpenAuth.Mvc/OpenAuth.Mvc.csproj
@@ -150,10 +150,13 @@
+
+
+
@@ -586,7 +589,6 @@
-
@@ -666,7 +668,6 @@
-
diff --git a/OpenAuth.Mvc/Views/CategoryManager/Add.cshtml b/OpenAuth.Mvc/Views/CategoryManager/Add.cshtml
deleted file mode 100644
index bb053e25..00000000
--- a/OpenAuth.Mvc/Views/CategoryManager/Add.cshtml
+++ /dev/null
@@ -1,150 +0,0 @@
-@model OpenAuth.Domain.Category
-@{
- ViewBag.Title = "Category编辑界面";
- Layout = null;
-}
-
-
-
\ No newline at end of file
diff --git a/OpenAuth.Mvc/Views/CategoryManager/Index.cshtml b/OpenAuth.Mvc/Views/CategoryManager/Index.cshtml
index 5119bd5f..f65c2b74 100644
--- a/OpenAuth.Mvc/Views/CategoryManager/Index.cshtml
+++ b/OpenAuth.Mvc/Views/CategoryManager/Index.cshtml
@@ -3,154 +3,79 @@
}
@{ Html.RenderAction("MenuHeader", "Home");}
-