From dbaed7bc121ff38688aa2ea94092e1ea1e754f6f Mon Sep 17 00:00:00 2001 From: p31729568 Date: Mon, 13 May 2019 09:42:08 +0800 Subject: [PATCH] modify reject trial auth modal --- .../_reject_authorization_model.html.erb | 32 ++++++++++++++++--- .../_trial_authorization_passed_list.html.erb | 4 ++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/app/views/managements/_reject_authorization_model.html.erb b/app/views/managements/_reject_authorization_model.html.erb index 4d35359f..6d7468f4 100644 --- a/app/views/managements/_reject_authorization_model.html.erb +++ b/app/views/managements/_reject_authorization_model.html.erb @@ -51,15 +51,15 @@ - +
  • - - + +
  • @@ -79,8 +79,23 @@ var modal = $(".modal.reject-auth-modal"); var form = modal.find("#reject-auth-form"); var applyIdInput = form.find("input[name='apply_id']"); + var rejectDescriptionSpan = form.find(".reject-description-label span"); + var needRejectDescription = false; var error = modal.find(".error"); + modal.on("click", "input[name='reasons[]']", function(){ + var checkbox = $(this); + if (checkbox.data("type") != "other") { return; } + + if (checkbox.prop("checked")) { + needRejectDescription = true; + rejectDescriptionSpan.show(); + } else { + needRejectDescription = false; + rejectDescriptionSpan.hide(); + } + }); + modal.on('click', '.submit-btn', function(){ if (!formValid()) { return; } form.submit(); @@ -88,8 +103,13 @@ var formValid = function () { error.html("").hide(); - if (form.find("input[name='reasons[]']:checked").length == 0 || form.find("textarea[name='reject_description']").val() == '') { - error.html("原因和说明不能为空,请完善后再确认提交").show(); + if (form.find("input[name='reasons[]']:checked").length == 0) { + error.html("撤销原因不能为空,请完善后再确认提交").show(); + return false; + } + + if (needRejectDescription && form.find("textarea[name='reject_description']").val() == '') { + error.html("备注说明不能为空,请完善后再确认提交").show(); return false; } @@ -100,6 +120,8 @@ applyIdInput.val(''); form.find("textarea[name='reject_description']").val(''); form.find("input[name='reasons[]']").each(function(){this.checked=false;}) + needRejectDescription = false; + rejectDescriptionSpan.hide(); modal.hide(); }; // 隐藏弹窗 diff --git a/app/views/managements/_trial_authorization_passed_list.html.erb b/app/views/managements/_trial_authorization_passed_list.html.erb index 6f31ffc6..bfaf91c2 100644 --- a/app/views/managements/_trial_authorization_passed_list.html.erb +++ b/app/views/managements/_trial_authorization_passed_list.html.erb @@ -38,7 +38,9 @@ <% if authorization.status == 2 %>
  • 原因:<%= authorization.reason.blank? ? "空" : authorization.reason %>
  • -
  • 备注说明:<%= authorization.reject_description.blank? ? "空" : authorization.reject_description %>
  • + <% if authorization.reject_description.present? %> +
  • 备注说明:<%= authorization.reject_description %>
  • + <% end %> <% end %>