ASP.NET MVC5+EF6+EasyUI 后台管理系统(45)-工作流设计-设计步骤-程序员宅基地

技术标签: ViewUI  测试  json  javascript  

系列目录

步骤设计很重要,特别是规则的选择。

我这里分为几个规则

1.按自行选择(在起草时候自行选审批人,比较灵活)

2.按上级(无需指定,当时需要知道用户的上司是谁,可以在职位管理设置,或者在用户表直接设置)

3.按职位(选择职位,直接获得该职位的人员)

4.按部门(按部门,直接获得该部分的人员)

5.按人员(设置步骤时就指定人员)

以上用户必须和部门,职位,上级有所关联,只要做好一个其实全部都同理

表结构分析:Flow_FormStep中有IsAllCheck字段我设计这个的目的是批量审核,比如我选择了部门,那么这个步骤要全部门的人都审核通过才算通过否则其中一人审核即可

先创建一个新的表单,必须有新的表单才能设置步骤

 OK,新建好表单的字段之后,就可以设置步骤了

步骤设置很简单,就是一个从表关系,对应了表单的ID。从表可以直接简单看出关系,但设计其实比较有复杂,当选择组织架构,按职位,按指定人。都必须弹出窗口来进行选择,所以还要设计多3个弹出窗口,我这里只设计按人员筛选为例,因为按人员之前在权限管理的角色组管理已经实现

我这里“又”设计成了一个手风琴,具体实现如下

新建步骤和修改步骤=设计步骤

核心Action

[SupportFilter(ActionName = "Edit")]
        public ActionResult EditStep(string id)
        {
            ViewBag.Perm = GetPermission();
            Flow_FormModel flowFormModel = m_BLL.GetById(id);
            List<Flow_StepModel> stepList = stepBLL.GetList(ref setNoPagerDescBySort, flowFormModel.Id);//获得全部步骤
            foreach (var r in stepList)//获取步骤下面的步骤规则
            {
                r.stepRuleList = GetStepRuleListByStepId(r.Id);
            }
            flowFormModel.stepList = stepList;//获取表单关联的步骤
            ViewBag.Form = flowFormModel;
            Flow_StepModel model = new Flow_StepModel();
            model.FormId = flowFormModel.Id;
            model.IsEditAttr = true;
            return View(model);
        }

     

        [HttpPost]
        [SupportFilter(ActionName = "Edit")]
        public JsonResult EditStep(Flow_StepModel model)
        {
            model.Id = ResultHelper.NewId;
            if (model != null && ModelState.IsValid)
            {

                if (stepBLL.Create(ref errors, model))
                {
                    LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name, "成功", "创建", "Flow_Step");
                    return Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed, model.Id));
                }
                else
                {
                    string ErrorCol = errors.Error;
                    LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "创建", "Flow_Step");
                    return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol));
                }
            }
            else
            {
                return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail));
            }
        }
Controller

完整EditStep.cshtml代码

@model App.Models.Flow.Flow_StepModel
@using App.Common;
@using App.Models.Flow;
@using App.Admin;
@using App.Models.Sys;
@{
    ViewBag.Title = "创建";
    Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
    List<permModel> perm = (List<permModel>)ViewBag.Perm;
    if (perm == null)
    {
        perm = new List<permModel>();
    }
    Flow_FormModel formModel = (Flow_FormModel)ViewBag.Form;
}
<style>
    .stepContent table td {
        padding: 3px;
    }

    .lineheight {
        line-height: 20px;
    }
</style>
<script type="text/javascript">
    $(function () {
        $(".icon-delete").click(function () {
            if ($(this).next("a").attr("class") == "accordion-collapse accordion-expand") {
                $(this).next("a").trigger("click");
            }
        });
        $("#FlowRule").change(function () {
            $("#Execution").val("");
            $("#ExecutionName").val("");
            if ($("#FlowRule").val() == "上级" || $("#FlowRule").val() == "自选") {
                $("#ruleExecution").hide();
            } else if ($("#FlowRule").val() == "职位") {
                $("#selExc").html("审批职位");
                $("#ruleExecution").show();
            }
            else if ($("#FlowRule").val() == "部门") {
                $("#selExc").html("审批部门");
                $("#ruleExecution").show();
            } else if ($("#FlowRule").val() == "人员") {
                $("#selExc").html("审批人员");
                $("#ruleExecution").show();
            }
        });
        $("#selExc").click(function () {
            var html = $("#selExc").html()
            if (html == "审批人员") {
                $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='no' frameborder='0'' src='/SysHelper/UserLookUp'></iframe>");
                $("#modalwindow").window({ title: '选择人员', width: 620, height: 388, iconCls: 'icon-add' }).window('open');
            } else if (html == "审批职位") {
                $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='no' frameborder='0'' src='/SysHelper/PosMulLookUp'></iframe>");
                $("#modalwindow").window({ title: '选择职位', width: 620, height: 388, iconCls: 'icon-add' }).window('open');
            } else if (html == "审批部门") {
                $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='no' frameborder='0'' src='/SysHelper/DepMulLookUp'></iframe>");
                $("#modalwindow").window({ title: '选择部门', width: 320, height: 300, iconCls: 'icon-add' }).window('open');
            }
        });
    });

    var idx = @(formModel.stepList.Count());
    function Create() {
        if ($("form").valid()) {
            $.ajax({
                url: "@Url.Action("EditStep")",
                type: "Post",
                data: $("form").serialize(),
                dataType: "json",
                success: function (data) {
                    var stepId = data.value;
                    var currentIDX = idx + 1;
                    $('#stepList').accordion('add', {
                        title: '' + (idx + 1) + '',
                        iconCls: 'pic_244',
                        content: '<div class="stepContent" style="padding:5px"><table class="wid100f"><tr><td style="width:100px;" class="tr">步骤名称:</td><td>'+$("#Name").val()+'</td></tr><tr><td class="tr">步骤说明:</td><td>'+$("#Remark").val()+'</td></tr></table></div>',
                        tools: [{
                            iconCls: 'icon-delete',
                            handler: function (i) {
                                DeleteStep(stepId);
                            }
                        }]
                    });
                    idx++;
                    $("#Sort").val(idx);
                    $(".icon-delete").click(function () {
                        if ($(this).next("a").attr("class") == "accordion-collapse accordion-expand") {
                            $(this).next("a").trigger("click");
                        }
                    });
                }
            });
        }
    }
   
    function DeleteStep(stepId)
    {
        $.messager.confirm('提示', '你要删除当前步骤及条件吗?', function (r) {
            if (r) {
                $.post("@Url.Action("DeleteStep")?id=" + stepId, function (data) {
     //从数据库删除
                    if (data.type == 1)
                    {
                        var pp = $('#stepList').accordion('getSelected');
                        if (pp) {
                            var index = $('#stepList').accordion('getPanelIndex', pp)
                   
                            $('#stepList').accordion('remove', index);
                            idx--;
                            //删除后需要重新设置标题
                            $("#stepList .panel .panel-title").each(function (i) {
                                $(this).html('' + (i + 1) + '');
                            })
                        }
                        $.messageBox5s('提示', data.message);
                    }
                }, "json");
               
            }
        });
    }

    function SetSelResult(result,resultName)
    {
        
        $("#Execution").val(result);
        $("#ExecutionName").val(resultName);
    }
    function GetSelResult()
    {
        var arrayObj = new Array()
        arrayObj[0]= $("#Execution").val();
        arrayObj[1]= $("#ExecutionName").val();
        return arrayObj;
    }
    //ifram 返回
    function frameReturnByClose() {
        $("#modalwindow").window('close');
    }
</script>
<div id="modalwindow" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>


<table style="height: 393px;">
    <tr>
        <td style="width: 480px; border-right: 1px #ccc solid; vertical-align: top">
            @using (Html.BeginForm())
            {
                @Html.HiddenFor(model => model.FormId)
                @Html.HiddenFor(model => model.Sort)
                <table class="fromEditTable setTextWidth100" style="width: 100%">
                    <tbody>
                        <tr>
                            <td style="width: 100px; text-align: right;">表单名称:
                            </td>
                            <td colspan="2">
                                @Html.DisplayFor(model => formModel.Name)
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 100px; text-align: right;">
                                @Html.LabelFor(model => model.Name):
                            </td>
                            <td>
                                @Html.EditorFor(model => model.Name)
                            </td>
                            <td>@Html.ValidationMessageFor(model => model.Name)</td>
                        </tr>
                        <tr>
                            <td style="width: 100px; text-align: right;">
                                @Html.LabelFor(model => model.Remark):
                            </td>
                            <td colspan="2">
                                @Html.TextAreaFor(model => model.Remark, new { @style = "width:330px;height:50px" })
                            </td>

                        </tr>

                        <tr>
                            <td style="width: 100px; text-align: right;">
                                @Html.LabelFor(model => model.FlowRule):
                            </td>
                            <td>
                                <select id="FlowRule" name="FlowRule">
                                    <option value="自选">自行指定人</option>
                                    <option value="上级">按上级</option>
                                    <option value="职位">按职位</option>
                                    <option value="部门">按部门</option>
                                    <option value="人员">按人员</option>
                                </select>
                            </td>
                            <td>@Html.ValidationMessageFor(model => model.FlowRule)</td>
                        </tr>
                        <tr id="ruleExecution" style="display: none">
                            <td style="width: 100px; text-align: right;">
                                @Html.LabelFor(model => model.Execution):
                            </td>
                            <td colspan="2">
                                @Html.HiddenFor(model => model.Execution)
                                <input id="ExecutionName" disabled="disabled" type="text" style="width: 200px" />
                                <a class="icon-add" id="selExc" href="#" ></a>
                            </td>
                            <td>@Html.ValidationMessageFor(model => model.Execution)</td>
                        </tr>
                       
                        <tr style="display:none">
                            <td style="width: 100px; text-align: right;">
                                @Html.LabelFor(model => model.IsAllCheck):
                            </td>
                            <td colspan="2">
                                @Html.CheckBoxFor(model => model.IsAllCheck, new { @checked = "checked" })
                                <span class="gray">当规则或者角色被选择为多人时候,是否启用多人审核才通过</span>
                            </td>

                        </tr>

                        <tr>
                            <td style="width: 100px; text-align: right;">
                                @Html.LabelFor(model => model.CompulsoryOver):
                            </td>
                            <td colspan="2">
                                @Html.CheckBoxFor(model => model.CompulsoryOver)
                                <span class="gray">审核人是否可以强制完成整个流程</span>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 100px; text-align: right;">
                                @Html.LabelFor(model => model.IsEditAttr):
                            </td>
                            <td colspan="2">
                                @Html.CheckBoxFor(model => model.IsEditAttr)
                                <span class="gray">审核者是否可以编辑发起者的附件</span>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 100px; text-align: right;"></td>
                            <td colspan="2">
                                <a href="javascript:Create()" class="easyui-linkbutton" data-options="iconCls:'icon-add'">添加步骤</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            }

        </td>
        <td style="width: 414px;">
            <div id="stepList" class="easyui-accordion" data-options="animate:false" style="width: 414px; height: 393px; overflow-y: auto; border: 0px;">
                @for (int i = 0; i < formModel.stepList.Count(); i++)
                {
                    <div title="第 @(i + 1) 步" data-options="iconCls:'pic_244'
                        ,tools: [{
                            iconCls: 'icon-delete',
                            handler: function (i) {
                                 DeleteStep('@(@formModel.stepList[i].Id)');
                                
                            }
                        }]">
                        <div class="stepContent" style="padding: 5px">
                            <table class="wid100f">
                                <tr>
                                    <td style="width: 100px;" class="tr">步骤名称:</td>
                                    <td>@formModel.stepList[i].Name</td>
                                </tr>
                                <tr>
                                    <td class="tr">步骤说明:</td>
                                    <td>@formModel.stepList[i].Remark</td>
                                </tr>
                            </table>
                         
                        </div>
                    </div>
                }
            
            </div>
        </td>
    </tr>
</table>
View Code

代码分析,控制器中的删除,修改,直接复制代码生成器生成的即可。

ActionResult EditStep,返回Flow_Step模型的同时也返回了Flow_Form的模型。

我修改了Flow_FormModel,让他支持自己的从表关系,必须添加以下2段即可

public List<Flow_FormAttrModel> attrList { get; set; }
public List<Flow_StepModel> stepList { get; set; }

注:本节一点悬念和技术点都没有,就是一个主表和从表的关系,只不过我是换了另一种方式来显示罢了

 

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_34255055/article/details/85718689

智能推荐

正确设置 MME类型-程序员宅基地

文章浏览阅读2.4k次。请求中的 response - header 中的content-type项是指�0�2�0�2服务器发送给客户端内容的MIME类型,如果 设置不对 那么浏览器怕是不能正常解析;const path = require(“path”);// 多用途Internet邮件扩展(MIME)类型const mimeType= {“.323”:“text/h323” ,“.3gp”:“video..._mme类型

关于EM算法_语音特征建模算法中常用期望最大化算法进行优化,一下关于em算法说法错误的是-程序员宅基地

文章浏览阅读143次。EM算法的简介1.什么是EM算法最大期望算法(Expectation-maximization algorithm,又译为期望最大化算法),是在概率模型中寻找参数最大似然估计或者最大后验估计的算法,其中概率模型依赖于无法观测的隐性变量。最大期望算法经过两个步骤交替进行计算,第一步是计算期望(E),利用对隐藏变量的现有估计值,计算其最大似然估计值;第二步是最大化(M),最大化在E步上求得的..._语音特征建模算法中常用期望最大化算法进行优化,一下关于em算法说法错误的是

Harbor 重启失败--已解决_error: for harbor-log cannot start service log: dr-程序员宅基地

文章浏览阅读1.4w次,点赞5次,收藏13次。harbor版本:v1.10.2遇到问题:使用 docker-compose down命令关闭harbor,然后使用./install.sh --with-chartmuseum命令重新安装带chart仓库的harbor,然后发现启动不了,报以下错误:[Step 5]: starting Harbor ...Creating network "harbor_harbor" with the default driverCreating network "harbor_harbor-chartmu_error: for harbor-log cannot start service log: driver failed programming ex

MySql like模糊查询优化 后缀模糊查询走索引 百万级别数据优化_mysql 模糊查询后六位-程序员宅基地

文章浏览阅读5.2k次,点赞5次,收藏18次。在使用msyql进行模糊查询的时候,很自然的会用到like语句,通常情况下,在数据量小的时候,不容易看出查询的效率,但在数据量达到百万级,千万级的时候,查询的效率就很容易显现出来。这个时候查询的效率就显得很重要!一般情况下like模糊查询的写法为(field已建立索引):SELECT`column`FROM`table`WHERE`field`like'%keyword%';上面的..._mysql 模糊查询后六位

来自西弗吉利亚大学li xin整理的CV代码合集(转)_ahd demosaicing c++-程序员宅基地

文章浏览阅读460次。http://blog.csdn.net/shuzfan/article/details/44592599 [-]Image denoisingImage codingImage demosaicingImage interpolation and SuperresolutionRGBD image processingImage segmentationparsi_ahd demosaicing c++

VUE3 中实现拖拽和缩放自定义看板 vue-grid-layout_vue组件拖拽自定义界面-程序员宅基地

文章浏览阅读1.1w次,点赞4次,收藏33次。vue3 使用vue-grid-layout进行自定义拖拽布局_vue组件拖拽自定义界面

随便推点

优化器提示——性能调整手册和参考_oracle_pred arule-程序员宅基地

文章浏览阅读544次。Hint是Oracle数据库灵活性的体现。由于Hint具有最高的优先级,因此可以通过Hint使优化器根据用户的需要来生成指定的执行计划。Oracle的hint种类繁多,大致可以分为下面几类:优化方式和目标:如RULE、CHOOSE、FIRST_ROWS、ALL_ROWS等。访问路径:如INDEX、FULL、CLUSTER、INDEX_FFS等。查询转换:如MERGE、USE_CON_pred arule

“iPhone邮件应用程序无法同步最新电子邮件“ - 解决方案与源代码示例_苹果手机邮箱不更新邮件-程序员宅基地

文章浏览阅读679次。在邮件设置中,您可以找到"账户"选项,然后选择您的电子邮件账户。然而,有时候我们可能会遇到问题,即我们的iPhone邮件应用程序未能显示最新的电子邮件。在本篇文章中,我们将探讨这个问题的解决方案,并提供相应的源代码示例,帮助您解决此类问题。在邮件设置中,您可以检查您的电子邮件帐户的配置和同步设置。下面是一个简单的示例代码,演示如何使用Swift语言编写一个简单的邮件应用程序,并实现邮件的同步功能。下面是一些您可以尝试的解决方案,以确保您的iPhone邮件应用程序能够显示最新的电子邮件。_苹果手机邮箱不更新邮件

unity 一个拼图demo(七巧板)和一个切割demo_untiy开发七巧板-程序员宅基地

文章浏览阅读6.6k次。好久没更新博客了,那么今天就来装一下b吧。还是先上一波图,看看我们到底要做什么。前面2张是切割的的demo,后面的这个是拼图,但是我们看到材质,这里的解释一下2个demo用的都是一个网格构建代码,所以才会出现这种情况,正确的做法应该是把添加uv的代码做个判断一下,把这个变量放到这个方法参数列表中,同时把它变成一个对外的方法。这里顺便给大家提一下封装的思想,厉害的程序员他们其实大部分的时_untiy开发七巧板

SpringCloud微服务架构升级总结_springcloud 升级了annotation-程序员宅基地

文章浏览阅读263次。SpringCloud微服务架构升级总结wuli程序员2019-06-26 15:37:28一、背景1.1 应用系统的架构历史1.2 什么是微服务?起源:微服务的概念源于 2014 年 3 月 Martin Fowler 所写的一篇文章“Microservices”。文中内容提到:微服务架构是一种架构模式,它提倡将单一应用程序划分成一组小的服务,服务之间互相协调、互..._springcloud 升级了annotation

GEM5教程-Garnet 2.0_gem5 garnet-程序员宅基地

文章浏览阅读2.7k次,点赞8次,收藏15次。GEM5教程-Garnet 2.0一、Garnet2.0:一种用于异构SoCs的片上网络模型二、调用三、配置四、拓扑结构网络组件五、路由六、流量控制七、路由器微体系结构1、缓冲区写入(BW)2、路线计算(RC)3、交换机分配(SA)4、VC选择(VS)5、链路遍历(LT)多周期路由器八、缓冲区管理一、Garnet2.0:一种用于异构SoCs的片上网络模型1、 garent2.0是gem5内部一..._gem5 garnet

线程中断interrupt(), interrupted(), isInterrupted()总结_线程 interrupter 还是能找到这个线程-程序员宅基地

文章浏览阅读277次。interrupt():中断此线程,但实际上只是给线程设置一个中断标志,线程仍会继续运行interrupted():测试当前线程是否被中断,清除中断状态isInterrupted(): 测试此线程是否被中断,不清楚中断状态总结:interrupt()是给线程设置中断标志;interrupted()是检测中断并清除中断状态;isInterrupted()只检测中断。还有interrupted()作用于当前线程,interrupt()和isInterrupted()作用于此线程,即代码中调用此方_线程 interrupter 还是能找到这个线程

推荐文章

热门文章

相关标签