修改authcode全域變數

This commit is contained in:
dev02 2022-12-22 18:01:17 +08:00
parent 21e3890686
commit a671bc2a55
2 changed files with 91 additions and 89 deletions

View File

@ -328,7 +328,7 @@
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" }); 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("修改", "accManEdiBtn" + data, null, ["btn", "btn-info"], { "toggle": "modal", "target": "#accManModal" }));
btnDiv.append(creBtnHtml("設備權限", "accManSysRolEdiBtn" + data, null, ["btn", "btn-info"], { "toggle": "modal", "target": "#accManSysModal", "fullname": row.full_name })); 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" })); btnDiv.append(creBtnHtml("刪除", "accManDelBtn" + data, null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal" }));
return btnDiv.outerHtml(); return btnDiv.outerHtml();
} }
@ -392,7 +392,7 @@
function loadRolAuthTable() { function loadRolAuthTable() {
pageAct.authCode = []; pageAct.authCode = [];
let ajaxObj = { let ajaxObj = {
url: baseApiUrl + "/User/RoleAuthList", url: baseApiUrl + "/User/RoleAuthList",
method: "POST", method: "POST",
@ -447,7 +447,6 @@
"title": "功能", "title": "功能",
"data": "role_guid", "data": "role_guid",
"render": function (data, type, row, meta) { "render": function (data, type, row, meta) {
pageAct.authCode.push(row.authCode);
let btnDiv = creDiv(["row", "m-0", "justify-content-center"], { "style": "gap:10px" }); 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 })); btnDiv.append(creBtnHtml("刪除", "rolAuthDelBtn" + data, null, ["btn", "btn-danger"], { "toggle": "modal", "target": "#delModal", "id": data, "authcode": row.authCode }));
return btnDiv.outerHtml(); return btnDiv.outerHtml();
@ -456,6 +455,18 @@
]; ];
rolAuthTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs); rolAuthTable = new YourTeam.JqDataTables.getTableByAjax(ajaxObj, tag, null, columns, column_defs);
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();
} }
function loadAuthPageTable() { function loadAuthPageTable() {
@ -474,14 +485,14 @@
let columns = [ let columns = [
{ {
"title": "選擇", "title": "選擇",
"data": 'authCode', "data": 'authCode',
"render": function (data, type, row, meta) { "render": function (data, type, row, meta) {
return `<td><input id='${data}' type="checkbox"></td>` return `<td><input id='${data}' type="checkbox"></td>`
} }
}, },
{ {
"title": "編號", "title": "編號",
"data": null, "data": null,
"render": function (data, type, row, meta) { "render": function (data, type, row, meta) {
return meta.row + 1; return meta.row + 1;
@ -489,7 +500,7 @@
}, },
{ {
"title": "存取權限", "title": "存取權限",
"data": "subName" "data": "subName"
} }
]; ];
@ -497,37 +508,37 @@
} }
function loadDevSysTable(data) { function loadDevSysTable(data) {
let tag = "#devSysTable"; let tag = "#devSysTable";
let column_defs = [ let column_defs = [
{ "targets": [0], "width": "33%", "sortable": true }, { "targets": [0], "width": "33%", "sortable": true },
{ "targets": [1], "width": "33%", "sortable": true }, { "targets": [1], "width": "33%", "sortable": true },
{ "targets": [2], "width": "33%", "sortable": true }, { "targets": [2], "width": "33%", "sortable": true },
]; ];
let columns = [ let columns = [
{ {
"title": "類別代號", "title": "類別代號",
"data": 'sub_system_tag', "data": 'sub_system_tag',
}, },
{ {
"title": "類別名稱", "title": "類別名稱",
"data": "full_name", "data": "full_name",
}, },
{ {
"title": "功能名稱", "title": "功能名稱",
"data": null, "data": null,
"render": function (data, type, row, meta) { "render": function (data, type, row, meta) {
return `<div class="custom-control custom-checkbox"> return `<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="${row.auth_code}" data-type="usrDevSys"> <input type="checkbox" class="custom-control-input" id="${row.auth_code}" data-type="usrDevSys">
<label class="custom-control-label" for="${row.auth_code}">啟用</label> <label class="custom-control-label" for="${row.auth_code}">啟用</label>
</div>`; </div>`;
} }
} }
]; ];
devSysTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi"); devSysTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
} }
function getRoleSel() { function getRoleSel() {
@ -556,10 +567,10 @@
function events() { function events() {
onEvent("change", "#roleSel", function () { onEvent("change", "#roleSel", function () {
let roleGuid = $(this).val(); let roleGuid = $(this).val();
pageAct.selRolAuth = $(this).val(); pageAct.selRolAuth = $(this).val();
dtAjaxResetSendData(rolAuthTable, { SelectedRoleId: roleGuid }) dtAjaxResetSendData(rolAuthTable, { SelectedRoleId: roleGuid })
loadRolAuthTable(); loadRolAuthTable();
setAuthPage(); setAuthPage();
}) })
onEvent("click", "[data-target*=accManModal]", function () { onEvent("click", "[data-target*=accManModal]", function () {
@ -654,7 +665,7 @@
else if (acc_table == "rolAuth") { else if (acc_table == "rolAuth") {
loadRolAuthTable(); loadRolAuthTable();
setAuthPage(); setAuthPage();
} }
}); });
onEvent("click", "li.nav-item", function () { onEvent("click", "li.nav-item", function () {
@ -767,11 +778,11 @@
let name = $(this).data('fullname'); let name = $(this).data('fullname');
let id = $(this).prop('id').split('Btn')[1]; let id = $(this).prop('id').split('Btn')[1];
let url = baseApiUrl + "/User/GetMainSub"; let url = baseApiUrl + "/User/GetMainSub";
let sendData = { let sendData = {
building_tag: pageAct.buiTag building_tag: pageAct.buiTag
} }
objSendData.Data = sendData; objSendData.Data = sendData;
function success(res) { function success(res) {
$('#devSysTabTitle').html(name); $('#devSysTabTitle').html(name);
$('#accManSysRolSavBtn').attr('data-id', id); $('#accManSysRolSavBtn').attr('data-id', id);
@ -785,41 +796,41 @@
if (data.length > 0) { if (data.length > 0) {
loadDevSysTable(data); loadDevSysTable(data);
getUsrDevSys(id); getUsrDevSys(id);
} }
} }
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send(); ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
}); });
onEvent("click", "[data-type=usrDevSys]", function () { onEvent("click", "[data-type=usrDevSys]", function () {
if (pageAct.usrDevSys.length > 0) { if (pageAct.usrDevSys.length > 0) {
if ($(this).is(':checked')) { if ($(this).is(':checked')) {
if ((jQuery.inArray($(this).prop('id'), pageAct.usrDevSys) == -1)) { if ((jQuery.inArray($(this).prop('id'), pageAct.usrDevSys) == -1)) {
pageAct.addUsrDevSys.push($(this).prop('id')); pageAct.addUsrDevSys.push($(this).prop('id'));
} }
if (jQuery.inArray($(this).prop('id'), pageAct.delUsrDevSys) != -1) { if (jQuery.inArray($(this).prop('id'), pageAct.delUsrDevSys) != -1) {
pageAct.delUsrDevSys.splice($.inArray($(this).prop('id'), pageAct.delUsrDevSys), 1); pageAct.delUsrDevSys.splice($.inArray($(this).prop('id'), pageAct.delUsrDevSys), 1);
} }
} }
else { else {
if (jQuery.inArray($(this).prop('id'), pageAct.usrDevSys) != -1) { if (jQuery.inArray($(this).prop('id'), pageAct.usrDevSys) != -1) {
pageAct.delUsrDevSys.push($(this).prop('id')); pageAct.delUsrDevSys.push($(this).prop('id'));
} }
if (jQuery.inArray($(this).prop('id'), pageAct.addUsrDevSys) != -1) { if (jQuery.inArray($(this).prop('id'), pageAct.addUsrDevSys) != -1) {
pageAct.addUsrDevSys.splice($.inArray($(this).prop('id'), pageAct.addUsrDevSys), 1); pageAct.addUsrDevSys.splice($.inArray($(this).prop('id'), pageAct.addUsrDevSys), 1);
} }
} }
} }
}); });
onEvent("click", "#accManSysRolSavBtn", function () { onEvent("click", "#accManSysRolSavBtn", function () {
//get user role id //get user role id
let url = baseApiUrl + "/User/GetUsrRolId"; let url = baseApiUrl + "/User/GetUsrRolId";
let sendData = { let sendData = {
userinfo_guid: $(this).data('id') userinfo_guid: $(this).data('id')
} }
objSendData.Data = sendData; objSendData.Data = sendData;
function success(res) { function success(res) {
//save role auth(devSys) //save role auth(devSys)
url = baseApiUrl + "/User/SaveRoleAuth"; url = baseApiUrl + "/User/SaveRoleAuth";
@ -831,16 +842,16 @@
ytAjax = new YourTeam.Ajax(url, objSendData, null, null, "POST").send(); ytAjax = new YourTeam.Ajax(url, objSendData, null, null, "POST").send();
//delete role auth(devSys) //delete role auth(devSys)
url = baseApiUrl + "/User/DelDevSysRoleAuth"; url = baseApiUrl + "/User/DelDevSysRoleAuth";
sendData = { sendData = {
SelectedRoleId: res.data, SelectedRoleId: res.data,
SaveCheckAuth: pageAct.delUsrDevSys SaveCheckAuth: pageAct.delUsrDevSys
} }
objSendData.Data = sendData; objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, null, null, "POST").send(); ytAjax = new YourTeam.Ajax(url, objSendData, null, null, "POST").send();
$("#accManSysModal").modal("hide"); $("#accManSysModal").modal("hide");
} }
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send(); ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
}); });
} }
@ -862,22 +873,22 @@
$(v).click(); $(v).click();
}); });
pageAct.authCode = pageAct.authCode.filter(function (elem, index, self) { pageAct.authCode = pageAct.authCode.filter(function (elem, index, self) {
return index === self.indexOf(elem); return index === self.indexOf(elem);
}); });
$.each(pageAct.authCode, function (i, v) { $.each(pageAct.authCode, function (i, v) {
$(`#accAuthPageTable input[id=${v}]`).click(); $(`#accAuthPageTable input[id=${v}]`).click();
$(`#accAuthPageTable input[id=${v}]`).attr('disabled', true); $(`#accAuthPageTable input[id=${v}]`).attr('disabled', true);
}); });
} }
function getUsrDevSys(user_guid) { function getUsrDevSys(user_guid) {
let url = baseApiUrl + "/User/GetUsrDevSys"; let url = baseApiUrl + "/User/GetUsrDevSys";
let sendData = { let sendData = {
userinfo_guid: user_guid userinfo_guid: user_guid
} }
objSendData.Data = sendData; objSendData.Data = sendData;
function success(res) { function success(res) {
pageAct.usrDevSys = []; pageAct.usrDevSys = [];
@ -886,11 +897,11 @@
}); });
$.each(res.data, function (i, v) { $.each(res.data, function (i, v) {
$(`#devSysTable input[type=checkbox][id=${v}]`).click(); $(`#devSysTable input[type=checkbox][id=${v}]`).click();
}); });
pageAct.usrDevSys = res.data; pageAct.usrDevSys = res.data;
} }
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send(); ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
} }
</script> </script>

View File

@ -2036,10 +2036,6 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
var loadingTip = ''; var loadingTip = '';
var pageAct = {}; //記錄全頁面已選擇項目 var pageAct = {}; //記錄全頁面已選擇項目
pageAct.AreaTag = "TPE"; pageAct.AreaTag = "TPE";
if (localStorage.getItem("buiTag")) {
pageAct.buiTag = localStorage.getItem("buiTag");
}
if (location.href.indexOf("ord") != -1) { if (location.href.indexOf("ord") != -1) {
location.href = "/file/index.html" location.href = "/file/index.html"
} }
@ -2153,11 +2149,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
} else { } else {
let strHtml = ``; let strHtml = ``;
$.each(res.data, (index, buiObj) => { $.each(res.data, (index, buiObj) => {
let actStr = ""; strHtml += `<a id="buiBtn${buiObj.building_tag}" data-urn="${buiObj.urn_3D}" class="dropdown-item" href="javascript:;">${buiObj.full_name}</a>`;
if (pageAct.buiTag == buiObj.building_tag) {
actStr = "active";
}
strHtml += `<a id="buiBtn${buiObj.building_tag}" data-urn="${buiObj.urn_3D}" class="dropdown-item ${actStr}" href="javascript:;">${buiObj.full_name}</a>`;
}) })
$("#buiList").append(strHtml).droSetItem(); //droSetItem 預設第一筆 active $("#buiList").append(strHtml).droSetItem(); //droSetItem 預設第一筆 active
} }
@ -2249,9 +2241,9 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
onEvent("active:change", "#buiList", function (e, actEle) { onEvent("active:change", "#buiList", function (e, actEle) {
if (actEle) { if (actEle) {
pageAct.buiTag = $(actEle).prop("id").split("buiBtn")[1]; pageAct.buiTag = $(actEle).prop("id").split("buiBtn")[1];
localStorage.setItem("buiTag", pageAct.buiTag);
pageAct.urn = $(actEle).data("urn"); pageAct.urn = $(actEle).data("urn");
} }
}) })
$(window).on("timeout:3s", function () { $(window).on("timeout:3s", function () {
@ -2403,7 +2395,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
//loadErrRecTable2($(oriEle).data("number")); //loadErrRecTable2($(oriEle).data("number"));
//loadErrRecTable(); //loadErrRecTable();
loadErr($(oriEle).data("number")); loadErr($(oriEle).data("number"));
typeof subDeviceSetTable != "undefined" ? subDeviceSetTable($(oriEle).data("number")) : "" subDeviceSetTable ? subDeviceSetTable($(oriEle).data("number")) : ""
} }
}) })
}) })
@ -2650,9 +2642,8 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) { ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
console.log(res); console.log(res);
if (!res || res.code != "0000" || !res.data) { if (!res || res.code != "0000" || !res.data) {
console.log('aaaaa');
} else { } else {
console.log('bbbbb');
$("#sysMonBtnList").html("") $("#sysMonBtnList").html("")
$.each(res.data.history_Main_Systems, (index, mainSysObj) => { $.each(res.data.history_Main_Systems, (index, mainSysObj) => {
$.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => { $.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => {