로그인화면에 기관,사용자아이디 저장 기능 추가

main
이범준 5 months ago
parent 30853541ff
commit fd5c5de8af

@ -31,7 +31,10 @@ public class MainController extends cokr.xit.base.web.MainController {
@Override @Override
public ModelAndView loginPage() { public ModelAndView loginPage() {
return new ModelAndView("login"); ModelAndView mav = new ModelAndView("login");
List<DataObject> instList = fimsOgdpBean.selectAllInstList();
mav.addObject("instList", instList);
return mav;
} }
@Override @Override

@ -54,8 +54,14 @@
<form id="formAuthentication" method="post"> <form id="formAuthentication" method="post">
<div class="input_wrap"> <div class="input_wrap">
<div class="input-group"> <div class="input-group">
<select id="institute" name="institute" class="form-select mb-2 h-px-40 no-max-w"> <select id="institute" name="institute" required title="기관명" class="form-select mb-2 h-px-40 no-max-w">
<option value="default">기본</option> <option value="">[기관 선택]</option>
<option value="default">시스템관리</option>
<c:forEach items="${instList}" var="item">
<option value="${item.INST_CD}"
<c:if test="${item.USER_USE_YN == 'N'}"> disabled </c:if>
>${item.INST_NM}</option>
</c:forEach>
</select> </select>
</div> </div>
<div class="input-group"> <div class="input-group">
@ -67,6 +73,10 @@
required title="비밀번호 입력" class="typePassword required form-control inp-long" placeholder="비밀번호" autocomplete="false" /> required title="비밀번호 입력" class="typePassword required form-control inp-long" placeholder="비밀번호" autocomplete="false" />
<span class="input-group-text cursor-pointer"><i class="bx bxs-lock"></i></span> <span class="input-group-text cursor-pointer"><i class="bx bxs-lock"></i></span>
</div> </div>
<div class="mt-3 form-chcek">
<input id="remember" type="checkbox" class="form-check-input">
<label class="form-check-label">로그인 정보 유지</label>
</div>
<div class="input_wrap2"> <div class="input_wrap2">
<!-- <!--
<a href="#" onclick="javascript:fn_FindId(); return false;">아이디 찾기</a> <a href="#" onclick="javascript:fn_FindId(); return false;">아이디 찾기</a>
@ -88,24 +98,26 @@
<template id="selectInstDialogTemplate"> <template id="selectInstDialogTemplate">
<select class="form-select form-control-sm" id="selectInst"> <select class="form-select form-control-sm" id="selectInst">
<option value="">선택</option> <option value="">선택</option>
<c:forEach items="${instList}" var="item">
<option value="${item.INST_CD}">${item.INST_NM}</option>
</c:forEach>
</select> </select>
</template> </template>
<jsp:include page="/WEB-INF/jsp/include/tail.jsp" /> <jsp:include page="/WEB-INF/jsp/include/tail.jsp" />
<script type="text/javascript"> <script type="text/javascript">
var INST_LIST = [];
${functions} ${functions}
function login() { function login() {
if (!$("#formAuthentication input").validInputs()) return; if (!$("#formAuthentication input,select").validInputs()) return;
var params = { var params = {
account:$("#userId").val(), account:$("#userId").val(),
password:$("#password").val(), password:$("#password").val(),
institute:$("#institute").val() institute:$("#institute").val(),
<%--, rememberCredentials:true--%> rememberCredentials: $("#remember").prop("checked")
}; };
json.post({ json.post({
@ -154,11 +166,6 @@ function fnOpenSignup(){
content : document.getElementById("selectInstDialogTemplate").innerHTML, content : document.getElementById("selectInstDialogTemplate").innerHTML,
size : "sm", size : "sm",
init : () => { init : () => {
var options = "";
for(var i=0; i < INST_LIST.length; i++){
options += "<option value='"+INST_LIST[i].INST_CD+"'>"+INST_LIST[i].INST_NM+"</option>";
}
$("#selectInst").append(options);
}, },
onOK : () => { onOK : () => {
if($("#selectInst").val() == ""){ if($("#selectInst").val() == ""){
@ -205,24 +212,35 @@ function fn_FindPw(){
$(function(){ $(function(){
$("#formAuthentication input").onEnterPress(login); $("#formAuthentication input").onEnterPress(login);
if ($("#userId").val())
$("#password").focus();
ajax.get({
url : wctx.url("/instList.do"),
data : { },
success : (resp) => {
INST_LIST = resp.instList;
var options = "";
for(var i=0; i < INST_LIST.length; i++){
options += "<option value='"+INST_LIST[i].INST_CD+"'>"+INST_LIST[i].INST_NM+"</option>";
}
$("#institute").append(options);
$("#institute").val(<%= systemInst %>); let sysInst = "<%= systemInst %>";
let cookieInst = "${cookie['userInstitute'].getValue()}";
let cookieUserId = "${cookie['userAccount'].getValue()}";
let hasCookie = (cookieInst != "" && cookieUserId != "");
let selectValue = "";
let isSelectable = false;
if(hasCookie){
selectValue = cookieInst;
isSelectable = $("#institute option[value='"+selectValue+"']").not("[disabled]").length;
if(isSelectable){
$("#institute").val(cookieInst);
$("#userId").val(cookieUserId);
$("#remember").prop("checked", true);
$("#password").focus();
return;
} }
}); }
selectValue = sysInst;
isSelectable = $("#institute option[value='"+selectValue+"']").not("[disabled]").length;
if(isSelectable){
$("#institute").val(selectValue);
$("#userId").focus();
} else {
$("#institute").focus();
}
}); });
</script> </script>

Loading…
Cancel
Save