修改使用者權限
This commit is contained in:
parent
d68beacee5
commit
d6d8f91378
@ -191,59 +191,19 @@
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">
|
||||
王小明
|
||||
<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">
|
||||
<table class="table table-bordered table-striped text-center m-0 w-100">
|
||||
<thead class="thead-themed">
|
||||
<tr>
|
||||
<th>類別代號</th>
|
||||
<th>類別名稱</th>
|
||||
<th>存取權限</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>0220100010</td>
|
||||
<td>電錶</td>
|
||||
<td>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
||||
<label class="custom-control-label" for="defaultUnchecked">啟用</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0220100010</td>
|
||||
<td>照明設備</td>
|
||||
<td>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
||||
<label class="custom-control-label" for="defaultUnchecked">啟用</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0220100010</td>
|
||||
<td>環境感測</td>
|
||||
<td>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="defaultUnchecked">
|
||||
<label class="custom-control-label" for="defaultUnchecked">啟用</label>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<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>
|
||||
<button id="accManSysRolSavBtn" type="button" class="btn btn-primary">儲存</button>
|
||||
<button id="accManSysRolSavBtn" type="button" class="btn btn-primary" data-id="">儲存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -368,7 +328,7 @@
|
||||
|
||||
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("設備權限", "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();
|
||||
}
|
||||
@ -487,6 +447,7 @@
|
||||
"title": "功能",
|
||||
"data": "role_guid",
|
||||
"render": function (data, type, row, meta) {
|
||||
pageAct.authCode.push(row.authCode);
|
||||
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" });
|
||||
btnDiv.append(creBtnHtml("刪除", "rolAuthDelBtn" + data, null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal", "id": data, "authcode": row.authCode }));
|
||||
return btnDiv.outerHtml();
|
||||
@ -513,28 +474,61 @@
|
||||
|
||||
let columns = [
|
||||
{
|
||||
"title": "選擇",
|
||||
"title": "選擇",
|
||||
"data": 'authCode',
|
||||
"render": function (data, type, row, meta) {
|
||||
return `<td><input id='${data}' type="checkbox"></td>`
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "編號",
|
||||
"title": "編號",
|
||||
"data": null,
|
||||
"render": function (data, type, row, meta) {
|
||||
return meta.row + 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "功能名稱",
|
||||
"data": "subName",
|
||||
"title": "存取權限",
|
||||
"data": "subName"
|
||||
}
|
||||
];
|
||||
|
||||
accAuthPageTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
|
||||
}
|
||||
|
||||
function loadDevSysTable(data) {
|
||||
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": "功能名稱",
|
||||
"data": null,
|
||||
"render": function (data, type, row, meta) {
|
||||
return `<div class="custom-control custom-checkbox">
|
||||
<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>`;
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
devSysTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
|
||||
}
|
||||
|
||||
function getRoleSel() {
|
||||
|
||||
let url = baseApiUrl + "/User/RoleManagerList";
|
||||
@ -562,7 +556,10 @@
|
||||
function events() {
|
||||
onEvent("change", "#roleSel", function () {
|
||||
let roleGuid = $(this).val();
|
||||
pageAct.selRolAuth = $(this).val();
|
||||
dtAjaxResetSendData(rolAuthTable, { SelectedRoleId: roleGuid })
|
||||
loadRolAuthTable();
|
||||
setAuthPage();
|
||||
})
|
||||
|
||||
onEvent("click", "[data-target*=accManModal]", function () {
|
||||
@ -735,12 +732,6 @@
|
||||
}, 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');
|
||||
@ -769,6 +760,89 @@
|
||||
}
|
||||
}, null, "POST").send();
|
||||
});
|
||||
|
||||
onEvent("click", "[id*=accManSysRolEdiBtn]", function () {
|
||||
pageAct.addUsrDevSys = [];
|
||||
pageAct.delUsrDevSys = [];
|
||||
|
||||
let name = $(this).data('fullname');
|
||||
let id = $(this).prop('id').split('Btn')[1];
|
||||
let url = baseApiUrl + "/User/GetMainSub";
|
||||
let sendData = {
|
||||
building_tag: pageAct.buiTag
|
||||
}
|
||||
objSendData.Data = sendData;
|
||||
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);
|
||||
}
|
||||
}
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
||||
});
|
||||
|
||||
onEvent("click", "[data-type=usrDevSys]", function () {
|
||||
if (pageAct.usrDevSys.length > 0) {
|
||||
if ($(this).is(':checked')) {
|
||||
if ((jQuery.inArray($(this).prop('id'), pageAct.usrDevSys) == -1)) {
|
||||
pageAct.addUsrDevSys.push($(this).prop('id'));
|
||||
}
|
||||
|
||||
if (jQuery.inArray($(this).prop('id'), pageAct.delUsrDevSys) != -1) {
|
||||
pageAct.delUsrDevSys.splice($.inArray($(this).prop('id'), pageAct.delUsrDevSys), 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (jQuery.inArray($(this).prop('id'), pageAct.usrDevSys) != -1) {
|
||||
pageAct.delUsrDevSys.push($(this).prop('id'));
|
||||
}
|
||||
|
||||
if (jQuery.inArray($(this).prop('id'), pageAct.addUsrDevSys) != -1) {
|
||||
pageAct.addUsrDevSys.splice($.inArray($(this).prop('id'), pageAct.addUsrDevSys), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
onEvent("click", "#accManSysRolSavBtn", function () {
|
||||
//get user role id
|
||||
let url = baseApiUrl + "/User/GetUsrRolId";
|
||||
let sendData = {
|
||||
userinfo_guid: $(this).data('id')
|
||||
}
|
||||
objSendData.Data = sendData;
|
||||
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)
|
||||
url = baseApiUrl + "/User/DelDevSysRoleAuth";
|
||||
sendData = {
|
||||
SelectedRoleId: res.data,
|
||||
SaveCheckAuth: pageAct.delUsrDevSys
|
||||
}
|
||||
objSendData.Data = sendData;
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, null, null, "POST").send();
|
||||
|
||||
$("#accManSysModal").modal("hide");
|
||||
}
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
||||
});
|
||||
}
|
||||
|
||||
function clearPagSes() {
|
||||
@ -779,11 +853,10 @@
|
||||
pageAct.rolManId = null;
|
||||
pageAct.selRolAuth = null;
|
||||
pageAct.authCode = [];
|
||||
pageAct.useDevSys = [];
|
||||
}
|
||||
|
||||
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();
|
||||
@ -798,4 +871,26 @@
|
||||
$(`#accAuthPageTable input[id=${v}]`).attr('disabled', true);
|
||||
});
|
||||
}
|
||||
|
||||
function getUsrDevSys(user_guid) {
|
||||
let url = baseApiUrl + "/User/GetUsrDevSys";
|
||||
let sendData = {
|
||||
userinfo_guid: user_guid
|
||||
}
|
||||
objSendData.Data = sendData;
|
||||
function success(res) {
|
||||
pageAct.usrDevSys = [];
|
||||
|
||||
$.each($(`#devSysTable input[type=checkbox]:checked`), function (i, v) {
|
||||
$(v).click();
|
||||
});
|
||||
|
||||
$.each(res.data, function (i, v) {
|
||||
$(`#devSysTable input[type=checkbox][id=${v}]`).click();
|
||||
});
|
||||
|
||||
pageAct.usrDevSys = res.data;
|
||||
}
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
||||
}
|
||||
</script>
|
@ -1463,62 +1463,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ml-auto d-flex">
|
||||
<div class="btn-group mx-4">
|
||||
<a href="javascript:;" name="topFunBtn" data-page="dashboard" class="text-center">
|
||||
<i class="fal fa-home fa-2x"></i><br>首頁
|
||||
</a>
|
||||
<!--<div class="dropdown-menu">
|
||||
<button class="dropdown-item" type="button">Action</button>
|
||||
<button class="dropdown-item" type="button">Another action</button>
|
||||
<button class="dropdown-item" type="button">Something else here</button>
|
||||
</div>-->
|
||||
</div>
|
||||
<div class="btn-group mx-4">
|
||||
<a href="javascript:;" class="dropdown-toggle no-arrow text-center" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fal fa-tv fa-2x"></i><br>系統監控
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-select-menu js-auto-close" id="sysMonBtnList">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group mx-4">
|
||||
<a href="javascript:;" name="topFunBtn" class="dropdown-toggle no-arrow text-center"
|
||||
data-page="energyManagement">
|
||||
<i class="fal fa-chart-pie fa-2x"></i><br>能源管理
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group mx-4">
|
||||
<a href="javascript:;" name="topFunBtn" class="dropdown-toggle no-arrow text-center"
|
||||
data-page="historyData">
|
||||
<i class="fal fa-chart-area fa-2x"></i><br>歷史資料
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group mx-4">
|
||||
<a href="javascript:;" name="topFunBtn" class="dropdown-toggle no-arrow text-center"
|
||||
data-page="alert">
|
||||
<i class="fal fa-bell fa-2x"></i><br>即時告警
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group mx-4">
|
||||
<a href="javascript:;" name="topFunBtn" class="no-arrow text-center"
|
||||
data-page="operation">
|
||||
<i class="fal fa-server fa-2x"></i><br>運維管理
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group mx-4">
|
||||
<a href="javascript:;" name="topFunBtn" class="no-arrow text-center"
|
||||
data-page="graphManagement">
|
||||
<i class="fal fa-image fa-2x"></i><br>圖資管理
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group mx-4">
|
||||
<a href="javascript:;" name="topFunBtn" class="no-arrow text-center"
|
||||
data-page="accountManagement">
|
||||
<i class="fal fa-user fa-2x"></i><br>帳號管理
|
||||
</a>
|
||||
</div>
|
||||
<div class="ml-auto d-flex" id="froLisPage">
|
||||
|
||||
</div>
|
||||
<div class="ml-auto d-flex">
|
||||
@ -2190,38 +2135,12 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
function isValidLogin() {
|
||||
$("#app").load("_dashboard.html", loadCallback);
|
||||
|
||||
iniFroList();
|
||||
showMainSys();
|
||||
getBuiList();
|
||||
getSysMonBtnList();
|
||||
checkDevState();
|
||||
|
||||
function getSysMonBtnList() {
|
||||
let url = baseApiUrl + "/api/Device/GetMainSub";
|
||||
let sendData = {
|
||||
building_tag: pageAct.buiTag,
|
||||
};
|
||||
objSendData.Data = sendData;
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
||||
if (!res || res.code != "0000" || !res.data) {
|
||||
|
||||
} else {
|
||||
$("#sysMonBtnList").html("")
|
||||
$.each(res.data.history_Main_Systems, (index, mainSysObj) => {
|
||||
$.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => {
|
||||
let page = "systemMonitor";
|
||||
if (subSysObj.sub_system_tag == "EL") {
|
||||
page = "sysElevator";
|
||||
}
|
||||
let btn = creBtn(subSysObj.full_name, `subSysBtn${subSysObj.sub_system_tag}`, "topFunBtn", ["dropdown-item"], { page: page });
|
||||
subSysObj.main_system_tag = mainSysObj.main_system_tag;
|
||||
btn.data("subSysObj", subSysObj);
|
||||
$("#sysMonBtnList").append(btn);
|
||||
})
|
||||
})
|
||||
}
|
||||
}, null, "POST").send();
|
||||
}
|
||||
|
||||
function getBuiList() {
|
||||
let url = baseApiUrl + "/api/Device/GetBuild";
|
||||
ytAjax = new YourTeam.Ajax(url, null, function (res) {
|
||||
@ -2417,7 +2336,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
function drawErrRecTabBlo() {
|
||||
let strHtml = `<table id="errRecTable" class="table table-bordered table-striped text-center m-0 w-100">
|
||||
|
||||
</table>`
|
||||
</table>`
|
||||
return strHtml;
|
||||
}
|
||||
|
||||
@ -2425,7 +2344,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
function drawOpeRecTabBlo() {
|
||||
let strHtml = `<table id="opeRecTable" class="table table-bordered table-striped text-center m-0 w-100">
|
||||
|
||||
</table>`
|
||||
</table>`
|
||||
return strHtml;
|
||||
}
|
||||
|
||||
@ -2438,37 +2357,37 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
$(ele).YTTooltip({
|
||||
html: `<div class="card m-1 border device-wrap">
|
||||
|
||||
<div class="card-header p-3">
|
||||
|
||||
<div class="position-absolute w-50" style="word-break: break-all;">
|
||||
<label class="m-0 mt-2">${devName}</label>
|
||||
</div>
|
||||
<div id="card-tab" class="row justify-content-end nav nav-tabs" role="tablist">
|
||||
<button type="button" id="state-tab" class="btn btn-icon nav-link active" role="tab" data-tabname="cardTab" data-target="#state"><i class="fa fa-desktop icon"></i></button>
|
||||
<button type="button" id="info-tab" class="btn btn-icon nav-link" role="tab" data-tabname="cardTab" data-target="#info"><i class="fa fa-cog icon"></i></button>
|
||||
<button type="button" id="errRec-tab" class="btn btn-icon nav-link" role="tab" data-tabname="cardTab" data-target="#errRec"><i class="fas fa-exclamation-triangle"></i></button>
|
||||
<button type="button" id="opeRec-tab" class="btn btn-icon nav-link" role="tab" data-tabname="cardTab" data-target="#opeRec"><i class="fa fa-bars icon"></i></button>
|
||||
<button class="btn p-2"><i class="fas fa-times fs-1 text-white-50" data-close="yttooltip"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-2 tab-content">
|
||||
|
||||
<div id="state" class="show active" data-tabname="cardTab" data-tabrole="child">
|
||||
${drawStateTabBlo(devNum)}
|
||||
</div>
|
||||
<div id="info" data-tabname="cardTab" data-tabrole="child">
|
||||
${drawInfoTabBlo(devGuid)}
|
||||
</div>
|
||||
<div id="errRec" data-tabname="cardTab" data-tabrole="child">
|
||||
${drawErrRecTabBlo()}
|
||||
</div>
|
||||
<div id="opeRec" data-tabname="cardTab" data-tabrole="child">
|
||||
${drawOpeRecTabBlo()}
|
||||
</div>
|
||||
|
||||
<div class="card-header p-3">
|
||||
|
||||
<div class="position-absolute w-50" style="word-break: break-all;">
|
||||
<label class="m-0 mt-2">${devName}</label>
|
||||
</div>
|
||||
</div>`,
|
||||
<div id="card-tab" class="row justify-content-end nav nav-tabs" role="tablist">
|
||||
<button type="button" id="state-tab" class="btn btn-icon nav-link active" role="tab" data-tabname="cardTab" data-target="#state"><i class="fa fa-desktop icon"></i></button>
|
||||
<button type="button" id="info-tab" class="btn btn-icon nav-link" role="tab" data-tabname="cardTab" data-target="#info"><i class="fa fa-cog icon"></i></button>
|
||||
<button type="button" id="errRec-tab" class="btn btn-icon nav-link" role="tab" data-tabname="cardTab" data-target="#errRec"><i class="fas fa-exclamation-triangle"></i></button>
|
||||
<button type="button" id="opeRec-tab" class="btn btn-icon nav-link" role="tab" data-tabname="cardTab" data-target="#opeRec"><i class="fa fa-bars icon"></i></button>
|
||||
<button class="btn p-2"><i class="fas fa-times fs-1 text-white-50" data-close="yttooltip"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-2 tab-content">
|
||||
|
||||
<div id="state" class="show active" data-tabname="cardTab" data-tabrole="child">
|
||||
${drawStateTabBlo(devNum)}
|
||||
</div>
|
||||
<div id="info" data-tabname="cardTab" data-tabrole="child">
|
||||
${drawInfoTabBlo(devGuid)}
|
||||
</div>
|
||||
<div id="errRec" data-tabname="cardTab" data-tabrole="child">
|
||||
${drawErrRecTabBlo()}
|
||||
</div>
|
||||
<div id="opeRec" data-tabname="cardTab" data-tabrole="child">
|
||||
${drawOpeRecTabBlo()}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>`,
|
||||
group: "device",
|
||||
onShow: function (tooltipEle, oriEle) {
|
||||
var tab = new YT.Tab({ tabName: "cardTab" })
|
||||
@ -2662,6 +2581,86 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
loadingTip = null;
|
||||
}
|
||||
}
|
||||
|
||||
function iniFroList() {
|
||||
url = baseApiUrl + '/api/GetUsrFroList'
|
||||
let hasMonitor = false;
|
||||
|
||||
ytAjax = new YourTeam.Ajax(url, null, function (res) {
|
||||
if (!res || res.code != "0000" || !res.data) {
|
||||
|
||||
} else {
|
||||
let strHtml = `<div class="btn-group mx-4">
|
||||
<a href="javascript:;" name="topFunBtn" data-page="dashboard" class="text-center">
|
||||
<i class="fal fa-home fa-2x"></i><br>首頁
|
||||
</a>
|
||||
<!--<div class="dropdown-menu">
|
||||
<button class="dropdown-item" type="button">Action</button>
|
||||
<button class="dropdown-item" type="button">Another action</button>
|
||||
<button class="dropdown-item" type="button">Something else here</button>
|
||||
</div>-->
|
||||
</div>`;
|
||||
|
||||
$.each(res.data, function (i, v) {
|
||||
if (v.authCode == 'FL1') {
|
||||
strHtml += `<div class="btn-group mx-4" >
|
||||
<a href="javascript:;" class="dropdown-toggle no-arrow text-center" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fal fa-tv fa-2x"></i><br>${v.subName}
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-select-menu js-auto-close" id="${v.showView}">
|
||||
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
hasMonitor = true;
|
||||
}
|
||||
else {
|
||||
let icon = v.authCode == 'FL2' ? 'fa-chart-pie' : v.authCode == 'FL3' ? 'fa-chart-area' : v.authCode == 'FL4' ? 'fa-bell' : v.authCode == 'FL5' ? 'fa-server' : v.authCode == 'FL6' ? 'fa-image' : v.authCode == 'FL7' ? 'fa-user' : '';
|
||||
strHtml += `<div class="btn-group mx-4">
|
||||
<a href="javascript:;" name="topFunBtn" class="dropdown-toggle no-arrow text-center"
|
||||
data-page="${v.showView}">
|
||||
<i class="fal ${icon} fa-2x"></i><br>${v.subName}
|
||||
</a>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#froLisPage').html(strHtml);
|
||||
|
||||
}
|
||||
}, null, "POST").send();
|
||||
}
|
||||
|
||||
function getSysMonBtnList() {
|
||||
let url = baseApiUrl + "/api/Device/GetMainSub";
|
||||
let sendData = {
|
||||
building_tag: pageAct.buiTag,
|
||||
};
|
||||
objSendData.Data = sendData;
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
||||
console.log(res);
|
||||
if (!res || res.code != "0000" || !res.data) {
|
||||
console.log('aaaaa');
|
||||
} else {
|
||||
console.log('bbbbb');
|
||||
$("#sysMonBtnList").html("")
|
||||
$.each(res.data.history_Main_Systems, (index, mainSysObj) => {
|
||||
$.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => {
|
||||
let page = "systemMonitor";
|
||||
if (subSysObj.sub_system_tag == "EL") {
|
||||
page = "sysElevator";
|
||||
}
|
||||
let btn = creBtn(subSysObj.full_name, `subSysBtn${subSysObj.sub_system_tag}`, "topFunBtn", ["dropdown-item"], { page: page });
|
||||
subSysObj.main_system_tag = mainSysObj.main_system_tag;
|
||||
btn.data("subSysObj", subSysObj);
|
||||
$("#sysMonBtnList").append(btn);
|
||||
})
|
||||
})
|
||||
}
|
||||
}, null, "POST").send();
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
@ -69,8 +69,12 @@ namespace FrontendWebApi.ApiControllers
|
||||
join userinfo c on c.role_guid = a.role_guid
|
||||
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
|
||||
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
|
||||
join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0
|
||||
left join device_kind dk on v1.system_value = dk.device_system_tag and v2.system_value = dk.device_name_tag and dk.device_building_tag = @building_tag
|
||||
-- left join device_item di on v2.system_value = di.device_name_tag and v1.system_value = di.device_system_tag and di.deleted = 0
|
||||
join (
|
||||
select distinct main_system_tag, sub_system_tag from building_menu where building_tag = @building_tag
|
||||
) as bm on v2.system_value = bm.sub_system_tag and v1.system_value = bm.main_system_tag
|
||||
where c.account = @account
|
||||
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type, @building_tag = fd.building_tag });
|
||||
var mains = dbsub.GroupBy(a => a.main_system_tag).ToList();
|
||||
|
@ -204,7 +204,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
join userinfo c on c.role_guid = a.role_guid
|
||||
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
|
||||
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
|
||||
left join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0
|
||||
join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0
|
||||
where c.account = @account
|
||||
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
||||
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
||||
|
@ -610,8 +610,6 @@ namespace FrontendWebApi.ApiControllers
|
||||
};
|
||||
|
||||
await backendRepository.AddOneByCustomTable(roleAuth, "role_auth");
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -700,6 +698,90 @@ namespace FrontendWebApi.ApiControllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 即時趨勢條件過濾條件面板
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ApiResult<List<string>>>> GetUsrDevSys([FromBody] User u)
|
||||
{
|
||||
ApiResult<List<string>> apiResult = new ApiResult<List<string>>();
|
||||
List<string> ss = new List<string>();
|
||||
try
|
||||
{
|
||||
var sqlString = $@"select ap.AuthCode
|
||||
from role_auth ra
|
||||
join auth_page ap on ra.AuthCode = ap.AuthCode
|
||||
join variable v on ap.ShowView = v.id
|
||||
join userinfo ui on ra.role_guid = ui.role_guid
|
||||
where v.system_type = 'device_system_category_layer3' and v.deleted = 0 and ui.userinfo_guid = @user_guid";
|
||||
|
||||
ss = await backendRepository.GetAllAsync<string>(sqlString, new { @user_guid = u.userinfo_guid });
|
||||
|
||||
apiResult.Data= ss;
|
||||
apiResult.Code = "0000";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
return Ok(apiResult);
|
||||
}
|
||||
return Ok(apiResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 編輯 系統權限
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<string>> DelDevSysRoleAuth([FromBody] PostSaveRoleAuth post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
RoleManagerList roleManager = null;
|
||||
|
||||
try
|
||||
{
|
||||
roleManager = await backendRepository.GetOneAsync<RoleManagerList>("role", $"role_guid='{post.SelectedRoleId}'");
|
||||
|
||||
if (roleManager == null)
|
||||
{
|
||||
apiResult.Code = "9994";
|
||||
apiResult.Msg = "查無該角色";
|
||||
return apiResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (post.SaveCheckAuth.Count > 0)
|
||||
{
|
||||
foreach (var item in post.SaveCheckAuth)
|
||||
{
|
||||
#region 刪除權限
|
||||
await backendRepository.PurgeOneByGuidWithCustomDBNameAndTable("role_auth", $"role_guid = '{post.SelectedRoleId}' and AuthCode = '{item}'");
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/getUser")]
|
||||
public ActionResult GetUser()
|
||||
@ -710,5 +792,117 @@ namespace FrontendWebApi.ApiControllers
|
||||
data = myUser.userinfo_guid
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<string>> GetUsrRolId([FromBody] User post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
User user = null;
|
||||
|
||||
try
|
||||
{
|
||||
user = await backendRepository.GetOneAsync<User>("userinfo", $"userinfo_guid='{post.userinfo_guid}'");
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
apiResult.Code = "9994";
|
||||
apiResult.Msg = "查無該使用者";
|
||||
return apiResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = await backendRepository.GetOneAsync<string>($@"select role_guid from userinfo where userinfo_guid = @userinfo_guid", new { @userinfo_guid = post.userinfo_guid });
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 即時趨勢條件過濾條件面板
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ApiResult<History_MainSubBuildFloor>>> GetMainSub([FromBody] HistoryFind hf)
|
||||
{
|
||||
ApiResult<History_MainSubBuildFloor> apiResult = new ApiResult<History_MainSubBuildFloor>(jwt_str);
|
||||
if (!jwtlife)
|
||||
{
|
||||
apiResult.Code = "5000";
|
||||
return BadRequest(apiResult);
|
||||
}
|
||||
else if (string.IsNullOrEmpty(hf.building_tag))
|
||||
{
|
||||
apiResult.Code = "0002";
|
||||
apiResult.Msg = "必須選擇東別";
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>(
|
||||
@$"select distinct v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name, v2.system_value sub_system_tag, v1.system_priority, v2.system_priority,
|
||||
d.device_number, d.full_name as device_full_name, d.device_serial_tag, b.AuthCode
|
||||
from role_auth a
|
||||
join auth_page b on a.AuthCode = b.AuthCode
|
||||
join userinfo c on c.role_guid = a.role_guid
|
||||
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
|
||||
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
|
||||
join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0
|
||||
where c.account = @account
|
||||
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
||||
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
||||
@$"select distinct d.building_guid,d.full_name,d.priority from role_auth a
|
||||
join auth_page b on a.AuthCode = b.AuthCode
|
||||
join userinfo c on c.role_guid = a.role_guid
|
||||
join building d on d.building_tag = b.building_tag
|
||||
where c.account = @account and d.building_tag = @building_tag
|
||||
order by d.priority
|
||||
", new { @account = myUser.account, @building_tag = hf.building_tag });
|
||||
var mains = dbsub.GroupBy(a => a.main_system_tag).ToList();
|
||||
apiResult.Data = new History_MainSubBuildFloor();
|
||||
apiResult.Data.history_Main_Systems = new List<History_Main_system>();
|
||||
foreach (var main in mains)
|
||||
{
|
||||
History_Main_system history_Main_System = new History_Main_system();
|
||||
history_Main_System.main_system_tag = main.Select(a => a.main_system_tag).FirstOrDefault();
|
||||
history_Main_System.full_name = main.Select(a => a.main_name).FirstOrDefault();
|
||||
|
||||
var subs = dbsub.Where(x => x.main_system_tag == main.Select(m => m.main_system_tag).FirstOrDefault()).GroupBy(x => x.sub_system_tag).ToList();
|
||||
history_Main_System.History_Sub_systems = subs.Count > 0 ? new List<History_Sub_system>() : null;
|
||||
foreach (var sub in subs)
|
||||
{
|
||||
History_Sub_system history_Sub_System = new History_Sub_system();
|
||||
history_Sub_System.full_name = sub.Select(x => x.sub_name).FirstOrDefault();
|
||||
history_Sub_System.sub_system_tag = sub.Select(x => x.sub_system_tag).FirstOrDefault();
|
||||
history_Sub_System.auth_code = sub.Select(x => x.AuthCode).FirstOrDefault();
|
||||
history_Main_System.History_Sub_systems.Add(history_Sub_System);
|
||||
}
|
||||
apiResult.Data.history_Main_Systems.Add(history_Main_System);
|
||||
}
|
||||
apiResult.Data.history_Builds = dbbuilding;
|
||||
apiResult.Code = "0000";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
return Ok(apiResult);
|
||||
}
|
||||
return Ok(apiResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
join userinfo c on c.role_guid = a.role_guid
|
||||
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
|
||||
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
|
||||
left join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0
|
||||
join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0
|
||||
where c.account = @account
|
||||
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
||||
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
||||
@ -127,5 +127,33 @@ namespace FrontendWebApi.ApiControllers
|
||||
}
|
||||
return Ok(apiResult);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/GetUsrFroList")]
|
||||
public async Task<ApiResult<List<AuthPage>>> UsrAuthPageList()
|
||||
{
|
||||
ApiResult<List<AuthPage>> apiResult = new ApiResult<List<AuthPage>>();
|
||||
List<AuthPage> authPage = new List<AuthPage>();
|
||||
|
||||
try
|
||||
{
|
||||
var sqlString = $@"select ap.* from auth_page ap
|
||||
join role_auth ra on ap.AuthCode = ra.AuthCode
|
||||
join userinfo ui on ra.role_guid = ui.role_guid
|
||||
where ap.AuthCode like 'FL%' and ui.userinfo_guid = @userinfo_guid
|
||||
order by ap.AuthCode";
|
||||
authPage = await backendRepository.GetAllAsync<AuthPage>(sqlString, new { @userinfo_guid = myUser.userinfo_guid });
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = authPage;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,10 +73,10 @@ namespace FrontendWebApi.Models
|
||||
public byte device_item_is_controll { get; set; }
|
||||
public byte device_item_is_bool { get; set; }
|
||||
public byte device_item_is_link { get; set; }
|
||||
|
||||
public string device_normal_flashing { get; set; }
|
||||
public string device_close_flashing { get; set; }
|
||||
public string device_error_flashing { get; set; }
|
||||
public string AuthCode { get; set; }
|
||||
}
|
||||
|
||||
public class HistoryFind
|
||||
@ -126,6 +126,7 @@ namespace FrontendWebApi.Models
|
||||
public string device_normal_flashing { get; set; }
|
||||
public string device_close_flashing { get; set; }
|
||||
public string device_error_flashing { get; set; }
|
||||
public string auth_code { get; set; }
|
||||
}
|
||||
public class History_PostDevice
|
||||
{
|
||||
|
@ -140,6 +140,7 @@ namespace FrontendWebApi.Models
|
||||
public string AuthCode { get; set; }
|
||||
public string MainName { get; set; }
|
||||
public string SubName { get; set; }
|
||||
public string ShowView { get; set; }
|
||||
}
|
||||
|
||||
public class PostSaveRoleAuth
|
||||
|
Loading…
Reference in New Issue
Block a user