diff --git a/Frontend/_accountManagement.html b/Frontend/_accountManagement.html
index 7e83377..73e8f97 100644
--- a/Frontend/_accountManagement.html
+++ b/Frontend/_accountManagement.html
@@ -4,12 +4,18 @@
帳號與權限管理
@@ -48,15 +56,17 @@
@@ -72,8 +82,10 @@
@@ -103,7 +115,7 @@
+ placeholder="Email">
@@ -166,8 +178,8 @@
@@ -175,7 +187,7 @@
-
+
-
+
類別代號 |
@@ -231,14 +243,14 @@
-
-
+
+
-
-
-
- 選擇 |
- 編號 |
- 功能名稱 |
-
-
-
-
- |
- 1 |
- 系統監控 |
-
-
- |
- 2 |
- 歷史資料 |
-
-
- |
- 3 |
- 異常記錄 |
-
-
- |
- 4 |
- 即時告警 |
-
-
- |
- 5 |
- 運維管理 |
-
-
- |
- 6 |
- 圖資管理 |
-
-
- |
- 7 |
- 帳號管理 |
-
-
+
@@ -329,7 +297,9 @@
getRoleSel();
loadAccManTable();
loadRolManTable();
+ loadAuthPageTable();
loadRolAuthTable();
+ setAuthPage();
events();
})
@@ -342,21 +312,21 @@
let sendData = {};
if (pageAct.accManName != null)
- sendData.Full_name = pageAct.accManName;
+ sendData.Full_name = pageAct.accManName;
if (pageAct.accRolName != null)
- sendData.Role_full_name = pageAct.accRolName;
+ sendData.Role_full_name = pageAct.accRolName;
ajaxObj.data = sendData;
let column_defs = [
{ "targets": [0], "width": "6%", "sortable": true },
- { "targets": [1], "width": "12%", "sortable": true },
+ { "targets": [1], "width": "10%", "sortable": true },
{ "targets": [2], "width": "14%", "sortable": true },
- { "targets": [3], "width": "12%", "sortable": true },
+ { "targets": [3], "width": "10%", "sortable": true },
{ "targets": [4], "width": "14%", "sortable": true },
- { "targets": [5], "width": "14%", "sortable": true },
+ { "targets": [5], "width": "10%", "sortable": true },
{ "targets": [6], "width": "14%", "sortable": true },
- { "targets": [7], "width": "14%", "sortable": true },
+ { "targets": [7], "width": "22%", "sortable": true },
];
let columns = [
@@ -398,21 +368,28 @@
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
btnDiv.append(creBtnHtml("修改", "accManEdiBtn" + data, null, ["btn", "btn-info"], { "toggle": "modal", "target": "#accManModal" }));
+ btnDiv.append(creBtnHtml("設備權限", "accManSysRolEdiBtn" + data, null, ["btn", "btn-info"], { "toggle": "modal", "target": "#accManSysModal" }));
btnDiv.append(creBtnHtml("刪除", "accManDelBtn" + data, null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
return btnDiv.outerHtml();
}
},
];
- let accManTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
+ let accManTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
}
function loadRolManTable() {
let ajaxObj = {
url: baseApiUrl + "/User/RoleManagerList",
method: "POST",
- data: { post: 0 },
}
+
+ let sendData = {};
+ sendData.Layer = 0;
+ if (pageAct.rolName != null)
+ sendData.Full_name = pageAct.rolName;
+
+ ajaxObj.data = sendData;
let tag = "#rolManTable";
let column_defs = [
@@ -443,8 +420,8 @@
"data": "layer",
"render": function (data, type, row, meta) {
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
- btnDiv.append(creBtnHtml("修改", "rolManEdiBtn" + data, null, ["btn", "btn-info"], { "toggle": "modal", "target": "#groupModal" }));
- btnDiv.append(creBtnHtml("刪除", "rolManDelBtn" + data, null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
+ btnDiv.append(creBtnHtml("修改", "rolManEdiBtn" + data, null, ["btn", "btn-info"], { "toggle": "modal", "target": "#groupModal", "name": row.full_name, "id": row.role_guid }));
+ btnDiv.append(creBtnHtml("刪除", "rolManDelBtn" + data, null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal", "id": row.role_guid }));
return btnDiv.outerHtml();
}
},
@@ -454,10 +431,12 @@
}
function loadRolAuthTable() {
+ pageAct.authCode = [];
+
let ajaxObj = {
url: baseApiUrl + "/User/RoleAuthList",
method: "POST",
- data: { SelectedRoleId: "882b7e2c-1205-4d7c-81dc-818b8d1c1b33" },
+ data: { SelectedRoleId: pageAct.selRolAuth },
}
let tag = "#rolAuthTable";
@@ -475,7 +454,7 @@
let columns = [
{
"title": "編號",
- "data": null,
+ "data": "authCode",
"render": function (data, type, row, meta) {
return meta.row + 1;
}
@@ -506,10 +485,10 @@
},
{
"title": "功能",
- "data": "userinfo_guid",
+ "data": "role_guid",
"render": function (data, type, row, meta) {
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
- btnDiv.append(creBtnHtml("刪除", "rolAuthDelBtn", null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
+ btnDiv.append(creBtnHtml("刪除", "rolAuthDelBtn" + data, null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal", "id": data, "authcode": row.authCode }));
return btnDiv.outerHtml();
}
},
@@ -518,6 +497,44 @@
rolAuthTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
}
+ function loadAuthPageTable() {
+ let ajaxObj = {
+ url: baseApiUrl + "/User/AuthPageList",
+ method: "POST"
+ }
+
+ let tag = "#accAuthPageTable";
+
+ let column_defs = [
+ { "targets": [0], "width": "33%", "sortable": true },
+ { "targets": [1], "width": "33%", "sortable": true },
+ { "targets": [2], "width": "33%", "sortable": true },
+ ];
+
+ let columns = [
+ {
+ "title": "選擇",
+ "data": 'authCode',
+ "render": function (data, type, row, meta) {
+ return ` | `
+ }
+ },
+ {
+ "title": "編號",
+ "data": null,
+ "render": function (data, type, row, meta) {
+ return meta.row + 1;
+ }
+ },
+ {
+ "title": "功能名稱",
+ "data": "subName",
+ }
+ ];
+
+ accAuthPageTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
+ }
+
function getRoleSel() {
let url = baseApiUrl + "/User/RoleManagerList";
@@ -529,11 +546,14 @@
if (!res || res.code != "0000" || !res.data) {
} else {
- $("#roleSel").html();
- $("#selRolAuth").html();
+ $("#roleSel").html('');
+ $("#selRolAuth").html('');
$.each(res.data, (index, roleObj) => {
$("#roleSel").append(creOption(roleObj.full_name, roleObj.role_guid));
$("#selRolAuth").append(creOption(roleObj.full_name, roleObj.role_guid));
+
+ if (index == 0)
+ pageAct.selRolAuth = roleObj.role_guid
})
}
}, null, "POST").send();
@@ -573,9 +593,10 @@
}, null, "POST").send();
}
});
- onEvent("click", "[data-target*=delModal]", function () {
- pageAct.accManId = $(this).prop('id').split('Btn')[1]
- });
+
+ onEvent("click", "[id*=accManDelBtn]", function () {
+ pageAct.accManId = $(this).prop('id').split('Btn')[1];
+ });
onEvent("click", "#accManSendBtn", function () {
let form = $("#accManForm");
@@ -616,51 +637,165 @@
onEvent("change", "#seaAccManName", function () {
pageAct.accManName = $(this).val() || null;
- });
+ });
onEvent("change", "#seaAccManRolName", function () {
pageAct.accRolName = $(this).val() || null;
});
- onEvent("click", "#acc_searchBtn", function () {
- let acc_table = $('div.tab-pane.fade.show.active').data('id');
-
+ onEvent("change", "#seaRolName", function () {
+ pageAct.rolName = $(this).val() || null;
+ });
+
+ onEvent("click", "#acc_searchBtn, #rol_searchBtn", function () {
+ let acc_table = $('div.tab-pane.fade.show.active').data('id');
+
if (acc_table == "accMan")
loadAccManTable();
else if (acc_table == "rolMan")
loadRolManTable();
- else if (acc_table == "rolAuth")
+ else if (acc_table == "rolAuth") {
loadRolAuthTable();
+ setAuthPage();
+ }
});
- onEvent("change", ".tab-pane.fade", function () {
- console.log('aaa');
+ onEvent("click", "li.nav-item", function () {
+ pageAct.rolManId = null;
+ pageAct.accManId = null;
+ $('#roleSel').html('');
+ $("#selRolAuth").html('');
+ getRoleSel();
});
onEvent("click", "#confirmDelBtn", function () {
- let url = baseApiUrl + "/User/DeleteOneUser";
- let sendData = {
- Id: pageAct.accManId,
- };
+ let url = baseApiUrl + "/User/" + (pageAct.accManId != null ? "DeleteOneUser" : (pageAct.rolManId != null ? "DeleteOneRole" : (pageAct.authUsrId != null ? "DeleteOneRoleAuth" : null)));
+ let sendData = {
+ Id: pageAct.accManId ?? pageAct.rolManId ?? pageAct.authUsrId,
+ };
- objSendData.Data = sendData;
- ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
- if (!res || res.code != "0000" || !res.msg) {
+ if (pageAct.authUsrId != null)
+ sendData.AuthCode = pageAct.authCode;
- } else {
- toast_ok(common.DelSuc);
- //$("#accManModal").modal("hide");
- $("#closeDelBtn").click();
- pageAct.accManId = null;
- loadAccManTable();
- }
- }, null, "POST").send();
+ objSendData.Data = sendData;
+
+ ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
+ if (!res || res.code != "0000" || !res.msg) {
+
+ } else {
+ toast_ok(common.DelSuc);
+ //$("#accManModal").modal("hide");
+ $("#closeDelBtn").click();
+ if (pageAct.accManId) {
+ pageAct.accManId = null;
+ loadAccManTable();
+ }
+ else if (pageAct.rolManId) {
+ pageAct.rolManId = null;
+ loadRolManTable();
+ }
+ else if (pageAct.authUsrId) {
+ pageAct.authUsrId = null;
+ pageAct.authCode = null;
+ loadRolAuthTable();
+ setAuthPage();
+ }
+ }
+ }, null, "POST").send();
})
+
+ onEvent("click", "[id*=rolManEdiBtn]", function () {
+ pageAct.rolManId = $(this).data('id');
+ $('#groupName').val($(this).data('name'));
+ })
+
+ onEvent("click", "[id*=rolManDelBtn]", function () {
+ pageAct.rolManId = $(this).data('id');
+ })
+
+ onEvent("click", "#accRolSavBtn", function () {
+ let url = baseApiUrl + "/User/SaveRole";
+ let sendData = {
+ Name: $('#groupName').val(),
+ };
+
+ sendData.Id = pageAct.rolManId ?? "0";
+
+ objSendData.Data = sendData;
+ ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
+ if (!res || res.code != "0000" || !res.msg) {
+
+ } else {
+ toast_ok(common.DelSuc);
+ //$("#groupModal").modal("hide");
+ $('#accRolCanBtn').click();
+ pageAct.rolManId = null;
+ loadRolManTable();
+ }
+ }, null, "POST").send();
+ });
+
+ onEvent("change", "#roleSel", function () {
+ pageAct.selRolAuth = $(this).val();
+ loadRolAuthTable();
+ setAuthPage();
+ });
+
+ onEvent("click", "[id*=rolAuthDelBtn]", function () {
+ pageAct.authCode = $(this).data('authcode');
+ pageAct.authUsrId = $(this).data('id');
+ });
+
+ onEvent("click", "#authPageSavBtn", function () {
+ pageAct.authCode = [];
+ pageAct.authCode = $(`#accAuthPageTable input[type=checkbox]:checked:not(:disabled)`).map(function (i, v) { return $(v).prop('id').toString(); }).toArray();
+
+ let url = baseApiUrl + "/User/SaveRoleAuth";
+ let sendData = {
+ SelectedRoleId: $('#roleSel option:selected').val(),
+ SaveCheckAuth: pageAct.authCode,
+ };
+
+ objSendData.Data = sendData;
+ ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
+ if (!res || res.code != "0000" || !res.msg) {
+
+ } else {
+ toast_ok(common.EditSuc);
+ $("#authPageModal").modal("hide");
+ pageAct.authCode = [];
+ loadRolAuthTable();
+ setAuthPage();
+ }
+ }, null, "POST").send();
+ });
}
function clearPagSes() {
pageAct.accManId = null;
pageAct.accManName = null;
pageAct.accRolName = null;
- }
+ pageAct.rolName = null;
+ pageAct.rolManId = null;
+ pageAct.selRolAuth = null;
+ pageAct.authCode = [];
+ }
+
+ function setAuthPage() {
+ pageAct.authCode = $('[id*=rolAuthDelBtn]').map(function (i, v) { return $(v).data('authcode'); }).toArray();
+
+ $(`#accAuthPageTable input[type=checkbox]`).prop('disabled', false);
+ $.each($(`#accAuthPageTable input[type=checkbox]:checked`), function (i, v) {
+ $(v).click();
+ });
+
+ pageAct.authCode = pageAct.authCode.filter(function (elem, index, self) {
+ return index === self.indexOf(elem);
+ });
+
+ $.each(pageAct.authCode, function (i, v) {
+ $(`#accAuthPageTable input[id=${v}]`).click();
+ $(`#accAuthPageTable input[id=${v}]`).attr('disabled', true);
+ });
+ }
\ No newline at end of file
diff --git a/FrontendWebApi/ApiControllers/UserController.cs b/FrontendWebApi/ApiControllers/UserController.cs
index 8944159..37d414c 100644
--- a/FrontendWebApi/ApiControllers/UserController.cs
+++ b/FrontendWebApi/ApiControllers/UserController.cs
@@ -2,6 +2,7 @@
using FrontendWebApi.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using Repository.BackendRepository.Interface;
@@ -9,6 +10,7 @@ using Repository.BaseRepository.Interface;
using Repository.FrontendRepository.Interface;
using System;
using System.Collections.Generic;
+using System.Data.SqlTypes;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Net;
@@ -90,21 +92,26 @@ namespace FrontendWebApi.ApiControllers
///
///
[HttpPost]
- public async Task>> RoleManagerList(int post) //是否判斷layer 0:否 1:是
+ public async Task>> RoleManagerList([FromBody] RoleManagerList post) //是否判斷layer 0:否 1:是
{
ApiResult> apiResult = new ApiResult>();
List roleList = new List();
try
{
- var layersql = "";
- if (post == 1)
+ var whereSql = "";
+ if (post.Layer == 1)
{
- layersql = "and A.layer = 1 ";
+ whereSql += " and A.layer = 1 ";
+ }
+
+ if (post.Full_name != null)
+ {
+ whereSql += $@" and A.full_name like '%{post.Full_name}%'";
}
var sqlString = @$"SELECT *
FROM role A
- WHERE A.deleted = 0 {layersql}
+ WHERE A.deleted = 0 {whereSql}
ORDER BY A.created_at DESC";
roleList = await backendRepository.GetAllAsync(sqlString);
@@ -505,7 +512,7 @@ namespace FrontendWebApi.ApiControllers
INNER JOIN auth_page C ON A.AuthCode=C.AuthCode
LEFT JOIN building D ON C.building_tag=D.building_tag AND D.deleted=0
WHERE A.role_guid='{post.SelectedRoleId}'
- ORDER BY A.created_at DESC";
+ ORDER BY A.AuthCode ASC";
roleAuthList = await backendRepository.GetAllAsync(sqlString);
apiResult.Code = "0000";
@@ -638,7 +645,7 @@ namespace FrontendWebApi.ApiControllers
try
{
- roleManager = await backendRepository.GetOneAsync("role", $"role_guid='{post.RoleId}'");
+ roleManager = await backendRepository.GetOneAsync("role", $"role_guid='{post.Id}'");
if (roleManager == null)
{
@@ -647,7 +654,7 @@ namespace FrontendWebApi.ApiControllers
return apiResult;
}
- await backendRepository.PurgeOneByGuidWithCustomDBNameAndTable("role_auth", $"role_guid='{post.RoleId}' AND AuthCode='{post.AuthCode}'");
+ await backendRepository.PurgeOneByGuidWithCustomDBNameAndTable("role_auth", $"role_guid='{post.Id}' AND AuthCode='{post.AuthCode}'");
apiResult.Code = "0000";
apiResult.Msg = "刪除成功";
@@ -665,6 +672,34 @@ namespace FrontendWebApi.ApiControllers
return apiResult;
}
+ ///
+ /// 前台頁面列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task>> AuthPageList()
+ {
+ ApiResult> apiResult = new ApiResult>();
+ List authPage = new List();
+
+ try
+ {
+ var sqlString = $@"select * from auth_page where AuthCode like 'FL%' order by AuthCode";
+ authPage = await backendRepository.GetAllAsync(sqlString);
+ apiResult.Code = "0000";
+ apiResult.Data = authPage;
+ }
+ catch (Exception exception)
+ {
+ apiResult.Code = "9999";
+ apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
+ Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
+ }
+
+ return apiResult;
+ }
+
[HttpPost]
[Route("api/getUser")]
public ActionResult GetUser()
diff --git a/FrontendWebApi/Models/User.cs b/FrontendWebApi/Models/User.cs
index b07bada..f96acbb 100644
--- a/FrontendWebApi/Models/User.cs
+++ b/FrontendWebApi/Models/User.cs
@@ -151,7 +151,7 @@ namespace FrontendWebApi.Models
public class PostDeleteRoleAuth
{
- public string RoleId { get; set; }
+ public string Id { get; set; }
public string AuthCode { get; set; }
}
@@ -167,6 +167,7 @@ namespace FrontendWebApi.Models
public string MainName { get; set; }
public string SubName { get; set; }
public string building_guid { get; set; }
+ public string building_tag { get; set; }
public string ShowView { get; set; }
public string created_at { get; set; }
}