TenantManager.vue 21.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690
<template>
  <div class="fullheight">
    <ht-table
      @load="loadData"
      :data="data"
      :pageResult="pageResult"
      :selection="true"
      :quick-search-props="[{prop: 'mq.name_', label: '租户名称'}]"
      :show-export="false"
      :show-custom-column="false"
      ref="htTable"
      @row-click="rowClick"
      :header-cell-class-name="headerCellClassName"
    >
      <template v-slot:toolbar>
        <el-button-group>
          <el-button
            size="small"
            @click="showDialog('', '', '')"
            icon="el-icon-plus"
            type="primary"
            >添加租户</el-button
          >
          <!-- <ht-delete-button url="${uc}/uc/tenantManage/v1/remove" :htTable="$refs.htTable">删除</ht-delete-button> -->
        </el-button-group>
      </template>
      <template>
        <ht-table-column type="index" width="50" align="center" label="序号" />
        <ht-table-column
          prop="name"
          label="租户名称"
          :sortable="true"
          :show-overflow-tooltip="true"
        >
          <template v-slot="{row}">
            <el-link
              type="primary"
              @click="showDialog(row.id, row.name, row.code, row.status)"
              title="查看详情"
              >{{ row.name }}</el-link
            >
          </template>
        </ht-table-column>
        <ht-table-column
          prop="typeName"
          label="租户类型"
          :sortable="true"
          :show-overflow-tooltip="true"
        >
        </ht-table-column>
        <ht-table-column
          prop="code"
          label="租户别名"
          :sortable="true"
          :show-overflow-tooltip="true"
        >
        </ht-table-column>
        <ht-table-column
          prop="mq.status_"
          label="状态"
          width="110"
          :render-header="renderHeaderMethod"
          :filters="[
            {text: '禁用', value: 'disabled'},
            {text: '启用', value: 'enable'}
          ]"
        >
          <template v-slot="{row}">
            <el-tag type="info" v-if="row.status == 'draft'">草稿</el-tag>
            <el-tag type="warning" v-if="row.status == 'disabled'">禁用</el-tag>
            <el-tag type="success" v-if="row.status == 'enable'">启用</el-tag>
          </template>
        </ht-table-column>
        <ht-table-column
          prop="shorthand"
          label="租户简称"
          :sortable="true"
          :show-overflow-tooltip="true"
        >
        </ht-table-column>
        <ht-table-column width="210" label="操作" align="left">
          <template v-slot="{row}">
            <el-button
              type="text"
              @click="handleCommand({row: row, command: 'assignUser'})"
              v-if="row.id != '-1'"
              >设置管理员</el-button
            >
            <el-button
              type="text"
              @click="handleCommand({row: row, command: 'copyAddress'})"
              v-if="row.id != '-1'"
              >复制地址</el-button
            >
            <el-button
              type="text"
              @click="handleCommand({row: row, command: 'delete'})"
              v-if="
                (row.id != '-1' && row.status == 'draft') ||
                  row.status == 'disabled'
              "
              >删除</el-button
            >
            <!-- <el-dropdown
              size="mini"
              split-button
              @command="handleCommand"
              @click="handleCommand({row: row, command: 'assignUser'})"
              v-if="row.id != '-1'"
            >
            <span>
              <i class="el-icon-user"></i>设置管理员
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item v-if="row.id!='-1'" icon="el-icon-user" :command="{row:row,command:'copyAddress'}">复制地址</el-dropdown-item>
              <el-dropdown-item v-if="row.id!='-1' && row.status=='draft' || row.status=='disabled'" icon="el-icon-delete" :command="{row:row,command:'delete'}">删除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown> -->
            <el-button
              v-if="row.id == '-1'"
              @click="handleCommand({row: row, command: 'assignUser'})"
              type="text"
            >
              <span>
                设置管理员
              </span>
            </el-button>
          </template>
        </ht-table-column>
      </template>
    </ht-table>
    <ht-sidebar-dialog
      width="100%"
      :close-on-click-modal="false"
      :visible="dialogVisible"
      :before-close="handleClose"
      append-to-body
      class="tenant_conf"
    >
      <el-container class="fullheight" style="overflow: hidden;">
        <el-header height="48px" style="padding:0">
          <div
            class="flex"
            style="float:left;justify-content: left;width:100%;height: 47px;padding-left: 24px;font-size: 16px;font-weight: bold;color: #409EFF;border-bottom:1px solid #eee;"
          >
            <el-page-header
              @back="handleClose"
              title="返回"
              :content="curSelectTenantName"
            ></el-page-header>
          </div>
        </el-header>
        <el-main style="padding:0">
          <el-tabs
            class="tenant-edit-container"
            v-if="dialogVisible"
            style="height: 100%;"
            tab-position="left"
            v-model="activeName"
            @tab-click="handlePaneClick"
            @tab-remove="handlePaneRemove"
            :before-leave="beforePaneleave"
            ref="tenantEditTables"
          >
            <el-tab-pane label="租户信息" name="tenantInfo">
              <tenant-info-manager
                ref="tenantInfoManager"
                @after-add-success="addSuccess"
                :tenantId="curSelectTenantId ? curSelectTenantId : 'add'"
              ></tenant-info-manager>
            </el-tab-pane>

            <el-tab-pane
              label="禁用菜单"
              v-if="
                curSelectTenantId &&
                  curSelectTenantStatus != 'draft' &&
                  curSelectTenantId != -1
              "
              name="ignoreMenu"
            >
              <el-button
                style="float: right;z-index: 15000;position: fixed;top:8px;right:15px"
                type="primary"
                @click="saveTenantIgnoreMenu"
                >保存禁用菜单信息</el-button
              >

              <div class="fullheight tenant-ignore-tree">
                <ht-tree
                  ref="tenantIgnoreMenuTree"
                  :data="baseMenuList"
                  :props="{label: 'name'}"
                  show-checkbox
                  node-key="alias"
                  :default-expanded-keys="menuTreeExpanded"
                  :default-checked-keys="tenantIgnoreMenus"
                  support-filter
                  @node-click="handleNodeClick"
                ></ht-tree>
              </div>
            </el-tab-pane>
            <el-tab-pane
              label="组织管理"
              v-if="curSelectTenantId && curSelectTenantStatus != 'draft'"
              name="orgManage"
            >
              <el-tabs
                type="card"
                class="tenant-org-container"
                v-model="currentOrgManager"
                style="height: 100%;"
                @tab-click="tabClick"
              >
                <el-tab-pane label="维度管理" name="henantDemension">
                  <demension
                    v-if="henantDemension"
                    ref="henantDemension"
                    :tenantId="curSelectTenantId"
                  ></demension>
                </el-tab-pane>
                <el-tab-pane label="组织管理" name="henantOrgManager">
                  <organization
                    v-if="henantOrgManager"
                    ref="henantOrgManager"
                    :tenantId="curSelectTenantId"
                  ></organization>
                </el-tab-pane>
                <el-tab-pane label="职务管理" name="henantJobManager">
                  <jobManager
                    v-if="henantJobManager"
                    ref="henantJobManager"
                    :tenantId="curSelectTenantId"
                  ></jobManager>
                </el-tab-pane>
                <el-tab-pane label="岗位管理" name="henantPostManager">
                  <postManager
                    v-if="henantPostManager"
                    ref="henantPostManager"
                    :tenantId="curSelectTenantId"
                  ></postManager>
                </el-tab-pane>
                <el-tab-pane label="组织参数管理" name="henantPrgParamManager">
                  <prgParamManage
                    v-if="henantPrgParamManager"
                    ref="henantPrgParamManager"
                    :tenantId="curSelectTenantId"
                  ></prgParamManage>
                </el-tab-pane>
              </el-tabs>
            </el-tab-pane>
            <el-tab-pane
              label="用户管理"
              v-if="curSelectTenantId && curSelectTenantStatus != 'draft'"
              name="userManage"
            >
              <user-list-manager
                ref="userListManager"
                :tenantId="curSelectTenantId"
                isTenant
              ></user-list-manager>
            </el-tab-pane>
            <el-tab-pane
              label="角色管理"
              v-if="curSelectTenantId && curSelectTenantStatus != 'draft'"
              name="roleManage"
            >
              <role-manager
                ref="roleManager"
                :tenantId="curSelectTenantId"
              ></role-manager>
            </el-tab-pane>
            <el-tab-pane
              label="汇报线"
              v-if="curSelectTenantId && curSelectTenantStatus != 'draft'"
              name="relLine"
            >
              <report-line
                ref="reportLine"
                :tenantId="curSelectTenantId"
              ></report-line>
            </el-tab-pane>
            <el-tab-pane
              label="实例管理"
              v-if="curSelectTenantId && curSelectTenantStatus != 'draft'"
              name="instance"
            >
              <instance-manager
                ref="instanceManager"
                :tenantId="curSelectTenantId"
              ></instance-manager>
            </el-tab-pane>
            <el-tab-pane
              label="在线集成"
              v-if="curSelectTenantId && curSelectTenantStatus != 'draft'"
              name="onlineCom"
            >
              <sys-external-unite
                ref="sysExternalUnite"
                :tenantId="curSelectTenantId"
              ></sys-external-unite>
            </el-tab-pane>
          </el-tabs>
        </el-main>
      </el-container>
    </ht-sidebar-dialog>
    <!-- 租户用户管理 -->
    <tenant-auth-manager ref="tenantAuthManager"></tenant-auth-manager>

    <!-- 租户访问地址 -->
    <tenant-access-address ref="tenantAccessAddress"></tenant-access-address>
  </div>
</template>
<script>
import ElButton from '../../../node_modules/element-ui/packages/button/src/button.vue'

const tenantInfoManager = () => import('@/views/system/TenantInfoManager.vue')
const tenantAuthManager = () => import('@/views/uc/TenantAuthManager.vue')
const demension = () => import('@/views/uc/org/Demension.vue')
const organization = () => import('@/views/uc/org/Organization.vue')
const jobManager = () => import('@/views/uc/org/JobManager.vue')
const postManager = () => import('@/views/uc/org/PostManager.vue')
const prgParamManage = () => import('@/views/uc/org/PrgParamManage.vue')
const userListManager = () => import('@/views/uc/UserListManager.vue')
const RoleManager = () => import('@/views/uc/RoleManager.vue')
const reportLine = () => import('@/views/uc/ReportLine.vue')
const instanceManager = () => import('@/views/flow/InstanceManager.vue')
const sysExternalUnite = () =>
  import('@/views/system/sysExternalUnite/SysExternalUnite.vue')
const tenantAccessAddress = () =>
  import('@/components/tenant/TenantAccessAddress.vue')
import tableHeaderFilter from '@/mixins/tableHeaderFilter.js'
export default {
  name: 'tenantManager',
  mixins: [tableHeaderFilter],
  data() {
    return {
      dialogVisible: false,
      data: [],
      pageResult: {
        page: 1,
        pageSize: 50,
        total: 0
      },
      tenantManage: {code: '', name: ''},
      tenantTypeList: [],
      currentTabName: 'basic',
      currentOrgManager: 'henantOrgManager',
      tenantParam: {}, //当前租户的参数值
      tenantParams: [], //系统的所有组合类型参数
      activeName: 'tenantInfo',
      curSelectTenantId: '',
      curSelectTenantStatus: 'draft',
      curSelectTenantAlias: '',
      curSelectTenantName: '',
      // 配置页面是否需要刷新缓存
      tenantConfigShouldRefresh: false,
      baseMenuList: [], //系统默认菜单
      tenantIgnoreMenus: [], //租户被禁用菜单别名列表
      menuTreeExpanded: [],
      henantDemension: true,
      henantOrgManager: true,
      henantJobManager: true,
      henantPostManager: true,
      henantPrgParamManager: true
    }
  },
  components: {
    ElButton,
    tenantInfoManager,
    tenantAuthManager,
    demension,
    organization,
    jobManager,
    postManager,
    prgParamManage,
    userListManager,
    RoleManager,
    reportLine,
    instanceManager,
    sysExternalUnite,
    tenantAccessAddress
  },
  mounted() {
    this.$validator = this.$root.$validator
  },
  methods: {
    rowClick(row, column, event) {
      this.$refs.htTable.$refs.htTable.toggleRowSelection(row)
    },
    handlePaneClick: function(data) {
      const this_ = this
      if (data.alias) {
        this.currentTabComponent = data.alias
      }
      //租户基本信息
      if (data.name == 'tenantInfo') {
        this.tenantConfigShouldRefresh = false
      }
      if (data.name == 'orgManage') {
        this.$refs.henantOrgManager.reloadTree()
      }
      if (data.name == 'userManage') {
        this.$refs.userListManager.getAllDemList()
      }
    },
    handlePaneRemove: function(data) {
      this.activeName = 'tenantInfo'
      this.tenantConfigShouldRefresh = true
    },
    beforePaneleave(activeName, oldActiveName) {},
    beforeCloseDialog() {
      this.$refs.htTable.load()
    },
    handleClose() {
      this.$store.dispatch('tenant/actionTenantId', null)
      this.dialogVisible = false
      this.tenantManage = {}
      this.curSelectTenantId = ''
      this.curSelectTenantStatus = 'draft'
      this.curSelectTenantName = ''
      this.curSelectTenantAlias = ''
      this.$refs.htTable.load(true)
    },
    showDialog(id, name, code, status) {
      this.activeName = 'tenantInfo'
      this.currentTabName = 'basic'
      this.curSelectTenantId = ''
      this.curSelectTenantAlias = ''
      this.curSelectTenantName = name
      if (id) {
        this.curSelectTenantId = id
        this.curSelectTenantAlias = code
        this.$store.dispatch('tenant/actionTenantId', id)
        this.dialogVisible = true
        this.initIgnoreMenus()
      } else {
        this.dialogVisible = true
      }
      this.curSelectTenantStatus = status ? status : 'draft'
    },
    //初始化租户禁用菜单
    initIgnoreMenus() {
      this.$http
        .get(
          '${portal}/sys/sysMenu/v1/getTree?tenantId=-1&ignoreAlias=tenant,sysPwdStrategy,mobile_menu,app_menu'
        )
        .then(response => {
          this.baseMenuList = response.data
          let aliasList = []
          this.getExpandTreeMenu(response.data, aliasList, 2)
          this.menuTreeExpanded = aliasList
        })
        .then(params => {
          this.$http
            .get(
              '${uc}/uc/tenantIgnoreMenu/v1/getIgnoreMenuCodes?tenantId=' +
                this.curSelectTenantId
            )
            .then(response => {
              if (response.data && response.data.constructor == Array) {
                this.tenantIgnoreMenus = response.data
              } else {
                this.tenantIgnoreMenus = []
              }
            })
        })
    },
    handleCommand(params) {
      switch (params.command) {
        case 'edit':
          this.showDialog(
            params.row.id,
            params.row.name,
            params.row.code,
            params.row.status
          )
          break
        case 'delete':
          this.deleteById(params.row)
          break
        case 'assignUser':
          this.$refs.tenantAuthManager.showDialog(
            params.row.typeId,
            params.row.id
          )
          break
        case 'copyAddress':
          this.$refs.tenantAccessAddress.showDialog(params.row.code, params.row.baseUrl)
        default:
          break
      }
    },
    loadData(param, cb) {
      this.$http
        .post('${uc}/uc/tenantManage/v1/listJson', param)
        .then(
          resp => {
            let response = resp.data
            this.data = response.rows
            this.pageResult = {
              page: response.page,
              pageSize: response.pageSize,
              total: response.total
            }
          },
          error => {
            reject(error)
          }
        )
        .finally(() => cb())
    },
    deleteById(row) {
      let that = this
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          that.$http
            .remove('${uc}/uc/tenantManage/v1/remove?ids=' + row.id)
            .then(
              resp => {
                let response = resp.data
                if (!response.state) {
                  that.$message.error(response.message)
                } else {
                  that.$message.success(response.message)
                  that.$refs.htTable.load()
                }
              },
              error => {
                reject(error)
              }
            )
        })
        .catch(() => {})
    },
    handleNodeClick() {},
    addSuccess(tenant) {
      this.curSelectTenantId = tenant.id
      this.curSelectTenantName = tenant.name
      this.curSelectTenantAlias = tenant.code
      this.curSelectTenantStatus = tenant.status
      this.$store.dispatch('tenant/actionTenantId', tenant.id)
      this.initIgnoreMenus()
      this.$refs.htTable.load()
    },
    //保存租户禁用菜单信息
    saveTenantIgnoreMenu() {
      let that = this
      let checkedKeys = this.$refs.tenantIgnoreMenuTree.$refs.elTree.getCheckedKeys()
      if (!checkedKeys) {
        checkedKeys = []
      }
      this.$http
        .post('${uc}/uc/tenantIgnoreMenu/v1/saveByTenantId', checkedKeys)
        .then(
          resp => {
            let response = resp.data
            if (!response.state) {
              that.$message.error(response.message)
            } else {
              that.$message.success(response.message)
            }
          },
          error => {
            reject(error)
          }
        )
    },
    //设置菜单默认展开
    getExpandTreeMenu(treeMenu, aliasList, level) {
      let _this = this
      if (treeMenu && treeMenu.constructor == Array && level > 0) {
        level--
        treeMenu.forEach(menu => {
          if (
            menu.children &&
            menu.children.constructor == Array &&
            menu.children.length > 0
          ) {
            aliasList.push(menu.alias)
            this.getExpandTreeMenu(menu.children, aliasList, level)
          }
        })
      }
    },
    tabClick(data, event) {
      //点击tab卡片
      this[data.name] = false
      this.$nextTick(() => {
        this[data.name] = true
      })
    }
  }
}
</script>
<style lang="scss" scoped>
@import '@/assets/css/element-variables.scss';

::v-deep {
  .cell > .el-table__column-filter-trigger {
    display: none;
  }
}

div[aria-invalid='true'] >>> .el-input__inner,
div[aria-invalid='true'] >>> .el-input__inner:focus {
  border-color: #f56c6c;
}
div.tenant_conf >>> .el-dialog__header {
  display: none;
}
div.tenant_conf >>> .el-dialog__header,
div.tenant_conf >>> .el-dialog__body {
  height: 100%;
  padding: 0;
}

div >>> .el-tabs__content > .el-tab-pane {
  height: 100%;
}

div >>> .el-form-item__error {
  display: none;
}
.tenant-edit-container /deep/ > .el-tabs__header {
  width: 180px;
  padding-top: 24px;
}

.tenant-edit-container
  /deep/
  > .el-tabs__header
  > .el-tabs__nav-wrap
  > .el-tabs__nav-scroll
  > .el-tabs__nav {
    border: none;
    .el-tabs__active-bar{
      display: block;
    }
}

.tenant-edit-container
  /deep/
  > .el-tabs__header
  > .el-tabs__nav-wrap
  > .el-tabs__nav-scroll
  > .el-tabs__nav
  > .el-tabs__item {
  border: none !important;
  color: #666;
  padding-left: 26px !important;
  text-align: left;
}

.tenant-edit-container
  /deep/
  > .el-tabs__header
  > .el-tabs__nav-wrap
  > .el-tabs__nav-scroll
  > .el-tabs__nav
  > .el-tabs__item.is-active {
  background: #F0F7FF;
  color: #409EFF;
}
.tenant-edit-container /deep/ > .el-tabs__content {
  height: calc(100% - 3px);
  padding-top: 24px;
}
div >>> .tenant-ignore-tree {
  padding: 15px 20px;
  overflow: auto;
}
div >>> .el-tab-pane .el-table {
  height: calc(100% - 120px) !important;
  max-height: calc(100% - 120px) !important;
}

div >>> .el-tab-pane .el-table > .el-table__body-wrapper {
  height: calc(100% - 37px) !important;
  max-height: calc(100% - 37px) !important;
}

.tenant-org-container /deep/ > .el-tabs__content {
  height: calc(100% - 38px);
}
</style>