@model List<Com._9pm2.ClientWeb.Database.WorkFlow>
@{
    ViewBag.Title = "工作流程配置";
}
<script src="../../Scripts/workflow.js?vn=20180813"></script>

<div>
    <button id="btnNew" type="button" class="btn btn-default">新增</button>
</div>
<div class="error-msg"></div>
<div class="list">

    <table id="tWorkFlow">
        <thead>
            <tr>
                <th>名称</th>
                <th>描述</th>
                <th>包含步骤</th>
                <th style="width:60px;">状态</th>
                <th style="width:100px">操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr id="@item.WorkFlowNo">
                    <td>
                        @Html.DisplayFor(modelItem => item.WorkFlowName)
                    </td>
                    <td>
                        @item.WorkFlowDescription
                    </td>
                    <td onclick="showCanvas('@item.WorkFlowNo')">
                        <a>
                            @String.Join(", ", item.WorkFlowStep.OrderBy(n => n.SN).Select(m => m.WorkFlowStepName).ToList())
                        </a>
                    </td>
                    <td>
                        @if (item.IsActive)
                        {
                            <span>可用</span>
                        }
                        else
                        {
                            <span>已禁用</span>
                        }
                    </td>
                    <td>

                        <div class="operation-btns">
                            <div>
                                <button id="select">&nbsp;</button>
                            </div>
                            <ul>
                                @if (item.IsActive)
                                {
                                    <li><a href="javascript:void(0);" onclick="EditWorkFlow('@item.WorkFlowNo');">编辑</a></li>
                                    <li><a href="javascript:void(0);" onclick="ConfigWorkFlow('@item.WorkFlowNo');">配置步骤</a></li>
                                }

                                <li><a href="javascript:void(0);" onclick="DeleteWorkFlow('@item.WorkFlowNo','@item.WorkFlowName');">删除</a></li>


                            </ul>
                        </div>
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>

<div id="divWorkFlow" title="流程信息" style="display:none">
    <div id="divWorkFlowContent" style="overflow-y: auto;">
        @using (Html.BeginForm())
            {
            <table class="font85 tableEdit">
                <tr>
                    <td class="label">流程名称</td>
                    <td>
                        @Html.TextBox("WorkFlowName", null, new { maxlength = "50" })&nbsp;<span class="redStar">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">禁用</td>
                    <td>
                        @Html.CheckBox("IsActive")
                    </td>
                </tr>
                <tr>
                    <td class="label">流程描述</td>
                    <td>
                        @Html.TextArea("WorkFlowDescription", null, new { maxlength = "50" })
                    </td>
                </tr>
            </table>

            @Html.Hidden("WorkFlowNo")
        }
    </div>
    <div style="text-align:right;">
        <div class="error-msg"></div>
        <button type="button" class="btn btn-default" id="btnCancel">取消</button>
        <button type="button" class="btn btn-primary" id="btnSave">保存</button>
    </div>
</div>


<div id="divCanvas" title="流程图" style="display:none;padding:0 0 10px 0">
    <div id="divCanvasContent" style="overflow-y: auto; height: 320px;">
        <canvas id="canvas" height="300" width="800" style="background-color:#F0F0F0">
            您的浏览器不支持canvas显示，请升级您的浏览器或使用其它浏览器访问。（比如Google Chrome或Firefox等）
        </canvas>
    </div>
    <div style="text-align:right;">
        <button type="button" class="btn btn-default" onclick="$('#divCanvas').dialog('close');">关闭</button>
        <button type="button" class="btn btn-primary" onclick="GotoDetail()">编辑流程图</button>
    </div>
</div>
