系列目录

步骤设置完毕之后,就要设置好流转了,比如财务申请大于50000元(请假天数>5天)要总经理审批,否则财务审批之后就结束了。

设置分支没有任何关注点,我们把关注点都放在了用户的起草表单。所以本节如同设置字段,设置步骤一样,只需要填充好Flow_StepRule表

表结构:Flow_StepRule表主要是字段对比值,所以需要操作符,我们约定操作符为=、>、<、<=、>=、!=六种

    表Flow_StepRule的主表是Flow_Step,所以跟步骤一样为主从关系的设置

我是这样设计的,先获取步骤列表,再按列表的步骤来设置分支,如图

分支具体代码如下

<tableid="List"></table>
<divid="modalwindow"class="easyui-window"data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
<scripttype="text/javascript">$(function() {$('#List').datagrid({url:'@Url.Action("GetStepList")?id=@(ViewBag.FormId)',width: SetGridWidthSub(10),methord:'post',height: SetGridHeightSub(39),fitColumns:true,sortName:'Sort',sortOrder:'asc',idField:'Id',pageSize:15,pageList: [15,20,30,40,50],pagination:true,striped:true,//奇偶行是否区分
singleSelect:true,//单选模式//rownumbers: true,//行号
columns: [[{ field:'StepNo', title:'步骤', width:80},{ field:'Id', title:'', width:80, hidden:true},{ field:'Name', title:'步骤名称', width:80, sortable:true},{ field:'Remark', title:'步骤说明', width:280, sortable:true},{ field:'Sort', title:'排序', width:80, sortable:true, hidden:true},{ field:'FormId', title:'所属表单', width:80, sortable:true, hidden:true},{ field:'FlowRule', title:'流转规则', width:80, sortable:true},{ field:'Action', title:'操作分支',align:'center', width:80, sortable:true}]]});});//ifram 返回functionframeReturnByClose() {$("#modalwindow").window('close');}functionframeReturnByReload(flag) {if(flag)$("#List").datagrid('load');else$("#List").datagrid('reload');}functionframeReturnByMes(mes) {$.messageBox5s('提示', mes);}functionSetRule(stepId){$("#modalwindow").html("<iframe width='100%' height='100%' scrolling='no' frameborder='0'' src='/Flow/Form/StepRuleList?stepId=" +stepId+ "&formId=@(ViewBag.FormId)'></iframe>");$("#modalwindow").window({ title:'设置分支', width:620, height:300, iconCls:'icon-add'}).window('open');}</script>

StepList.cshtml

[SupportFilter(ActionName = "Edit")]public ActionResult StepList(string id){ViewBag.FormId = id;return View();}[HttpPost][SupportFilter(ActionName = "Edit")]public JsonResult GetStepList(GridPager pager, string id){List<Flow_StepModel>stepList = stepBLL.GetList(ref pager, id);int i = 1;var json = new{total = pager.totalRows,rows = (from r in stepListselect new Flow_StepModel(){StepNo = "第 "+(i++)+" 步",Id = r.Id,Name = r.Name,Remark = r.Remark,Sort = r.Sort,FormId = r.FormId,FlowRule = r.FlowRule,Action = "<ahref='javascript:SetRule(\""+ r.Id + "\")'>分支(" + GetStepRuleListByStepId(r.Id).Count() + ")</a></a>"}).ToArray()};return Json(json);}

StepList Action

点击操作分支按钮将弹出分支的添加和删除

分支代码如下(增删查)

@using App.Admin;
@using App.Common;
@using App.Models.Sys;
@{ViewBag.Title = "主页";Layout = "~/Views/Shared/_Index_Layout.cshtml";List<permModel> perm = (List<permModel>)ViewBag.Perm;if (perm == null){perm = new List<permModel>();}
}<table><tr><td><tableid="List"></table></td><tdstyle="width: 180px; vertical-align: top"><tablestyle="line-height: 40px;"><tr><tdclass="tr">字段:</td><td><selectid="LeftVal">@foreach (var r in (List<App.Models.Flow.Flow_FormAttrModel>)ViewBag.AttrList){<optionvalue="@r.Id">@r.Title</option>}</select></td></tr><tr><tdclass="tr">操作:</td><td><selectid="CenterVal"><optionvalue="=">= </option><optionvalue=">">> </option><optionvalue="<"><</option><optionvalue="<="><= </option><optionvalue=">=">>= </option><optionvalue=">=">!= </option></select></td></tr><tr><tdclass="tr">值:</td><td><inputid="RightVal"type="text"style="width: 80px;" /></td><tr><tdclass="tr">下一步:</td><td><selectid="NextVal"><optionvalue="0">结束流程</option>@foreach (var r in (List<App.Models.Flow.Flow_StepModel>)ViewBag.StepList){<optionvalue="@r.Id">@r.Name</option>}</select></td></tr><tr><td></td><tdstyle="line-height:0px"><aid="Result"href="javascript:AddEvent('@(ViewBag.StepId)')"class="easyui-linkbutton"data-options="iconCls:'icon-add'">添加分支</a></td></tr></table></td></tr>
</table>
<divid="modalwindow"class="easyui-window"data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>@Html.Partial("~/Views/Shared/_Partial_AutoGrid.cshtml")<scripttype="text/javascript">$(function() {$('#List').datagrid({url:'@Url.Action("GetStepRuleList")?stepId=@(ViewBag.StepId)',width: SetGridWidthSub(180),methord:'post',height: SetGridHeightSub(9),fitColumns:true,sortName:'Id',sortOrder:'desc',idField:'Id',pageSize:115,pagination:false,striped:true,//奇偶行是否区分
singleSelect:true,//单选模式//rownumbers: true,//行号
columns: [[{ field:'Id', title:'ID', width:80, hidden:true},{ field:'Mes', title:'Mes', width:80, hidden:true},{ field:'StepId', title:'步骤ID', width:80, sortable:true, hidden:true},{ field:'AttrId', title:'字段ID', width:80, sortable:true, hidden:true},{ field:'AttrName', title:'字段', width:80, sortable:true},{ field:'Operator', title:'操作', width:80, sortable:true},{ field:'Result', title:'', width:80, sortable:true},{ field:'NextStep', title:'下一步ID', width:80, sortable:true, hidden:true},{ field:'NextStepName', title:'下一步', width:80, sortable:true},{ field:'Action', title:'操作', width:80},]]});});//ifram 返回functionframeReturnByClose() {$("#modalwindow").window('close');}functionframeReturnByReload(flag) {if(flag)$("#List").datagrid('load');else$("#List").datagrid('reload');}functionframeReturnByMes(mes) {$.messageBox5s('提示', mes);}//添加条件functionAddEvent(stepId) {varleftVal=$("#LeftVal").val();varleftText=$("option[value='" +leftVal+ "']").html();varcenterVal=$("#CenterVal").val();varrightVal=$("#RightVal").val();varnextVal=$("#NextVal").val();if(rightVal== "") {$.messageBox5s('提示',"值不能为空");return;}$.post("@Url.Action("CreateStepEvent")", {"StepId": stepId,"AttrId": leftVal,"Operator": centerVal,"Result": rightVal,"NextStep": nextVal },function(data) {if(data.type== 1) {$("#List").datagrid('load');}else{$.messageBox5s('提示', data.message);return}},"json");}functionDeleteEvent(stepId) {$.messager.confirm('提示','你要删除此条件吗?',function(r) {if(r) {$.post("@Url.Action("DeleteStepRule")?id=" +stepId,function(data) {if(data.type== 1) {$("#List").datagrid('load');}else{$.messageBox5s('提示', data.message);return}},"json");}});}</script>

StepRuleList.cshtml

[SupportFilter(ActionName = "Edit")]public ActionResult StepRuleList(string stepId,string formId){//获取现有的步骤GridPager pager = new GridPager(){rows = 1000,page = 1,sort = "Id",order = "desc"};Flow_FormModel flowFormModel = m_BLL.GetById(formId);List<Flow_FormAttrModel>  attrList = new List<Flow_FormAttrModel>();//获取表单关联的字段attrList = GetAttrList(flowFormModel);List<Flow_StepModel>stepList = stepBLL.GetList(ref pager, formId);ViewBag.StepId = stepId;ViewBag.AttrList = attrList;ViewBag.StepList = stepList;return View();}[HttpPost][SupportFilter(ActionName = "Edit")]public JsonResult GetStepRuleList(string stepId){List<Flow_StepRuleModel>stepList = stepRuleBLL.GetList(stepId);int i =1;var json = new{rows = (from r in stepListselect new Flow_StepRuleModel(){Mes="分支"+(i++),Id = r.Id,StepId = r.StepId,AttrId = r.AttrId,AttrName = r.AttrName,Operator = r.Operator,Result = r.Result,NextStep = r.NextStep,NextStepName = r.NextStepName,Action = "<ahref='#'title='删除'class='icon-remove'onclick='DeleteEvent(\""+r.Id+"\")'></a>"}).ToArray()};return Json(json);}[HttpPost][SupportFilter(ActionName = "Edit")]public JsonResult CreateStepEvent(Flow_StepRuleModel model){model.Id = ResultHelper.NewId;if (model != null && ModelState.IsValid){if (stepRuleBLL.Create(ref errors, model)){LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",StepId" + model.Id, "成功", "创建", "Flow_StepRule");return Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed, model.Id));}else{string ErrorCol = errors.Error;LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",StepId" + model.Id + "," + ErrorCol, "失败", "创建", "Flow_StepRule");return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol));}}else{return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail));}}[HttpPost][SupportFilter(ActionName = "Edit")]public JsonResult DeleteStepRule(string id){if (!string.IsNullOrWhiteSpace(id)){if (stepRuleBLL.Delete(ref errors, id)){LogHandler.WriteServiceLog(GetUserId(), "Id:" + id, "成功", "删除", "Flow_StepRule");return Json(JsonHandler.CreateMessage(1, Suggestion.DeleteSucceed));}else{string ErrorCol = errors.Error;LogHandler.WriteServiceLog(GetUserId(), "Id" + id + "," + ErrorCol, "失败", "删除", "Flow_StepRule");return Json(JsonHandler.CreateMessage(0, Suggestion.DeleteFail + ErrorCol));}}else{return Json(JsonHandler.CreateMessage(0, Suggestion.DeleteFail));}}//获取已经添加的字段private List<Flow_FormAttrModel> GetAttrList(Flow_FormModel model){List<Flow_FormAttrModel> list = new List<Flow_FormAttrModel>();Flow_FormAttrModel attrModel = new Flow_FormAttrModel();#region 处理字段//获得对象的类型,myClass1Type formType = model.GetType();//查找名称为"MyProperty1"的属性string[] arrStr = { "AttrA", "AttrB", "AttrC", "AttrD", "AttrE", "AttrF", "AttrG", "AttrH", "AttrI", "AttrJ", "AttrK", "AttrL", "AttrM", "AttrN", "AttrO", "AttrP", "AttrQ", "AttrR", "AttrS", "AttrT", "AttrU", "AttrV", "AttrW", "AttrX", "AttrY", "AttrZ"};foreach (string str in arrStr){object o = formType.GetProperty(str).GetValue(model, null);if (o != null){//查找model类的Class对象的"str"属性的值attrModel = attrBLL.GetById(o.ToString()); list.Add(attrModel);}}#endregionreturn list;}

StepRuleList Action

写了这么多都是为了填充这种主从表关系的数据,目前为止都很容易消化。

ASP.NET MVC5+EF6+EasyUI 后台管理系统(46)-工作流设计-设计分支相关推荐

  1. ASP.NET MVC5+EF6+EasyUI 后台管理系统(1)-前言与目录(持续更新中...)

    开发工具:VS2015(2012以上)+SQL2008R2以上数据库  您可以有偿获取一份最新源码联系QQ:729994997 价格 666RMB  升级后界面效果如下: 日程管理   http:// ...

  2. ASP.NET MVC5+EF6+EasyUI 后台管理系统

    ASP.NET MVC5+EF6+EasyUI 后台管理系统(1)-前言与目录(持续更新中...) 开发工具:VS2015(2012以上)+SQL2008R2以上数据库  您可以有偿获取一份最新源码联 ...

  3. ASP.NET MVC5+EF6+EasyUI 后台管理系统-WebApi的用法与调试

    ASP.NET MVC5+EF6+EasyUI 后台管理系统-WebApi的用法与调试 1:ASP.NET MVC5+EF6+EasyUI 后台管理系统(1)-WebApi与Unity注入 使用Uni ...

  4. ASP.NET MVC5+EF6+EasyUI 后台管理系统(51)-系统升级

    系统很久没有更新内容了,期待已久的更新在今天发布了,最近花了2个月的时间每天一点点,从原有系统 MVC4+EF5+UNITY2.X+Quartz 2.0+easyui 1.3.4无缝接入 MVC5+E ...

  5. ASP.NET MVC5+EF6+EasyUI 后台管理系统(2)-easyui构建前端页面框架[附源码]

    系列目录 前言 为了符合后面更新后的重构系统,本文于2016-10-31日修正一些截图,文字 我们有了一系列的解决方案,我们将动手搭建新系统吧. 后台系统没有多大的UI视觉,这次我们采用的是标准的左右 ...

  6. ASP.NET MVC5+EF6+EasyUI 后台管理系统(67)-MVC与ECharts

    系列目录 ECharts 特性介绍 ECharts,一个纯 Javascript 的图表库,可以流畅的运行在 PC 和移动设备上,兼容当前绝大部分浏览器(IE8/9/10/11,Chrome,Fire ...

  7. ASP.NET MVC5+EF6+EasyUI 后台管理系统(63)-WebApi与Unity注入

    系列目录 前言: 有时候我们系统需要开放数据给手机App端或其他移动设备,不得不说Asp.net WebApi是目前首选 本节记录Asp.net MVC WebApi怎么利用Unity注入.系列开头已 ...

  8. ASP.NET MVC5+EF6+EasyUI 后台管理系统--任务调度系统解析

    系列目录 任务调度系统是什么:他是一个类似Sql Server的代理,他可以帮助你定时处理一些SQL事务 但是他又远远超过代理,因为他还能定时执行一些C#方法,比如定时发送邮件等 总结:任务可以执行的 ...

  9. ASP.NET MVC5+EF6+EasyUI 后台管理系统(73)-微信公众平台开发-消息管理

    前言 回顾上一节,我们熟悉的了解了消息的请求和响应,这一节我们来建立数据库的表,表的设计蛮复杂 你也可以按自己所分析的情形结构来建表 必须非常熟悉表的结果才能运用这张表,这表表的情形涵盖比较多 思维导 ...

最新文章

  1. 用Construct 2制作入门小游戏~
  2. R语言广义线性模型函数GLM、广义线性模型(Generalized linear models)、GLM函数的语法形式、glm模型常用函数、常用连接函数、逻辑回归、泊松回归、系数解读、过散度分析
  3. Centos7下 Redis的安装、配置开机自启动、开放远程连接
  4. XML Schema介绍之namespace
  5. 枚举对象注释_如何以及何时使用枚举和注释
  6. 旅行报告:JavaOne 2013 –重归荣耀
  7. oracle分析函数over(Partition by...)及开窗函数详解
  8. 迅为IMX8M mini开发板Yocto系统交叉编译C程序
  9. IEC61850建模说明
  10. deepin linux 怎么安装软件,deepinLinux系统安装及软件安装
  11. linux shell 中的idd,shell脚本入门教程.pdf
  12. U盘数据恢复免费破解版哪里有?
  13. 关于组长、队长和团长
  14. 计算机5克,C盘莫名其妙少了5个多G,这是怎么回事??
  15. Outlook 2007对于不同(Gmail.Sina.Sohu.126.163.Yahoo.Hotmail)Email账号设置
  16. js中判断是否为图片以及常见图片后缀
  17. (LeetCode)数数关系——Non-decreasing Array(非递减数组)
  18. 如何快速增加NFC能力到任何应用程序
  19. word 多级标题的编辑
  20. 【双节快乐】十万人都在疯转的国旗中秋专属头像

热门文章

  1. Android高级编程(笔记)-第6章 数据存储、检索和共享--2--本地文件
  2. [转]23种经典设计模式的java实现_5_职责链模式
  3. 【自然框架】之“元数据”的威力
  4. Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource c
  5. mysql数据库-主主配置
  6. redux源码分析之一:createStore.js
  7. Spring中复杂类型注入
  8. 转: Python集合(set)类型的操作
  9. CentOS 6.5安装Xen虚拟化
  10. 基于SSH的在线音乐点评网站-java在线音乐点评网站