Files
zszq-trs/YLErpWeb/Views/Client_Rating/Edit.cshtml
T
2024-05-09 14:06:26 +08:00

251 lines
8.7 KiB
Plaintext

@model ClientRating
@{
ViewBag.Title = "客户评级 | 编辑";
Layout = "~/Views/Shared/_InfoLayout.cshtml";
}
@section CSS{
}
@section JS
{
<script type="text/javascript">
$(function () {
SetAceDropDown(false);
$(".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 ("@ViewBag.IsAdd" == "True") {
chaneOpt();
}
else {
//如果是修改,并且在编辑第二条记录。则禁止再次编辑已通过验证的日期范围。
@*if ("@ViewBag.CanEditDateRange"=="False") {
$("#RatingDeadLine").prop("disabled", true);
$("#RatingStartDate").prop("disabled", true);
}*@
}
});
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");
$(".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 changeCredit() {
var CreditVal = $("#Credit").val();
var CreditValue = $("#CreditVal").val();
if (CreditVal != CreditValue) {
// main.message("评级额度已经被修改");
}
}
function checkSubmitData() {
var pass = $('#creditEditForm').valid();
return pass;
}
function saveclientratinginner()
{
var data = $("#creditEditForm").local_serialize();
main.post("/client_rating/EditJson", data).done(function (res) {
window.parent.showmiddlemessage("成功更新本条数据");
window.location.href = "/client_rating/Detail?enid=" + res.obj.EncryptId;
try {
window.parent.reloadcredit();
} catch (e) {
}
});
}
function saveclientrating() {
if (!checkSubmitData()) {
return false;
}
var postData = { ClientId: $("#ClientId").val() };
main.post("/client/GetClientStatus/", postData).done(function (res) {
//如果是已销户客户
if (res.obj == "已销户") {
main.confirm("该客户为“已销户”客户,确认保存该客户资信?", function () {
saveclientratinginner();
});
}
else {
saveclientratinginner();
}
});
}
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 changeForm(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 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);
changeForm(money + "");
}
function moneyOnFocus() {
var moneyStr = $("#Credit").val().replace(/,/g, "");
$("#Credit").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, "元");
}
$.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("Edit", "client_rating", 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 (ViewBag.IsAdd)
{
@Html.MyDropdownFor(model => model.ClientId, ClientDataModel.GetAllOpenClient(true), "", false)
}
else
{
<div class="form-group col-md-6">
<label class="formlabel" for="ClientName">客户名称</label>
@Html.HiddenFor(model => model.ClientId)
<label class="client-title" style="display:initial;">@Html.DisplayFor(model => model.ClientName)</label>
</div>
}
@Html.MyDropdownFor(m => m.CreditRatingId, credit_ratingController.GetValidcredit_rating(), new { }, "", false, true, false)
@Html.MyDateFor(model => model.RatingStartDate, true)
@Html.MyDateFor(model => model.RatingDeadLine, true)
@if (PS.Config.Is浙期)
{
@Html.MyTextFor(model => model.RatingAccording, false)
@Html.MyTextFor(model => model.RatingPersonnel, false)
@Html.MyTextFor(model => model.CheckPersonnel, false)
}
@Html.MyTextAreaFor(model => model.Comments, 3, new { maxlength = 50 })
</div>
<div class="form-buttons">
@MyControls.Btn("保存", "saveclientrating()")
@MyControls.Btn("关闭", "closecreditWindow()")
</div>
}