<script>
  import { depListManage, funListManage, orgListManage, roleListManage, staffListManage } from '@vue2-client/pages/resourceManage'
  import exp403 from '@vue2-client/pages/exception/403'
  import { getResourceFunction, searchFun } from '@vue2-client/base-client/plugins/GetLoginInfoService'

  export default {
    name: 'ResourceManageMain',
    components: { depListManage, funListManage, orgListManage, roleListManage, staffListManage },
    data () {
      return {
        renderSW: false,
        resFun: []
      }
    },
    render () {
      if (!this.renderSW) return
      if (!this.resFun || this.resFun.length <= 0) {
        return (
          <div id="resourceManageMain">
            <exp403></exp403>
          </div>
        )
      }
      const tabPane = []
      for (const [index, row] of this.resFun.entries()) {
        tabPane.push(
          <a-tab-pane key={index} force-render>
            <span slot="tab"><a-icon type={row.icon || 'exclamation'}/>{row.name}</span>
            <row.link></row.link>
          </a-tab-pane>
        )
      }
      return (
        <div id="resourceManageMain">
          <a-tabs>
            {tabPane}
          </a-tabs>
        </div>
      )
    },
    created () {
    },
    async mounted () {
      const fun = await getResourceFunction()
      this.resFun = searchFun(fun, '资源功能')
      this.renderSW = true
    },
    methods: {
    }
  }
</script>

<style lang="less">
  #resourceManageMain {
    background-color: @gray-1;
  }
</style>
