diff --git a/Controllers/ApiController.cs b/Controllers/ApiController.cs index c5945e7d..6082d179 100644 --- a/Controllers/ApiController.cs +++ b/Controllers/ApiController.cs @@ -28,6 +28,57 @@ namespace QuotationMaker.Controllers } + [Route("modalQuotationList")] + public ActionResult ModalQuotationList(IFormCollection obj) + { + modelQuotationListResult ret = new modelQuotationListResult(); + + authToken token = new authToken(this._httpContextAccessor); + if (token.user_isLogin == false) + { + HttpContext.Response.Cookies.Delete("token_key"); + ret.ret = "no"; + ret.err_code = "99999"; + ret.message = "非登入狀態!"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + + + string dept_uid = obj["dept_uid"].ToString(); + string modelProj_uid = obj["modelProj_uid"].ToString(); + + ret.modelQuotations = conn.Query("select * from modelQuotation where modelProj_uid = @modelProj_uid and dept_uid = @dept_uid", new { modelProj_uid = modelProj_uid, dept_uid = dept_uid }).ToList(); + ret.ret = "yes"; + + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + [Route("modalProjList")] + public ActionResult ModalProjList(IFormCollection obj) + { + modelProjListResult ret = new modelProjListResult(); + + authToken token = new authToken(this._httpContextAccessor); + if (token.user_isLogin == false) + { + HttpContext.Response.Cookies.Delete("token_key"); + ret.ret = "no"; + ret.err_code = "99999"; + ret.message = "非登入狀態!"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + + + + string dept_uid = obj["dept_uid"].ToString(); + + ret.modelProjs = conn.Query("select * from modelProj where modelProj_isdel = 'N' and dept_uid = @dept_uid", new { dept_uid = dept_uid }).ToList(); + ret.ret = "yes"; + + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + [Route("quotationList")] public ActionResult QuotationList(IFormCollection obj) { diff --git a/Views/Home/Login.cshtml b/Views/Home/Login.cshtml index c8d00ecb..5c446ff8 100644 --- a/Views/Home/Login.cshtml +++ b/Views/Home/Login.cshtml @@ -101,8 +101,8 @@ - - + + diff --git a/Views/Home/ProjectList.cshtml b/Views/Home/ProjectList.cshtml index 5ff4df38..5d3c5f5e 100644 --- a/Views/Home/ProjectList.cshtml +++ b/Views/Home/ProjectList.cshtml @@ -272,4 +272,87 @@ + + + +
+
\ No newline at end of file diff --git a/wwwroot/assets/javascript/custom/login.js b/wwwroot/assets/javascript/custom/login.js index 8d2186cf..f8d66394 100644 --- a/wwwroot/assets/javascript/custom/login.js +++ b/wwwroot/assets/javascript/custom/login.js @@ -2,7 +2,7 @@ if ($.UrlParam("isLogout") != "true") { if ($.cookie("token_key") != null) { if ($.cookie("token_key") != "") { - location.href = "/Home/UserList"; + location.href = "/Home/ProjectList"; //alert("has token_key value :" + $.cookie("token_key")); } @@ -48,7 +48,7 @@ data: formData, success: function (data, textStatus, jqXHR) { if (data.ret == "yes") { - location.href = "/Home/UserList"; + location.href = "/Home/ProjectList"; //location.href = "/BackEnd/nounsList"; } else { diff --git a/wwwroot/assets/javascript/custom/projectlist.js b/wwwroot/assets/javascript/custom/projectlist.js index 83e56672..393d2dfb 100644 --- a/wwwroot/assets/javascript/custom/projectlist.js +++ b/wwwroot/assets/javascript/custom/projectlist.js @@ -110,6 +110,11 @@ $(document).ready(function () { }); }); + $('#QuotationListNewBtn').on('click', function () { + $('#quotation_method').val('add'); + $('#clientModelQuotationModal').modal("toggle"); + }); + $('#dept_select').on('change', function () { $('#dt-responsive').DataTable().ajax.reload(); }); @@ -118,6 +123,51 @@ $(document).ready(function () { $('#clientProjectModal').modal("toggle"); }); + $("#modelProject_select").on('change', function () { + var modelProj_uid = $("#modelProject_select").val(); + + $("#modelQuotation_select").empty().append(''); + + if (modelProj_uid != '') { + var formData = { + dept_uid: $('#dept_select').val(), + modelProj_uid: modelProj_uid + } + + $.ajax({ + url: "/Api/modalQuotationList", + type: "post", + data: formData, + success: function (data, textStatus, jqXHR) { + if (data.ret == "yes") { + var obj = data.modelQuotations; + + + + $.each(obj, function (i, item) { + $("#modelQuotation_select").append($("'); + $("#modelQuotation_select").empty().append(''); + + $.each(obj, function (i, item) { + $("#modelProject_select").append($("