mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-18 04:33:27 +08:00
添加Category
This commit is contained in:
parent
999046f887
commit
f79e5c08fa
@ -36,9 +36,6 @@ public String GetModelName()
|
|||||||
<form action="/<%=ModuleName%>Manager/Add" class="pageForm" data-toggle="validate">
|
<form action="/<%=ModuleName%>Manager/Add" class="pageForm" data-toggle="validate">
|
||||||
<table class="table table-condensed table-hover">
|
<table class="table table-condensed table-hover">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
|
||||||
<td align="center"><h3>* 添加</h3></td>
|
|
||||||
</tr>
|
|
||||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) {
|
<% foreach (ColumnSchema column in this.SourceTable.Columns) {
|
||||||
if(column.Name == CascadeName) continue;
|
if(column.Name == CascadeName) continue;
|
||||||
%>
|
%>
|
||||||
|
@ -29,7 +29,7 @@ using OpenAuth.App.ViewModel;
|
|||||||
|
|
||||||
namespace OpenAuth.Mvc.Controllers
|
namespace OpenAuth.Mvc.Controllers
|
||||||
{
|
{
|
||||||
public class <%=ModuleName%>ManagerController : BaseController
|
public class <%=ModuleName%>ManagerController : BaseController
|
||||||
{
|
{
|
||||||
private <%=ModuleName%>ManagerApp _app;
|
private <%=ModuleName%>ManagerApp _app;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// GET: /<%=ModuleName%>Manager/
|
// GET: /UserManager/
|
||||||
public ActionResult Index()
|
public ActionResult Index()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
@ -50,7 +50,7 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
return View(_app.Find(id));
|
return View(_app.Find(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加或修改组织
|
//添加或修改<%=ModuleName %>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public string Add(<%=GetModelName()%> model)
|
public string Add(<%=GetModelName()%> model)
|
||||||
{
|
{
|
||||||
@ -75,20 +75,11 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
return JsonHelper.Instance.Serialize(_app.Load(orgId, pageCurrent, pageSize));
|
return JsonHelper.Instance.Serialize(_app.Load(orgId, pageCurrent, pageSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取组织下面用户个数
|
public string Delete(int Id)
|
||||||
public int GetCount(int orgId)
|
|
||||||
{
|
|
||||||
return _app.Get<%=GetModelName()%>CntInOrg(orgId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Delete(string Id)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var obj in Id.Split(','))
|
_app.Delete(Id);
|
||||||
{
|
|
||||||
_app.Delete(int.Parse(obj));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -98,5 +89,7 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
|
|
||||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,9 @@ Description: Create a list of properties from a database table
|
|||||||
var _gridId = _prefix + "Grid";
|
var _gridId = _prefix + "Grid";
|
||||||
var _treeDetail = _prefix + "Detail";
|
var _treeDetail = _prefix + "Detail";
|
||||||
}
|
}
|
||||||
<div class="bjui-pageContent">
|
|
||||||
|
@{ Html.RenderAction("MenuHeader", "Home");}
|
||||||
|
<div class="bjui-pageContent tableContent">
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
|
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
|
||||||
<ul id="@_treeId" class="ztree"></ul>
|
<ul id="@_treeId" class="ztree"></ul>
|
||||||
@ -29,7 +31,6 @@ Description: Create a list of properties from a database table
|
|||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var gridid = '#@_gridId';
|
|
||||||
var selectedId = 0;
|
var selectedId = 0;
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
initZtree();
|
initZtree();
|
||||||
@ -39,17 +40,12 @@ Description: Create a list of properties from a database table
|
|||||||
function loadDataGrid() {
|
function loadDataGrid() {
|
||||||
//b-jui的datagrid需要重新处理HTML
|
//b-jui的datagrid需要重新处理HTML
|
||||||
$('#@_treeDetail').empty()
|
$('#@_treeDetail').empty()
|
||||||
.append('<table id="@_gridId" class="table table-bordered"></table>');
|
.append('<table id="@_gridId" class="table table-bordered table-hover table-striped table-top"></table>');
|
||||||
|
|
||||||
$(gridid).datagrid({
|
$('#@_gridId').datagrid({
|
||||||
gridTitle: '列表',
|
showToolbar: false,
|
||||||
showToolbar: true,
|
|
||||||
filterThead: false,
|
filterThead: false,
|
||||||
toolbarItem: 'refresh, |, del',
|
columns: [
|
||||||
toolbarCustom: '<a href="/<%=ModuleName%>Manager/Add" class="btn btn-green" data-icon ="plus" ' +
|
|
||||||
'data-toggle="dialog" data-id="dialog-mask" data-mask="true" data-on-close="refreshGrid">添加</a>' +
|
|
||||||
'<button class=" btn-green" onclick="edit<%=ModuleName%>()" data-icon="pencil" type="button">编辑</button>',
|
|
||||||
columns: [
|
|
||||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
|
<% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
|
||||||
{
|
{
|
||||||
name: '<%=column.Name%>',
|
name: '<%=column.Name%>',
|
||||||
@ -76,22 +72,13 @@ Description: Create a list of properties from a database table
|
|||||||
<% } %>
|
<% } %>
|
||||||
],
|
],
|
||||||
dataUrl: '<%=ModuleName%>Manager/Load?orgId=' + selectedId,
|
dataUrl: '<%=ModuleName%>Manager/Load?orgId=' + selectedId,
|
||||||
delUrl: '<%=ModuleName%>/Delete',
|
|
||||||
delPK: "Id",
|
|
||||||
fullGrid: true,
|
fullGrid: true,
|
||||||
showLinenumber: true,
|
showLinenumber: true,
|
||||||
showCheckboxcol: true,
|
showCheckboxcol: true,
|
||||||
paging: true,
|
paging: true,
|
||||||
filterMult: false,
|
filterMult: false,
|
||||||
showTfoot: true,
|
showTfoot: true,
|
||||||
height: '700',
|
height: '700'
|
||||||
delCallback: function (delResult) {
|
|
||||||
if (delResult.statusCode == "200")
|
|
||||||
loadDataGrid();
|
|
||||||
else {
|
|
||||||
$(this).alertmsg('warn', delResult.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,38 +104,29 @@ Description: Create a list of properties from a database table
|
|||||||
},
|
},
|
||||||
callback: {onClick: zTreeOnClick}
|
callback: {onClick: zTreeOnClick}
|
||||||
};
|
};
|
||||||
$.getJSON('OrgManager/LoadOrg', function (json) {
|
$.getJSON('<%=ModuleName%>Manager/LoadModuleWithRoot', function (json) {
|
||||||
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
||||||
zTreeObj.expandAll(true);
|
zTreeObj.expandAll(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取勾选的值
|
//删除
|
||||||
//column:为从0开始的列标识
|
function del<%=ModuleName%>() {
|
||||||
function getSelected(column) {
|
var selected = getSelected('#@_gridId',2);
|
||||||
var selected = $(gridid).data('selectedTrs');
|
if (selected == null) return;
|
||||||
if (selected == null || selected.length == 0) {
|
|
||||||
$(this).alertmsg('warn', '至少选择一个对象', {
|
|
||||||
displayMode: 'slide',
|
|
||||||
title: '重要提示'
|
|
||||||
});
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//todo:下面这段只能chrome有效
|
$.get('<%=ModuleName%>Manager/Delete?Id=' + selected, function (data) {
|
||||||
var records = new Array();
|
if (data.statusCode == "200")
|
||||||
selected.each(function () {
|
loadDataGrid();
|
||||||
records[records.length] = this.children[column].innerText;
|
else {
|
||||||
|
$(this).alertmsg('warn', data.message);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return records[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//自定义的编辑按钮
|
//自定义的编辑按钮
|
||||||
function edit<%=ModuleName%>() {
|
function edit<%=ModuleName%>() {
|
||||||
var selected = getSelected(2);
|
var selected = getSelected('#@_gridId',2);
|
||||||
if (selected == null) return;
|
if (selected == null) return;
|
||||||
|
|
||||||
$(this).dialog({
|
$(this).dialog({
|
||||||
@ -156,13 +134,13 @@ Description: Create a list of properties from a database table
|
|||||||
url: '/<%=ModuleName%>Manager/Add?id=' + selected,
|
url: '/<%=ModuleName%>Manager/Add?id=' + selected,
|
||||||
title: '编辑',
|
title: '编辑',
|
||||||
onClose:function() {
|
onClose:function() {
|
||||||
refreshGrid();
|
refreshModuleGrid();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshGrid() {
|
function refresh<%=ModuleName%>Grid() {
|
||||||
$('#@_gridId').datagrid('refresh');
|
$('#@_gridId').datagrid('refresh');
|
||||||
// loadDataGrid();
|
// loadDataGrid();
|
||||||
}
|
}
|
||||||
|
99
OpenAuth.App/CategoryManagerApp.cs
Normal file
99
OpenAuth.App/CategoryManagerApp.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
|
||||||
|
using OpenAuth.Domain;
|
||||||
|
using OpenAuth.Domain.Interface;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace OpenAuth.App
|
||||||
|
{
|
||||||
|
public class CategoryManagerApp
|
||||||
|
{
|
||||||
|
private ICategoryRepository _repository;
|
||||||
|
private IOrgRepository _orgRepository;
|
||||||
|
|
||||||
|
public CategoryManagerApp(ICategoryRepository repository,
|
||||||
|
IOrgRepository orgRepository)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_orgRepository = orgRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetCategoryCntInOrg(int orgId)
|
||||||
|
{
|
||||||
|
if (orgId == 0)
|
||||||
|
{
|
||||||
|
return _repository.Find(null).Count();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _repository.GetCategoryCntInOrgs(GetSubOrgIds(orgId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载一个部门及子部门全部Categorys
|
||||||
|
/// </summary>
|
||||||
|
public dynamic Load(int orgId, int pageindex, int pagesize)
|
||||||
|
{
|
||||||
|
IEnumerable<Category> Categorys;
|
||||||
|
int total = 0;
|
||||||
|
if (orgId == 0)
|
||||||
|
{
|
||||||
|
Categorys = _repository.LoadCategorys(pageindex, pagesize);
|
||||||
|
total = _repository.GetCount();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Categorys = _repository.LoadInOrgs(pageindex, pagesize,GetSubOrgIds(orgId));
|
||||||
|
total = _repository.GetCategoryCntInOrgs(orgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
total = total,
|
||||||
|
list = Categorys,
|
||||||
|
pageCurrent = pageindex
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前组织的所有下级组织
|
||||||
|
/// </summary>
|
||||||
|
private int[] GetSubOrgIds(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Category Find(int id)
|
||||||
|
{
|
||||||
|
var category = _repository.FindSingle(u => u.Id == id);
|
||||||
|
if (category == null) return new Category();
|
||||||
|
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(int id)
|
||||||
|
{
|
||||||
|
_repository.Delete(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddOrUpdate(Category model)
|
||||||
|
{
|
||||||
|
Category category = model;
|
||||||
|
if (category.Id == 0)
|
||||||
|
{
|
||||||
|
_repository.Add(category);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_repository.Update(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -43,6 +43,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="CategoryManagerApp.cs" />
|
||||||
<Compile Include="LoginApp.cs" />
|
<Compile Include="LoginApp.cs" />
|
||||||
<Compile Include="ModuleElementManagerApp.cs" />
|
<Compile Include="ModuleElementManagerApp.cs" />
|
||||||
<Compile Include="ModuleManagerApp.cs" />
|
<Compile Include="ModuleManagerApp.cs" />
|
||||||
|
17
OpenAuth.Domain/Interface/ICategoryRepository.cs
Normal file
17
OpenAuth.Domain/Interface/ICategoryRepository.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace OpenAuth.Domain.Interface
|
||||||
|
{
|
||||||
|
public interface ICategoryRepository :IRepository<Category>
|
||||||
|
{
|
||||||
|
IEnumerable<Category> LoadCategorys(int pageindex, int pagesize);
|
||||||
|
|
||||||
|
IEnumerable<Category> LoadInOrgs(params int[] orgId);
|
||||||
|
int GetCategoryCntInOrgs(params int[] orgIds);
|
||||||
|
IEnumerable<Category> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds);
|
||||||
|
|
||||||
|
void Delete(int id);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -46,6 +46,7 @@
|
|||||||
<Compile Include="Core\User.cs" />
|
<Compile Include="Core\User.cs" />
|
||||||
<Compile Include="DicDetail.cs" />
|
<Compile Include="DicDetail.cs" />
|
||||||
<Compile Include="DicIndex.cs" />
|
<Compile Include="DicIndex.cs" />
|
||||||
|
<Compile Include="Interface\ICategoryRepository.cs" />
|
||||||
<Compile Include="Interface\IModuleRepository.cs" />
|
<Compile Include="Interface\IModuleRepository.cs" />
|
||||||
<Compile Include="Interface\IOrgRepository.cs" />
|
<Compile Include="Interface\IOrgRepository.cs" />
|
||||||
<Compile Include="Interface\IRepository.cs" />
|
<Compile Include="Interface\IRepository.cs" />
|
||||||
|
73
OpenAuth.Mvc/Controllers/CategoryManagerController.cs
Normal file
73
OpenAuth.Mvc/Controllers/CategoryManagerController.cs
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using Infrastructure;
|
||||||
|
using OpenAuth.App;
|
||||||
|
using OpenAuth.Domain;
|
||||||
|
|
||||||
|
namespace OpenAuth.Mvc.Controllers
|
||||||
|
{
|
||||||
|
public class CategoryManagerController : BaseController
|
||||||
|
{
|
||||||
|
private CategoryManagerApp _app;
|
||||||
|
|
||||||
|
public CategoryManagerController()
|
||||||
|
{
|
||||||
|
_app = (CategoryManagerApp)DependencyResolver.Current.GetService(typeof(CategoryManagerApp));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// GET: /UserManager/
|
||||||
|
public ActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult Add(int id = 0)
|
||||||
|
{
|
||||||
|
return View(_app.Find(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加或修改Category
|
||||||
|
[HttpPost]
|
||||||
|
public string Add(Category model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_app.AddOrUpdate(model);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
BjuiResponse.statusCode = "300";
|
||||||
|
BjuiResponse.message = ex.Message;
|
||||||
|
}
|
||||||
|
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载组织下面的所有用户
|
||||||
|
/// </summary>
|
||||||
|
public string Load(int orgId, int pageCurrent = 1, int pageSize = 30)
|
||||||
|
{
|
||||||
|
return JsonHelper.Instance.Serialize(_app.Load(orgId, pageCurrent, pageSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Delete(int Id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_app.Delete(Id);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
BjuiResponse.statusCode = "300";
|
||||||
|
BjuiResponse.message = e.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,7 @@
|
|||||||
<IISExpressAnonymousAuthentication>enabled</IISExpressAnonymousAuthentication>
|
<IISExpressAnonymousAuthentication>enabled</IISExpressAnonymousAuthentication>
|
||||||
<IISExpressWindowsAuthentication>disabled</IISExpressWindowsAuthentication>
|
<IISExpressWindowsAuthentication>disabled</IISExpressWindowsAuthentication>
|
||||||
<IISExpressUseClassicPipelineMode />
|
<IISExpressUseClassicPipelineMode />
|
||||||
|
<UseGlobalApplicationHostFile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@ -125,6 +126,7 @@
|
|||||||
<Compile Include="App_Start\RouteConfig.cs" />
|
<Compile Include="App_Start\RouteConfig.cs" />
|
||||||
<Compile Include="AutofacExt.cs" />
|
<Compile Include="AutofacExt.cs" />
|
||||||
<Compile Include="Controllers\BaseController.cs" />
|
<Compile Include="Controllers\BaseController.cs" />
|
||||||
|
<Compile Include="Controllers\CategoryManagerController.cs" />
|
||||||
<Compile Include="Controllers\ErrorController.cs" />
|
<Compile Include="Controllers\ErrorController.cs" />
|
||||||
<Compile Include="Controllers\HomeController.cs" />
|
<Compile Include="Controllers\HomeController.cs" />
|
||||||
<Compile Include="Controllers\LoginController.cs" />
|
<Compile Include="Controllers\LoginController.cs" />
|
||||||
@ -554,6 +556,8 @@
|
|||||||
<Content Include="BJUI\themes\purple\zTreeStandard.png" />
|
<Content Include="BJUI\themes\purple\zTreeStandard.png" />
|
||||||
<Content Include="favicon.ico" />
|
<Content Include="favicon.ico" />
|
||||||
<Content Include="Global.asax" />
|
<Content Include="Global.asax" />
|
||||||
|
<Content Include="Views\CategoryManager\Add.cshtml" />
|
||||||
|
<Content Include="Views\CategoryManager\Index.cshtml" />
|
||||||
<None Include="Views\Error\NoAccess.cshtml" />
|
<None Include="Views\Error\NoAccess.cshtml" />
|
||||||
<None Include="Views\Home\git.cshtml" />
|
<None Include="Views\Home\git.cshtml" />
|
||||||
<Content Include="Web.config" />
|
<Content Include="Web.config" />
|
||||||
|
143
OpenAuth.Mvc/Views/CategoryManager/Add.cshtml
Normal file
143
OpenAuth.Mvc/Views/CategoryManager/Add.cshtml
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
@model OpenAuth.Domain.Category
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "Category编辑界面";
|
||||||
|
Layout = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="bjui-pageContent">
|
||||||
|
<form action="/CategoryManager/Add" class="pageForm" data-toggle="validate">
|
||||||
|
<table class="table table-condensed table-hover">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.HiddenFor(m =>m.Id)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="CascadeId" class="control-label x90">节点语义ID:</label>
|
||||||
|
<input type="text" name="CascadeId" id="CascadeId" value="@Model.CascadeId"
|
||||||
|
data-rule="required" size="20">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Name" class="control-label x90">名称:</label>
|
||||||
|
<input type="text" name="Name" id="Name" value="@Model.Name"
|
||||||
|
data-rule="required" size="20">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="ParentId" class="control-label x85">父节点流水号:</label>
|
||||||
|
<input id="ParentId" name="ParentId" value="" style="display: none"/>
|
||||||
|
<input type="text" name="ParentName" id="ParentName"
|
||||||
|
data-toggle="selectztree" size="20" data-tree="#j_select_tree1" value="@Model.ParentName">
|
||||||
|
<ul id="j_select_tree1" class="ztree hide" data-toggle="ztree"></ul>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="Status" class="control-label x85">当前状态:</label>
|
||||||
|
<select name="Status" id="Status" data-toggle="selectpicker" data-rule="required">
|
||||||
|
<option value="0" @if (Model.Status == 0) { <text> selected="selected" </text> }>默认</option>
|
||||||
|
<option value="1" @if (Model.Status == 1) { <text> selected="selected" </text> }>状态1</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="SortNo" class="control-label x85">排序号:</label>
|
||||||
|
<select name="SortNo" id="SortNo" data-toggle="selectpicker" data-rule="required">
|
||||||
|
<option value="0" @if (Model.SortNo == 0) { <text> selected="selected" </text> }>默认</option>
|
||||||
|
<option value="1" @if (Model.SortNo == 1) { <text> selected="selected" </text> }>状态1</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="RootKey" class="control-label x90">资源分类标识:</label>
|
||||||
|
<input type="text" name="RootKey" id="RootKey" value="@Model.RootKey"
|
||||||
|
data-rule="required" size="20">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="RootName" class="control-label x90">资源分类:</label>
|
||||||
|
<input type="text" name="RootName" id="RootName" value="@Model.RootName"
|
||||||
|
data-rule="required" size="20">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="bjui-pageFooter">
|
||||||
|
<ul>
|
||||||
|
<li><button type="button" class="btn-close">关闭</button></li>
|
||||||
|
<li><button type="submit" class="btn-green">保存</button></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function () {
|
||||||
|
Init();
|
||||||
|
});
|
||||||
|
function Init() {
|
||||||
|
var setting = {
|
||||||
|
view: {
|
||||||
|
selectedMulti: false
|
||||||
|
},
|
||||||
|
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: zTreeOnClick,
|
||||||
|
onCheck: zTreeCheck
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$.getJSON('OrgManager/LoadOrg', function (json) {
|
||||||
|
var zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
|
||||||
|
zTreeObj.expandAll(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function zTreeCheck(e, treeId, treeNode) {
|
||||||
|
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
||||||
|
nodes = zTree.getCheckedNodes(true);
|
||||||
|
var ids = '', names = '';
|
||||||
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
|
ids += ',' + nodes[i].Id;
|
||||||
|
names += ',' + nodes[i].Name;
|
||||||
|
}
|
||||||
|
if (ids.length > 0) { //去掉第一个逗号
|
||||||
|
ids = ids.substr(1);
|
||||||
|
names = names.substr(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
var $from = $('#' + treeId).data('fromObj');
|
||||||
|
if ($from && $from.length) $from.val(names);
|
||||||
|
|
||||||
|
$('#ParentId').val(ids);
|
||||||
|
}
|
||||||
|
function zTreeOnClick(event, treeId, treeNode) {
|
||||||
|
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
||||||
|
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
</script>
|
162
OpenAuth.Mvc/Views/CategoryManager/Index.cshtml
Normal file
162
OpenAuth.Mvc/Views/CategoryManager/Index.cshtml
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
@{
|
||||||
|
string _prefix = "Category";
|
||||||
|
var _treeId = _prefix + "Tree";
|
||||||
|
var _gridId = _prefix + "Grid";
|
||||||
|
var _treeDetail = _prefix + "Detail";
|
||||||
|
}
|
||||||
|
|
||||||
|
@{ Html.RenderAction("MenuHeader", "Home");}
|
||||||
|
<div class="bjui-pageContent tableContent">
|
||||||
|
<div class="clearfix">
|
||||||
|
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
|
||||||
|
<ul id="@_treeId" class="ztree"></ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="@_treeDetail" style="margin-left: 225px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var selectedId = 0;
|
||||||
|
$(document).ready(function () {
|
||||||
|
initZtree();
|
||||||
|
loadDataGrid();
|
||||||
|
});
|
||||||
|
//加载数据到datagrid
|
||||||
|
function loadDataGrid() {
|
||||||
|
//b-jui的datagrid需要重新处理HTML
|
||||||
|
$('#@_treeDetail').empty()
|
||||||
|
.append('<table id="@_gridId" class="table table-bordered table-hover table-striped table-top"></table>');
|
||||||
|
|
||||||
|
$('#@_gridId').datagrid({
|
||||||
|
showToolbar: false,
|
||||||
|
filterThead: false,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
name: 'Id',
|
||||||
|
label: '资源表ID',
|
||||||
|
width: 100
|
||||||
|
, hide: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'CascadeId',
|
||||||
|
label: '节点语义ID',
|
||||||
|
width: 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Name',
|
||||||
|
label: '名称',
|
||||||
|
width: 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ParentId',
|
||||||
|
label: '父节点流水号',
|
||||||
|
width: 100
|
||||||
|
,type: 'select',
|
||||||
|
align: 'center',
|
||||||
|
items: [{ '0': '默认' }, { '1': '状态1' }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Status',
|
||||||
|
label: '当前状态',
|
||||||
|
width: 100
|
||||||
|
,type: 'select',
|
||||||
|
align: 'center',
|
||||||
|
items: [{ '0': '默认' }, { '1': '状态1' }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'SortNo',
|
||||||
|
label: '排序号',
|
||||||
|
width: 100
|
||||||
|
,type: 'select',
|
||||||
|
align: 'center',
|
||||||
|
items: [{ '0': '默认' }, { '1': '状态1' }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'RootKey',
|
||||||
|
label: '根节点',
|
||||||
|
width: 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'RootName',
|
||||||
|
label: '根节点名称',
|
||||||
|
width: 100
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dataUrl: 'CategoryManager/Load?orgId=' + selectedId,
|
||||||
|
fullGrid: true,
|
||||||
|
showLinenumber: true,
|
||||||
|
showCheckboxcol: true,
|
||||||
|
paging: true,
|
||||||
|
filterMult: false,
|
||||||
|
showTfoot: true,
|
||||||
|
height: '700'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function zTreeOnClick(event, treeId, treeNode) {
|
||||||
|
selectedId = treeNode.Id;
|
||||||
|
loadDataGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
function initZtree() {
|
||||||
|
var setting = {
|
||||||
|
view: {selectedMulti: false},
|
||||||
|
data: {
|
||||||
|
key: {
|
||||||
|
name: 'Name',
|
||||||
|
title: 'Name'
|
||||||
|
},
|
||||||
|
simpleData: {
|
||||||
|
enable: true,
|
||||||
|
idKey: 'Id',
|
||||||
|
pIdKey: 'ParentId',
|
||||||
|
rootPId: 'null'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {onClick: zTreeOnClick}
|
||||||
|
};
|
||||||
|
$.getJSON('CategoryManager/LoadModuleWithRoot', function (json) {
|
||||||
|
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
||||||
|
zTreeObj.expandAll(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除
|
||||||
|
function delCategory() {
|
||||||
|
var selected = getSelected('#@_gridId',2);
|
||||||
|
if (selected == null) return;
|
||||||
|
|
||||||
|
$.get('CategoryManager/Delete?Id=' + selected, function (data) {
|
||||||
|
if (data.statusCode == "200")
|
||||||
|
loadDataGrid();
|
||||||
|
else {
|
||||||
|
$(this).alertmsg('warn', data.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//自定义的编辑按钮
|
||||||
|
function editCategory() {
|
||||||
|
var selected = getSelected('#@_gridId',2);
|
||||||
|
if (selected == null) return;
|
||||||
|
|
||||||
|
$(this).dialog({
|
||||||
|
id: 'editDialog',
|
||||||
|
url: '/CategoryManager/Add?id=' + selected,
|
||||||
|
title: '编辑',
|
||||||
|
onClose:function() {
|
||||||
|
refreshModuleGrid();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshCategoryGrid() {
|
||||||
|
$('#@_gridId').datagrid('refresh');
|
||||||
|
// loadDataGrid();
|
||||||
|
}
|
||||||
|
//@@ sourceURL=CategoryManagerIndex.js
|
||||||
|
</script>
|
39
OpenAuth.Repository/CategoryRepository.cs
Normal file
39
OpenAuth.Repository/CategoryRepository.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenAuth.Domain;
|
||||||
|
using OpenAuth.Domain.Interface;
|
||||||
|
|
||||||
|
namespace OpenAuth.Repository
|
||||||
|
{
|
||||||
|
public class CategoryRepository :BaseRepository<Category>, ICategoryRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
public IEnumerable<Category> LoadCategorys(int pageindex, int pagesize)
|
||||||
|
{
|
||||||
|
return Context.Categories.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Category> LoadInOrgs(params int[] orgId)
|
||||||
|
{
|
||||||
|
var result = from category in Context.Categories where orgId.Contains(category.Id)
|
||||||
|
select category;
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetCategoryCntInOrgs(params int[] orgIds)
|
||||||
|
{
|
||||||
|
return LoadInOrgs(orgIds).Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Category> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
|
||||||
|
{
|
||||||
|
return LoadInOrgs(orgIds).OrderBy(u =>u.Id).Skip((pageindex -1)*pagesize).Take(pagesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(int id)
|
||||||
|
{
|
||||||
|
Delete(u =>u.Id == id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -72,6 +72,7 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ModuleRepository.cs" />
|
<Compile Include="ModuleRepository.cs" />
|
||||||
<Compile Include="RoleRepository.cs" />
|
<Compile Include="RoleRepository.cs" />
|
||||||
|
<Compile Include="CategoryRepository.cs" />
|
||||||
<Compile Include="UserRepository.cs" />
|
<Compile Include="UserRepository.cs" />
|
||||||
<Compile Include="RelevanceRepository.cs" />
|
<Compile Include="RelevanceRepository.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user