@model  Com._9pm2.ClientWeb.Models.WorkFlowDetailModel
@{
    ViewBag.Title = "流程配置";
}
<script src="../../Scripts/workflowdetail.js?vn=20180813"></script>

<div style="padding: 5px 0">
    <span class="tableTitle">工作流名称：@Model.WorkFlowName</span>
</div>
<canvas id="canvas" height="300" style="background-color:#FFFFFF;border: 1px #1596ad solid">
    您的浏览器不支持canvas显示，请升级您的浏览器或使用其它浏览器访问。（比如Google Chrome或Firefox等）
</canvas>

<div class="list">
    <div style="display:inline; margin-top:15px"></div>
    <div>
        <button id="btnNew" type="button" class="btn btn-default">新增步骤</button>

        <button id="btnReturn" type="button" onclick="location.href = '/System/WorkFlow'" class="btn btn-default">返回流程列表</button>
        <span class="errorSpan" style="padding-top:20px" id="message"></span>
    </div>

    <div class="FR">


    </div>

    <table id="tWorkFlowDetail">
        <thead>
            <tr>
                <th style="width:80px">序号</th>
                <th style="width:120px">步骤名称</th>
                <th style="width:120px">状态名称</th>
                <th>经办人员</th>
                <th>后续步骤</th>
                <th>参与绩效提成</th>
                <th>绩效提成比例</th>
                <th style="width:120px">操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.Steps)
            {
                <tr id="@item.WorkFlowStepNo">
                    <td>@item.SN </td>
                    <td>

                        @item.WorkFlowStepName

                    </td>
                    <td>@item.StatusName</td>
                    <td>
                        @(item.IsEndPoint ? "--" : String.Join(", ", item.Users.Select(m => m.OptionText)))
                    </td>

                    <td>
                        @(item.IsEndPoint ? "--" : String.Join(", ", item.FollowUps.Select(m => m.OptionText)))
                    </td>
                    <td>@(item.IsEndPoint ? "--" : (item.CtInvolved.HasValue && item.CtInvolved.Value ? "是" : "否"))</td>
                    <td>@(item.IsEndPoint ? "--" : (item.CtPercent.HasValue ? string.Format("{0:F2}", item.CtPercent.Value) : ""))</td>

                    <td>
                        @if (!item.IsEndPoint)
                        {
                            <a href="javascript:void(0);" onclick="EditStep('@item.WorkFlowStepNo');">[编辑]</a>
                        }

                        @if (!item.IsSystemReserved)
                        {
                            <a href="javascript:void(0);" onclick="DeleteStep('@item.WorkFlowStepNo','@item.WorkFlowStepName');">[删除]</a>
                        }
                        else
                        {
                            <span style="color:gray">系统保留</span>
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>


<div id="divStep" title="流程步骤" style="display:none">
    <div id="divStepContent">
        <form id="formStep">
            <table class="font85 tableEdit">
                <tr>
                    <td class="label">步骤名称</td>
                    <td>
                        @Html.TextBox("WorkFlowStepName", null, new { maxlength = "50" })&nbsp;<span class="redStar">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">步骤序号</td>
                    <td>
                        @Html.TextBox("SN", null, new { maxlength = "50" })&nbsp;<span class="redStar">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="label">步骤状态</td>
                    <td>
                        @Html.DropDownList("StatusNo", new SelectList(Model.DdlOrderStatus, "ItemValue", "ItemText"))&nbsp;<span class="redStar">*</span>
                        &nbsp;
                        <a href="javascript:void(0)" style="padding-top:5px;" onclick="addStatus()">列表中没有？</a>
                    </td>
                </tr>
                <tr>
                    <td class="label">后续步骤</td>
                    <td>
                        <table class="font85">
                            <thead>
                                <tr>
                                    <th>可用步骤</th>
                                    <th></th>
                                    <th>后续步骤</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>
                                        <select style="width:160px; height:100px;" id="aFollowUp" multiple="multiple" size="24" />
                                    </td>
                                    <td>
                                        <input style="margin-bottom:5px" type="button" value="添加-&gt;" id="btnAddStep" />
                                        <br />
                                        <input type="button" value="&lt;-移除" id="btnRemoveStep" />
                                    </td>
                                    <td>
                                        <select style="width:160px; height:100px;" id="bFollowUp" multiple="multiple" size="24"></select>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td class="label">经办人员</td>
                    <td>
                        <table class="font85">
                            <thead>
                                <tr>
                                    <th>可用人员</th>
                                    <th></th>
                                    <th>经办人员</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>
                                        <select style="width:160px; height:200px;" id="aUser" multiple="multiple" size="24" />
                                    </td>
                                    <td>
                                        <input style="margin-bottom:5px" type="button" value="添加-&gt;" id="btnAddUser" />
                                        <br />
                                        <input type="button" value="&lt;-移除" id="btnRemoveUser" />
                                    </td>
                                    <td>
                                        <select style="width:160px; height:200px;" id="bUser" multiple="multiple" size="24" />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>

                <tr id="tr_ctinvolved">
                    <td class="label">参与绩效提成</td>
                    <td>
                        @Html.CheckBox("CtInvolved")
                    </td>
                </tr>
                <tr id="tr_ctpercent">
                    <td class="label">绩效提成比例</td>
                    <td>
                        @Html.TextBox("CtPercent", null, new { maxlength = "50" }) %
                    </td>
                </tr>
            </table>
        </form>
    </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>
        <input type="hidden" id="WorkFlowStepNo" />
        @Html.Hidden("WorkFlowNo")
    </div>
</div>

<div id="divStatus" title="添加新状态" style="display:none">
    <div id="divStatusContent">
        <form id="formStep">
            <table class="font85 tableEdit">
                <tr>
                    <td class="label">状态名称</td>
                    <td>
                        @Html.TextBox("StatusName", null, new { maxlength = "50" })&nbsp;<span class="redStar">*</span>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <div style="text-align:right;">

        <div class="error-msg"></div>
        <button type="button" class="btn btn-default" id="btnCancelStatus">取消</button>
        <button type="button" class="btn btn-primary" id="btnSaveStatus">保存</button>
    </div>
</div>  