diff --git a/Project/Web/Controller/TodoController.cs b/Project/Web/Controller/TodoController.cs index 8fcdeaf..b56161e 100644 --- a/Project/Web/Controller/TodoController.cs +++ b/Project/Web/Controller/TodoController.cs @@ -57,7 +57,18 @@ namespace Project.Web.Controllers string gcode = FCOMMON.info.Login.gcode; string uid = FCOMMON.info.Login.no; - var sql = "SELECT * FROM EETGW_Todo WHERE gcode = @gcode AND uid = @uid ORDER BY flag DESC, seqno DESC, expire ASC, wdate ASC"; + var sql = @"SELECT * FROM EETGW_Todo WHERE gcode = @gcode AND uid = @uid + ORDER BY + CASE + WHEN ISNULL(status,'0') = '1' THEN 1 -- 진행 + WHEN ISNULL(status,'0') = '0' THEN 2 -- 대기 + WHEN ISNULL(status,'0') = '3' THEN 3 -- 보류 + WHEN ISNULL(status,'0') = '5' THEN 4 -- 완료 + WHEN ISNULL(status,'0') = '2' THEN 5 -- 취소 + ELSE 6 + END, flag DESC, + ISNULL(seqno, 0) DESC, + expire ASC"; var todos = DBM.Query(sql, new { gcode = gcode, uid = uid }); return CreateJsonResponse(new @@ -149,13 +160,35 @@ namespace Project.Web.Controllers if (todo.seqno == null) todo.seqno = 0; if (todo.flag == null) todo.flag = false; + if (todo.status == '\0') todo.status = '0'; + + // 새로 생성할 때 완료 상태면 완료일 설정 + DateTime? okdateValue = null; + if (todo.status == '5') + { + okdateValue = DateTime.Now; + } var sql = @" - INSERT INTO EETGW_Todo (gcode, uid, title, remark, flag, expire, seqno, request, wuid, wdate) - VALUES (@gcode, @uid, @title, @remark, @flag, @expire, @seqno, @request, @wuid, @wdate); + INSERT INTO EETGW_Todo (gcode, uid, title, remark, flag, expire, seqno, request, status, okdate, wuid, wdate) + VALUES (@gcode, @uid, @title, @remark, @flag, @expire, @seqno, @request, @status, @okdate, @wuid, @wdate); SELECT SCOPE_IDENTITY();"; - var newId = DBM.QuerySingle(sql, todo); + var newId = DBM.QuerySingle(sql, new + { + gcode = todo.gcode, + uid = todo.uid, + title = todo.title, + remark = todo.remark, + flag = todo.flag, + expire = todo.expire, + seqno = todo.seqno, + request = todo.request, + status = todo.status, + okdate = okdateValue, + wuid = todo.wuid, + wdate = todo.wdate + }); return CreateJsonResponse(new { @@ -210,9 +243,24 @@ namespace Project.Web.Controllers string gcode = FCOMMON.info.Login.gcode; string uid = FCOMMON.info.Login.no; + // 상태가 완료('5')로 변경되고 아직 완료일이 설정되지 않은 경우 완료일 설정 + DateTime? okdateValue = null; + if (todo.status == '5') + { + // 기존 완료일이 있는지 확인 + var existingTodo = DBM.QuerySingleOrDefault( + "SELECT okdate FROM EETGW_Todo WHERE idx = @idx AND gcode = @gcode AND uid = @uid", + new { idx = todo.idx, gcode = gcode, uid = uid }); + + if (existingTodo?.okdate == null) + { + okdateValue = DateTime.Now; + } + } + var sql = @" UPDATE EETGW_Todo - SET title = @title, remark = @remark, flag = @flag, expire = @expire, seqno = @seqno, request = @request + SET title = @title, remark = @remark, flag = @flag, expire = @expire, seqno = @seqno, request = @request, status = @status, okdate = @okdate WHERE idx = @idx AND gcode = @gcode AND uid = @uid"; var affectedRows = DBM.Execute(sql, new @@ -223,6 +271,8 @@ namespace Project.Web.Controllers expire = todo.expire, seqno = todo.seqno ?? 0, request = todo.request, + status = todo.status == '\0' ? '0' : todo.status, + okdate = okdateValue, idx = todo.idx, gcode = gcode, uid = uid diff --git a/Project/Web/Model/TodoModel.cs b/Project/Web/Model/TodoModel.cs index 094fdbd..8035822 100644 --- a/Project/Web/Model/TodoModel.cs +++ b/Project/Web/Model/TodoModel.cs @@ -74,5 +74,11 @@ namespace Project.Web.Model /// 자동 셋팅 /// public DateTime wdate { get; set; } + + /// + /// 완료일 + /// 상태를 완료로 변경할 때 자동 설정 + /// + public DateTime? okdate { get; set; } } } diff --git a/Project/Web/wwwroot/DashBoard/index.html b/Project/Web/wwwroot/DashBoard/index.html index e31dc7e..b2572d1 100644 --- a/Project/Web/wwwroot/DashBoard/index.html +++ b/Project/Web/wwwroot/DashBoard/index.html @@ -252,9 +252,17 @@ 할일 - +
+ + +
@@ -542,14 +550,20 @@
- -
+ +
-
+
+ +
+ - +
+
@@ -572,6 +586,93 @@
+ + +