본문 바로가기

개발관련/국비지원수업

팝업 안에 메모 넣기

728x90

팝업안에 메모 테이블을 만들 공간을 만든다.

함수로 메모 테이블을 가져온다.

//----------------------------------------------메모 테이블 불러오기
 function drawMeMoTable(list) {
var html="";
var no = 0;

html += " <colgroup>";
html += " <col width=\"100px\"/>";
html += " <col width=\"100px\"/>";
html += " <col width=\"50px\"/>";
html += " <col width=\"700px\"/>";
html += " </colgroup>";
html += "   <thead>";
html += "   <tr>";
html += "   <th>번호</th>";
html += "   <th>날짜</th>";
html += "   <th></th>";
html += "   <th>메모내용</th>";
html += "   </tr>";
html += "   </thead>";
html += "   <tbody>";

if(list.length == 0) {
html += "<tr>";
html += "<td colspan=\"5\">등록된 글이 없습니다.</td>";
html += "</tr>";
} else {

for(var d of list){
no++;
html+= " <tr name=\""+  d.MEMO_NO +"\">";
html+= " <td> " + no +"</td>";
html+= " <td>  "+ d.REGISTER_DATE +"</td>";

if(d.MARKING == 0){
html += " <td><img class=\"star_table_img\" id=\"starIconYellow\" alt=\"중요별\" src=\"resources/images/yellow_star_icon.png\"></td>";
} else {
html+= " <td> </td>";
}

html+= " <td>  "+ d.CONTENTS +"</td>";
html+= " </tr>";
}
}
html += " </tbody>";

$(".btm_memo table").html(html);
}

 

//----------------------------------------------메모 상세보기
function showMeMo() {
var params = $("#actionForm").serialize();

$.ajax({
url:"reportMemo",
type:"post",
dataType :"json",
data:params,
success : function (result) {

var html = "";

html += "<div class=\"background8\"></div>";
html += "<div class=\"ctts8\">";
html += " <div class=\"top_div\">";
if(result.memo.MARKING == 0){
html += "<img class=\"star_img\" id=\"starIconYellow\" alt=\"중요별\" src=\"resources/images/yellow_star_icon.png\">";
} else {
html += "<img class=\"star_img\" id=\"starIconBlack\" alt=\"별\" src=\"resources/images/empty_star_icon.png\">";
}
html += " <div class=\"memo_title\">메모</div>";
html += " <img class=\"close_img\" id=\"closeMemo\" alt=\"닫기\" src=\"resources/images/cross.png\">";
html += " </div>";
html += " <div class=\"memo_ctts_div\">";
html += " <form id=\"memoForm\">";
html += " <input type=\"hidden\" name=\"mNo\" value=\"" + result.memo.MEMO_NO + "\" />";
html += " <input type=\"hidden\" name=\"marking\" value=\"" + result.memo.MARKING + "\" />";
html += " <input type=\"hidden\" name=\"uNo\" value=\"" + result.memo.R_NO + "\" />";
html += " <table>";
html += " <colgroup>";    
html += " <col width=\"210px\"/>";
html += " <col width=\"20px\"/>";
html += " <col width=\"210px\"/>";
html += " </colgroup>";
html += " <tr>";
html += " <td>작성자</td>";
html += " <td colspan=\"3\">" + result.memo.ADMIN_NAME + "&nbsp;&nbsp;&nbsp;관리자</td> ";
html += " </tr>";
html += " <tr>";
html += " <td>발생일</td>";
html += " <td colspan=\"3\">";
html += " <div class=\"accur_div\">" +result.memo.ACCUR_DATE + "</div>";
html += "<input type=\"text\" class=\"update_input\" size=\"38\" name=\"occur\" id=\"accur\" value=\"" + result.memo.ACCUR_DATE + "\" />";
html += " </td></tr>";
html += " <tr>";
html += " <td>작성일</td>";
html += " <td colspan=\"3\">" + result.memo.MEMO_REGI + "</td>";
html += " </tr>";
html += " <tr>";
html += " <td colspan=\"4\"> ";
html += " <div class=\"detail_ctts\">";
html += result.memo.CONTENTS;
html += " </div>";
html += "<textarea class=\"update_input\" rows=\"16\" name=\"contents\" id=\"contents\">" + result.memo.CONTENTS + "</textarea>";
html += " </td> ";
html += " </tr> ";
html += " </table>";
html += " <div class=\"btn_div\" id=\"btn_div\">";
html += " <input type=\"button\" value=\"수정\" id=\"BtnUpdate\">";
html += " <input type=\"button\" value=\"삭제\" id=\"BtnDelete\">";
html += " </div> ";
html += " <div class=\"update_btn_div\" id=\"update_btn_div\"> ";
html += " <input type=\"button\" value=\"저장\" id=\"BtnSave\">";
html += " <input type=\"button\" value=\"취소\" id=\"BtnCancel\"> ";
html += " </div> ";
html += " </form>";
html += " </div>";
html += "</div>  ";

$("body").prepend(html);

$(".background8").hide();
$(".ctts8").hide();
$(".background8").fadeIn();
$(".ctts8").fadeIn();


//-------------------------------------------------------------중요도 아이콘
  $(".ctts8").on("click", ".star_img", function(){
if(($(this).attr("src") == "resources/images/empty_star_icon.png") &&
result.memo.MARKING == 1){

var params= $("#memoForm").serialize();

$.ajax({
url : "onStar",
type : "post",
dataType : "json",
data : params,
success: function(res) {
$(".star_img").attr("src", "resources/images/yellow_star_icon.png");
},
error: function(request, status, error) {
console.log(error);
}
});

} else if(($(this).attr("src") == "resources/images/yellow_star_icon.png") &&
result.memo.MARKING == 0) {

$.ajax({
url : "offStar",
type : "post",
dataType : "json",
data : params,
success: function(res) {
$(".star_img").attr("src", "resources/images/empty_star_icon.png");
console.log("검정별");

},
error: function(request, status, error) {
console.log(error);
}
});
} else {
alert("중요도 변경시 오류가 발생했습니다.");
}

}); 



$(".background8").off("click");
$(".background8").on("click", function(){
closeMemoDetail();
});

$("#closeMemo").off("click");
$("#closeMemo").on("click", function(){
closeMemoDetail();
fastClosePopup();
drawPopup();
//setTimeout(function(){drawPopup();}, 400);

});

 

//상세보기 메모 닫기
function closeMemoDetail() {
$(".background8").fadeOut(function(){
$(".background8").remove();
});

$(".ctts8").fadeOut(function(){
$(".ctts8").remove();
});
}

 

//-----------------------------------------------------------추가버튼 클릭할 때
$(".btn_add").off("click");
$(".btn_add").on("click", function(){

var html = "";

html += "<div class=\"background8\"></div>";
html += "<div class=\"ctts8\">";
html += " <form id=\"memoForm\">";
html += " <div class=\"top_div\">";
html += "<img class=\"star_img\" id=\"starIconBlack\" alt=\"별\" src=\"resources/images/empty_star_icon.png\">";
html += " <div class=\"memo_title\">메모</div>";
html += " <img class=\"close_img\" id=\"closeMemo\" alt=\"닫기\" src=\"resources/images/cross.png\">";
html += " </div>";
html += " <div class=\"memo_ctts_div\">";
html +=" <input type=\"hidden\" name=\"marking\" id=\"marking\" value=\"1\"/>";
html +=" <input type=\"hidden\" name=\"rNo\" value=\""+ result.data.REPORT_NO +"\"/>";
html +=" <input type=\"hidden\" name=\"admin\" id=\"admin\"/>";
html += " <input type=\"hidden\" name=\"uNo\" value=\"" + result.data.R_NO + "\" />";
html += " <table>";
html += " <tr>";
html += " <td>작성자</td>";
html += " <td><input type=\"text\" size=\"38\"id=\"a\" /></td>  ";
html += " </tr>";
html += " <tr>";
html += " <td>발생일</td>";
html += " <td colspan=\"3\">";
html += "<input type=\"date\" name=\"occur\" id=\"occur\" min=\"2021-01-01\"/>";
html += " </td></tr>";
html += " <tr>";
html += " <td colspan=\"4\"> ";
html += "<textarea rows=\"16\" name=\"contents\" id=\"contents\"></textarea>";
html += " </td> ";
html += " </tr> ";
html += " </table>";
html += " <div class=\"save_btn_div\" id=\"save_btn_div\"> ";
html += " <input type=\"button\" value=\"저장\" id=\"BtnSave\">";
html += " <input type=\"button\" value=\"취소\" id=\"BtnCancel\"> ";
html += " </div> ";
html += " </div>";
html += " </form>";
html += "</div>  ";

$("body").prepend(html);

$(".background8").hide();
$(".ctts8").hide();
$(".background8").fadeIn();
$(".ctts8").fadeIn();

$("#memoForm").on("keypress", "input", function(event){
if(event.keyCode == 13){
return false;
}
});


//-------------------------------------------------------------중요도 아이콘
  $(".ctts8").on("click", ".star_img", function(){
if($(this).attr("src") == "resources/images/empty_star_icon.png"){
$(".star_img").attr("src", "resources/images/yellow_star_icon.png");
$("#marking").val(0);
} else {
$(".star_img").attr("src", "resources/images/empty_star_icon.png");
$("#marking").val(1);
}

}); 



$(".background8").off("click");
$(".background8").on("click", function(){
closeMemoDetail();
});

$("#closeMemo").off("click");
$("#closeMemo").on("click", function(){
closeMemoDetail();
fastClosePopup();
drawPopup();
//setTimeout(function(){drawPopup();}, 400);

});


//----------------------------------------------취소버튼 누를 때
$("#BtnCancel").off("click");
$("#BtnCancel").on("click", function(){
closeMemoDetail();
});

 

//-------------------------------------------MYBATIS

<update id="onStar" parameterType="hashmap">
UPDATE MEMO
SET MARKING = 0
WHERE MEMO_NO = #{mNo}
</update>

<update id="offStar" parameterType="hashmap">
UPDATE MEMO
SET MARKING = 1
WHERE MEMO_NO = #{mNo}
</update>

 

 

//메모 중요체크
@RequestMapping(value = "/onStar",
method = RequestMethod.POST,
produces = "text/json;charset=UTF-8")
@ResponseBody
public String onStarAjax(
@RequestParam HashMap<String, String> params) throws Throwable {

ObjectMapper mapper = new ObjectMapper();
Map<String, Object> modelMap = new HashMap<String, Object>();


try {
int cnt = iManagerService.onStar(params);

if (cnt > 0) {
modelMap.put("msg", "success");
} else {
modelMap.put("msg", "failed");
}

} catch (Throwable e) {
e.printStackTrace();
modelMap.put("msg", "error");
}

return mapper.writeValueAsString(modelMap);
}

//메모 중요체크
@RequestMapping(value = "/offStar",
method = RequestMethod.POST,
produces = "text/json;charset=UTF-8")
@ResponseBody
public String offStarAjax(
@RequestParam HashMap<String, String> params) throws Throwable {

ObjectMapper mapper = new ObjectMapper();
Map<String, Object> modelMap = new HashMap<String, Object>();


try {
int cnt = iManagerService.offStar(params);

if (cnt > 0) {
modelMap.put("msg", "success");
} else {
modelMap.put("msg", "failed");
}

} catch (Throwable e) {
e.printStackTrace();
modelMap.put("msg", "error");
}

return mapper.writeValueAsString(modelMap);
}

'개발관련 > 국비지원수업' 카테고리의 다른 글

책갈피, 북마크  (0) 2021.07.07
테이블정의서2  (0) 2021.07.02
테이블 정의서1  (0) 2021.07.02
0527 json 배우기  (0) 2021.06.19
mav  (0) 2021.06.19