<%@ Page Title="" Language="C#" MasterPageFile="../BaseMaster.Master" CodeBehind="BorrowTypeDetail.aspx.cs" Inherits="WAP2P.Web.PC.Admin.Sys.BorrowTypeDetail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="header" runat="server">
    <style type="text/css">
        .interestStartType label{display:block; margin-top:5px;}
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <form class="auto" method="post" action="" beforeSubmit="setSaveJson();"  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 class="info-listhead" colspan="4">借款类型基本设置</th>
                </tr>
                <tr>
                    <th>借款类型名称</th>
                    <td colspan="3"><input type="text" name="name" placeholder="请输入借款类型名称" value="<% =Model.Name.HtmlEncode() %>" class="w250" maxlength="50" data-vtype="must" data-vmsg="请输入借款类型名称" /></td>
                </tr>
                <tr>
                    <th>是否启用</th>
                    <td colspan="3"><div class="ui-checkbox"><%= HtmlHelper.CheckBox("active","启用", IsNew || Model.Active) %></div></td>
                </tr>
                <tr>
                    <th>借款类型图标</th>
                    <td colspan="3">
                        <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">60 X 18 像素</i> 的LOGO图片</em>
                    </td>
                </tr>
                <tr>
                    <th>借款类型封面</th>
                    <td colspan="3">
                        <div id="coverResult" class="mb10"><% =IsNew ? string.Empty : string.Format("<img src=\"{0}\" alt=\"\">", Model.Cover)  %></div>
                        <div class="pl136"><input type="hidden" name="cover" id="cover" value="<% =Model.Cover.HtmlEncode() %>"  data-vtype="must" data-vmsg="请上传借款类型封面" /></div>
                        <input type="file" id="coverFile" />
                        <em>请上传尺寸为 <i class="fcred-3">120 X 120 像素</i> 的LOGO图片</em>
                    </td>
                </tr>                
                <tr>
                    <th>投资积分奖励比</th>
                    <td>
                        <input type="text" name="bidScoreRate" class="w100 ui-interest" value="<%= (Model.BidScoreRate * 100).RoundX().ToInterestString() %>" data-vtype="money|range" data-vmax="100000" data-vmsg="请输入正确的比例|比例超出范围" /> %
                        <em>投资金额 * 该设定比例 * 月份 = 所获积分</em>
                    </td>
                    <th>排序值</th>
                    <td>
                        <input type="text" name="orderBy" class="w60 ui-int"value="<%=Model.OrderBy %>" data-vtype="number" data-vmsg="排序必须为数字" /><em>数值越大越靠前</em>
                    </td>
                </tr>
                <tr>
                    <th>还款信用奖励比</th>
                    <td>
                        <input type="text" name="repayCreditRate" class="w100 ui-interest" value="<%= (Model.RepayCreditRate * 100).RoundX().ToInterestString() %>" data-vtype="money|range" data-vmax="100000" data-vmsg="请输入正确的比例|比例超出范围" /> %
                        <em>还款金额 * 该设定比例 = 所获信用</em>
                    </td>
                    <th>逾期信用扣除比</th>
                    <td>
                        <input type="text" name="overdueCreditRate" class="w100 ui-interest" value="<%= (Model.OverdueCreditRate * 100).RoundX().ToInterestString() %>" data-vtype="money|range" data-vmax="100000" data-vmsg="请输入正确的比例|比例超出范围" /> %
                        <em>逾期本金 * 该设定比例 * 逾期天数 = 所扣信用</em>
                    </td>
                </tr>              
                <tr>
                    <th>类型描述</th>
                    <td colspan="3"><textarea name="description"><% =Model.Description.HtmlEncode() %></textarea></td>
                </tr>
                <tr>
                    <th class="info-listhead" colspan="4">借款类型发布设置</th>
                </tr>
                <tr>
                    <th width="15%">是否仅为系统发标</th>
                    <td width="35%">
                        <div class="ui-checkbox"><%= HtmlHelper.CheckBox("systemPublish","启用", Model.SystemPublish) %></div>
                    </td>
                    <th width="15%">未满标时可审核</th>
                    <td width="35%">
                        <div class="ui-checkbox"><%= HtmlHelper.CheckBox("supportNoFullPass","启用", Model.SupportNoFullPass) %></div>
                    </td>
                </tr>
                <tr>
                    <th>发标时自动审核</th>
                    <td>
                        <div class="ui-checkbox"><%= HtmlHelper.CheckBox("autoAddPass","启用", Model.AutoAddPass) %></div>
                    </td>
                    <th>满标时自动审核</th>
                    <td>
                        <div class="ui-checkbox"><%= HtmlHelper.CheckBox("autoFullPass","启用", Model.AutoFullPass) %></div>
                    </td>
                </tr>
                <tr>
                    <th>是否允许提前还款</th>
                    <td>
                        <div class="ui-checkbox"><%= HtmlHelper.CheckBox("supportAdvanceRepayment","启用", Model.AdvanceRepay != BorrowType.AdvanceRepayEnum.NoSupport) %></div>
                    </td>
                    <th>是否允许推荐人提成</th>
                    <td>
                        <div class="ui-checkbox"><%= HtmlHelper.CheckBox("supportRecommend","启用", IsNew || Model.SupportRecommend) %></div>
                    </td>
                </tr>
                <tr id="js-advanceRepay" class="g-hide">
                    <th>提前还款设置</th>
                    <td colspan="3">
                        <div class="ui-radio">
                            <label><input type="radio" name="advanceRepay" value="<% =(int)WAP2P.Sys.BorrowType.AdvanceRepayEnum.ByShould %>" <% =Model.AdvanceRepay != BorrowType.AdvanceRepayEnum.ByDay ? " checked=\"checked\"" : string.Empty %> /> <% =WAP2P.Sys.BorrowType.AdvanceRepayEnum.ByShould.GetDescription() %></label>
                            <label><input type="radio" name="advanceRepay" value="<% =(int)WAP2P.Sys.BorrowType.AdvanceRepayEnum.ByDay %>" <% =Model.AdvanceRepay == BorrowType.AdvanceRepayEnum.ByDay ? " checked=\"checked\"" : string.Empty %> /> <% =WAP2P.Sys.BorrowType.AdvanceRepayEnum.ByDay.GetDescription() %></label>
                        <em>注意：按实际还款日结算时，将自动结算至最近一期包含本金的还款期数。</em>
                        </div>
                        <div class="mt10">提前还款违约金 <input type="text" class="w100 ui-interest" name="advanceRepayOutRate" value="<% =(Model.AdvanceRepayOutRate * 100).ToInterestString() %>"  data-vtype="money|range" data-vmax="100" data-vmsg="请输入正确的比例值|比例需在0%-100%之间" /> %
                          <em>当期应还本金 * 该费率 = 提前还款违约金</em>
                        </div>
                        <div class="mt10">可免违约金期限 <input type="text" class="w100 ui-int" name="advanceRepayOutDay" value="<% =Model.AdvanceRepayOutDay %>" /> 天</div>
                        <em>在设定的期限内提前还款，将不扣除提前还款违约金，如为 0 则提前还款都将扣除违约金。</em>
                    </td>                   
                </tr>
                <tr>
                    <th>选择还款方式</th>
                    <td colspan="3" id="js-repayment">
                        <asp:Repeater runat="server" ID="rptRepayment">
                            <ItemTemplate>
                                <div class="pt5">
                                    <span class="ui-checkbox autonext"><label><input type="checkbox" name="supportRepayments" data-vtype="group" data-vmin="1" data-vmsg="最少必须选择一种还款方式" value="<%# Eval("Item1") %>"<%# Model.Repayment.ContainsKey((string)Eval("Item1")) ? " checked=\"checked\"" : string.Empty %> /> <%# Eval("Item2") %></label></span>
                                    <span class="pl50">年化费用率 <input type="text" class="w100 ui-interest" data-vmust="false" data-vtype="money|range" data-vmax="100" data-vmsg="请输入正确的比例值|比例需在0%-100%之间" value="<%# Model.Repayment.ContainsKey((string)Eval("Item1")) ? (Model.Repayment[(string)Eval("Item1")] * 100).ToInterestString() : "0" %>" /> %</span>
                                </div>
                            </ItemTemplate>
                        </asp:Repeater>
                        <input type="hidden" id="repaymentJson" name="repaymentJson" />
                    </td>
                </tr>
                <tr>
                    <th class="info-listhead" colspan="4">借款金额设置</th>
                </tr>
                <tr>
                    <th>借款金额限制区间</th>
                    <td colspan="3">
                        从 <input type="text" name="minAmount" class="w150 ui-float" data-vtype="money" data-vmsg="请输入正确的金额" value="<%= Model.MinAmount.ToMoneyString() %>" /> 元 至
                        <input type="text" name="maxAmount" class="w150 ui-float" data-vtype="money" data-vmsg="请输入正确的金额" value="<%= Model.MaxAmount.ToMoneyString() %>" /> 元
                    </td>
                </tr>
                <tr>
                    <th>借款/投资方式</th>
                    <td colspan="3">
                        <span class="ui-radio"><label><input type="radio" name="byStep" onclick="$('#trByCustom').show();$('#trByStep').hide();" value="" <% =Model.ByStep ? string.Empty : "checked=\"checked\"" %>/>自由借款/投资</label></span>
                        <span class="ui-radio"><label><input type="radio" name="byStep" onclick="$('#trByStep').show();$('#trByCustom').hide();" value="1" <% =Model.ByStep ? "checked=\"checked\"" : string.Empty %>/>基数借款/投资</label></span>
                    </td>
                </tr>
                <tr id="trByCustom"<% =Model.ByStep ? " style='display:none;'" : string.Empty %>>
                    <th>起投最小金额</th>
                    <td colspan="3">
                       <input type="text" name="stepAmountCustom" value="<% =Model.StepAmount.ToMoneyString() %>" class="w150 ui-float" data-vtype="money" data-vmsg="请输入正确的金额" /> 元                         
                    </td>
                </tr>
                <tr id="trByStep"<% =Model.ByStep ? string.Empty : " style='display:none;'" %>>
                    <th>增长基数</th>
                    <td colspan="3">
                        <span class="ui-radio"><label><input type="radio" name="stepAmountFast" value="5" onclick="$('#stepAmountStep').val($(this).val()).parent().hide();" />5 元</label></span>
                        <span class="ui-radio"><label><input type="radio" name="stepAmountFast" value="10" onclick="$('#stepAmountStep').val($(this).val()).parent().hide();" />10 元</label></span>
                        <span class="ui-radio"><label><input type="radio" name="stepAmountFast" value="20" onclick="$('#stepAmountStep').val($(this).val()).parent().hide();" />20 元</label></span>
                        <span class="ui-radio"><label><input type="radio" name="stepAmountFast" value="50" onclick="$('#stepAmountStep').val($(this).val()).parent().hide();" />50 元</label></span>
                        <span class="ui-radio"><label><input type="radio" name="stepAmountFast" value="100" onclick="$('#stepAmountStep').val($(this).val()).parent().hide();" />100 元</label></span>
                        <span class="ui-radio"><label><input type="radio" name="stepAmountFast" value="" onclick="$('#stepAmountStep').val($(this).val()).parent().show();" />自定义</label></span>
                        <span><input type="text" name="stepAmountStep" id="stepAmountStep" value="<% =Model.StepAmount.ToMoneyString() %>" class="w100 ui-float" data-vtype="money" data-vmsg="请输入正确的金额" /> 元</span>
                    </td>
                </tr>
                <tr>
                    <th>保证金比例</th>
                    <td colspan="3"><input type="text" name="marginRatio" class="w100 ui-interest" data-vtype="money|range" data-vmax="100" data-vmsg="请输入正确的比例值|比例需在0%-100%之间" value="<%= (Model.MarginRatio * 100).RoundX().ToInterestString() %>" /> <span class="ui-autoculation js-autoculation">%</span><em>此为借款保证金参考值</em></td>
                </tr>
                <tr>
                    <th class="info-listhead" colspan="4">借款时间及利率</th>
                </tr>
                <tr>
                    <th>计息周期</th>
                    <td colspan="3">
                        <div class="ui-radio interestStartType"><ruson:EnumInput runat="server" ID="interestStartType" Type="Radio" TypeName="WAP2P.Sys.BorrowType+InterestStartTypeEnum, WAP2P.Sys"></ruson:EnumInput></div>
                    </td>
                </tr>
                <tr>
                    <th>计息周期计算方式</th>
                    <td>
                        <div class="ui-radio"><ruson:EnumInput runat="server" ID="interestType" Type="Radio" TypeName="WAP2P.Sys.BorrowType+InterestTypeEnum, WAP2P.Sys"></ruson:EnumInput></div>
                    </td>
                    <th>投标立即到账</th>
                    <td>
                        <div class="ui-checkbox"><% =HtmlHelper.CheckBox("bidPushAccount", "投标立即到账", Model.BidPushAccount) %></div>
                    </td>
                </tr>
                <tr>
                    <th>借款期限</th>
                    <td colspan="3">
                        <asp:Repeater runat="server" ID="rptLoanTimes">
                            <ItemTemplate>
                                <div class="pt5">
                                    <span class="ui-checkbox autonext"><%# HtmlHelper.CheckBox("loanTime_unit_" + Eval("Key") , string.Format("允许按{0}借款", Eval("Value")), Model.LoanTime.FirstOrDefault(item => item.Unit == (WAP2P.Sys.BorrowType.LoanTimeUnit)Eval("Key")) != null) %></span>
                                    <span class="pl50">最小期限 <input type="text" name="loanTime_min_<%# Eval("Key") %>" class="w100 ui-int" data-vtype="number" data-vmsg="请输入最小期限" value="<%# (Model.LoanTime.FirstOrDefault(item => item.Unit == (WAP2P.Sys.BorrowType.LoanTimeUnit)Eval("Key")) ?? new WAP2P.Sys.BorrowType.LoanTimeInfo()).Min %>" /> <%# Eval("Value") %></span>
                                    <span class="pl50">最大期限 <input type="text" name="loanTime_max_<%# Eval("Key") %>" class="w100 ui-int" data-vtype="number" data-vmsg="请输入最大期限" value="<%# (Model.LoanTime.FirstOrDefault(item => item.Unit == (WAP2P.Sys.BorrowType.LoanTimeUnit)Eval("Key")) ?? new WAP2P.Sys.BorrowType.LoanTimeInfo()).Max %>" /> <%# Eval("Value") %></span>
                                </div>
                            </ItemTemplate>
                        </asp:Repeater>                        
                    </td>
                </tr>
                <tr>
                    <th>最大投标期限</th>
                    <td colspan="3"><input type="text" name="maxBidDay" class="w60 ui-int" data-vtype="number" data-vmsg="请输入正确的数值" value="<%= Model.MaxBidDay %>" /> 天</td>
                </tr>                             
                <tr>
                    <th>利率区间选择</th>
                    <td colspan="3">
                        <div id="interestArea" class="js-autoInterestShow">
                            <div>
                                <span class="ui-radio"><label><input type="radio" name="useFiexdInterest" value="1"<% =Model.MinInterest == Model.MaxInterest ? " checked=\"checked\"" : string.Empty %> />使用固定利率</label></span>
                                <span class="pl50 g-hide">固定年化率 <input type="text" name="fiexdInterest" class="w100 ui-interest" data-vtype="money|range" data-vmax="100" data-vmsg="请输入正确的利率|利率需在0%-100%之间" value="<%= (Model.MinInterest * 100).RoundX().ToInterestString() %>" /> %</span>
                                <span>(执行月利率约为<span class="js-ratem fcred-3"></span>，执行日利率约为<span class="js-rated fcred-3"></span>)</span>
                            </div>
                            <div class="pt10">
                                <span class="ui-radio"><label><input type="radio" name="useFiexdInterest" value="0"<% =Model.MinInterest == Model.MaxInterest ? string.Empty : " checked=\"checked\"" %> />使用区间利率</label></span>
                                <span class="pl50 g-hide">
                                    <div class="pt15 pl5">
                                        <span>最小年化率 <input type="text" name="minInterest" class="w100 ui-interest" data-vtype="money|range" data-vmax="100" data-vmsg="请输入正确的利率|利率需在0%-100%之间" value="<%= (Model.MinInterest * 100).RoundX().ToInterestString() %>" /> %</span>
                                        <span class="pl10">(执行月利率约为<span class="js-ratem fcred-3"></span>，执行日利率约为<span class="js-rated fcred-3"></span>)</span>
                                    </div>
                                    <div class="pt10 pl5">
                                        <span>最大年化率 <input type="text" name="maxInterest" class="w100 ui-interest" data-vtype="money|range" data-vmax="100" data-vmsg="请输入正确的利率|利率需在0%-100%之间" value="<%= (Model.MaxInterest * 100).RoundX().ToInterestString() %>" /> %</span>
                                        <span class="pl10">(执行月利率约为<span class="js-ratem fcred-3"></span>，执行日利率约为<span class="js-rated fcred-3"></span>)</span>
                                    </div>
                                    <div class="pt10 pl5">
                                        <span>最大区间数 <input type="text" name="interestPeriod" class="w100 ui-int" data-vtype="number" data-vmsg="请输入最大区间数" value="<%= IsNew ? 1: Model.InterestPeriod %>" /></span>
                                    </div>
                                </span>
                            </div>
                        </div>                        
                    </td>
                </tr>
                <tr>
                    <th>逾期最大免息天数</th>
                    <td colspan="3">
                        <input type="text" name="overdueInDay" class="w100 ui-int" value="<%= Model.OverdueInDay %>" data-vtype="number" data-vmsg="请输入正确的天数" /> 天
                        <em>填写后将允许该借款在期间内执行免息期逾期利率</em>
                    </td>
                </tr>
                <tr>
                    <th>免息期内逾期日利率</th>
                    <td>
                        <span><input type="text" name="overdueInRate" class="w100 ui-interest" value="<%= (Model.OverdueInRate * 10000).RoundX(3).ToInterestString() %>" data-vtype="money" data-vmsg="请输入正确的利率" /><span class="ui-autoculation js-autoculation">‱</span></span>                                                
                    </td>
                    <th>免息期外逾期日利率</th>
                    <td>
                        <span><input type="text" name="overdueOutRate" class="w100 ui-interest" value="<%= (Model.OverdueOutRate  * 10000).RoundX(3).ToInterestString() %>" data-vtype="money" data-vmsg="请输入正确的利率" /><span class="ui-autoculation js-autoculation">‱</span></span>
                    </td>
                </tr>                
                <tr>
                    <th class="info-listhead" colspan="4">借款人条件设置</th>
                </tr>
                <tr>
                    <th>借款时需信用等级</th>
                    <td><ruson:Select runat="server" ID="creditLevelId"></ruson:Select></td>
                    <th>风险用户限制</th>
                    <td><ruson:Select runat="server" ID="gradeLevel" TipsText="不限制"></ruson:Select></td>
                </tr>
                <tr>
                    <th>现场认证限制</th>
                    <td colspan="3"><% =HtmlHelper.CheckBox("onsiteValid", "需通过现场认证", Model.OnsiteValid) %></td>
                </tr> 
                <tr>
                    <th>借款时额度参考值</th>
                    <td colspan="3">
                        <ul id="checkQuotaType">
                            <asp:Repeater runat="server" ID="rptCheckQuotaType">
                                <ItemTemplate>
                                    <li class="pt10">
                                        <div class="ui-radio"><label><input type="radio" name="checkQuotaType" value="<%# Eval("Key") %>"<%# Model.CheckQuotaType == (BorrowType.CheckQuotaTypeEnum)Eval("Key") ? " checked=\"checked\"" : string.Empty %> /> <%# Eval("Value") %></label></div>
                                        <%# (BorrowType.CheckQuotaTypeEnum)Eval("Key") == BorrowType.CheckQuotaTypeEnum.PayAndReceive ? string.Format(@"
                                            <div class=""g-hide pt20"">
                                                <p>待收金额执行比例：<input type=""text"" class=""ui-interest w100"" name=""checkWaitReceive"" value=""{0}"" data-vtype=""money|range"" data-vmax=""100"" data-vmsg=""请输入正确的比例|比例需在0%-100%之间"" /> %</p>
                                                <p class=""pt10"">待付金额执行比例：<input type=""text"" class=""ui-interest w100"" name=""checkWaitRepayment"" value=""{1}"" data-vtype=""money|range"" data-vmax=""100"" data-vmsg=""请输入正确的比例|比例需在0%-100%之间"" /> %</p>
                                                <em>借款额度=（待收金额*待收金额执行比例）-（待付金额*待付金额执行比例）</em>
                                            </div>", (Model.CheckWaitReceive * 100).RoundX().ToInterestString(), (Model.CheckWaitRepayment * 100).RoundX().ToInterestString()) : string.Empty
                                        %>
                                    </li>
                                </ItemTemplate>
                            </asp:Repeater>                            
                        </ul>
                    </td>
                </tr>
                <tr>
                    <th>借款时验证借款资料</th>
                    <td colspan="3">
                        <div class="ui-checkbox">
                            <input type="checkbox" name="validInfoTypeIds" value="" checked="checked" style="display:none;" />
                             <asp:Repeater runat="server" ID="rptBorrowInfoType" ItemType="WAP2P.Sys.BorrowInfoType">
                                <ItemTemplate>                                
                                    <label><input type="checkbox" name="validInfoTypeIds" value="<%# Item.Id %>"<%# Model.ValidInfoTypeIds != null && Model.ValidInfoTypeIds.Contains("|" + Item.Id + "|") ? " checked=\"checked\"" : string.Empty %> /> <%# Item.Name %></label>
                                </ItemTemplate>
                            </asp:Repeater>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>借款合同模板</th>
                    <td colspan="3"><script id="borrowAgreement" name="borrowAgreement" class="ui-editor" type="text/plain"><%= Model.BorrowAgreement %></script></td>
                </tr>
                <tr>
                    <th class="info-listhead" colspan="4">债权转让设置</th>
                </tr>
                <tr>
                    <th>是否可债权转让</th>
                    <td colspan="3"><% =HtmlHelper.CheckBox("canTransfer", "允许", Model.CanTransfer) %></td>
                </tr>
                <tr>
                    <th>债权最少持有天数</th>
                    <td colspan="3"><input type="text" name="transferMinHoldDay" class="w60 ui-int" data-vtype="number" data-vmsg="请输入正确的数值" value="<%= Model.TransferMinHoldDay %>" /> 天</td>
                </tr>
                <tr>
                    <th>债权最少转让本金</th>
                    <td colspan="3"><input type="text" name="transferMinAmount" class="w100 ui-float" data-vtype="money" data-vmsg="请输入正确的金额" value="<%= Model.TransferMinAmount.ToMoneyString() %>" /> 元</td>
                </tr>
                <tr>
                    <th>债权最少转让期数</th>
                    <td colspan="3"><input type="text" name="transferMinPeriod" class="w60 ui-int" data-vtype="number" data-vmsg="请输入正确的数值" value="<%= Model.TransferMinPeriod %>" /></td>
                </tr>
                <tr>
                    <th>允许拆分转让</th>
                    <td colspan="3"><% =HtmlHelper.CheckBox("transferCanSplit", "允许拆多次出售债权", Model.TransferCanSplit) %></td>
                </tr>
                <tr>
                    <th>允许多人购买</th>
                    <td colspan="3"><% =HtmlHelper.CheckBox("transferCanMultiBuyer", "允许多人购买债权", Model.TransferCanMultiBuyer) %></td>
                </tr>
                <tr>
                    <th>转让允许上浮的百分比</th>
                    <td colspan="3"><input type="text" name="transferUpRate" class="w100 ui-interest" value="<%= (Model.TransferUpRate * 100).RoundX().ToInterestString() %>" data-vtype="money|range" data-vmust-src="false" data-vmax="100" data-vmsg="请输入正确的百分比|百分比需在0%-100%之间" /> %</td>
                </tr>
                <tr>
                    <th>转让允许下浮的百分比</th>
                    <td colspan="3"><input type="text" name="transferDownRate" class="w100 ui-interest" value="<%= (Model.TransferDownRate * 100).RoundX().ToInterestString() %>" data-vtype="money|range" data-vmust-src="false" data-vmax="100" data-vmsg="请输入正确的百分比|百分比需在0%-100%之间" /> %</td>
                </tr> 
                <tr>
                    <th>债权合同模板</th>
                    <td colspan="3"><script id="transferAgreement" name="transferAgreement" class="ui-editor" type="text/plain"><%= Model.TransferAgreement %></script></td>
                </tr>  
            </table>
        </div>
    </form>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="server">
    <script src="<% =this.ImportJsCss("../res/ueditor/ueditor.config.js") %>"></script>
    <script src="<% =this.ImportJsCss("../res/ueditor/ueditor.all.min.js") %>"></script>
    <script>
        function setSaveJson()
        {
            var kv = [];
            $('#js-repayment :checked').each(function(i, n) {
                n = $(n), v = parseFloat(n.closest('span').next().find('input').val().replace(/,/g, ''));
                kv.push('"' + n.val() + '"' + ':' + (isNaN(v) ? 0 : finance.roundx(v / 100, 4)));
            });
            $('#repaymentJson').val('{' + kv.join(',') + '}');
        };

        //开关切换
        function toggleNext(dom, show) {
            var els = $(dom).nextAll();

            if (show) {
                els.show();
                els.find(':input').attr('data-vmust', 'true');
            }
            else {
                els.hide();
                els.find(':input').attr('data-vmust', 'false');
            }
        };        

        $('.autonext').each(function (i, n) {
            toggleNext(n, $(n).find(':checkbox').first()[0].checked);
        }).click(function () {
            toggleNext(this, $(this).find(':checkbox').first()[0].checked);
        });

        //提前还款
        var advanceRepayChange = function() {
            if ($('#supportAdvanceRepayment')[0].checked)
                $('#js-advanceRepay').show();
            else
                $('#js-advanceRepay').hide();
        };
        advanceRepayChange();
        $('#supportAdvanceRepayment').click(advanceRepayChange);

        //额度
        var checkQuotaType = $('#checkQuotaType :radio');
        var checkQuotaTypeChange = function() {
            var checked = checkQuotaType.filter(':checked');
            checked.closest('div').nextAll().show().find(':input').attr('data-vmust', 'true');
            checkQuotaType.not(checked).closest('div').nextAll().hide().find(':input').attr('data-vmust', 'false');
        };
        checkQuotaTypeChange();
        checkQuotaType.click(checkQuotaTypeChange);

        //利率
        var intersetReset = function(dom) {            
            dom = $(dom);
            var val = parseFloat(dom.val()), ctr = dom.closest('span').next();            
            ctr.find('.js-ratem').html(finance.yearRateTo(val, 'm'));
            ctr.find('.js-rated').html(finance.yearRateTo(val, 'd'));
        };
        $('.js-autoInterestShow .ui-interest').each(function(i, n) {
            intersetReset(n);
        }).keyup(function() {
            intersetReset(this);
        })

        var interestRadio = $('#interestArea :radio');
        var interestRadioChange = function() {
            var checked = interestRadio.filter(':checked');
            checked.closest('span').nextAll().show().find(':input').attr('data-vmust', 'true');
            interestRadio.not(checked).closest('span').nextAll().hide().find(':input').attr('data-vmust', 'false');
        };
        interestRadioChange();
        interestRadio.click(interestRadioChange);

        //债权转让
        var canTransfer = $('#canTransfer');
        var canTransferChange = function() {
            if (canTransfer[0].checked) {
                canTransfer.closest('tr').nextAll().show().find(':input').each(function(i, n) {
                    n = $(n);
                    n.attr('data-vmust', n.attr('data-vmust-src') == 'false' ? 'false' : 'true');
                });
            } else {
                canTransfer.closest('tr').nextAll().hide().find(':input').attr('data-vmust', 'false');
            }
        };
        canTransferChange();
        canTransfer.click(canTransferChange);

        //增长基数
        $('#trByStep :radio').each(function(i, n) {
            n = $(n);
            if (n.val()) {
                if (parseInt(n.val()) == <% =Model.StepAmount.ToJsString() %>) {
                    n.trigger('click');
                    return false;
                }                
            } else {
                n.val('<% =Model.StepAmount.ToMoneyString() %>').trigger('click');
                return false;
            }
        });

        //图标、封面 
        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=60&height=18',
                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);
                    }
                }
            }); 

            $('#coverFile').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) {
                        $('#cover').val(d.Message).trigger('blur');
                        $('#coverResult').html('<img src="' + d.Message + '" />');
                    } else {
                        $.jError(d.Message);
                    }
                }
            }); 
        }, 10);
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="list" runat="server">
</asp:Content>
