修改賬號管理群組權限
This commit is contained in:
		
							parent
							
								
									f134b849cb
								
							
						
					
					
						commit
						8911525b5a
					
				@ -4,12 +4,18 @@
 | 
			
		||||
            <h1 class="p-2 mb-0">帳號與權限管理</h1>
 | 
			
		||||
            <div class="row mt-5">
 | 
			
		||||
                <ul class="nav nav-tabs w-100" role="tablist">
 | 
			
		||||
                    <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> </li>
 | 
			
		||||
                    <li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#tab_borders_icons-3"
 | 
			
		||||
                            role="tab"><i class="fal fa-cog mr-1"></i> 群組權限</a> </li>
 | 
			
		||||
                    <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>
 | 
			
		||||
                    </li>
 | 
			
		||||
                    <li class="nav-item">
 | 
			
		||||
                        <a class="nav-link" data-toggle="tab" href="#tab_borders_icons-3"
 | 
			
		||||
                           role="tab"><i class="fal fa-cog mr-1"></i> 群組權限</a>
 | 
			
		||||
                    </li>
 | 
			
		||||
                </ul>
 | 
			
		||||
                <div class="tab-content border border-top-0 p-3 w-100">
 | 
			
		||||
                    <div class="tab-pane fade show active" id="tab_borders_icons-1" role="tabpanel" data-id="accMan">
 | 
			
		||||
@ -38,8 +44,10 @@
 | 
			
		||||
                            <div class="col-auto"> <a href="#" class="btn btn-info" id="acc_searchBtn">搜尋</a> </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="frame-wrap">
 | 
			
		||||
                            <div class="mb-3"> <a href="#" class="btn btn-success" data-toggle="modal"
 | 
			
		||||
                                    data-target="#accManModal">+ 新增</a> </div>
 | 
			
		||||
                            <div class="mb-3">
 | 
			
		||||
                                <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>
 | 
			
		||||
@ -48,15 +56,17 @@
 | 
			
		||||
                        <div class="row mb-5 align-items-end">
 | 
			
		||||
                            <div class="col-auto">
 | 
			
		||||
                                <div class="form-group">
 | 
			
		||||
                                    <label class="form-label" for="simpleinput">角色</label>
 | 
			
		||||
                                    <input type="text" id="simpleinput" class="form-control">
 | 
			
		||||
                                    <label class="form-label" for="seaRolName">角色</label>
 | 
			
		||||
                                    <input type="text" id="seaRolName" class="form-control">
 | 
			
		||||
                                </div>
 | 
			
		||||
                            </div>
 | 
			
		||||
                            <div class="col-auto"> <a href="#" class="btn btn-info">搜尋</a> </div>
 | 
			
		||||
                            <div class="col-auto"> <a href="#" class="btn btn-info" id="rol_searchBtn">搜尋</a> </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="frame-wrap">
 | 
			
		||||
                            <div class="mb-3"> <a href="#" class="btn btn-success" data-toggle="modal"
 | 
			
		||||
                                    data-target="#groupModal">+ 新增</a> </div>
 | 
			
		||||
                            <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>
 | 
			
		||||
@ -72,8 +82,10 @@
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="frame-wrap">
 | 
			
		||||
                            <div class="mb-3"> <a href="#" class="btn btn-success" data-toggle="modal"
 | 
			
		||||
                                    data-target="#modal-center-users">+ 加入可用功能</a> </div>
 | 
			
		||||
                            <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>
 | 
			
		||||
@ -103,7 +115,7 @@
 | 
			
		||||
                            <div class="form-group">
 | 
			
		||||
                                <label class="form-label" for="inpEmail">Email</label>
 | 
			
		||||
                                <input type="email" id="inpEmail" name="inpEmail" class="form-control"
 | 
			
		||||
                                    placeholder="Email">
 | 
			
		||||
                                       placeholder="Email">
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="col-md-6">
 | 
			
		||||
@ -166,8 +178,8 @@
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="modal-footer">
 | 
			
		||||
                    <button type="button" class="btn btn-secondary" id="" data-dismiss="modal">關閉</button>
 | 
			
		||||
                    <button type="button" class="btn btn-primary" id="" e-prevent>儲存</button>
 | 
			
		||||
                    <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>
 | 
			
		||||
@ -175,7 +187,7 @@
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<!-- Modal center 設備權限 -->
 | 
			
		||||
<div class="modal fade" id="modal-center-cog" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
 | 
			
		||||
<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">
 | 
			
		||||
@ -187,7 +199,7 @@
 | 
			
		||||
                </button>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="modal-body">
 | 
			
		||||
                <table class="table table-bordered table-striped text-center m-0">
 | 
			
		||||
                <table class="table table-bordered table-striped text-center m-0 w-100">
 | 
			
		||||
                    <thead class="thead-themed">
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <th>類別代號</th>
 | 
			
		||||
@ -231,14 +243,14 @@
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="modal-footer">
 | 
			
		||||
                <button type="button" class="btn btn-secondary" data-dismiss="modal">關閉</button>
 | 
			
		||||
                <button type="button" class="btn btn-primary">儲存</button>
 | 
			
		||||
                <button id="accManSysRolSavBtn" type="button" class="btn btn-primary">儲存</button>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<!-- Modal center 設備權限 -->
 | 
			
		||||
<div class="modal fade" id="modal-center-users" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
 | 
			
		||||
<!-- 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">
 | 
			
		||||
@ -250,56 +262,12 @@
 | 
			
		||||
                </button>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="modal-body">
 | 
			
		||||
                <table class="table table-bordered table-striped text-center m-0">
 | 
			
		||||
                    <thead class="thead-themed">
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <th>選擇</th>
 | 
			
		||||
                            <th>編號</th>
 | 
			
		||||
                            <th>功能名稱</th>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                    </thead>
 | 
			
		||||
                    <tbody>
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td><input type="checkbox"></td>
 | 
			
		||||
                            <td>1</td>
 | 
			
		||||
                            <td>系統監控</td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td><input type="checkbox"></td>
 | 
			
		||||
                            <td>2</td>
 | 
			
		||||
                            <td>歷史資料</td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td><input type="checkbox"></td>
 | 
			
		||||
                            <td>3</td>
 | 
			
		||||
                            <td>異常記錄</td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td><input type="checkbox"></td>
 | 
			
		||||
                            <td>4</td>
 | 
			
		||||
                            <td>即時告警</td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td><input type="checkbox"></td>
 | 
			
		||||
                            <td>5</td>
 | 
			
		||||
                            <td>運維管理</td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td><input type="checkbox"></td>
 | 
			
		||||
                            <td>6</td>
 | 
			
		||||
                            <td>圖資管理</td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td><input type="checkbox"></td>
 | 
			
		||||
                            <td>7</td>
 | 
			
		||||
                            <td>帳號管理</td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                    </tbody>
 | 
			
		||||
                <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>
 | 
			
		||||
                <button type="button" class="btn btn-primary">儲存</button>
 | 
			
		||||
                <button type="button" id="authPageSavBtn" class="btn btn-primary">儲存</button>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
@ -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 `<td><input id='${data}' type="checkbox"></td>`
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "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);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
</script>
 | 
			
		||||
@ -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
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<List<RoleManagerList>>> RoleManagerList(int post) //是否判斷layer 0:否 1:是
 | 
			
		||||
        public async Task<ApiResult<List<RoleManagerList>>> RoleManagerList([FromBody] RoleManagerList post) //是否判斷layer 0:否 1:是
 | 
			
		||||
        {
 | 
			
		||||
            ApiResult<List<RoleManagerList>> apiResult = new ApiResult<List<RoleManagerList>>();
 | 
			
		||||
            List<RoleManagerList> roleList = new List<RoleManagerList>();
 | 
			
		||||
 | 
			
		||||
            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<RoleManagerList>(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<RoleAuthList>(sqlString);
 | 
			
		||||
 | 
			
		||||
                apiResult.Code = "0000";
 | 
			
		||||
@ -638,7 +645,7 @@ namespace FrontendWebApi.ApiControllers
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                roleManager = await backendRepository.GetOneAsync<RoleManagerList>("role", $"role_guid='{post.RoleId}'");
 | 
			
		||||
                roleManager = await backendRepository.GetOneAsync<RoleManagerList>("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;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 前台頁面列表
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="post"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<ApiResult<List<AuthPage>>> AuthPageList()
 | 
			
		||||
        {
 | 
			
		||||
            ApiResult<List<AuthPage>> apiResult = new ApiResult<List<AuthPage>>();
 | 
			
		||||
            List<AuthPage> authPage = new List<AuthPage>();
 | 
			
		||||
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                var sqlString = $@"select * from auth_page where AuthCode like 'FL%' order by AuthCode";
 | 
			
		||||
                authPage = await backendRepository.GetAllAsync<AuthPage>(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()
 | 
			
		||||
 | 
			
		||||
@ -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; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user