调整流程详情显示效果

添加DataGrid数据格式
This commit is contained in:
yubaolee 2016-09-04 01:15:43 +08:00
parent 574f5f9e1f
commit d5a6ffe3b8
19 changed files with 288 additions and 122 deletions

View File

@ -91,7 +91,6 @@
<Compile Include="Filter.cs" />
<Compile Include="GenerateId.cs" />
<Compile Include="HttpHelper.cs" />
<Compile Include="JQData.cs" />
<Compile Include="JsonConverter.cs" />
<Compile Include="JsonHelper.cs" />
<Compile Include="LogHelper.cs" />

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
@ -32,14 +33,34 @@ namespace OpenAuth.App
}
/// <summary>
/// 更改流程状态
/// </summary>
public void ChangeState(Guid id,string state, string statename)
{
_repository.Update(u =>u.Id == id, u =>new GoodsApply
{
State = state,
StateName = statename
});
}
public GoodsApply Get(Guid value)
{
return _repository.FindSingle(u =>u.Id == value);
}
public IEnumerable<GoodsApply> Load(Guid userid, Guid parentId, int pageCurrent, int pageSize)
public GridData Load(Guid userid, Guid parentId, int pageCurrent, int pageSize)
{
return _repository.Find( pageCurrent, pageSize);
var result = new GridData
{
pageCurrent = pageCurrent
};
result.list= _repository.Find( pageCurrent, pageSize);
result.total = _repository.GetCount(null);
return result;
}
}
}

View File

@ -95,6 +95,7 @@
<Compile Include="UserManagerApp.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="OrgManagerApp.cs" />
<Compile Include="ViewModel\GridData.cs" />
<Compile Include="ViewModel\UserWithAccessedCtrls.cs" />
<Compile Include="ViewModel\ModuleElementVM.cs" />
<Compile Include="ViewModel\ModuleView.cs" />

View File

@ -46,7 +46,7 @@ namespace OpenAuth.App.SSO
if (cache.InvalidTime > DateTime.Now)
{
//延长
cache.InvalidTime = DateTime.Now.AddMinutes(5);
cache.InvalidTime = DateTime.Now.AddDays(1);
//设置缓存
CacheContext.Set(cache.Token, cache);

View File

@ -43,7 +43,7 @@ namespace OpenAuth.App
/// <summary>
/// 加载一个部门及子部门全部用户
/// </summary>
public dynamic Load(Guid orgId, int pageindex, int pagesize)
public GridData Load(Guid orgId, int pageindex, int pagesize)
{
if (pageindex < 1) pageindex = 1; //TODO:如果列表为空新增加一个用户后前端会传一个0过来奇怪
IEnumerable<User> users;
@ -69,7 +69,7 @@ namespace OpenAuth.App
userviews.Add(uv);
}
return new
return new GridData
{
total = total,
list = userviews,

View File

@ -9,31 +9,28 @@
// <copyright file="JqData.cs" company="Microsoft">
// 版权所有(C) Microsoft 2015
// </copyright>
// <summary>jqGrid的数据格式</summary>
// <summary>B-JUIDataGrid的数据格式</summary>
// ***********************************************************************
using System.Collections.Generic;
namespace Entity
namespace OpenAuth.App.ViewModel
{
/// <summary>
/// jqGrid的返回值
/// </summary>
public class JqData
public class GridData
{
/// <summary>
/// 页码
/// </summary>
public int page;
public int pageCurrent;
/// <summary>
/// 总页数
/// </summary>
public int total;
/// <summary>
/// 总记录条数
/// </summary>
public int records;
public IEnumerable<object> rows;
/// <summary>
/// 数据内容
/// </summary>
public dynamic list;
}
}

View File

@ -51,9 +51,7 @@ function MainGrid() {
columns: [
{
name: 'Id',
label: '数据ID',
width: 100
, hide: true
hide: true
},
{
name: 'Name',
@ -65,34 +63,16 @@ function MainGrid() {
label: '产品数量',
width: 100
},
{
name: 'Price',
label: '产品单价',
name: 'StateName',
label: '当前流程',
width: 100
},
{
name: 'Status',
label: '出库/入库',
width: 100
, align: 'center',
items: [{ '0': '出库' }, { '1': '入库' }],
},
{
name: 'User',
label: '可见范围(测试资源使用)',
width: 100,
items: [{ '': '全部可见' }, { 'ADMIN': '管理员可见' },{'DEV':'开发可见'}],
},
{
name: 'Time',
label: '操作时间',
width: 100
},
{
name: 'OrgId',
label: '组织ID',
width: 100
},
name: 'State',
hide:true
}
],
dataUrl: url + selectedId,
fullGrid: true,
@ -114,7 +94,6 @@ var list = new MainGrid();
//添加(编辑)对话框
var editDlg = function () {
var update = false;
var show = function () {
BJUI.dialog({ id: 'editDlg', title: '编辑对话框', target: '#editDlg' });
$("#btnSave").on("click", function () {
@ -123,13 +102,11 @@ var editDlg = function () {
}
return {
add: function () { //弹出添加
update = false;
show();
$.CurrentDialog.find("form")[0].reset(); //reset方法只能通过dom调用
$("#Id").val('00000000-0000-0000-0000-000000000000');
},
update: function (ret) { //弹出编辑框
update = true;
show();
$('#Id').val(ret.Id);
$('#Name').val(ret.Name);
@ -179,6 +156,21 @@ function edit() {
editDlg.update(selected);
}
//进度详情
function detail() {
var selected = list.getSelectedObj();
if (selected == null) {
return;
}
$(this).dialog({
id: 'detailDlg',
url: '/GoodsApplies/Detail?id=' + selected.Id,
title: '进度详情',
width: 800,
height:600
});
}
function add() {
editDlg.add();
}

View File

@ -0,0 +1,40 @@
var schemecode = 'SimpleWF';
var wfdesigner = undefined;
console.log("detail");
function wfdesignerRedraw() {
var data;
if (wfdesigner != undefined) {
data = wfdesigner.data;
wfdesigner.destroy();
}
console.log(QueryString.id); //取不到值??
var processid = $("#processId").val();
wfdesigner = new WorkflowDesigner({
name: 'simpledesigner',
apiurl: '/Designer/API',
renderTo: 'wfdesigner',
imagefolder: '/images/',
graphwidth: 800,
graphheight: 600
});
if (data == undefined) {
var p = { schemecode: schemecode, processid: processid, readonly: true };
if (wfdesigner.exists(p))
wfdesigner.load(p);
else
wfdesigner.create();
} else {
wfdesigner.data = data;
wfdesigner.render();
}
}
wfdesignerRedraw();
//@@ sourceURL=processDetail.js

View File

@ -0,0 +1,36 @@
// ***********************************************************************
// Assembly : OpenAuth.Mvc
// Author : yubaolee
// Created : 09-04-2016
//
// Last Modified By : yubaolee
// Last Modified On : 09-04-2016
// ***********************************************************************
// <copyright file="queryString.js" company="www.cnblogs.com/yubaolee">
// 版权所有(C) 2015
// </copyright>
// <summary>解析URL中的参数</summary>
// ***********************************************************************
var QueryString = function () {
// This function is anonymous, is executed immediately and
// the return value is assigned to QueryString!
var query_string = {};
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
// If first entry with this name
if (typeof query_string[pair[0]] === "undefined") {
query_string[pair[0]] = pair[1];
// If second entry with this name
} else if (typeof query_string[pair[0]] === "string") {
var arr = [query_string[pair[0]], pair[1]];
query_string[pair[0]] = arr;
// If third or later entry with this name
} else {
query_string[pair[0]].push(pair[1]);
}
}
return query_string;
}();

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Xml.Linq;
using OpenAuth.Mvc.Models;
using OptimaJet.Workflow;
using OptimaJet.Workflow.Core.Builder;
using OptimaJet.Workflow.Core.Bus;
@ -21,7 +22,7 @@ namespace OpenAuth.Mvc.Controllers
{
return View();
}
public ActionResult API()
{
Stream filestream = null;
@ -30,8 +31,8 @@ namespace OpenAuth.Mvc.Controllers
var pars = new NameValueCollection();
pars.Add(Request.Params);
if(Request.HttpMethod.Equals("POST", StringComparison.InvariantCultureIgnoreCase))
if (Request.HttpMethod.Equals("POST", StringComparison.InvariantCultureIgnoreCase))
{
var parsKeys = pars.AllKeys;
foreach (var key in Request.Form.AllKeys)
@ -49,8 +50,7 @@ namespace OpenAuth.Mvc.Controllers
return Content(res);
}
}
}
}

View File

@ -5,6 +5,7 @@ using Infrastructure;
using OpenAuth.App;
using OpenAuth.App.SSO;
using OpenAuth.Domain;
using OpenAuth.Mvc.Models;
using OptimaJet.Workflow.Core.Runtime;
using ProcessStatus = OptimaJet.Workflow.Core.Persistence.ProcessStatus;
@ -12,11 +13,11 @@ namespace OpenAuth.Mvc.Controllers
{
public class GoodsAppliesController : BaseController
{
private GoodsApplyApp _app;
private GoodsApplyApp _app;
public GoodsAppliesController()
{
_app = AutofacExt.GetFromFac<GoodsApplyApp>();
public GoodsAppliesController()
{
_app = AutofacExt.GetFromFac<GoodsApplyApp>();
}
public ActionResult Index()
@ -45,15 +46,20 @@ namespace OpenAuth.Mvc.Controllers
return JsonHelper.Instance.Serialize(BjuiResponse);
}
public dynamic Get(Guid id)
public ActionResult Detail(Guid id)
{
try
{
var apply = _app.Get(id);
CreateWorkflowIfNotExists(id);
return new
return View(apply);
}
catch (Exception e)
{
Apply=apply
};
Console.WriteLine(e);
}
return View();
}

View File

@ -1,40 +0,0 @@
using System;
using System.Collections.Generic;
using OpenAuth.App;
using OptimaJet.Workflow.Core.Model;
using OptimaJet.Workflow.Core.Runtime;
namespace OpenAuth.Mvc.Controllers
{
public class WorkflowRuleProvider : IWorkflowRuleProvider
{
private RoleManagerApp _app;
public WorkflowRuleProvider()
{
_app = AutofacExt.GetFromFac<RoleManagerApp>();
}
public List<string> GetRules()
{
var roles = _app.Load(Guid.Empty, 1, 100).list;
var rolestrs = new List<string>();
foreach (var role in roles)
{
rolestrs.Add(role.Name);
}
return rolestrs;
}
public bool Check(ProcessInstance processInstance, WorkflowRuntime runtime, string identityId, string ruleName,
string parameter)
{
throw new NotImplementedException();
}
public IEnumerable<string> GetIdentities(ProcessInstance processInstance, WorkflowRuntime runtime, string ruleName, string parameter)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OpenAuth.App;
using OptimaJet.Workflow.Core.Model;
using OptimaJet.Workflow.Core.Runtime;
namespace OpenAuth.Mvc.Controllers
namespace OpenAuth.Mvc.Models
{
public class WorkflowActionProvider :IWorkflowActionProvider
{

View File

@ -1,14 +1,16 @@
using System;
using System.Configuration;
using System.Xml.Linq;
using OpenAuth.App;
using OptimaJet.Workflow.Core.Builder;
using OptimaJet.Workflow.Core.Bus;
using OptimaJet.Workflow.Core.Persistence;
using OptimaJet.Workflow.Core.Runtime;
using OptimaJet.Workflow.DbPersistence;
namespace OpenAuth.Mvc.Controllers
namespace OpenAuth.Mvc.Models
{
public class WorkflowInit
public static class WorkflowInit
{
private static volatile WorkflowRuntime _runtime;
private static readonly object _sync = new object();
@ -39,6 +41,7 @@ namespace OpenAuth.Mvc.Controllers
.WithBus(new NullBus())
.SwitchAutoUpdateSchemeBeforeGetAvailableCommandsOn()
.Start();
_runtime.ProcessStatusChanged += _runtime_ProcessStatusChanged;
}
}
}
@ -46,5 +49,26 @@ namespace OpenAuth.Mvc.Controllers
return _runtime;
}
}
private static void _runtime_ProcessStatusChanged(object sender, ProcessStatusChangedEventArgs e)
{
if (e.NewStatus != ProcessStatus.Idled && e.NewStatus != ProcessStatus.Finalized)
return;
if (string.IsNullOrEmpty(e.SchemeCode))
return;
//¸ü¸ÄÉęÇëľÄ×´ĚŹ
var nextState = WorkflowInit.Runtime.GetLocalizedStateName(e.ProcessId, e.ProcessInstance.CurrentState);
var _app = AutofacExt.GetFromFac<GoodsApplyApp>();
var goodsapply = _app.Get(e.ProcessId);
if (goodsapply != null)
{
goodsapply.StateName = nextState;
}
_app.ChangeState(goodsapply.Id, e.ProcessInstance.CurrentState, nextState);
}
}
}

View File

@ -1,19 +1,29 @@
using System;
using System.Collections.Generic;
using OpenAuth.App;
using OptimaJet.Workflow.Core.Model;
using OptimaJet.Workflow.Core.Runtime;
namespace OpenAuth.Mvc.Models
{
public class WorkflowRuleProvider :IWorkflowRuleProvider
public class WorkflowRuleProvider : IWorkflowRuleProvider
{
private RoleManagerApp _app;
public WorkflowRuleProvider()
{
_app = AutofacExt.GetFromFac<RoleManagerApp>();
}
public List<string> GetRules()
{
return new List<string>
var roles = _app.Load(Guid.Empty, 1, 100).list;
var rolestrs = new List<string>();
foreach (var role in roles)
{
"管理员",
"普通用户"
};
rolestrs.Add(role.Name);
}
return rolestrs;
}
public bool Check(ProcessInstance processInstance, WorkflowRuntime runtime, string identityId, string ruleName,

View File

@ -153,9 +153,9 @@
<Compile Include="Controllers\RoleManagerController.cs" />
<Compile Include="Controllers\StockManagerController.cs" />
<Compile Include="Controllers\UserManagerController.cs" />
<Compile Include="Controllers\WorkflowActionProvider.cs" />
<Compile Include="Controllers\WorkflowInit.cs" />
<Compile Include="Controllers\WorkflowRuleProvider.cs" />
<Compile Include="Models\WorkflowActionProvider.cs" />
<Compile Include="Models\WorkflowInit.cs" />
<Compile Include="Models\WorkflowRuleProvider.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
@ -168,10 +168,12 @@
<Content Include="BllScripts\assignOrg.js" />
<Content Include="BllScripts\assignModuleElement.js" />
<Content Include="BllScripts\categoryManager.js" />
<Content Include="BllScripts\processDetail.js" />
<Content Include="BllScripts\grid.js" />
<Content Include="BllScripts\moduleElementMan.js" />
<Content Include="BllScripts\modulemanager.js" />
<Content Include="BllScripts\orgManager.js" />
<Content Include="BllScripts\queryString.js" />
<Content Include="BllScripts\resourceManager.js" />
<Content Include="BllScripts\roleManager.js" />
<Content Include="BllScripts\goodsApply.js" />
@ -721,6 +723,7 @@
<Content Include="fonts\glyphicons-halflings-regular.woff" />
<None Include="Properties\PublishProfiles\default.pubxml" />
<Content Include="Views\Designer\Index.cshtml" />
<Content Include="Views\GoodsApplies\Detail.cshtml" />
<None Include="Views\Error\NoAccess.cshtml" />
<Content Include="Views\Home\git.cshtml" />
<Content Include="Web.config">

View File

@ -50,6 +50,7 @@
<script>
var schemecode = 'SimpleWF';
var wfdesigner = undefined;
function wfdesignerRedraw() {
var data;
@ -74,8 +75,7 @@
wfdesigner.load(p);
else
wfdesigner.create();
}
else {
} else {
wfdesigner.data = data;
wfdesigner.render();
}
@ -86,6 +86,7 @@
function DownloadScheme() {
wfdesigner.downloadscheme({ schemecode: schemecode });
}
function UploadScheme() {
var file = $('#uploadFile');
if (file == undefined || file.val().length == 0) {
@ -93,9 +94,10 @@
return false;
}
wfdesigner.uploadscheme($('#uploadform')[0], function () {
alert('The file is uploaded!');
});
wfdesigner.uploadscheme($('#uploadform')[0],
function() {
alert('The file is uploaded!');
});
}
function OnSave() {
@ -104,13 +106,13 @@
var err = wfdesigner.validate();
if (err != undefined && err.length > 0) {
alert(err);
}
else {
wfdesigner.save(function () {
} else {
wfdesigner.save(function() {
alert('The scheme is saved!');
});
}
}
function OnNew() {
wfdesigner.create();
}

View File

@ -0,0 +1,26 @@
@{
Layout = null;
}
@model OpenAuth.Domain.GoodsApply
<script src="/Scripts/jquery.js"></script>
<script src="/Scripts/jquery-ui.js"></script>
<link href="/Content/style.css" rel="stylesheet" />
<link href="/Content/themes/base/jquery-ui.min.css" rel="stylesheet" />
<script src="/Scripts/kinetic-v5.1.0.min.js"></script>
<link href="/Content/workflowdesigner.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/workflowdesigner.min.js"></script>
<script src="/Scripts/ace.js"></script>
<script src="/Scripts/json5.js"></script>
<div class="bjui-pageContent">
<input value="@Model.Id" id="processId" class="hidden"/>
<span class="h1">@Model.Name</span>
<span class="alert-info">数量:@Model.Number</span>
<br/>
<div id="wfdesigner"></div>
</div>
<script src="/BllScripts/queryString.js"></script>
<script src="/BllScripts/processDetail.js"></script>

View File

@ -0,0 +1,51 @@
@{
Layout = "~/Views/Shared/_BjuiLayout.cshtml";
}
@{ Html.RenderAction("MenuHeader", "Home");}
<div class="bjui-pageContent tableContent" style="position: relative">
<div class="clearfix">
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
<ul id="tree" class="ztree"></ul>
</div>
<div id="detail" style="margin-left: 225px;">
<table id="maingrid" class="table table-bordered"></table>
</div>
</div>
</div>
<!--编辑对话框-->
<div class="bjui-dialog hidden bjui-dialog-container" id="editDlg" data-noinit="true">
<div class="bjui-pageContent">
<form action="/GoodsApplies/Edit" class="pageForm" data-toggle="validate" data-reload="false" id="editForm">
<table class="table table-condensed table-hover">
<tbody>
<input type="text" id="Id" name="Id" value="" class="hidden" />
<tr>
<td>
<label for="Name" class="control-label x120">产品名称:</label>
<input type="text" id="Name" name="Name" value="" />
</td>
</tr>
<tr>
<td>
<label for="Number" class="control-label x120">产品数量:</label>
<input type="text" id="Number" name="Number" value="" />
</td>
</tr>
</tbody>
</table>
</form>
</div>
<div class="bjui-pageFooter">
<ul>
<li><button type="button" class="btn btn-close">关闭</button></li>
<li><button type="button" class="btn btn-primary" id="btnSave">保存</button></li>
</ul>
</div>
</div>
<script src="~/BllScripts/grid.js"></script>
<script src="~/BllScripts/goodsApply.js"></script>