mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-16 16:50:54 +08:00
1.0 beta版
1 完成进出库实例Stock; 2 全面实现组织数据分离,参考Stock实例; 3 全新的基于CodeSmith EF生成机制; 4 全面完成菜单授权; 5 增加Anonymous机制,可以灵活控制Action是否需要权限控制;
This commit is contained in:
parent
5317e07ae5
commit
ab3fc27301
@ -71,9 +71,9 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载节点下面的所有<%=ModuleName %>s
|
/// 加载节点下面的所有<%=ModuleName %>s
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Load(int parentidId, int pageCurrent = 1, int pageSize = 30)
|
public string Load(int parentId, int pageCurrent = 1, int pageSize = 30)
|
||||||
{
|
{
|
||||||
return JsonHelper.Instance.Serialize(_app.Load(parentidId, pageCurrent, pageSize));
|
return JsonHelper.Instance.Serialize(_app.Load(parentId, pageCurrent, pageSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string LoadForTree()
|
public string LoadForTree()
|
||||||
|
@ -80,7 +80,7 @@ namespace OpenAuth.App
|
|||||||
var orgids = _relevanceRepository.Find(
|
var orgids = _relevanceRepository.Find(
|
||||||
u =>
|
u =>
|
||||||
(u.FirstId == user.Id && u.Key == "UserAccessedOrg") ||
|
(u.FirstId == user.Id && u.Key == "UserAccessedOrg") ||
|
||||||
(u.Key == "RoleAccessdOrg" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList();
|
(u.Key == "RoleAccessedOrg" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList();
|
||||||
loginVM.AccessedOrgs = _orgRepository.Find(u => orgids.Contains(u.Id)).ToList();
|
loginVM.AccessedOrgs = _orgRepository.Find(u => orgids.Contains(u.Id)).ToList();
|
||||||
|
|
||||||
return loginVM;
|
return loginVM;
|
||||||
@ -95,7 +95,8 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Name = "开发者账号"
|
Name = "开发者账号",
|
||||||
|
Account = "System"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
loginUser.Modules = _moduleRepository.Find(null).MapToList<ModuleView>();
|
loginUser.Modules = _moduleRepository.Find(null).MapToList<ModuleView>();
|
||||||
|
@ -98,14 +98,14 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
public void AssignForRole(int roleId,int moduleId, int[] menuIds)
|
public void AssignForRole(int roleId,int moduleId, int[] menuIds)
|
||||||
{
|
{
|
||||||
var elements = _repository.Find(u => u.ModuleId == moduleId).Select(u =>u.Id);
|
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.Delete(u =>elements.Contains(u.SecondId) &&u.Key =="RoleElement" && u.FirstId == roleId);
|
||||||
_relevanceRepository.AddRelevance("RoleElement", menuIds.ToLookup(u => roleId));
|
_relevanceRepository.AddRelevance("RoleElement", menuIds.ToLookup(u => roleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AssignForUser(int userId, int moduleId, int[] ids)
|
public void AssignForUser(int userId, int moduleId, int[] ids)
|
||||||
{
|
{
|
||||||
var elements = _repository.Find(u => u.ModuleId == moduleId).Select(u => u.Id);
|
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.Delete(u => elements.Contains(u.SecondId) && u.Key == "UserElement" && u.FirstId == userId);
|
||||||
_relevanceRepository.AddRelevance("UserElement", ids.ToLookup(u => userId));
|
_relevanceRepository.AddRelevance("UserElement", ids.ToLookup(u => userId));
|
||||||
}
|
}
|
||||||
|
@ -39,16 +39,7 @@ namespace OpenAuth.App
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<Org> LoadAllChildren(int orgId)
|
public IList<Org> LoadAllChildren(int orgId)
|
||||||
{
|
{
|
||||||
string cascadeId = "0.";
|
return _repository.GetSubOrgs(orgId).ToList();
|
||||||
if (orgId != 0)
|
|
||||||
{
|
|
||||||
var org = _repository.FindSingle(u => u.Id == orgId);
|
|
||||||
if (org == null)
|
|
||||||
throw new Exception("未能找到指定对象信息");
|
|
||||||
cascadeId = org.CascadeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return _repository.Find(u => u.CascadeId.Contains(cascadeId) && u.Id != orgId).ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
|
||||||
using OpenAuth.Domain;
|
using OpenAuth.Domain;
|
||||||
using OpenAuth.Domain.Interface;
|
using OpenAuth.Domain.Interface;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
|
using Infrastructure.Helper;
|
||||||
|
using OpenAuth.App.ViewModel;
|
||||||
|
|
||||||
namespace OpenAuth.App
|
namespace OpenAuth.App
|
||||||
{
|
{
|
||||||
@ -20,39 +21,38 @@ namespace OpenAuth.App
|
|||||||
_orgRepository = orgRepository;
|
_orgRepository = orgRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetStockCntInOrg(int orgId)
|
|
||||||
{
|
|
||||||
if (orgId == 0)
|
|
||||||
{
|
|
||||||
return _repository.Find(null).Count();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return _repository.GetStockCntInOrgs(GetSubOrgIds(orgId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Stock> LoadAll()
|
|
||||||
{
|
|
||||||
return _repository.Find(null).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载一个节点下面的一个或全部Stocks
|
/// 根据部门ID得到进出库信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public dynamic Load(int orgId, int pageindex, int pagesize)
|
public dynamic Load(int orgId, int pageindex, int pagesize)
|
||||||
{
|
{
|
||||||
IEnumerable<Stock> Stocks;
|
IEnumerable<Stock> Stocks;
|
||||||
int total = 0;
|
var user = SessionHelper.GetSessionUser<LoginUserVM>();
|
||||||
|
var loginOrgs = user.AccessedOrgs.Select(u => u.Id).ToArray();
|
||||||
|
|
||||||
|
int total;
|
||||||
if (orgId == 0)
|
if (orgId == 0)
|
||||||
{
|
{
|
||||||
Stocks = _repository.LoadStocks(pageindex, pagesize);
|
|
||||||
total = _repository.GetCount();
|
if (loginOrgs.Length == 0) //改用户没有任何可见机构
|
||||||
|
{
|
||||||
|
Stocks = _repository.Find(pageindex, pagesize, "", u => u.User == user.User.Account);
|
||||||
|
total = _repository.GetCount(u =>u.User ==user.User.Account);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Stocks = _repository.LoadInOrgs(pageindex, pagesize, loginOrgs);
|
||||||
|
total = _repository.GetStockCntInOrgs(loginOrgs);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else //加载选择的机构及用户可访问的所有子机构
|
||||||
{
|
{
|
||||||
Stocks = _repository.LoadInOrgs(pageindex, pagesize,GetSubOrgIds(orgId));
|
var orgs = _orgRepository.GetSubOrgs(orgId).Where(u =>loginOrgs.Contains(u.Id));
|
||||||
total = _repository.GetStockCntInOrgs(orgId);
|
List<int> orgIds = orgs.Select(u => u.Id).ToList();
|
||||||
|
orgIds.Add(orgId);
|
||||||
|
Stocks = _repository.LoadInOrgs(pageindex, pagesize, orgIds.ToArray());
|
||||||
|
total = _repository.GetStockCntInOrgs(orgIds.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new
|
return new
|
||||||
@ -63,16 +63,6 @@ namespace OpenAuth.App
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <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 Stock Find(int id)
|
public Stock Find(int id)
|
||||||
{
|
{
|
||||||
var stock = _repository.FindSingle(u => u.Id == id);
|
var stock = _repository.FindSingle(u => u.Id == id);
|
||||||
|
@ -11,5 +11,11 @@ namespace OpenAuth.Domain.Interface
|
|||||||
IEnumerable<Org> LoadOrgs();
|
IEnumerable<Org> LoadOrgs();
|
||||||
|
|
||||||
IEnumerable<Org> LoadByUser(int userId);
|
IEnumerable<Org> LoadByUser(int userId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 得到全部子部门
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orgId">部门ID</param>
|
||||||
|
IEnumerable<Org> GetSubOrgs(int orgId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
using Infrastructure.Helper;
|
using Infrastructure.Helper;
|
||||||
using OpenAuth.App.ViewModel;
|
using OpenAuth.App.ViewModel;
|
||||||
using OpenAuth.Mvc.Models;
|
using OpenAuth.Mvc.Models;
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
|
||||||
namespace OpenAuth.Mvc.Controllers
|
namespace OpenAuth.Mvc.Controllers
|
||||||
@ -36,8 +38,15 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
|
|
||||||
if (controllername != "home") //主页控制器无需权限控制
|
if (controllername != "home") //主页控制器无需权限控制
|
||||||
{
|
{
|
||||||
|
var actionname = Request.RequestContext.RouteData.Values["action"].ToString();
|
||||||
|
var function = this.GetType().GetMethods().FirstOrDefault(u => u.Name == actionname);
|
||||||
|
if (function == null)
|
||||||
|
throw new Exception("未能找到Action");
|
||||||
|
|
||||||
|
var anonymous = function.GetCustomAttribute(typeof(AnonymousAttribute));
|
||||||
|
|
||||||
var module = loginUser.Modules.FirstOrDefault(u => u.Url.ToLower().Contains(controllername));
|
var module = loginUser.Modules.FirstOrDefault(u => u.Url.ToLower().Contains(controllername));
|
||||||
if (module == null)
|
if (module == null && anonymous == null)
|
||||||
{
|
{
|
||||||
filterContext.Result = new RedirectResult("/Login/Index");
|
filterContext.Result = new RedirectResult("/Login/Index");
|
||||||
return;
|
return;
|
||||||
|
@ -60,6 +60,7 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs;
|
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs;
|
||||||
return JsonHelper.Instance.Serialize(orgs);
|
return JsonHelper.Instance.Serialize(orgs);
|
||||||
}
|
}
|
||||||
|
[Anonymous]
|
||||||
public string LoadOrg()
|
public string LoadOrg()
|
||||||
{
|
{
|
||||||
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs.MapToList<Org>();
|
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs.MapToList<Org>();
|
||||||
|
@ -3,6 +3,8 @@ using OpenAuth.App;
|
|||||||
using OpenAuth.Domain;
|
using OpenAuth.Domain;
|
||||||
using System;
|
using System;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
using Infrastructure.Helper;
|
||||||
|
using OpenAuth.App.ViewModel;
|
||||||
|
|
||||||
namespace OpenAuth.Mvc.Controllers
|
namespace OpenAuth.Mvc.Controllers
|
||||||
{
|
{
|
||||||
@ -33,7 +35,10 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_app.AddOrUpdate(model);
|
var newmodel = new Stock();
|
||||||
|
model.CopyTo(newmodel);
|
||||||
|
newmodel.User = SessionHelper.GetSessionUser<LoginUserVM>().User.Account;
|
||||||
|
_app.AddOrUpdate(newmodel);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -46,24 +51,11 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载节点下面的所有Stocks
|
/// 加载节点下面的所有Stocks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Load(int parentidId, int pageCurrent = 1, int pageSize = 30)
|
public string Load(int parentId, int pageCurrent = 1, int pageSize = 30)
|
||||||
{
|
{
|
||||||
return JsonHelper.Instance.Serialize(_app.Load(parentidId, pageCurrent, pageSize));
|
return JsonHelper.Instance.Serialize(_app.Load(parentId, pageCurrent, pageSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string LoadForTree()
|
|
||||||
{
|
|
||||||
var models = _app.LoadAll();
|
|
||||||
//添加根节点
|
|
||||||
models.Add(new Stock
|
|
||||||
{
|
|
||||||
Id = 0,
|
|
||||||
OrgId = -1,
|
|
||||||
Name = "根结点",
|
|
||||||
});
|
|
||||||
return JsonHelper.Instance.Serialize(models);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Delete(int Id)
|
public string Delete(int Id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
14
OpenAuth.Mvc/Models/AnonymousAttribute.cs
Normal file
14
OpenAuth.Mvc/Models/AnonymousAttribute.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace OpenAuth.Mvc.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 允许匿名访问
|
||||||
|
/// </summary>
|
||||||
|
public class AnonymousAttribute :Attribute
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -137,6 +137,7 @@
|
|||||||
<Compile Include="Global.asax.cs">
|
<Compile Include="Global.asax.cs">
|
||||||
<DependentUpon>Global.asax</DependentUpon>
|
<DependentUpon>Global.asax</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Models\AnonymousAttribute.cs" />
|
||||||
<Compile Include="Models\BJUIResponse.cs" />
|
<Compile Include="Models\BJUIResponse.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -5,13 +5,13 @@ using System.Runtime.InteropServices;
|
|||||||
// 有关程序集的常规信息是通过以下项进行控制的
|
// 有关程序集的常规信息是通过以下项进行控制的
|
||||||
// 控制。更改这些特性值可修改
|
// 控制。更改这些特性值可修改
|
||||||
// 与程序集关联的信息。
|
// 与程序集关联的信息。
|
||||||
[assembly: AssemblyTitle("OpenAuth.Mvc")]
|
[assembly: AssemblyTitle("基于DDDLite的权限管理系统")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("www.cnblogs.com/yubaolee")]
|
||||||
[assembly: AssemblyProduct("OpenAuth.Mvc")]
|
[assembly: AssemblyProduct("OpenAuth.Mvc")]
|
||||||
[assembly: AssemblyCopyright("版权所有(C) 2015")]
|
[assembly: AssemblyCopyright("版权所有(C) 2015")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("OpenAuth.Net")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
// 将 ComVisible 设置为 false 将使此程序集中的类型
|
// 将 ComVisible 设置为 false 将使此程序集中的类型
|
||||||
|
@ -40,13 +40,7 @@
|
|||||||
data-rule="required" size="20">
|
data-rule="required" size="20">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<label for="User" class="control-label x120">:</label>
|
|
||||||
<input type="text" name="User" id="User" value="@Model.User"
|
|
||||||
data-rule="required" size="20">
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label for="Time" class="control-label x120">操作时间:</label>
|
<label for="Time" class="control-label x120">操作时间:</label>
|
||||||
@ -59,9 +53,9 @@
|
|||||||
@Html.HiddenFor(m =>m.OrgId)
|
@Html.HiddenFor(m =>m.OrgId)
|
||||||
@if (Model.Id == 0) //添加
|
@if (Model.Id == 0) //添加
|
||||||
{
|
{
|
||||||
//这个只用于显示使用,并不会进行提交处理,真正提交的是cascadeId
|
//这个只用于显示使用,并不会进行提交处理,真正提交的是OrgId
|
||||||
<label for="CascadeName" class="control-label x120">父节点流水号:</label>
|
<label for="OrgName" class="control-label x120">所属部门:</label>
|
||||||
<input type="text" name="CascadeName" id="CascadeName"
|
<input type="text" name="OrgName" id="OrgName"
|
||||||
data-toggle="selectztree" size="20" data-tree="#j_select_tree1" value="">
|
data-toggle="selectztree" size="20" data-tree="#j_select_tree1" value="">
|
||||||
<ul id="j_select_tree1" class="ztree hide" data-toggle="ztree"></ul>
|
<ul id="j_select_tree1" class="ztree hide" data-toggle="ztree"></ul>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -95,7 +89,7 @@
|
|||||||
onCheck: zTreeCheck
|
onCheck: zTreeCheck
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$.getJSON('CategoryManager/LoadForTree', function (json) {
|
$.getJSON('OrgManager/LoadForTree', function (json) {
|
||||||
var zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
|
var zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
|
||||||
zTreeObj.expandAll(true);
|
zTreeObj.expandAll(true);
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var selectedId = 0;
|
var selectedId = 0;
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
@ -33,59 +32,54 @@
|
|||||||
$('#@_gridId').datagrid({
|
$('#@_gridId').datagrid({
|
||||||
showToolbar: false,
|
showToolbar: false,
|
||||||
filterThead: false,
|
filterThead: false,
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
name: 'Id',
|
name: 'Id',
|
||||||
label: '数据ID',
|
label: '数据ID',
|
||||||
width: 100
|
width: 100,
|
||||||
, hide: true
|
hide: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Name',
|
name: 'Name',
|
||||||
label: '产品名称',
|
label: '产品名称',
|
||||||
width: 100
|
width: 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Number',
|
name: 'Number',
|
||||||
label: '产品数量',
|
label: '产品数量',
|
||||||
width: 100
|
width: 100
|
||||||
,type: 'select',
|
},
|
||||||
align: 'center',
|
{
|
||||||
items: [{ '0': '默认' }, { '1': '状态1' }],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Price',
|
name: 'Price',
|
||||||
label: '产品单价',
|
label: '产品单价',
|
||||||
width: 100
|
width: 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Status',
|
name: 'Status',
|
||||||
label: '出库/入库',
|
label: '出库/入库',
|
||||||
width: 100
|
width: 100
|
||||||
,type: 'select',
|
, type: 'select',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
items: [{ '0': '默认' }, { '1': '状态1' }],
|
items: [{ '0': '入库' }, { '1': '出库' }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'User',
|
name: 'User',
|
||||||
label: '',
|
label: '操作人',
|
||||||
width: 100
|
width: 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Time',
|
name: 'Time',
|
||||||
label: '操作时间',
|
label: '操作时间',
|
||||||
width: 100
|
width: 100
|
||||||
, type: 'date',
|
, type: 'date',
|
||||||
pattern: 'yyyy-MM-dd HH:mm:ss'
|
pattern: 'yyyy-MM-dd HH:mm:ss'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'OrgId',
|
name: 'OrgId',
|
||||||
label: '组织ID',
|
label: '所属部门',
|
||||||
width: 100
|
width: 100,
|
||||||
,type: 'select',
|
hide: true
|
||||||
align: 'center',
|
}
|
||||||
items: [{ '0': '默认' }, { '1': '状态1' }],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
dataUrl: 'StockManager/Load?parentId=' + selectedId,
|
dataUrl: 'StockManager/Load?parentId=' + selectedId,
|
||||||
fullGrid: true,
|
fullGrid: true,
|
||||||
@ -105,7 +99,7 @@
|
|||||||
|
|
||||||
function initZtree() {
|
function initZtree() {
|
||||||
var setting = {
|
var setting = {
|
||||||
view: {selectedMulti: false},
|
view: { selectedMulti: false },
|
||||||
data: {
|
data: {
|
||||||
key: {
|
key: {
|
||||||
name: 'Name',
|
name: 'Name',
|
||||||
@ -118,9 +112,9 @@
|
|||||||
rootPId: 'null'
|
rootPId: 'null'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
callback: {onClick: zTreeOnClick}
|
callback: { onClick: zTreeOnClick }
|
||||||
};
|
};
|
||||||
$.getJSON('StockManager/LoadForTree', function (json) {
|
$.getJSON('OrgManager/LoadOrg', function (json) {
|
||||||
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
||||||
zTreeObj.expandAll(true);
|
zTreeObj.expandAll(true);
|
||||||
});
|
});
|
||||||
@ -128,9 +122,9 @@
|
|||||||
|
|
||||||
//删除
|
//删除
|
||||||
function delStock() {
|
function delStock() {
|
||||||
var selected = getSelected('#@_gridId',2);
|
var selected = getSelected('#@_gridId', 2);
|
||||||
if (selected == null) return;
|
if (selected == null) return;
|
||||||
|
|
||||||
$.getJSON('StockManager/Delete?Id=' + selected, function (data) {
|
$.getJSON('StockManager/Delete?Id=' + selected, function (data) {
|
||||||
if (data.statusCode == "200")
|
if (data.statusCode == "200")
|
||||||
loadDataGrid();
|
loadDataGrid();
|
||||||
@ -142,14 +136,14 @@
|
|||||||
|
|
||||||
//自定义的编辑按钮
|
//自定义的编辑按钮
|
||||||
function editStock() {
|
function editStock() {
|
||||||
var selected = getSelected('#@_gridId',2);
|
var selected = getSelected('#@_gridId', 2);
|
||||||
if (selected == null) return;
|
if (selected == null) return;
|
||||||
|
|
||||||
$(this).dialog({
|
$(this).dialog({
|
||||||
id: 'editDialog',
|
id: 'editDialog',
|
||||||
url: '/StockManager/Add?id=' + selected,
|
url: '/StockManager/Add?id=' + selected,
|
||||||
title: '编辑',
|
title: '编辑',
|
||||||
onClose:function() {
|
onClose: function () {
|
||||||
refreshStockGrid();
|
refreshStockGrid();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -158,7 +152,7 @@
|
|||||||
|
|
||||||
function refreshStockGrid() {
|
function refreshStockGrid() {
|
||||||
$('#@_gridId').datagrid('refresh');
|
$('#@_gridId').datagrid('refresh');
|
||||||
// loadDataGrid();
|
// loadDataGrid();
|
||||||
}
|
}
|
||||||
//@@ sourceURL=StockManagerIndex.js
|
//@@ sourceURL=StockManagerIndex.js
|
||||||
</script>
|
</script>
|
@ -24,5 +24,19 @@ namespace OpenAuth.Repository
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Org> GetSubOrgs(int orgId)
|
||||||
|
{
|
||||||
|
string cascadeId = "0.";
|
||||||
|
if (orgId != 0)
|
||||||
|
{
|
||||||
|
var org = FindSingle(u => u.Id == orgId);
|
||||||
|
if (org == null)
|
||||||
|
throw new Exception("未能找到指定对象信息");
|
||||||
|
cascadeId = org.CascadeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Find(u => u.CascadeId.Contains(cascadeId) && u.Id != orgId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace OpenAuth.Repository
|
|||||||
|
|
||||||
public IEnumerable<Stock> LoadInOrgs(params int[] orgId)
|
public IEnumerable<Stock> LoadInOrgs(params int[] orgId)
|
||||||
{
|
{
|
||||||
var result = from stock in Context.Stocks where orgId.Contains(stock.Id)
|
var result = from stock in Context.Stocks where orgId.Contains(stock.OrgId)
|
||||||
select stock;
|
select stock;
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
BIN
建表&初始化数据.sql
BIN
建表&初始化数据.sql
Binary file not shown.
Loading…
Reference in New Issue
Block a user