From 91b785b7ea502adfe01dcaafbedc570383378fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=98=89=E7=A5=A5=20=E8=A9=B9?= Date: Wed, 10 Apr 2024 18:56:45 +0800 Subject: [PATCH] update new function --- Controllers/ApiController.cs | 33 +++ Models/DbTableClass.cs | 27 +++ Models/kolProjectViewDetail.cs | 39 +++ Views/Home/KolList.cshtml | 227 +++++++++++++++++- Views/Home/ProjectList.cshtml | 61 +++++ wwwroot/assets/javascript/custom/kollist.js | 128 +++++++++- .../assets/javascript/custom/projectlist.js | 78 ++++++ 7 files changed, 591 insertions(+), 2 deletions(-) create mode 100644 Models/kolProjectViewDetail.cs diff --git a/Controllers/ApiController.cs b/Controllers/ApiController.cs index 0360e80..a5bd345 100644 --- a/Controllers/ApiController.cs +++ b/Controllers/ApiController.cs @@ -59,6 +59,32 @@ namespace Journeys_WantHome.Controllers this._httpContextAccessor = httpContextAccessor; } + [Route("kolProjectViewList")] + public ActionResult KolProjectViewList(IFormCollection obj) { + kolProjectViewResult ret = new kolProjectViewResult(); + 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 project_uid = obj["project_uid"].ToString(); + + List kolProjectViews = conn.Query("select * from kolProjectView where project_uid = @project_uid order by kol_uid, optionItem_order", new { project_uid = project_uid }).ToList(); + + foreach (kolProjectView objView in kolProjectViews) + { + ret.detail.Add(new kolProjectViewDetail(objView)); + } + + ret.ret = "yes"; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + [HttpGet] [Route("fileService")] public ActionResult FileService(string uid) { @@ -1843,6 +1869,13 @@ namespace Journeys_WantHome.Controllers } + public class kolProjectViewResult + { + public string ret { get; set; } = "no"; + public string err_code { get; set; } = "0000"; + public string message { get; set; } = ""; + public List detail { get; set; } = new List(); + } public class kolProjectListResult { public string ret { get; set; } = "no"; diff --git a/Models/DbTableClass.cs b/Models/DbTableClass.cs index 529ccd3..4f38671 100644 --- a/Models/DbTableClass.cs +++ b/Models/DbTableClass.cs @@ -8,6 +8,33 @@ using Newtonsoft.Json.Linq; public class DbTableClass { + [Table("kolProjectView")] + public class kolProjectView + { + public string kol_name { get; set; } = ""; + public string kol_uid { get; set; } = ""; + public string kol_descript { get; set; } = ""; + public string kol_photo { get; set; } = ""; + public string project_uid { get; set; } = ""; + public string kolProject_uid { get; set; } = ""; + public string kolProject_isExec { get; set; } = ""; + public string kolProject_noExecReason { get; set; } = ""; + public string kolProject_memo { get; set; } = ""; + public string user_uid { get; set; } = ""; + public string user_name { get; set; } = ""; + public DateTime kolProject_modifydate { get; set; } + public string optionItem_uid { get; set; } = ""; + public string mediaItem_uid { get; set; } = ""; + public string kolProjectPrice_date { get; set; } = ""; + public int kolProjectPrice_cost { get; set; } + public string kolProjectPrice_num { get; set; } = ""; + public string kolProjectPrice_other { get; set; } = ""; + public string mediaItem_name { get; set; } = ""; + public string optionItem_name { get; set; } = ""; + public int optionItem_order { get; set; } = 0; + } + + [Table("kolfiles")] public class kolfiles { diff --git a/Models/kolProjectViewDetail.cs b/Models/kolProjectViewDetail.cs new file mode 100644 index 0000000..af2d551 --- /dev/null +++ b/Models/kolProjectViewDetail.cs @@ -0,0 +1,39 @@ +using Dapper; +using Dapper.Contrib.Extensions; +using NPOI.SS.Formula.Functions; +using System.Data.SqlClient; +using static DbTableClass; + +public class kolProjectViewDetail : kolProjectView +{ + DbConn dbConn = new DbConn(); + SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString")); + + public List kolProjectEvaluates = new List(); + + private kolProjectView _kolProjectView; + + public kolProjectViewDetail() { + _kolProjectView = new kolProjectView(); + } + + public kolProjectViewDetail(kolProjectView kolProjectView) + { + this._kolProjectView = kolProjectView; + + Type dataType = _kolProjectView.GetType(); + + foreach (var prop in dataType.GetProperties()) + { + string propName = prop.Name; + var valueProperty = dataType.GetProperty(propName); + object propValue = valueProperty.GetValue(_kolProjectView, null); + + this.GetType().GetProperty(propName).SetValue(this, propValue); + } + + kolProjectEvaluates = conn.Query("select * from kolProjectEvaluate where kolProject_uid = @kolProject_uid ", new { kolProject_uid = _kolProjectView.kolProject_uid}).ToList(); + + + } +} diff --git a/Views/Home/KolList.cshtml b/Views/Home/KolList.cshtml index 0ef395b..6ec9e8e 100644 --- a/Views/Home/KolList.cshtml +++ b/Views/Home/KolList.cshtml @@ -852,4 +852,229 @@ - \ No newline at end of file + + + +
+ +
diff --git a/Views/Home/ProjectList.cshtml b/Views/Home/ProjectList.cshtml index fd837d2..fce9e46 100644 --- a/Views/Home/ProjectList.cshtml +++ b/Views/Home/ProjectList.cshtml @@ -197,4 +197,65 @@ + + + +
+
\ No newline at end of file diff --git a/wwwroot/assets/javascript/custom/kollist.js b/wwwroot/assets/javascript/custom/kollist.js index bd42a33..207b2dc 100644 --- a/wwwroot/assets/javascript/custom/kollist.js +++ b/wwwroot/assets/javascript/custom/kollist.js @@ -970,7 +970,7 @@ $(document).ready(function () { render: function render(data, type, row, meta) { var ret = ''; ret += '
'; - ret += ' '; + ret += ' '; ret += '
'; return ret; //return row.gift_city + row.gift_area + row.gift_address; @@ -1771,7 +1771,111 @@ function buttonClick2(obj) { mainPos = mainTable.fnGetPosition($('#' + uid)[0]); + if (type == "preview") { + + var formData = { + method: "get", + kol_uid: uid + } + + $.ajax({ + url: "/Api/kolAddEditDelGet", + type: "post", + data: formData, + success: function (data, textStatus, jqXHR) { + if (data.ret == "yes") { + cleanPreviewData(); + + var obj = data.kol; + + + $('#previewKol_name').val(obj.kol_name).trigger('change'); + $('#previewKol_descript').val(obj.kol_descript).trigger('change'); + $('#previewKol_contact').html(obj.kol_contact1 + ' / ' + obj.kol_contact2).trigger('change'); + + var makeupStr = ''; + + $.each(obj.makeups, function (key, value) { + makeupStr += value.optionItem_name + ", "; + }); + + makeupStr = makeupStr.trim().replace(/,+$/, ''); + + + $('#previewKol_member').html(makeupStr).trigger('change'); + + var kol_typestr = ''; + + $.each(obj.styles, function (key, value) { + kol_typestr += value.optionItem_name + ", "; + }); + + kol_typestr = kol_typestr.trim().replace(/,+$/, ''); + + $('#previewKol_type').html(makeupStr).trigger('change'); + + var Kol_fansstr = ''; + + $.each(obj.fansTypes, function (key, value) { + Kol_fansstr += value.optionItem_name + ", "; + }); + + Kol_fansstr = Kol_fansstr.trim().replace(/,+$/, ''); + + $('#previewKol_fans').html(Kol_fansstr).trigger('change'); + + $('#previewKol_sexualRatio').html(obj.kol_men_ratio + '% : ' + obj.kol_women_ratio + '%').trigger('change'); + $('#13to17').html(obj.kol_13_17 + '%').trigger('change'); + $('#18to24').html(obj.kol_18_24 + '%').trigger('change'); + $('#25to34').html(obj.kol_25_34 + '%').trigger('change'); + $('#35to44').html(obj.kol_35_44 + '%').trigger('change'); + $('#45to54').html(obj.kol_45_54 + '%').trigger('change'); + $('#55to64').html(obj.kol_55_64 + '%').trigger('change'); + $('#64up').html(obj.kol_65 + '%').trigger('change'); + + $.each(obj.medias, function (key, value) { + var trHtml = ""; + trHtml += ''; + trHtml += ' ' + value.optionItem_name + ' '; + trHtml += ' ' + value.kolMedia_url + ' '; + trHtml += ' ' + AppendComma(value.kolMedia_fansNum) + ' '; + trHtml += ''; + + $('#preview_media_table tbody').append(trHtml); + //$("input:checkbox[value='" + value.optionItem_uid + "']").prop('checked', true); + }); + + var ret = ''; + + $.each(obj.tags, function (key, value) { + ret += '#' + value.tag_text + ' '; + }); + + $('#previewKol_tags').html(ret); + + + + + $('#clientPreviewModal').modal('toggle'); + } else { + alert(data.message); + + if (data.err_code == "9999") { + location.href = "/Home/Index"; + } + } + }, + error: function (jqXHR, textStatus, errorThrown) { + alert('網路或伺服器發生錯誤,請稍後重試!'); + } + }); + + $('#clientPreviewModal').modal('toggle'); + } + if (type == "case") { + + $('#kolProject_kol_uid').val(uid); @@ -2004,6 +2108,28 @@ function cleanModalData() { $('#kol_tags').val(null).trigger('change'); } +function cleanPreviewData() { + $('#previewKol_name').val(''); + $('#previewKol_descript').val(''); + $('#previewKol_contact').val(''); + $('#previewKol_member').val(''); + $('#previewKol_type').val(''); + $('#previewKol_fans').val(''); + $('#previewKol_sexualRatio').val(''); + $('#13to17').val(''); + $('#18to24').val(''); + $('#25to34').val(''); + $('#35to44').val(''); + $('#45to54').val(''); + $('#55to64').val(''); + $('#64up').val(''); + var trList = $("#preview_media_table").find("tbody").find("tr"); + $.each(trList, function (index, item) { + $(item).remove(); + }); + $('#previewKol_tags').val(''); +} + function loadMedia() { var formData = { option_uid: 'media' diff --git a/wwwroot/assets/javascript/custom/projectlist.js b/wwwroot/assets/javascript/custom/projectlist.js index 0cd7ac6..d7c5389 100644 --- a/wwwroot/assets/javascript/custom/projectlist.js +++ b/wwwroot/assets/javascript/custom/projectlist.js @@ -366,6 +366,15 @@ $(document).ready(function () { { data: 'project_modifydate', className: 'align-top text-left', orderable: false, searchable: true }, { data: 'project_uid', className: 'align-top text-center', orderable: false, searchable: false }], columnDefs: [ + { + targets: 2, + orderable: false, + searchable: true, + render: function render(data, type, row, meta) { + return '' + row.project_name + ''; + } + } + , { targets: 3, className: 'align-middle text-center', @@ -490,6 +499,75 @@ function buttonClick2(obj) { mainPos = mainTable.fnGetPosition($('#' + uid)[0]); + if (type == "preview") { + var formData = { + project_uid: uid + } + + $.ajax({ + url: "/Api/kolProjectViewList", + type: "post", + data: formData, + success: function (data, textStatus, jqXHR) { + if (data.ret == "yes") { + var trList = $("#preview_kol_table").find("tbody").find("tr"); + $.each(trList, function (index, item) { + $(item).remove(); + }); + + $.each(data.detail, function () { + var trHtml = ""; + trHtml += ''; + trHtml += ' ' + this.kol_name + ' '; + trHtml += ' ' + this.optionItem_name + ' '; + trHtml += ' ' + this.mediaItem_name + ' '; + trHtml += ' ' + AppendComma(this.kolProjectPrice_cost) + ' '; + + var execStr = ''; + + if (this.kolProject_isExec == 'N') { + + if (this.kolProject_noExecReason == '') { + execStr = "未執行"; + } else { + execStr = "未執行,原因:" + this.kolProject_noExecReason; + } + } else { + execStr = "執行"; + } + trHtml += ' ' + execStr + ' '; + + + var evaStr = ''; + + $.each(this.kolProjectEvaluates, function () { + evaStr += this.kolProjectEvaluate_text + ", "; + }); + + evaStr = evaStr.trim().replace(/,+$/, ''); + + trHtml += ' ' + evaStr + ' '; + + trHtml += ''; + + $('#preview_kol_table tbody').append(trHtml); + }); + + $('#clientPreviewModal').modal('toggle'); + } else { + alert(data.message); + + if (data.err_code == "9999") { + location.href = "/Home/Index"; + } + } + }, + error: function (jqXHR, textStatus, errorThrown) { + alert('網路或伺服器發生錯誤,請稍後重試!'); + } + }); + } + if (type == "del") { if (confirm('確定刪除此筆資料? 刪除後將無任何方法回復!')) { var formData = {