<%@ Page Title="" Language="C#" MasterPageFile="../BaseMaster.Master" CodeBehind="CreditLevelDetail.aspx.cs" Inherits="WAP2P.Web.PC.Admin.Sys.CreditLevelDetail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="header" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <form class="auto" method="post" action="" beforesubmit="setJsons();" onsuccess="parent.$.jPopupEdit.close(true);">
        <div class="m-editbar">
            <input type="submit" class="btn-larger c-priority iconfont" value="&#xe684; 保存" />
            <input type="button" class="btn-larger c-normal iconfont" value="&#xe634; 关闭" onclick="parent.$.jPopupEdit.close();" />
        </div>
        <div class="m-content m-editcontent">
            <table class="m-info" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <th>等级名称</th>
                    <td><input type="text" name="name" placeholder="请输入信用等级名称" class="w250" maxlength="50" value="<%= Model.Name.HtmlEncode() %>" data-vtype="must" data-vmsg="请输入等级名称"/></td>
                </tr>             
                <tr>
                    <th>到达该等级分值</th>
                    <td><input type="text" name="minValue" placeholder="请输入等级分值" class="w90 ui-int" value="<%=Model.MinValue %>" data-vtype="must|number" data-vmsg="请输入该等级起始分值|等级起始分值必须为数字" /> 分</td>
                </tr>
                <tr>
                    <th>信用额度</th>
                    <td>
                        <table id="creditQuota" class="info-inlinetable">
                            <asp:Repeater runat="server" ID="rptBorrowQuota" ItemType="WAP2P.Sys.BorrowType">
                                <ItemTemplate>
                                    <tr><td><%# Item.Name %> <span class="pl50">额度：<input type="text" data-id="<%# Item.Id %>" data-to="Quota" class="ui-float w150" data-vtype="money" data-vmsg="请输入正确金额值" value="<%# Model.CreditQuota != null && Model.CreditQuota.ContainsKey(Item.Id.ToString()) ? Model.CreditQuota[Item.Id.ToString()].ToMoneyString() : "0.00" %>" /> 元</span></td></tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </table>
                        <input type="hidden" name="creditQuotaJson" id="creditQuotaJson" />
                    </td>
                </tr>
                <tr>
                    <th>待付标比例</th>
                    <td>
                        <table id="payAndReceiveRate" class="info-inlinetable">
                            <asp:Repeater runat="server" ID="rptReceiveRate" ItemType="WAP2P.Sys.BorrowType">
                                <ItemTemplate>
                                    <tr><td><%# Item.Name %> <span class="pl50">影响待付比：<input type="text" data-id="<%# Item.Id %>" data-to="Rate" class="ui-float w150" data-vtype="money" data-vmsg="请输入正确值" placeholder="标类型比例+本值" value="<%# Model.PayAndReceiveRate != null && Model.PayAndReceiveRate.ContainsKey(Item.Id.ToString()) ? (Model.PayAndReceiveRate[Item.Id.ToString()] * 100).ToInterestString() : "0" %>" /> %</span></td></tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </table>
                        <input type="hidden" name="payAndReceiveRateJson" id="payAndReceiveRateJson" />
                    </td>
                </tr>
                <tr>
                    <th>图标</th>
                    <td>
                        <div id="iconResult" class="mb10"><% =IsNew ? string.Empty : string.Format("<img src=\"{0}\" alt=\"\">", Model.Icon)  %></div>
                        <div class="pl136" ><input type="hidden" name="icon" id="icon" value="<% =Model.Icon.HtmlEncode() %>" data-vtype="must" data-vmsg="请上传图标" /></div>
                        <input type="file" id="iconFile" />
                        <em>请上传尺寸为 <i class="fcred-3">120 X 120 像素</i> 以内的图片</em>
                    </td>
                </tr>
                <tr>
                    <th>备注</th>
                    <td><textarea name="description"><% =Model.Description.HtmlEncode() %></textarea></td>
                </tr>
            </table>
        </div>
    </form>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script>
        //提交前设置Json对象。
        function setJsons() {
            //额度
            var creditQuota = [];
            $('#creditQuota tr').each(function(i, n) {
                n = $(n).find('input[data-to=Quota]');
                var quota = n.val();
                quota = quota ? parseFloat(quota.replace(/,/g, '')) : 0;
                creditQuota.push('"' + [n.attr('data-id')] + '":'+ quota);
            });
            $('#creditQuotaJson').val('{' + creditQuota.join(',') + '}');

            //待付比
            var payAndReceiveRate = [];
            $('#payAndReceiveRate tr').each(function(i, n) {
                n = $(n).find('input[data-to=Rate]');
                var rate = n.val();
                rate = finance.roundx((rate ? parseFloat(rate.replace(/,/g, '')) : 0) / 100, 4);
                payAndReceiveRate.push('"' + [n.attr('data-id')] + '":'+ rate);
            });
            $('#payAndReceiveRateJson').val('{' + payAndReceiveRate.join(',') + '}');
        };

        setTimeout(function () {
            $('#iconFile').uploadify({
                width: 120,
                height: 32,
                multi: false,
                removeTimeout: 0,
                swf: '../res/uploadify/uploadify.swf?v=<% =CryptoHelper.Random(100000,999999) %>',
                uploader: '../res/uploadify/SwfUpload.aspx?type=image&width=120&height=120',
                buttonClass:'iconfont',
                buttonText: '&#xe629; 上传图标',
                fileTypeExts: '<% =WAP2P.Web.PC.Admin.Res.uploadify.SwfUpload.AllowImages %>',
                formData: {
                    <% =WAP2P.Web.Admin.Membership.CookieName %> : '<% =Request.Cookies[WAP2P.Web.Admin.Membership.CookieName].Value %>'
                },
                onUploadSuccess: function(res, data) {
                    eval('var d = ' + data);
                    if (d.Success) {
                        $('#icon').val(d.Message).trigger('blur');                    
                        $('#iconResult').html('<img src="' + d.Message + '" />');
                    } else {
                        $.jError(d.Message);
                    }
                }
            });
        }, 10);
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="list" runat="server">
</asp:Content>
