503 lines
20 KiB
Plaintext
503 lines
20 KiB
Plaintext
@model CreditTable
|
|
@{
|
|
ViewBag.Title = "授信 | 编辑";
|
|
Layout = "~/Views/Shared/_InfoLayout.cshtml";
|
|
var pageObj = new
|
|
{
|
|
UseClientStockEqvNotional = PS.Config.ErpElement.UseClientStockEqvNotional
|
|
};
|
|
}
|
|
@section CSS{
|
|
<style>
|
|
.form-layout .formlabel {
|
|
width:140px;
|
|
}
|
|
</style>
|
|
|
|
}
|
|
@section JS
|
|
{
|
|
<script type="text/javascript">
|
|
var page = @Json.Serialize(pageObj);
|
|
$(function () {
|
|
SetAceDropDown(false);
|
|
if (!page.UseClientStockEqvNotional) {
|
|
$("input[id*='StockEqvNotional']").parent(".form-group").hide();
|
|
}
|
|
if ("@ViewBag.IsVariety" == "False") {
|
|
$("#hidDiv1").addClass('hide');
|
|
$("#hidDiv2").addClass('hide');
|
|
$("#hidDiv3").addClass('hide');
|
|
}
|
|
if ("@ViewBag.IsVariety" == "") {
|
|
$("#hidDiv1").addClass('hide');
|
|
$("#hidDiv2").addClass('hide');
|
|
$("#hidDiv3").addClass('hide');
|
|
}
|
|
$(".datepicker").datepicker({
|
|
changeMonth: true,
|
|
changeYear: true,
|
|
showButtonPanel: true,
|
|
showOtherMonths: true,
|
|
selectOtherMonths: true
|
|
});
|
|
|
|
$(".search-choice-close").click(function () {
|
|
$("#IsAll").prop("checked",false);
|
|
$("#IsAll").val(false);
|
|
});
|
|
|
|
if ("@(Model.id)" == "0") {
|
|
chaneOpt();
|
|
}
|
|
|
|
$("#Credit").blur(function () {
|
|
changeCredit();
|
|
});
|
|
|
|
var moneytemp = $("#CreditVal").val();
|
|
if (moneytemp != null && moneytemp != undefined) {
|
|
changeFormCredit(Number(moneytemp).toFixed(2) + "");
|
|
}
|
|
|
|
//授信可用比例默认填1;授信额度置灰,按 原始授信值×最大授信可用比例 联动计算
|
|
if (!$("#MaxCreditUseRatio").val()) {
|
|
$("#MaxCreditUseRatio").val("1");
|
|
}
|
|
$("#OriginalCredit").on("input change", calcCreditByRatio);
|
|
$("#MaxCreditUseRatio").on("input change", calcCreditByRatio);
|
|
calcCreditByRatio();
|
|
|
|
//$('#Credit').keyup(function () {
|
|
// changePrice();
|
|
//});
|
|
|
|
$("#CreditDeadLine").next().addClass("errorSpan");
|
|
$("#CreditStartDate").next().addClass("errorSpan");
|
|
});
|
|
|
|
function setAllTradeType(obj) {
|
|
var checkall = $(obj).prop("checked");
|
|
$(obj).val(checkall);
|
|
}
|
|
|
|
function selallVariety(obj) {
|
|
var checkall = $(obj).prop("checked");
|
|
$(obj).val(checkall);
|
|
$("#VarietyId option").each(function(i, d) {
|
|
if (checkall)
|
|
$(d).prop("selected", true);
|
|
else
|
|
$(d).prop("selected",false);
|
|
});
|
|
$("#VarietyId").trigger("chosen:updated");
|
|
|
|
$("#VarietyId_chosen").find(".search-choice-close").click(function () {
|
|
$("#IsAll").prop("checked",false);
|
|
$("#IsAll").val(false);
|
|
});
|
|
}
|
|
|
|
function chaneOpt() {
|
|
var qualificationRating = $("#QualificationRating option:selected").text();
|
|
if (qualificationRating=="A") {
|
|
$("#Credit").val("2000000");
|
|
$("#CreditVal").val(2000000);
|
|
}
|
|
if (qualificationRating == "B") {
|
|
$("#Credit").val("2000000");
|
|
$("#CreditVal").val("2000000");
|
|
}
|
|
if (qualificationRating == "C") {
|
|
$("#Credit").val("0");
|
|
$("#CreditVal").val("0");
|
|
}
|
|
|
|
}
|
|
|
|
function selectVariety(obj) {
|
|
var check = $(obj).prop("checked");
|
|
$(obj).val(check);
|
|
if (check) {
|
|
$("#hidDiv1").removeClass('hide');
|
|
$("#hidDiv2").removeClass('hide');
|
|
$("#hidDiv3").removeClass('hide');
|
|
}
|
|
else {
|
|
$("#hidDiv1").addClass('hide');
|
|
$("#hidDiv2").addClass('hide');
|
|
$("#hidDiv3").addClass('hide');
|
|
}
|
|
$(".search-choice-close").click(function () {
|
|
$("#IsVariety").prop("checked",false);
|
|
$("#IsVariety").val(false);
|
|
});
|
|
}
|
|
|
|
function changeCredit() {
|
|
var CreditVal = $("#Credit").val();
|
|
var CreditValue = $("#CreditVal").val();
|
|
if (CreditVal != CreditValue) {
|
|
// main.message("授信额度已经被修改");
|
|
}
|
|
}
|
|
|
|
//授信额度 = 原始授信值 × 最大授信可用比例(空白按1);原始授信值为空时不折算,保留原授信额度
|
|
function calcCreditByRatio() {
|
|
var original = $("#OriginalCredit").val();
|
|
if (original == null || original == "") {
|
|
return;
|
|
}
|
|
var ratio = $("#MaxCreditUseRatio").val();
|
|
var money = (Number(original.replace(/,/g, "")) * (ratio == "" ? 1 : Number(ratio))).toFixed(2);
|
|
$("#Credit").val(money);
|
|
$("#CreditVal").val(money);
|
|
changeFormCredit(money);
|
|
}
|
|
|
|
function checkSubmitData() {
|
|
var pass = $('#creditEditForm').valid();
|
|
if (pass) {
|
|
if (page.UseClientStockEqvNotional) {
|
|
if ((!$("#Credit").val() && !$("#StockEqvNotional").val())) {
|
|
main.alert("名义本金规模和授信额度应至少填一项");
|
|
return false;
|
|
}
|
|
}
|
|
var ratio = $("#MaxCreditUseRatio").val();
|
|
if (ratio && (Number(ratio) < 0 || Number(ratio) > 1)) {
|
|
main.alert("最大授信可用比例取值范围为0-1");
|
|
return false;
|
|
}
|
|
}
|
|
return pass;
|
|
}
|
|
|
|
function savecreditinner() {
|
|
var data = $("#creditEditForm").local_serialize();
|
|
main.post("/credit/creditEditJson", data).done(function (res) {
|
|
window.parent.showmiddlemessage("成功更新本条数据");
|
|
window.location.href = "/credit/creditview?enid=" + res.obj.EncryptId;
|
|
try {
|
|
window.parent.reloadcredit();
|
|
} catch (e) {
|
|
}
|
|
});
|
|
}
|
|
|
|
function savecredit() {
|
|
if (!checkSubmitData()) {
|
|
return false;
|
|
}
|
|
|
|
var postData = { ClientId: $("#ClientId").val() };
|
|
main.post("/client/GetClientStatus/", postData).done(function (res) {
|
|
//如果是已销户客户
|
|
if (res.obj == "已销户") {
|
|
main.confirm("该客户为“已销户”客户,确认为该客户授信?", function () {
|
|
savecreditinner();
|
|
});
|
|
}
|
|
else {
|
|
savecreditinner();
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function closecreditWindow() {
|
|
try {
|
|
window.parent.layer.closeAll();
|
|
} catch (e) {
|
|
}
|
|
try {
|
|
window.parent.$('#modal-editcredit .close').click();
|
|
} catch (e) {
|
|
}
|
|
try {
|
|
window.parent.$('#modal-creditEditInner .close').click();
|
|
} catch (e) {
|
|
}
|
|
try {
|
|
if (window.parent.location.href.indexOf("creditEdit") >= 0) {
|
|
window.close();
|
|
}
|
|
} catch (e) {
|
|
}
|
|
}
|
|
|
|
//转换成财务计数
|
|
function cc(s) {
|
|
if (/[^0-9\.]/.test(s)) return "invalid value";
|
|
s = s.replace(/^(\d*)$/, "$1.");
|
|
s = (s + "00").replace(/(\d*\.\d\d)\d*/, "$1");
|
|
s = s.replace(".", ",");
|
|
var re = /(\d)(\d{3},)/;
|
|
while (re.test(s))
|
|
s = s.replace(re, "$1,$2");
|
|
s = s.replace(/,(\d\d)$/, ".$1");
|
|
|
|
return s.replace(/^\./, "0.")
|
|
}
|
|
|
|
|
|
function changeFormCredit(s) {
|
|
var arr = s.split(",");
|
|
var newArr = arr.join("");
|
|
//var arr = newArr.split(".");
|
|
$("#CreditVal").val = newArr;
|
|
//var newArr = arr.join("");
|
|
var newArr = toAmountMoney(newArr);
|
|
var $parent = $("#Credit").parent();
|
|
var $chineseSpan = $parent.children("span.chinese");
|
|
if ($chineseSpan.length == 0) {
|
|
$parent.append(`<span class="chinese" >${newArr}</span>`);
|
|
} else {
|
|
$chineseSpan.html(newArr);
|
|
}
|
|
//document.getElementById("moneyForm").innerHTML = newArr;
|
|
}
|
|
|
|
function changePFECredit(s) {
|
|
$("#PFECredit").val($("#PFECredit").val().match(/\d{1,}/) == null ? '' : $("#PFECredit").val().replace(/[^0-9.-]/g, ''));
|
|
var money = Number($("#PFECredit").val()).toFixed(2);
|
|
$("#PFECreditVal").val(money);
|
|
|
|
var arr = s.split(",");
|
|
var newArr = arr.join("");
|
|
$("#PFECreditVal").val = newArr;
|
|
var newArr = toAmountMoney(newArr);
|
|
var $parent = $("#PFECredit").parent();
|
|
var $chineseSpan = $parent.children("span.chinese");
|
|
if ($chineseSpan.length == 0) {
|
|
$parent.append(`<span class="chinese" >${newArr}</span>`);
|
|
} else {
|
|
$chineseSpan.html(newArr);
|
|
}
|
|
}
|
|
|
|
function changeIMCredit(s) {
|
|
$("#IMCredit").val($("#IMCredit").val().match(/\d{1,}/) == null ? '' : $("#IMCredit").val().replace(/[^0-9.-]/g, ''));
|
|
var money = Number($("#IMCredit").val()).toFixed(2);
|
|
$("#IMCreditVal").val(money);
|
|
|
|
var arr = s.split(",");
|
|
var newArr = arr.join("");
|
|
$("#IMCreditVal").val = newArr;
|
|
var newArr = toAmountMoney(newArr);
|
|
var $parent = $("#IMCredit").parent();
|
|
var $chineseSpan = $parent.children("span.chinese");
|
|
if ($chineseSpan.length == 0) {
|
|
$parent.append(`<span class="chinese" >${newArr}</span>`);
|
|
} else {
|
|
$chineseSpan.html(newArr);
|
|
}
|
|
}
|
|
|
|
function changeFormStockEqvNotional(s) {
|
|
var arr = s.split(",");
|
|
var newArr = arr.join("");
|
|
//var arr = newArr.split(".");
|
|
$("#StockEqvNotionalVal").val = newArr;
|
|
//var newArr = arr.join("");
|
|
var newArr = toAmountMoney(newArr);
|
|
var $parent = $("#StockEqvNotional").parent();
|
|
var $chineseSpan = $parent.children("span.chinese");
|
|
if ($chineseSpan.length == 0) {
|
|
$parent.append(`<span class="chinese" >${newArr}</span>`);
|
|
} else {
|
|
$chineseSpan.html(newArr);
|
|
}
|
|
//document.getElementById("moneyForm").innerHTML = newArr;
|
|
}
|
|
|
|
//function changePrice() {
|
|
// $("#Credit").val($("#Credit").val().match(/\d{1,}/) == null ? '' : $("#Credit").val().replace(/[^0-9.-]/g, ''));
|
|
// var money = Number($("#Credit").val()).toFixed(2);
|
|
// $("#CreditVal").val(money);
|
|
// changeFormCredit(money + "");
|
|
//}
|
|
|
|
function changeAuditCredit() {
|
|
$("#AuditCredit").val($("#AuditCredit").val().match(/\d{1,}/) == null ? '' : $("#AuditCredit").val().replace(/[^0-9.-]/g, ''));
|
|
var money = Number($("#AuditCredit").val()).toFixed(2);
|
|
$("#AuditCreditVal").val(money);
|
|
changeFormCredit(money + "");
|
|
}
|
|
|
|
function changeAuditStockEqvNotional() {
|
|
$("#AuditStockEqvNotional").val($("#AuditStockEqvNotional").val().match(/\d{1,}/) == null ? '' : $("#AuditStockEqvNotional").val().replace(/[^0-9.-]/g, ''));
|
|
var money = Number($("#AuditStockEqvNotional").val()).toFixed(2);
|
|
$("#AuditStockEqvNotionalVal").val(money);
|
|
changeFormStockEqvNotional(money + "");
|
|
}
|
|
|
|
function moneyOnFocus() {
|
|
var moneyStr = $("#Credit").val().replace(/,/g, "");
|
|
$("#Credit").val(moneyStr);
|
|
}
|
|
|
|
function pfeCreditOnFocus() {
|
|
var moneyStr = $("#PFECredit").val().replace(/,/g, "");
|
|
$("#PFECredit").val(moneyStr);
|
|
}
|
|
|
|
function imCreditOnFocus() {
|
|
var moneyStr = $("#IMCredit").val().replace(/,/g, "");
|
|
$("#IMCredit").val(moneyStr);
|
|
}
|
|
|
|
function moneyOnFocus2() {
|
|
var moneyStr = $("#AuditCredit").val().replace(/,/g, "");
|
|
$("#AuditCredit").val(moneyStr);
|
|
}
|
|
|
|
function moneyOnFocusStockEqvNotional() {
|
|
var moneyStr = $("#StockEqvNotional").val().replace(/,/g, "");
|
|
$("#StockEqvNotional").val(moneyStr);
|
|
}
|
|
|
|
function moneyOnFocusStockEqvNotional2() {
|
|
var moneyStr = $("#AuditStockEqvNotional").val().replace(/,/g, "");
|
|
$("#AuditStockEqvNotional").val(moneyStr);
|
|
}
|
|
|
|
function moneyOnFocusDeductStockEqvNotional() {
|
|
var moneyStr = $("#DeductStockEqvNotional").val().replace(/,/g, "");
|
|
$("#DeductStockEqvNotional").val(moneyStr);
|
|
}
|
|
|
|
|
|
function moneyOnFocusMarginLimit() {
|
|
var moneyStr = $("#MarginLimit").val().replace(/,/g, "");
|
|
$("#MarginLimit").val(moneyStr);
|
|
}
|
|
|
|
function moneyOnFocusOriginalCredit() {
|
|
var moneyStr = $("#OriginalCredit").val().replace(/,/g, "");
|
|
$("#OriginalCredit").val(moneyStr);
|
|
}
|
|
|
|
//转换为大写金额
|
|
function toAmountMoney(n) {
|
|
|
|
var unit = "千百拾亿千百拾万千百拾元角分", str = "";
|
|
var p = n.indexOf('.');
|
|
if (p >= 0)
|
|
n = n.substring(0, p) + n.substr(p + 1, 2);
|
|
unit = unit.substr(unit.length - n.length);
|
|
for (var i = 0; i < n.length; i++)
|
|
str += '零壹贰叁肆伍陆柒捌玖'.charAt(n.charAt(i)) + unit.charAt(i);
|
|
return str.replace(/零(千|百|拾|角|分)/g, "零").replace(/(零)+/g, "").replace(/零(万|亿|元)/g, "$1").replace(/(亿)万|壹(拾)/g, "$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "元");
|
|
}
|
|
document.getElementById("Credit").addEventListener("input", function (event) {
|
|
event.target.value = event.target.value.replace(/\-/g, "");
|
|
var money = Number($("#Credit").val()).toFixed(2);
|
|
changeFormCredit(money + "");
|
|
});
|
|
document.getElementById("StockEqvNotional").addEventListener("input", function (event) {
|
|
event.target.value = event.target.value.replace(/\-/g, "");
|
|
var money = Number($("#StockEqvNotional").val()).toFixed(2);
|
|
changeFormStockEqvNotional(money + "");
|
|
});
|
|
$.fn.local_serialize = function () {
|
|
var a = this.serializeArray();
|
|
var $radio = $('input[type=radio],input[type=checkbox]', this);
|
|
var temp = {};
|
|
$.each($radio, function () {
|
|
if (!temp.hasOwnProperty(this.name)) {
|
|
if ($("input[name='" + this.name + "']:checked").length == 0) {
|
|
temp[this.name] = "";
|
|
a.push({ name: this.name, value: "" });
|
|
}
|
|
}
|
|
});
|
|
return jQuery.param(a);
|
|
};
|
|
</script>
|
|
}
|
|
|
|
@using (Html.BeginForm("creditEdit", "credit", FormMethod.Post, new { id = "creditEditForm" }))
|
|
{
|
|
<div class="form-layout">
|
|
<input type="hidden" value="@Model.id" name="id" id="id" />
|
|
@Html.HiddenFor(model => model.EncryptId)
|
|
|
|
@if (Model.id == 0)
|
|
{
|
|
@Html.MyDropdownFor(model => model.ClientId, ClientDataModel.GetAllOpenClient(true), "", false)
|
|
}
|
|
else
|
|
{
|
|
<div class="form-group col-md-6" style="width:600px;">
|
|
<label class="formlabel" for="ClientName">客户名称</label>
|
|
<label style="display: inline;" class="client-title">@Html.DisplayFor(model => model.ClientName)</label>
|
|
@Html.HiddenFor(model => model.ClientId)
|
|
</div>
|
|
}
|
|
|
|
@Html.MyDecimalFor(model => model.Credit, new { @readonly = "readonly", style = "background-color:#eee;" }, !pageObj.UseClientStockEqvNotional)
|
|
<input type="hidden" value="@Model.Credit" name="CreditVal" id="CreditVal" />
|
|
@Html.MyDecimalFor(model => model.OriginalCredit, new { onfocus = "moneyOnFocusOriginalCredit()", onblur = "this.value=cc(this.value);" }, required: false)
|
|
@Html.MyDecimalFor(model => model.MaxCreditUseRatio, required: false)
|
|
<span style="color:red">注:授信额度按"原始授信值×最大授信可用比例(默认1)"自动计算,无需填写;原始授信值为空时不折算,保留原授信额度.</span>
|
|
@if (PS.Config.Company == CompanyEnum.中金)
|
|
{
|
|
@Html.MyDecimalFor(model => model.PFECredit, new { onkeyup = "changePFECredit()", onfocus = "pfeCreditOnFocus()", onblur = "this.value=cc(this.value);" }, true)
|
|
<input type="hidden" value="@Model.PFECredit" name="PFECreditVal" id="PFECreditVal" />
|
|
|
|
@Html.MyDecimalFor(model => model.IMCredit, new { onkeyup = "changeIMCredit()", onfocus = "imCreditOnFocus()", onblur = "this.value=cc(this.value);" }, true)
|
|
<input type="hidden" value="@Model.IMCredit" name="IMCreditVal" id="IMCreditVal" />
|
|
|
|
@Html.MyDecimalFor(model => model.DeductStockEqvNotional, new { onfocus = "moneyOnFocusDeductStockEqvNotional()", onblur = "this.value=cc(this.value);" }, true)
|
|
<input type="hidden" value="@Model.DeductStockEqvNotional" name="DeductStockEqvNotionalVal" id="DeductStockEqvNotionalVal" />
|
|
|
|
@Html.MyDecimalFor(model => model.MarginLimit, new { onfocus = "moneyOnFocusMarginLimit()", onblur = "this.value=cc(this.value);" }, true)
|
|
<input type="hidden" value="@Model.MarginLimit" name="MarginLimit" id="MarginLimit" />
|
|
}
|
|
@Html.MyDecimalFor(model => model.StockEqvNotional, new { onfocus = "moneyOnFocusStockEqvNotional()", onblur = "this.value=cc(this.value);" })
|
|
<input type="hidden" value="@Model.StockEqvNotional" name="StockEqvNotionalVal" id="StockEqvNotionalVal" />
|
|
|
|
@Html.MyDecimalFor(model => model.AuditCredit, new { onkeyup = "changeAuditCredit()", onfocus = "moneyOnFocus2()", onblur = "this.value=cc(this.value);" }, required: false)
|
|
<input type="hidden" value="@Model.AuditCredit" name="AuditCreditVal" id="AuditCreditVal" />
|
|
@Html.MyDecimalFor(model => model.AuditStockEqvNotional, new { onkeyup = "changeAuditStockEqvNotional()", onfocus = "moneyOnFocusStockEqvNotional2()", onblur = "this.value=cc(this.value);" }, required: false)
|
|
<input type="hidden" value="@Model.AuditStockEqvNotional" name="AuditStockEqvNotionalVal" id="AuditStockEqvNotionalVal" />
|
|
|
|
|
|
<input type="hidden" value="@CreditTable.ClientType" name="Type" />
|
|
@Html.MyDateFor(model => model.CreditStartDate, true)
|
|
@Html.MyDateFor(model => model.CreditDeadLine, true)
|
|
|
|
@if (PS.Config.ClientElement.CanSelectCreditVariety)
|
|
{
|
|
<div class="form-group col-md-6">
|
|
<label class="formlabel" for="IsVariety">限制交易品种</label>
|
|
<input type="checkbox" id="IsVariety" name="IsVariety" onclick="selectVariety(this)" @((Model.IsVariety == null ? false : Model.IsVariety.Value) ? "value=true" : "value=false") @((Model.IsVariety == null ? false : Model.IsVariety.Value) ? "checked" : "") />
|
|
</div>
|
|
|
|
<div class="form-group col-md-6" id="hidDiv2">
|
|
<label class="formlabel" for="VarietyId">全选品种</label>
|
|
<input type="checkbox" id="IsAll" name="IsAll" @((Model.IsAll == null ? false : Model.IsAll.Value) ? "value=true" : "value=false") @((Model.IsAll == null ? false : Model.IsAll.Value) ? "checked" : "") onclick="selallVariety(this)" />
|
|
</div>
|
|
<div id="hidDiv1">
|
|
@Html.MyDropdownFor(model => model.IsWhitelist, System.Web.Mvc.Html.EnumHelper.GetSelectList(typeof(YLErp.Web.Models.Enum.WhitelistEnum)), new { @id = "" }, "", false)
|
|
</div>
|
|
<div id="hidDiv3">
|
|
@Html.MyAceDropdownFor(model => model.VarietyId, varietyController.GetAllvariety(), "", false)
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
@Html.Hidden("IsWhitelist", 0)
|
|
}
|
|
@Html.MyTextAreaFor(model => model.Comments, 3, new { maxlength = 50 })
|
|
@if(pageObj.UseClientStockEqvNotional){
|
|
<span style="color:red">注:保存时授信额度和名义本金规模应至少填写一项,空白代表不设置.</span>
|
|
}
|
|
</div>
|
|
<div class="form-buttons">
|
|
@MyControls.Btn("保存", "savecredit()")
|
|
@MyControls.Btn("关闭", "closecreditWindow()")
|
|
</div>
|
|
} |