@model Com._9pm2.ClientWeb.Models.OrderList
@{
    ViewBag.Title = "员工绩效分配";
}

<script src="~/Scripts/ordercommon.js?vn=20180813"></script>
<script src="~/Scripts/orderperformance.js?vn=20180813"></script>
<style>
    #divCTContent table {
        margin-bottom: 15px;
    }

    #divCT table .label {
        height: 26px;
    }

    .btn-sm {
        padding: 2px 5px;
    }

    .table-title {
        height: 34px;
    }

    #divCT input[type=text] {
        height: 26px;
        width: 100px;
    }

    .tr-color-0 {
    }

    .tr-color-1 {
        background-color: #eeeeee;
    }
</style>
<div id="dSearch" class="divSearch">
    <form method="post">
        <div style="width:100%">
            @Html.DropDownList("sWorkFlow", new SelectList(Model.DdlWorkFlow, "ItemValue", "ItemText"))
            @Html.DropDownList("sCustomerNo", new SelectList(Model.DdlCustomer, "ItemValue", "ItemText"))
            <input type="text" placeholder="客户索引" class="form-control" style="width:80px" id="txtCustomer" />
            @Html.DropDownList("sCtStatus", new SelectList(Model.DdlCtStatus, "ItemValue", "ItemText"))
            @Html.DropDownList("sStatus", new SelectList(Model.DdlStatus, "ItemValue", "ItemText"))
            @Html.DropDownList("sPaymentStatus", new SelectList(Model.DdlPaymentStatus, "ItemValue", "ItemText"))
            @Html.TextBox("sBeginDate", null, new { maxlength = "50", @class = "text-date", placeholder = "交易日期" }) ~@Html.TextBox("sEndDate", null, new { maxlength = "50", @class = "text-date", placeholder = "交易日期" })
            @Html.TextBox("sCompletionBDate", null, new { maxlength = "50", @class = "text-date", placeholder = "完成日期" }) ~@Html.TextBox("sCompletionEDate", null, new { maxlength = "50", @class = "text-date", placeholder = "完成日期" })
            @Html.TextBox("sKey", null, new { maxlength = "50", @Style = "width:130px", placeholder = "关键字" })
            <button class="btn btn-default" id="btnSearch" onclick="return checkField();">搜索</button>
            <button type="button" class="btn btn-default" onclick="BatchProcess()">批量分配</button>
        </div>

    </form>
</div>
<div class="error-msg"></div>
<div id="Statement">
    <div class="list">
        <table id="tOrder">
            <thead>
                <tr>
                    <th>
                        <input type="checkbox" id="chkAll" onclick="SelectAll();" />
                    </th>
                    <th style="width:140px">订单编号</th>
                    <th style="width:100px">交易日期</th>
                    <th>客户</th>
                    <th>订单名称</th>
                    <th style="width:80px">订单状态</th>
                    <th style="width:100px">完工日期</th>
                    <th style="width:80px">支付状态</th>
                    <th style="width:80px">订单金额</th>
                    <th style="width:80px">绩效状态</th>
                    @*<th style="width:80px">已付</th>
                        <th style="width:80px">未付</th>*@
                    <th style="width:80px">操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.Orders)
                {
                    <tr id="@item.OrderNo">
                        <td class="td-checkbox">
                            <input type="checkbox" onclick="SelectOne();" />
                        </td>
                        <td>@Html.DisplayFor(modelItem => item.OrderNo)</td>
                        <td>@item.TransactionDate.ToString("yyyy-MM-dd")</td>

                        <td>@Html.DisplayFor(modelItem => item.CustomerShortName)</td>
                        <td>@Html.DisplayFor(modelItem => item.OrderName)</td>
                        <td>
                            <span id="spanStatus">@item.StatusDescription</span>
                        </td>
                        <td>@(item.CompletionDate.HasValue ? item.CompletionDate.Value.ToString("yyyy-MM-dd") : "")</td>
                        <td>
                            <span id="spanPaymentStatus">@Html.DisplayFor(modelItem => item.PaymentStatusDescription)</span>
                        </td>
                        <td>@Com._9pm2.ClientWeb.Utilities.NFormat.Format(item.Amount)</td>
                        <td id="ct-status">

                            @if (item.CtStatus.HasValue && item.CtStatus.Value)
                            {
                                <span>已分配</span>
                            }
                            else
                            {
                                <span>未分配</span>
                            }


                        </td>


                        @*<td>@smartcrm.Utilities.NFormat.Format(item.Paid)</td>
                            <td>@smartcrm.Utilities.NFormat.Format(item.Unpaid)</td>*@
                        <td class="text-center">
                            <a href="#" onclick="CtSetting('@item.OrderNo')">
                                绩效分配
                            </a>
                        </td>
                    </tr>
                }


            </tbody>
        </table>
        @Html.Pager("Performance", "Finance", Model.RouterDirectory, Model.PagerConfig, "pagerDiv", "pagerDiv", 8, true, false, true, true, false)
    </div>
</div>

@Html.Partial("OrderDetail", Session["LoginUser"] as Com._9pm2.ClientWeb.Models.LoginUser)
<input type="hidden" id="OrderNo" />


<div id="divCT" title="绩效提成分配" style="display:none;">
    <div id="divCTContent" style="overflow-y: auto;">
        <div class="FR" style="padding:4px 0;">
            <a target="_blank" href="~/VersionList/doc.html?c=11&d=8">如何配置？</a>
        </div>
        <table class="tableDetail">
            <thead>
                <tr>
                    <th colspan="4" class="text-left table-title">
                        <b>订单提成设置</b>
                        <div class="FR">
                            <button class="btn btn-success btn-sm" onclick="getAutoCt()">自动计算</button>
                        </div>
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="label">订单编号</td>
                    <td id="orderNo"></td>
                    <td class="label">客户名称</td>
                    <td id="customerName"></td>
                </tr>
                <tr>
                    <td class="label">交易日期</td>
                    <td id="transactionDate"></td>
                    <td class="label">完工日期</td>
                    <td id="completeDate"></td>
                </tr>
                <tr>
                    <td class="label">订单名称</td>
                    <td id="orderName" colspan="3"></td>
                </tr>
                <tr>
                    <td class="label">订单金额</td>
                    <td id="orderAmount"></td>
                    <td class="label">订单利润</td>
                    <td id="orderProfit"></td>
                </tr>
                <tr>
                    <td class="label">提成方式</td>
                    <td>
                        <input type="radio" name="orderCtType" value="1" />按订单金额 &nbsp;
                        <input type="radio" name="orderCtType" value="2" />按订单利润
                    </td>
                    <td class="label">提成比例</td>
                    <td>
                        <input type="text" id="orderCtRatio" /> %
                    </td>
                </tr>
                <tr>
                    <td class="label">提成总额</td>
                    <td colspan="3">
                        <input type="text" id="orderCtAmount" />
                    </td>
                </tr>
            </tbody>
        </table>

        <table>
            <thead>
                <tr>
                    <th colspan="4" class="text-left  table-title"><b>步骤提成设置</b></th>
                </tr>
                <tr>
                    <th>步骤名称</th>
                    <th>参与提成</th>
                    <th>提成比例</th>
                    <th>提成金额</th>
                </tr>
            </thead>
            <tbody id="tbody-step"></tbody>
        </table>


        <table>
            <thead>
                <tr>
                    <th colspan="3" onclick="showMemo()" style="cursor:pointer" class="text-left table-title"><b><img id="img-memo" class="imgToggle" title="折叠/展开" src="../../Images/grid/ExpandedBlockStart.gif">备忘</b></th>
                </tr>
                <tr id="tr-memo" style="display:none">
                    <th>内容</th>
                    <th style="width:80px">添加者</th>
                    <th style="width:130px">时间</th>
                </tr>
            </thead>
            <tbody id="tbody-memo" style="display:none"></tbody>
        </table>


        <table>
            <thead>
                <tr>
                    <th colspan="6" class="text-left  table-title">
                        <b>经办人/协作者提成设置</b>
                        <div class="FR">
                            <button class="btn btn-default btn-sm" onclick="addCooperator()">+ 协作者</button>
                        </div>
                    </th>
                </tr>
                <tr>
                    <th>步骤名称</th>
                    <th>经办人/协作者</th>
                    <th>参与提成</th>
                    <th>提成比例</th>
                    <th>提成金额</th>
                    <th></th>
                </tr>
            </thead>
            <tbody id="tbody-user"></tbody>
            <tfoot>
                <tr>
                    <td>合计：</td>
                    <td></td>
                    <td></td>
                    <td></td>

                    <td id="totalCtAmout"></td>

                    <td></td>
                </tr>
            </tfoot>
        </table>
    </div>
    <div style="text-align:right;">

        <div class="error-msg"></div>
        <button class="btn btn-primary" type="button" onclick="Save()">保存</button>
        <button class="btn btn-default" type="button" onclick="$('#divCT').dialog('close');">取消</button>
    </div>
</div>

<div id="divCooperators" title="添加协作者" style="display:none">
    <div id="divCooperatorsContent">
        <table class="tableEdit">
            <tr>
                <td class="label">步骤</td>
                <td>
                    <select id="selStep"></select>
                    <span class="redStar">*</span>
                </td>
            </tr>
            <tr>
                <td class="label">协作者</td>
                <td>
                    <select id="selUser"></select>
                    <span class="redStar">*</span>
                </td>
            </tr>
        </table>

    </div>
    <div style="text-align:right;">
        <div class="error-msg"></div>
        <button type="button" class="btn btn-default" onclick="$('#divCooperators').dialog('close');">关闭</button>
        <button id="btnSaveCooperators" type="button" onclick="SaveCooperator()" class="btn btn-primary">确定</button>
        <input type="hidden" id="orderNo" />
    </div>
</div>
