<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sptg="http://www.thymeleaf.org">
    <head>
        <script th:replace="common/head"></script>
        <!-- 省市区样式 -->
        <link rel="stylesheet" th:href="@{'/layui/lay/mymodules/region.css'}">
    </head>
    <style>
        .layui-fluid{
            min-height: 90%;
        }

        .xm-toolbar .toolbar-tag {
            width: 100%;
            display: flex;
            justify-content: center;
            background-color: #1E9FFF!important;
            color: #fff!important;
        }
    </style>
    <body>
        <div style="position: absolute;top:0;bottom: 0;left:0;right: 0;">
            <!--/*@thymesVar id="onLineUser" type="com.sptg.permissions.api.entity.Account"*/-->
            <input type="hidden" id="org_id" th:value="${onLineUser.orgId}" />
            <input type="hidden" id="showAd" value="true">
            <div class="layui-fluid">
                <!-- 下拉树 -->
                <div th:replace="common/org-tree"></div>
                <!-- 表格 -->
                <div class="x-body per-table">
                    <div class="layui-card">
                        <!-- 查询条件 -->
                        <div class="layui-form layui-card-header layuiadmin-card-header-auto"  style="padding:0;">
                            <div class="layui-form-item border-b">
                                <div class="layui-inline">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">机构地区</label>
                                        <div class="layui-input-block" id="region_body">
                                            <input type="hidden"  name="regionProvince" />
                                            <input type="hidden"  name="regionCity" />
                                            <input type="hidden"  name="regionArea" />
                                            <input type="text" id="region" readonly="readonly" placeholder="请选择" autocomplete="off" class="layui-input" />
                                            <div th:replace="common/region"></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label for="name" class="layui-form-label">机构名称</label>
                                    <div class="layui-input-block">
                                        <input id="name" type="text" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label for="code" class="layui-form-label">机构编码</label>
                                    <div class="layui-input-block">
                                        <input id="code" type="text" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <!--<div class="layui-inline">
                                    <label for="xq_name" class="layui-form-label">授权小区</label>
                                    <div class="layui-input-block">
                                        <div id="xq_name"></div>
                                        <input name="xqName" type="hidden" />
                                    </div>
                                </div>-->
                                <div class="layui-inline">
                                    <label for="org_type_select" class="layui-form-label">机构类型</label>
                                    <div class="layui-input-block">
                                        <select id="org_type_select">
                                            <option value="">请选择</option>
<!--                                            <option value="1">内部</option>-->
<!--                                            <option value="2">广告</option>-->
                                            <option value="3">物业</option>
                                            <option value="4">社区</option>
                                            <option value="5">园区</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label for="is_enable_select" class="layui-form-label">开启状态</label>
                                    <div class="layui-input-block">
                                        <select id="is_enable_select">
                                            <option value="">请选择</option>
                                            <option value="1">启用</option>
                                            <option value="2">禁用</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline" style="margin-left: 38px;">
                                    <button class="layui-btn layuiadmin-btn-useradmin"  lay-submit lay-filter="query">查询</button>
                                    <button class="layui-btn  layui-btn-primary"  lay-submit lay-filter="reset">重置</button>
                                </div>
                            </div>

                            <!-- 表格+头部按钮 -->
                            <div class="layui-card-body" style="padding:0;">
                                <div style="padding-bottom: 10px;">
                                    <button class="layui-btn layuiadmin-btn-useradmin"  lay-submit lay-filter="transfer" sptg:security="organization:transfer">机构迁移</button>
                                    <button class="layui-btn layuiadmin-btn-useradmin"  lay-submit lay-filter="add" sptg:security="organization:insert">添加机构</button>
                                    <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="import" lay-event="import" sptg:security="organization:insert">导入</button>
                                </div>
                                <table id="data_entity_table" lay-filter="data_table_event"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>

    <!-- javascript -->
    <script type="text/javascript" th:src="@{'/layui/layui.js'}"></script>
    <script type="text/javascript">
        layui.config({
            base: '/'
        });
        //  页面数据
        var pageData = {
            myOrgId     :   parseInt(document.getElementById('org_id').value)
        };
    </script>
    <script type="text/javascript" th:src="@{'/js/permissions/org-manage.js'}"></script>

    <!-- 机构状态 -->
    <script type="text/html" id="entity_is_enable">
        {{# if(d.id != pageData.myOrgId){ }}
        <input type="checkbox" name="isEnable" lay-skin="switch" lay-filter="switch_is_enable"
               data-json="{{ encodeURIComponent(JSON.stringify(d)) }}"
               lay-text="启用|禁用" {{ d.isEnable == 1 ? 'checked' : '' }} />
        {{# }else { }}
        <input type="checkbox" name="isEnable" lay-skin="switch" disabled
               lay-text="启用|禁用" {{ d.isEnable == 1 ? 'checked' : '' }} />
        {{# } }}
    </script>

    <!-- 工具栏（小区,部门不可修改/删除） -->
    <script type="text/html" id="table-useradmin-webuser">
        {{#  if(d.flag == 1 && d.id != pageData.myOrgId){ }}
        {{# if(d.orgType == 2){ }}
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="region_permissions" sptg:security="organization:region_permissions">
            <span>区域权限</span>
        </a>
        {{# } }}
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit" sptg:security="organization:update">
            <span>修改</span>
        </a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete" sptg:security="organization:delete">
            <span>删除</span>
        </a>
        {{# } }}
    </script>

    <!-- 机构类型 -->
    <script type="text/html" id="org_type">
        {{# if(d.orgType==1){ }}
        <span>内部</span>
        {{# }else if(d.orgType==2){ }}
        <span>广告商</span>
        {{# }else if(d.orgType==3){ }}
        <span>物业</span>
        {{# }else if(d.orgType==4){ }}
        <span>社区</span>
        {{# }else if(d.orgType==5){ }}
        <span>园区</span>
        {{# } }}
    </script>

</html>
