ibms-dome/Frontend/_accountManagement.html

938 lines
37 KiB
HTML
Raw Permalink Normal View History

<main id="js-page-content" role="main" class="page-content">
<div class="row">
<div class="col-sm-12 col-xl-12">
2022-12-28 13:00:17 +08:00
<h1 class="p-2 mb-0">帳號管理</h1>
<div class="row mt-5">
<ul class="nav nav-tabs w-100" role="tablist">
2022-12-15 14:26:20 +08:00
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#tab_borders_icons-1"
role="tab"><i class="fal fa-user mr-1"></i> 帳號管理</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab_borders_icons-2"
role="tab"><i class="fal fa-users mr-1"></i> 角色管理</a>
2022-12-15 14:26:20 +08:00
</li>
<li class="nav-item">
2023-04-24 16:18:48 +08:00
<a class="nav-link" data-toggle="tab" href="#tab_borders_icons-3"
role="tab"><i class="fal fa-cog mr-1"></i> 角色權限</a>
2022-12-15 14:26:20 +08:00
</li>
</ul>
<div class="tab-content border border-top-0 p-3 w-100">
2022-12-14 11:57:40 +08:00
<div class="tab-pane fade show active" id="tab_borders_icons-1" role="tabpanel" data-id="accMan">
<div class="row mb-5 align-items-end">
<div class="col-auto">
<div class="form-group">
2022-12-14 11:57:40 +08:00
<label class="form-label" for="seaAccManName">姓名</label>
<input type="text" id="seaAccManName" class="form-control">
</div>
</div>
<div class="col-auto">
<div class="form-group">
2022-12-14 11:57:40 +08:00
<label class="form-label" for="seaAccManRolName">角色</label>
<input type="text" id="seaAccManRolName" class="form-control">
</div>
</div>
2022-12-14 11:57:40 +08:00
<!--<div class="col-auto">
<div class="form-group">
<label class="form-label" for="example-select">狀態</label>
<select class="form-control" id="example-select select2bs4">
<option>啟用中</option>
<option>停用</option>
</select>
</div>
2022-12-14 11:57:40 +08:00
</div>-->
<div class="col-auto"> <a href="#" class="btn btn-info" id="acc_searchBtn">搜尋</a> </div>
</div>
<div class="frame-wrap">
2023-01-04 18:38:36 +08:00
<div class="mb-3" hidden>
2022-12-15 14:26:20 +08:00
<a href="#" class="btn btn-success" data-toggle="modal"
data-target="#accManModal">+ 新增</a>
</div>
<table id="accManTable" class="table table-bordered table-striped text-center m-0 w-100">
</table>
</div>
</div>
2022-12-14 11:57:40 +08:00
<div class="tab-pane fade" id="tab_borders_icons-2" role="tabpanel" data-id="rolMan">
<div class="row mb-5 align-items-end">
<div class="col-auto">
<div class="form-group">
2022-12-15 14:26:20 +08:00
<label class="form-label" for="seaRolName">角色</label>
<input type="text" id="seaRolName" class="form-control">
</div>
</div>
2022-12-15 14:26:20 +08:00
<div class="col-auto"> <a href="#" class="btn btn-info" id="rol_searchBtn">搜尋</a> </div>
</div>
<div class="frame-wrap">
2022-12-15 14:26:20 +08:00
<div class="mb-3">
<a href="#" class="btn btn-success" data-toggle="modal"
data-target="#groupModal">+ 新增</a>
</div>
<table id="rolManTable" class="table table-bordered table-striped text-center m-0 w-100">
</table>
</div>
</div>
2022-12-14 11:57:40 +08:00
<div class="tab-pane fade" id="tab_borders_icons-3" role="tabpanel" data-id="rolAuth">
<div class="row mb-5 align-items-end">
<div class="col-auto">
<div class="form-group">
<label class="form-label" for="roleSel">角色</label>
<select class="form-control select2bs4" id="roleSel">
</select>
</div>
</div>
</div>
<div class="frame-wrap">
2022-12-15 14:26:20 +08:00
<div class="mb-3">
<a href="#" class="btn btn-success" data-toggle="modal"
data-target="#authPageModal">+ 加入可用功能</a>
</div>
<table id="rolAuthTable" class="table table-bordered table-striped text-center m-0 w-100">
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!-- Modal center Add -->
2022-12-14 11:57:40 +08:00
<div class="modal fade" id="accManModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
人員基本資料新增 / 修改
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
<form id="accManForm">
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="inpEmail">Email</label>
<input type="email" id="inpEmail" name="inpEmail" class="form-control"
2022-12-15 14:26:20 +08:00
placeholder="Email">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="inpName">姓名</label>
<input type="text" id="inpName" name="inpName" class="form-control">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="inpAcc">帳號</label>
2023-01-04 18:38:36 +08:00
<input type="text" id="inpAcc" name="inpAcc" class="form-control" disabled>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="selRolAuth">角色權限</label>
<select class="form-control" id="selRolAuth" name="selRolAuth">
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="inpPhone">電話</label>
<input type="text" id="inpPhone" name="inpPhone" class="form-control">
</div>
</div>
</div>
</div>
<div class="modal-footer">
2022-12-14 11:57:40 +08:00
<button type="button" class="btn btn-secondary" id="accManCanBtn" data-dismiss="modal">關閉</button>
<button type="button" class="btn btn-primary" id="accManSendBtn" e-prevent>儲存</button>
</div>
</form>
</div>
</div>
</div>
<!-- Modal group Add -->
2022-12-14 11:57:40 +08:00
<div class="modal fade" id="groupModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
群組基本資料新增 / 修改
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
<form id="accManForm">
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="groupName">名稱</label>
<input type="text" id="groupName" name="groupName" class="form-control">
</div>
</div>
</div>
</div>
<div class="modal-footer">
2022-12-15 14:26:20 +08:00
<button type="button" class="btn btn-secondary" id="accRolCanBtn" data-dismiss="modal">關閉</button>
<button type="button" class="btn btn-primary" id="accRolSavBtn" e-prevent>儲存</button>
</div>
</form>
</div>
</div>
</div>
<!-- Modal center 設備權限 -->
2022-12-15 14:26:20 +08:00
<div class="modal fade" id="accManSysModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
2022-12-22 17:18:29 +08:00
<h4 id="devSysTabTitle" class="modal-title">
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
<div class="modal-body">
2022-12-22 17:18:29 +08:00
<table id="devSysTable" class="table table-bordered table-striped text-center m-0 w-100">
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">關閉</button>
2022-12-22 17:18:29 +08:00
<button id="accManSysRolSavBtn" type="button" class="btn btn-primary" data-id="">儲存</button>
</div>
</div>
</div>
</div>
2022-12-15 14:26:20 +08:00
<!-- Modal center 頁面權限 -->
<div class="modal fade" id="authPageModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
選擇功能
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
<div class="modal-body">
2022-12-15 14:26:20 +08:00
<table id="accAuthPageTable" class="table table-bordered table-striped text-center m-0 w-100">
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">關閉</button>
2022-12-15 14:26:20 +08:00
<button type="button" id="authPageSavBtn" class="btn btn-primary">儲存</button>
</div>
</div>
</div>
</div>
<!-- delete modal -->
2022-12-14 11:57:40 +08:00
<div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-footer">
<h4 class="mr-auto">確定刪除?</h4>
<button type="button" class="btn btn-primary" id="confirmDelBtn" aria-label="OK" e-prevent>
確定
</button>
2022-12-14 11:57:40 +08:00
<button type="button" class="btn btn-danger" id="closeDelBtn" data-dismiss="modal" aria-label="No">
取消
2022-12-14 11:57:40 +08:00
</button>
</div>
</div>
</div>
</div>
<script>
var rolAuthTable = null;
2023-04-24 16:18:48 +08:00
var accManTable = null;
var rolManTable = null;
$(function () {
2023-01-04 18:38:36 +08:00
asyncUser(initCallBack);
})
function loadAccManTable() {
let ajaxObj = {
url: baseApiUrl + "/User/UserManagerList",
method: "POST",
}
let tag = "#accManTable";
2022-12-14 11:57:40 +08:00
let sendData = {};
if (pageAct.accManName != null)
2022-12-15 14:26:20 +08:00
sendData.Full_name = pageAct.accManName;
2022-12-14 11:57:40 +08:00
if (pageAct.accRolName != null)
2022-12-15 14:26:20 +08:00
sendData.Role_full_name = pageAct.accRolName;
2022-12-14 11:57:40 +08:00
ajaxObj.data = sendData;
let column_defs = [
{ "targets": [0], "width": "6%", "sortable": true },
2022-12-15 14:26:20 +08:00
{ "targets": [1], "width": "10%", "sortable": true },
{ "targets": [2], "width": "14%", "sortable": true },
2022-12-15 14:26:20 +08:00
{ "targets": [3], "width": "10%", "sortable": true },
{ "targets": [4], "width": "14%", "sortable": true },
2022-12-15 14:26:20 +08:00
{ "targets": [5], "width": "10%", "sortable": true },
{ "targets": [6], "width": "14%", "sortable": true },
2022-12-15 14:26:20 +08:00
{ "targets": [7], "width": "22%", "sortable": true },
];
let columns = [
{
"title": "#",
"data": null,
"render": function (data, type, row, meta) {
return meta.row + 1;
}
},
{
"title": "姓名",
"data": "full_name",
},
{
"title": "帳號",
"data": "account",
},
{
"title": "角色",
"data": "role_full_name",
},
{
"title": "email",
"data": "email",
},
{
"title": "手機號碼",
"data": "phone",
},
{
"title": "建立時間",
"data": "created_at",
},
{
"title": "功能",
"data": "userinfo_guid",
"render": function (data, type, row, meta) {
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" }));
2022-12-22 18:01:17 +08:00
btnDiv.append(creBtnHtml("設備權限", "accManSysRolEdiBtn" + data, null, ["btn", "btn-info"], { "toggle": "modal", "target": "#accManSysModal", "fullname": row.full_name }));
/*btnDiv.append(creBtnHtml("刪除", "accManDelBtn" + data, null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));*/
return btnDiv.outerHtml();
}
},
];
2023-04-24 16:18:48 +08:00
accManTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
}
function loadRolManTable() {
let ajaxObj = {
url: baseApiUrl + "/User/RoleManagerList",
method: "POST",
}
2022-12-15 14:26:20 +08:00
let sendData = {};
2023-01-04 18:38:36 +08:00
sendData.Layer = 1;
2022-12-15 14:26:20 +08:00
if (pageAct.rolName != null)
sendData.Full_name = pageAct.rolName;
ajaxObj.data = sendData;
let tag = "#rolManTable";
let column_defs = [
{ "targets": [0], "width": "15%", "sortable": true },
{ "targets": [1], "width": "50%", "sortable": true },
{ "targets": [2], "width": "20%", "sortable": true },
{ "targets": [3], "width": "15%", "sortable": true },
];
let columns = [
{
"title": "編號",
"data": null,
"render": function (data, type, row, meta) {
return meta.row + 1;
}
},
{
"title": "名稱",
"data": "full_name",
},
{
"title": "建立時間",
"data": "created_at",
},
{
"title": "功能",
"data": "layer",
"render": function (data, type, row, meta) {
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
2022-12-15 14:26:20 +08:00
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();
}
},
];
2023-04-24 16:18:48 +08:00
rolManTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
}
function loadRolAuthTable() {
2022-12-15 14:26:20 +08:00
pageAct.authCode = [];
2022-12-22 18:01:17 +08:00
let ajaxObj = {
url: baseApiUrl + "/User/RoleAuthList",
method: "POST",
2022-12-15 14:26:20 +08:00
data: { SelectedRoleId: pageAct.selRolAuth },
}
let tag = "#rolAuthTable";
let column_defs = [
{ "targets": [0], "width": "6%", "sortable": true },
{ "targets": [1], "width": "12%", "sortable": true },
{ "targets": [2], "width": "14%", "sortable": true },
{ "targets": [3], "width": "12%", "sortable": true },
{ "targets": [4], "width": "14%", "sortable": true },
{ "targets": [5], "width": "14%", "sortable": true },
{ "targets": [6], "width": "14%", "sortable": true },
{ "targets": [7], "width": "14%", "sortable": true },
];
let columns = [
{
"title": "編號",
2022-12-15 14:26:20 +08:00
"data": "authCode",
"render": function (data, type, row, meta) {
return meta.row + 1;
}
},
{
"title": "角色",
"data": "role_full_name",
},
{
"title": "功能類型",
"data": "authTypeText",
},
{
"title": "區域",
"data": "building_full_name",
},
{
"title": "功能名稱",
"data": "mainName",
},
{
"title": "功能細項名稱",
"data": "subName",
},
{
"title": "建立時間",
"data": "created_at",
},
{
"title": "功能",
2022-12-15 14:26:20 +08:00
"data": "role_guid",
"render": function (data, type, row, meta) {
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
2022-12-15 14:26:20 +08:00
btnDiv.append(creBtnHtml("刪除", "rolAuthDelBtn" + data, null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal", "id": data, "authcode": row.authCode }));
return btnDiv.outerHtml();
}
},
];
rolAuthTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
2022-12-22 18:01:17 +08:00
let url = baseApiUrl + "/User/RoleAuthList";
objSendData.Data = { SelectedRoleId: pageAct.selRolAuth }
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
$.each(res.data, function (i, v) {
pageAct.authCode.push(v.authCode);
});
}
}, null, "POST").send();
}
2022-12-15 14:26:20 +08:00
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 = [
{
2022-12-22 18:01:17 +08:00
"title": "選擇",
2022-12-15 14:26:20 +08:00
"data": 'authCode',
"render": function (data, type, row, meta) {
return `<td><input id='${data}' type="checkbox"></td>`
}
},
{
2022-12-22 18:01:17 +08:00
"title": "編號",
2022-12-15 14:26:20 +08:00
"data": null,
"render": function (data, type, row, meta) {
return meta.row + 1;
}
},
{
2022-12-22 17:18:29 +08:00
"title": "存取權限",
2022-12-22 18:01:17 +08:00
"data": "subName"
2022-12-15 14:26:20 +08:00
}
];
accAuthPageTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
}
2022-12-22 17:18:29 +08:00
function loadDevSysTable(data) {
2022-12-22 18:01:17 +08:00
let tag = "#devSysTable";
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": 'sub_system_tag',
},
{
"title": "類別名稱",
"data": "full_name",
},
{
"title": "功能名稱",
2022-12-22 17:18:29 +08:00
"data": null,
2022-12-22 18:01:17 +08:00
"render": function (data, type, row, meta) {
return `<div class="custom-control custom-checkbox">
2022-12-22 17:18:29 +08:00
<input type="checkbox" class="custom-control-input" id="${row.auth_code}" data-type="usrDevSys">
<label class="custom-control-label" for="${row.auth_code}">啟用</label>
</div>`;
2022-12-22 18:01:17 +08:00
}
}
];
2022-12-22 17:18:29 +08:00
2022-12-22 18:01:17 +08:00
devSysTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
}
2022-12-22 17:18:29 +08:00
function getRoleSel() {
let url = baseApiUrl + "/User/RoleManagerList";
let sendData = {
post: 1,
2023-01-04 18:38:36 +08:00
Layer: 1
};
objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
2022-12-15 14:26:20 +08:00
$("#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));
2022-12-15 14:26:20 +08:00
if (index == 0)
2023-04-24 16:18:48 +08:00
pageAct.selRolAuth = roleObj.role_guid;
})
}
}, null, "POST").send();
}
function events() {
onEvent("change", "#roleSel", function () {
let roleGuid = $(this).val();
2022-12-22 18:01:17 +08:00
pageAct.selRolAuth = $(this).val();
dtAjaxResetSendData(rolAuthTable, { SelectedRoleId: roleGuid })
2022-12-22 18:01:17 +08:00
loadRolAuthTable();
setAuthPage();
})
2022-12-14 11:57:40 +08:00
onEvent("click", "[data-target*=accManModal]", function () {
pageAct.accManId = $(this).prop('id').split('Btn')[1]
$("#inpAcc").val('');
$("#inpName").val('');
$("#inpEmail").val('');
$("#inpPhone").val('');
$("#selRolAuth").val($($('#selRolAuth option')[0]).val());
if ($(this).prop('id') !== undefined) {
let url = baseApiUrl + "/User/GetOneUser";
let sendData = {
Id: $(this).prop('id').split('Btn')[1],
};
objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
$("#inpAcc").val(res.data.account);
$("#inpName").val(res.data.full_name);
$("#inpEmail").val(res.data.email);
$("#inpPhone").val(res.data.phone);
$("#selRolAuth").val(res.data.role_guid);
}
}, null, "POST").send();
}
});
2022-12-15 14:26:20 +08:00
onEvent("click", "[id*=accManDelBtn]", function () {
pageAct.accManId = $(this).prop('id').split('Btn')[1];
});
2022-12-14 11:57:40 +08:00
onEvent("click", "#accManSendBtn", function () {
let form = $("#accManForm");
$(form).validate({
rules: {
inpEmail: { required: true, email: true },
inpName: { required: true, minlength: 2, dbLimit: 50 },
2022-12-14 11:57:40 +08:00
inpAcc: { required: true, dbLimit: 50 },
selRolAuth: { required: true },
inpPhone: { phone: true },
}
});
if ($(form).valid()) {
let url = baseApiUrl + "/User/SaveUser";
let sendData = {
2022-12-14 11:57:40 +08:00
Id: pageAct.accManId ?? "0",
Account: $("#inpAcc").val(),
Name: $("#inpName").val(),
Email: $("#inpEmail").val(),
Phone: $("#inpPhone").val(),
RoleId: $("#selRolAuth").val(),
};
2022-12-14 11:57:40 +08:00
objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
2022-12-14 11:57:40 +08:00
if (!res || res.code != "0000" || !res.msg) {
} else {
2022-12-14 11:57:40 +08:00
toast_ok(pageAct.accManId == null ? common.AddSuc : common.EditSuc);
//$("#accManModal").modal("hide");
$("#accManCanBtn").click();
pageAct.accManId = null;
loadAccManTable();
}
}, null, "POST").send();
}
})
2022-12-14 11:57:40 +08:00
onEvent("change", "#seaAccManName", function () {
pageAct.accManName = $(this).val() || null;
2022-12-15 14:26:20 +08:00
});
2022-12-14 11:57:40 +08:00
onEvent("change", "#seaAccManRolName", function () {
pageAct.accRolName = $(this).val() || null;
});
2022-12-15 14:26:20 +08:00
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');
2022-12-14 11:57:40 +08:00
if (acc_table == "accMan")
loadAccManTable();
else if (acc_table == "rolMan")
loadRolManTable();
2022-12-15 14:26:20 +08:00
else if (acc_table == "rolAuth") {
2022-12-14 11:57:40 +08:00
loadRolAuthTable();
2022-12-15 14:26:20 +08:00
setAuthPage();
2022-12-22 18:01:17 +08:00
}
2022-12-14 11:57:40 +08:00
});
2022-12-15 14:26:20 +08:00
onEvent("click", "li.nav-item", function () {
2023-04-24 16:18:48 +08:00
let acc_table = $('#' + $(this).find('a').prop('href').split('#')[1]).data('id');
if (acc_table == "accMan") {
loadAccManTable();
}
else if (acc_table == "rolMan")
loadRolManTable();
else if (acc_table == "rolAuth") {
loadRolAuthTable();
setAuthPage();
}
2022-12-15 14:26:20 +08:00
pageAct.rolManId = null;
pageAct.accManId = null;
$('#roleSel').html('');
$("#selRolAuth").html('');
getRoleSel();
2022-12-14 11:57:40 +08:00
});
onEvent("click", "#confirmDelBtn", function () {
2022-12-15 14:26:20 +08:00
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,
};
if (pageAct.authUsrId != null)
sendData.AuthCode = pageAct.authCode;
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');
2022-12-14 11:57:40 +08:00
})
2022-12-15 14:26:20 +08:00
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 {
2023-04-24 16:18:48 +08:00
toast_ok(common.EditSuc);
2022-12-15 14:26:20 +08:00
//$("#groupModal").modal("hide");
$('#accRolCanBtn').click();
pageAct.rolManId = null;
loadRolManTable();
}
}, null, "POST").send();
});
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();
});
2022-12-22 17:18:29 +08:00
onEvent("click", "[id*=accManSysRolEdiBtn]", function () {
pageAct.addUsrDevSys = [];
pageAct.delUsrDevSys = [];
let name = $(this).data('fullname');
let id = $(this).prop('id').split('Btn')[1];
2022-12-22 18:01:17 +08:00
let url = baseApiUrl + "/User/GetMainSub";
let sendData = {
building_tag: pageAct.buiTag
}
objSendData.Data = sendData;
2022-12-22 17:18:29 +08:00
function success(res) {
$('#devSysTabTitle').html(name);
$('#accManSysRolSavBtn').attr('data-id', id);
let data = [];
$.each(res.data.history_Main_Systems, function (i, v) {
$.each(v.history_Sub_systems, function (i, v) {
data.push(v);
});
});
if (data.length > 0) {
loadDevSysTable(data);
getUsrDevSys(id);
2022-12-22 18:01:17 +08:00
}
}
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
2022-12-22 17:18:29 +08:00
});
onEvent("click", "[data-type=usrDevSys]", function () {
if (pageAct.usrDevSys.length > 0) {
if ($(this).is(':checked')) {
2022-12-22 18:01:17 +08:00
if ((jQuery.inArray($(this).prop('id'), pageAct.usrDevSys) == -1)) {
pageAct.addUsrDevSys.push($(this).prop('id'));
2022-12-22 17:18:29 +08:00
}
2022-12-22 18:01:17 +08:00
if (jQuery.inArray($(this).prop('id'), pageAct.delUsrDevSys) != -1) {
pageAct.delUsrDevSys.splice($.inArray($(this).prop('id'), pageAct.delUsrDevSys), 1);
}
2022-12-22 17:18:29 +08:00
}
else {
2022-12-22 18:01:17 +08:00
if (jQuery.inArray($(this).prop('id'), pageAct.usrDevSys) != -1) {
pageAct.delUsrDevSys.push($(this).prop('id'));
2022-12-22 17:18:29 +08:00
}
2022-12-22 18:01:17 +08:00
if (jQuery.inArray($(this).prop('id'), pageAct.addUsrDevSys) != -1) {
pageAct.addUsrDevSys.splice($.inArray($(this).prop('id'), pageAct.addUsrDevSys), 1);
}
}
2022-12-22 17:18:29 +08:00
}
});
onEvent("click", "#accManSysRolSavBtn", function () {
//get user role id
2022-12-22 18:01:17 +08:00
let url = baseApiUrl + "/User/GetUsrRolId";
let sendData = {
userinfo_guid: $(this).data('id')
}
objSendData.Data = sendData;
2022-12-22 17:18:29 +08:00
function success(res) {
//save role auth(devSys)
url = baseApiUrl + "/User/SaveRoleAuth";
sendData = {
SelectedRoleId: res.data,
SaveCheckAuth: pageAct.addUsrDevSys
}
objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, null, null, "POST").send();
//delete role auth(devSys)
2022-12-22 18:01:17 +08:00
url = baseApiUrl + "/User/DelDevSysRoleAuth";
sendData = {
SelectedRoleId: res.data,
SaveCheckAuth: pageAct.delUsrDevSys
}
objSendData.Data = sendData;
2022-12-22 17:18:29 +08:00
ytAjax = new YourTeam.Ajax(url, objSendData, null, null, "POST").send();
2022-12-22 18:01:17 +08:00
$("#accManSysModal").modal("hide");
}
2022-12-22 17:18:29 +08:00
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
});
}
2022-12-14 11:57:40 +08:00
function clearPagSes() {
pageAct.accManId = null;
pageAct.accManName = null;
pageAct.accRolName = null;
2022-12-15 14:26:20 +08:00
pageAct.rolName = null;
pageAct.rolManId = null;
pageAct.selRolAuth = null;
pageAct.authCode = [];
2022-12-22 17:18:29 +08:00
pageAct.useDevSys = [];
2022-12-15 14:26:20 +08:00
}
2023-08-03 12:20:37 +08:00
function setAuthPage() {
$(`#accAuthPageTable input[type=checkbox]`).removeClass();
$.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();
});
}
2022-12-22 17:18:29 +08:00
function getUsrDevSys(user_guid) {
2022-12-22 18:01:17 +08:00
let url = baseApiUrl + "/User/GetUsrDevSys";
2022-12-22 17:18:29 +08:00
let sendData = {
userinfo_guid: user_guid
2022-12-22 18:01:17 +08:00
}
objSendData.Data = sendData;
2022-12-22 17:18:29 +08:00
function success(res) {
pageAct.usrDevSys = [];
$.each($(`#devSysTable input[type=checkbox]:checked`), function (i, v) {
$(v).click();
});
$.each(res.data, function (i, v) {
2022-12-22 18:01:17 +08:00
$(`#devSysTable input[type=checkbox][id=${v}]`).click();
2022-12-22 17:18:29 +08:00
});
pageAct.usrDevSys = res.data;
2022-12-22 18:01:17 +08:00
}
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
2022-12-22 17:18:29 +08:00
}
2023-01-04 15:25:24 +08:00
2023-01-04 18:38:36 +08:00
function initCallBack() {
2023-04-24 16:18:48 +08:00
clearPagSes();
getRoleSel();
loadAccManTable();
loadRolManTable();
loadAuthPageTable();
loadRolAuthTable();
setAuthPage();
events();
2023-01-04 18:38:36 +08:00
}
2023-04-24 16:18:48 +08:00
function asyncUser() {
getUserByBaja(syncUsrCallBack)
2023-01-04 15:25:24 +08:00
}
function syncUsrCallBack(rel) {
let url = baseApiUrl + "/User/SyncUser";
2023-04-24 16:18:48 +08:00
var data = JSON.parse(rel);
2023-01-04 15:25:24 +08:00
objSendData.Data = data.data;
2023-01-04 18:38:36 +08:00
ytAjax = new YourTeam.Ajax(url, objSendData, function () {
2023-04-24 16:18:48 +08:00
initCallBack();
2023-01-04 18:38:36 +08:00
}, null, "POST").send();
}
</script>