From 5f4530f9ad143eb197f6c97d581da4afe517aed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=98=89=E7=A5=A5=20=E8=A9=B9?= Date: Sun, 28 Jul 2024 13:39:10 +0800 Subject: [PATCH] updates --- Controllers/AuthApiController.cs | 14 ++++- Views/Home/GroupList.cshtml | 2 +- wwwroot/assets/javascript/custom/grouplist.js | 54 +++++++++++++++++-- 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/Controllers/AuthApiController.cs b/Controllers/AuthApiController.cs index 2db9c8bc..292a283b 100644 --- a/Controllers/AuthApiController.cs +++ b/Controllers/AuthApiController.cs @@ -63,7 +63,7 @@ namespace QuotationMaker.Controllers try { usersJsonObj = JsonConvert.DeserializeObject(users_json_str); - conn.Insert(newGroup); + } @@ -75,7 +75,7 @@ namespace QuotationMaker.Controllers } string nowrite_msg = ""; - + int userCount = 0; foreach (dynamic item in usersJsonObj) { string user_uid = item.user_uid; string user_name = item.user_name; @@ -89,15 +89,25 @@ namespace QuotationMaker.Controllers newGU.groupUser_uid = GlobalClass.CreateRandomCode(16); newGU.dept_uid = dept_uid; conn.Insert(newGU); + userCount++; } else { nowrite_msg += user_name + " 此用戶已經是其他群組的成員,故此員取消加入!\n"; } } + if (userCount == 0) { + nowrite_msg += "成員數量不得為0,故取消建立群組!"; + ret.ret = "no"; + ret.err_code = "0007"; + ret.message = nowrite_msg; + return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); + } + conn.Insert(newGroup); ret.groups.Add(new groupDetail(newGroup)); ret.message = nowrite_msg; + ret.ret = "yes"; return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8"); diff --git a/Views/Home/GroupList.cshtml b/Views/Home/GroupList.cshtml index f2eb7ac0..8d93eea8 100644 --- a/Views/Home/GroupList.cshtml +++ b/Views/Home/GroupList.cshtml @@ -124,7 +124,7 @@
成員
-
+
    diff --git a/wwwroot/assets/javascript/custom/grouplist.js b/wwwroot/assets/javascript/custom/grouplist.js index aa6c7f60..5e6f30a2 100644 --- a/wwwroot/assets/javascript/custom/grouplist.js +++ b/wwwroot/assets/javascript/custom/grouplist.js @@ -71,7 +71,21 @@ $(document).ready(function () { data: formData, success: function (data, textStatus, jqXHR) { if (data.ret == "yes") { - + + var obj = data.groups; + + $.each(obj, function (index, item) { + $('#group_div').append(cardHtml(item)); + $('#' + item.group_uid).nestable(); + + //$('#' + item.optionItem_uid).on('change', function () { + // nestableChange(this); + //}); + }); + + if (data.message != '') { + alert(data.message); + } $('#groupModal').modal('toggle'); } else { @@ -208,7 +222,7 @@ function deptList() { function optionItemHtml(item) { var html = ''; - html += '
  1. '; + html += '
  2. '; html += '
    '; html += ' '; html += '
    ' + item.user_name + '
    '; @@ -225,10 +239,42 @@ function delMemberBtnClick(obj) { tmpNestableItem = $(obj).parent().parent().find("[data-name='option_name']"); var optionItem_name = $(obj).parent().parent().find("[data-name='option_name']").text(); var user_uid = $(obj).parent().parent().parent().attr("data-user-uid"); + var group_uid = $(obj).parent().parent().parent().parent().parent().attr("data-type"); + delItem = $(obj).parent().parent().parent(); + + if (group_uid == '') { + delItem.remove(); + } else { - if ($('#client_method').val() == 'add') { - tmpNestableItem.parent().parent().remove(); } } } +function cardHtml(groupOption) { + var html = ""; + html += ""; + html += "
    "; + html += " "; + html += "
    "; + html += "
    " + groupOption.group_name + "
    "; + html += "
    "; + html += " "; + html += "
      "; + html += "
    1. "; + + $.each(groupOption.users, function (index, item) { + html += optionItemHtml(item); + }); + + + html += "
    "; + html += "
    "; + html += " "; + html += "
    "; + html += " 新增成員 "; + html += "
    "; + html += "
    "; + html += "
    "; + + return html; +} \ No newline at end of file