mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 01:58:01 +08:00
1 完成用户部门权限分配处理,可以为用户分配可见部门,如果没有任何可见部门,则只能查看自己有关的数据;
2 完善进出库实例; 3 添加CodeSmith生成EF DbContext Entity Mapping;
This commit is contained in:
@@ -41,7 +41,8 @@ namespace OpenAuth.Mvc
|
||||
builder.RegisterType<ModuleManagerApp>();
|
||||
builder.RegisterType<ModuleElementManagerApp>();
|
||||
builder.RegisterType<CategoryManagerApp>();
|
||||
builder.RegisterType<ResourceManagerApp>();
|
||||
builder.RegisterType<ResourceManagerApp>();
|
||||
builder.RegisterType<StockManagerApp>();
|
||||
|
||||
// Register your MVC controllers.
|
||||
builder.RegisterControllers(typeof(MvcApplication).Assembly);
|
||||
@@ -65,7 +66,7 @@ namespace OpenAuth.Mvc
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ
|
||||
/// 从容器中获取对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public static T GetFromFac<T>()
|
||||
|
@@ -3,7 +3,10 @@ using OpenAuth.App;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Mvc.Models;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Infrastructure.Helper;
|
||||
using OpenAuth.App.ViewModel;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
@@ -23,6 +26,20 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
//用于选择模块时使用
|
||||
public ActionResult LookUpMultiForUser(int userId)
|
||||
{
|
||||
ViewBag.UserId = userId;
|
||||
return View();
|
||||
}
|
||||
|
||||
//为角色分配模块
|
||||
public ActionResult LookupMultiForRole(int roleId)
|
||||
{
|
||||
ViewBag.RoleId = roleId;
|
||||
return View();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选择上级机构页面
|
||||
/// </summary>
|
||||
@@ -37,6 +54,86 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public string LoadForTree()
|
||||
{
|
||||
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs;
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
}
|
||||
|
||||
public string LoadOrgWithRoot()
|
||||
{
|
||||
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs;
|
||||
//添加根节点
|
||||
orgs.Add(new Org
|
||||
{
|
||||
Id = 0,
|
||||
ParentId = -1,
|
||||
Name = "根节点",
|
||||
CascadeId = "0"
|
||||
});
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
}
|
||||
|
||||
public string LoadForUser(int userId)
|
||||
{
|
||||
var orgs = _orgApp.LoadForUser(userId);
|
||||
//添加根节点
|
||||
orgs.Add(new Org
|
||||
{
|
||||
Id = 0,
|
||||
ParentId = -1,
|
||||
Name = "用户及角色可访问的部门",
|
||||
CascadeId = "0"
|
||||
});
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
}
|
||||
|
||||
public string LoadForRole(int roleId)
|
||||
{
|
||||
var orgs = _orgApp.LoadForRole(roleId);
|
||||
//添加根节点
|
||||
orgs.Add(new Org
|
||||
{
|
||||
Id = 0,
|
||||
ParentId = -1,
|
||||
Name = "已为角色分配的可访问部门",
|
||||
CascadeId = "0"
|
||||
});
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
}
|
||||
|
||||
public string AssignOrgForRole(int roleId, string moduleIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ids = moduleIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||
_orgApp.AssignModuleForRole(roleId, ids);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.message = e.Message;
|
||||
BjuiResponse.statusCode = "300";
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
public string AssignOrgForUser(int userId, string moduleIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ids = moduleIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||
_orgApp.AssignModuleForUser(userId, ids);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.message = e.Message;
|
||||
BjuiResponse.statusCode = "300";
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
//添加组织提交
|
||||
[HttpPost]
|
||||
public string AddOrg(Org org)
|
||||
|
82
OpenAuth.Mvc/Controllers/StockManagerController.cs
Normal file
82
OpenAuth.Mvc/Controllers/StockManagerController.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using Infrastructure;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.Domain;
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class StockManagerController : BaseController
|
||||
{
|
||||
private StockManagerApp _app;
|
||||
|
||||
public StockManagerController()
|
||||
{
|
||||
_app = AutofacExt.GetFromFac<StockManagerApp>();
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /UserManager/
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult Add(int id = 0)
|
||||
{
|
||||
return View(_app.Find(id));
|
||||
}
|
||||
|
||||
//添加或修改Stock
|
||||
[HttpPost]
|
||||
public string Add(Stock model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.AddOrUpdate(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = ex.Message;
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载节点下面的所有Stocks
|
||||
/// </summary>
|
||||
public string Load(int parentidId, int pageCurrent = 1, int pageSize = 30)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.Load(parentidId, 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)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.Delete(Id);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = e.Message;
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
}
|
||||
}
|
@@ -132,6 +132,7 @@
|
||||
<Compile Include="Controllers\OrgManagerController.cs" />
|
||||
<Compile Include="Controllers\ResourceManagerController.cs" />
|
||||
<Compile Include="Controllers\RoleManagerController.cs" />
|
||||
<Compile Include="Controllers\StockManagerController.cs" />
|
||||
<Compile Include="Controllers\UserManagerController.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
@@ -574,6 +575,10 @@
|
||||
<Content Include="Views\RoleManager\LookupMulti.cshtml" />
|
||||
<Content Include="Views\ResourceManager\LookupMultiForUser.cshtml" />
|
||||
<Content Include="Views\ResourceManager\LookupMultiForRole.cshtml" />
|
||||
<Content Include="Views\StockManager\Index.cshtml" />
|
||||
<Content Include="Views\StockManager\Add.cshtml" />
|
||||
<Content Include="Views\OrgManager\LookupMultiForRole.cshtml" />
|
||||
<Content Include="Views\OrgManager\LookupMultiForUser.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
|
123
OpenAuth.Mvc/Views/OrgManager/LookupMultiForRole.cshtml
Normal file
123
OpenAuth.Mvc/Views/OrgManager/LookupMultiForRole.cshtml
Normal file
@@ -0,0 +1,123 @@
|
||||
@*
|
||||
选择多个模块ID,以ids的形式返回
|
||||
*@
|
||||
|
||||
@{
|
||||
ViewBag.Title = "title";
|
||||
Layout = null;
|
||||
}
|
||||
<div class="bjui-pageContent">
|
||||
<input style="display: none" id="roleId" value="@ViewBag.RoleId"/>
|
||||
<div style="float: left; width: 220px; height: 240px; overflow: auto;" class="table table-bordered">
|
||||
<ul id="lookupTree" class="ztree"></ul>
|
||||
</div>
|
||||
<!--已经选中的列表-->
|
||||
<div style="margin-left: 225px">
|
||||
<ul id="selected" class="ztree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bjui-pageFooter">
|
||||
<ul>
|
||||
<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
|
||||
<li><button type="button" onclick="save()" class="btn btn-blue" data-icon="check">保存</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var moduleIds;
|
||||
$(document).ready(function () {
|
||||
Init();
|
||||
InitSelected();
|
||||
});
|
||||
function Init() {
|
||||
var setting = {
|
||||
view: {
|
||||
selectedMulti: false
|
||||
},
|
||||
check: {
|
||||
enable: true,
|
||||
chkStyle: "checkbox"
|
||||
},
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick,
|
||||
onCheck: zTreeCheck
|
||||
}
|
||||
};
|
||||
$.getJSON('OrgManager/LoadForTree', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#lookupTree'), setting, json);
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
function InitSelected() {
|
||||
var setting = {
|
||||
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick,
|
||||
onCheck: zTreeCheck
|
||||
}
|
||||
};
|
||||
$.post('OrgManager/LoadForRole', { roleId: $('#roleId').val() },
|
||||
function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#selected'), setting, eval(json));
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
function save() {
|
||||
$.post('OrgManager/AssignOrgForRole', { roleId: $('#roleId').val(), moduleIds: moduleIds },
|
||||
function (json) {
|
||||
var rel = $.parseJSON(json);
|
||||
if (rel.statusCode == "200") {
|
||||
$(this).alertmsg('ok', rel.message);
|
||||
} else {
|
||||
$(this).alertmsg('error', rel.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function zTreeCheck(e, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
||||
nodes = zTree.getCheckedNodes(true);
|
||||
var ids = '';
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
ids += ',' + nodes[i].Id;
|
||||
}
|
||||
if (ids.length > 0) { //去掉第一个逗号
|
||||
ids = ids.substr(1);
|
||||
}
|
||||
|
||||
moduleIds = ids;
|
||||
}
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
//@@ sourceURL=lookupMultiForRole.js
|
||||
</script>
|
123
OpenAuth.Mvc/Views/OrgManager/LookupMultiForUser.cshtml
Normal file
123
OpenAuth.Mvc/Views/OrgManager/LookupMultiForUser.cshtml
Normal file
@@ -0,0 +1,123 @@
|
||||
@*
|
||||
选择多个模块ID,以ids的形式返回
|
||||
*@
|
||||
|
||||
@{
|
||||
ViewBag.Title = "title";
|
||||
Layout = null;
|
||||
}
|
||||
<div class="bjui-pageContent">
|
||||
<input style="display: none" id="userId" value="@ViewBag.UserId"/>
|
||||
<div style="float: left; width: 220px; height: 240px; overflow: auto;" class="table table-bordered">
|
||||
<ul id="lookupTree" class="ztree"></ul>
|
||||
</div>
|
||||
<!--已经选中的列表-->
|
||||
<div style="margin-left: 225px">
|
||||
<ul id="selected" class="ztree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bjui-pageFooter">
|
||||
<ul>
|
||||
<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
|
||||
<li><button type="button" onclick="save()" class="btn btn-blue" data-icon="check">保存</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var moduleIds;
|
||||
$(document).ready(function () {
|
||||
Init();
|
||||
InitSelected();
|
||||
});
|
||||
function Init() {
|
||||
var setting = {
|
||||
view: {
|
||||
selectedMulti: false
|
||||
},
|
||||
check: {
|
||||
enable: true,
|
||||
chkStyle: "checkbox"
|
||||
},
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick,
|
||||
onCheck: zTreeCheck
|
||||
}
|
||||
};
|
||||
$.getJSON('OrgManager/LoadForTree', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#lookupTree'), setting, json);
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
function InitSelected() {
|
||||
var setting = {
|
||||
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick,
|
||||
onCheck: zTreeCheck
|
||||
}
|
||||
};
|
||||
$.post('OrgManager/LoadForUser', { userId: $('#userId').val() },
|
||||
function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#selected'), setting, eval(json));
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
function save() {
|
||||
$.post('OrgManager/AssignOrgForUser', { userId: $('#userId').val(), moduleIds: moduleIds },
|
||||
function (json) {
|
||||
var rel = $.parseJSON(json);
|
||||
if (rel.statusCode == "200") {
|
||||
$(this).alertmsg('ok', rel.message);
|
||||
} else {
|
||||
$(this).alertmsg('error', rel.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function zTreeCheck(e, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
||||
nodes = zTree.getCheckedNodes(true);
|
||||
var ids = '';
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
ids += ',' + nodes[i].Id;
|
||||
}
|
||||
if (ids.length > 0) { //去掉第一个逗号
|
||||
ids = ids.substr(1);
|
||||
}
|
||||
|
||||
moduleIds = ids;
|
||||
}
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
//@@ sourceURL=lookupMulti.js
|
||||
</script>
|
@@ -52,7 +52,7 @@
|
||||
},
|
||||
{
|
||||
name: 'Name',
|
||||
label: '角色名称',
|
||||
label: '资源名称',
|
||||
width: 100
|
||||
},
|
||||
|
||||
|
@@ -52,7 +52,7 @@
|
||||
},
|
||||
{
|
||||
name: 'Name',
|
||||
label: '角色名称',
|
||||
label: '资源名称',
|
||||
width: 100
|
||||
},
|
||||
|
||||
|
@@ -38,12 +38,12 @@
|
||||
name: 'Id',
|
||||
label: '流水号'
|
||||
, hide: true
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Name',
|
||||
label: '角色名称',
|
||||
width:100
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Status',
|
||||
label: '当前状态',
|
||||
@@ -51,7 +51,7 @@
|
||||
align: 'center',
|
||||
items:[{'0':'正常','1':'禁用'}],
|
||||
width:50
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Type',
|
||||
label: '角色类型',
|
||||
@@ -59,28 +59,28 @@
|
||||
align: 'center',
|
||||
items: [{ '0': '管理员','1':'普通角色' }],
|
||||
width:50
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'CreateTime',
|
||||
label: '创建时间'
|
||||
, type: 'date',
|
||||
width: 150,
|
||||
pattern: 'yyyy-MM-dd HH:mm:ss'
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
name: 'OrgCascadeId',
|
||||
label: '所属部门节点语义ID',
|
||||
width:100
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'OrgName',
|
||||
label: '所属部门名称',
|
||||
width:100
|
||||
}
|
||||
}
|
||||
],
|
||||
dataUrl: 'RoleManager/Load?orgId=' + selectedId,
|
||||
|
||||
|
||||
fullGrid: true,
|
||||
showLinenumber: true,
|
||||
showCheckboxcol: true,
|
||||
@@ -169,6 +169,21 @@
|
||||
});
|
||||
}
|
||||
|
||||
//为角色分配可见机构
|
||||
function assignRoleOrg(obj) {
|
||||
var selected = getSelected('#@_gridId', 2);
|
||||
if (selected == null) return;
|
||||
|
||||
$(obj).dialog({
|
||||
id: 'accessRoleOrg',
|
||||
url: '/OrgManager/LookupMultiForRole',
|
||||
title: '为角色分配可见机构',
|
||||
data: {
|
||||
roleid: selected
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//为角色分配资源
|
||||
function openRoleReourceAccess(obj) {
|
||||
var selected = getSelected('#@_gridId', 2);
|
||||
|
137
OpenAuth.Mvc/Views/StockManager/Add.cshtml
Normal file
137
OpenAuth.Mvc/Views/StockManager/Add.cshtml
Normal file
@@ -0,0 +1,137 @@
|
||||
@model OpenAuth.Domain.Stock
|
||||
@{
|
||||
ViewBag.Title = "Stock编辑界面";
|
||||
Layout = null;
|
||||
}
|
||||
<div class="bjui-pageContent">
|
||||
<form action="/StockManager/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="Name" class="control-label x120">产品名称:</label>
|
||||
<input type="text" name="Name" id="Name" value="@Model.Name"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Number" class="control-label x120">产品数量:</label>
|
||||
<input type="text" name="Number" id="Number" value="@Model.Number"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Price" class="control-label x120">产品单价:</label>
|
||||
<input type="text" name="Price" id="Price" value="@Model.Price"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Status" class="control-label x120">出库/入库:</label>
|
||||
<input type="text" name="Status" id="Status" value="@Model.Status"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</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>
|
||||
<td>
|
||||
<label for="Time" class="control-label x120">操作时间:</label>
|
||||
<input type="text" name="Time" id="Time" value="@Model.Time"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.HiddenFor(m =>m.OrgId)
|
||||
@if (Model.Id == 0) //添加
|
||||
{
|
||||
//这个只用于显示使用,并不会进行提交处理,真正提交的是cascadeId
|
||||
<label for="CascadeName" class="control-label x120">父节点流水号:</label>
|
||||
<input type="text" name="CascadeName" id="CascadeName"
|
||||
data-toggle="selectztree" size="20" data-tree="#j_select_tree1" value="">
|
||||
<ul id="j_select_tree1" class="ztree hide" data-toggle="ztree"></ul>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
Init();
|
||||
});
|
||||
function Init() {
|
||||
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
|
||||
}
|
||||
};
|
||||
$.getJSON('CategoryManager/LoadForTree', 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);
|
||||
$('#OrgId').val(ids);
|
||||
}
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
||||
event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
}
|
||||
</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>
|
164
OpenAuth.Mvc/Views/StockManager/Index.cshtml
Normal file
164
OpenAuth.Mvc/Views/StockManager/Index.cshtml
Normal file
@@ -0,0 +1,164 @@
|
||||
@{
|
||||
string _prefix = "Stock";
|
||||
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: 'Name',
|
||||
label: '产品名称',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
name: 'Number',
|
||||
label: '产品数量',
|
||||
width: 100
|
||||
,type: 'select',
|
||||
align: 'center',
|
||||
items: [{ '0': '默认' }, { '1': '状态1' }],
|
||||
},
|
||||
{
|
||||
name: 'Price',
|
||||
label: '产品单价',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
name: 'Status',
|
||||
label: '出库/入库',
|
||||
width: 100
|
||||
,type: 'select',
|
||||
align: 'center',
|
||||
items: [{ '0': '默认' }, { '1': '状态1' }],
|
||||
},
|
||||
{
|
||||
name: 'User',
|
||||
label: '',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
name: 'Time',
|
||||
label: '操作时间',
|
||||
width: 100
|
||||
, type: 'date',
|
||||
pattern: 'yyyy-MM-dd HH:mm:ss'
|
||||
},
|
||||
{
|
||||
name: 'OrgId',
|
||||
label: '组织ID',
|
||||
width: 100
|
||||
,type: 'select',
|
||||
align: 'center',
|
||||
items: [{ '0': '默认' }, { '1': '状态1' }],
|
||||
},
|
||||
],
|
||||
dataUrl: 'StockManager/Load?parentId=' + 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('StockManager/LoadForTree', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
//删除
|
||||
function delStock() {
|
||||
var selected = getSelected('#@_gridId',2);
|
||||
if (selected == null) return;
|
||||
|
||||
$.getJSON('StockManager/Delete?Id=' + selected, function (data) {
|
||||
if (data.statusCode == "200")
|
||||
loadDataGrid();
|
||||
else {
|
||||
$(this).alertmsg('warn', data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//自定义的编辑按钮
|
||||
function editStock() {
|
||||
var selected = getSelected('#@_gridId',2);
|
||||
if (selected == null) return;
|
||||
|
||||
$(this).dialog({
|
||||
id: 'editDialog',
|
||||
url: '/StockManager/Add?id=' + selected,
|
||||
title: '编辑',
|
||||
onClose:function() {
|
||||
refreshStockGrid();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function refreshStockGrid() {
|
||||
$('#@_gridId').datagrid('refresh');
|
||||
// loadDataGrid();
|
||||
}
|
||||
//@@ sourceURL=StockManagerIndex.js
|
||||
</script>
|
@@ -173,6 +173,22 @@
|
||||
});
|
||||
}
|
||||
|
||||
//用户可见组织授权按钮
|
||||
function openUserOrgAccess(obj) {
|
||||
|
||||
var selected = getSelected('#@_gridId', 2);
|
||||
if (selected == null) return;
|
||||
|
||||
$(obj).dialog({
|
||||
id: 'accessUserOrg',
|
||||
url: '/OrgManager/LookupMultiForUser',
|
||||
title: '为用户分配可见部门',
|
||||
data: {
|
||||
userId: selected
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//用户角色授权
|
||||
function openUserRoleAccess(obj) {
|
||||
var selected = getSelected('#@_gridId', 2);
|
||||
|
@@ -46,6 +46,7 @@
|
||||
<component type=" OpenAuth.Repository.RelevanceRepository" service="OpenAuth.Domain.Interface.IRelevanceRepository,OpenAuth.Domain" />
|
||||
<component type=" OpenAuth.Repository.CategoryRepository" service="OpenAuth.Domain.Interface.ICategoryRepository,OpenAuth.Domain" />
|
||||
<component type=" OpenAuth.Repository.ResourceRepository" service="OpenAuth.Domain.Interface.IResourceRepository,OpenAuth.Domain" />
|
||||
<component type=" OpenAuth.Repository.StockRepository" service="OpenAuth.Domain.Interface.IStockRepository,OpenAuth.Domain" />
|
||||
</components>
|
||||
</autofac>
|
||||
|
||||
|
Reference in New Issue
Block a user