<template>
  <div class="app-container">
    <page-search :roleId = "route.params.roleId" :searchFormConfig="searchFormConfig" @resetBtnClick="handleResetClick"
      @queryBtnClick="handleQueryClick" />
    <page-content ref="pageContentRef" :contentTableConfig="contentTableConfig" pageName="/system/role/authUser/allocatedList"
      rowKey="id" :query="{ roleId: route.params.roleId }" :isCreate="false" :isExport="false"
      @newBtnClick="handleNewData" @editBtnClick="handleEditData">
      <template #rolestatus="{ row }">
        <el-tag :type="row.status === '1' ? 'error' : 'success'">{{ row.status === '1' ? '禁用' : '启用' }}</el-tag>
      </template> 
    </page-content>
    <!-- <page-modal :defaultInfo="defaultInfo" ref="pageModalRef" pageName="/system/role/authUser/allocatedList"
      :modalConfig="modalConfigRef"></page-modal> -->

    <select-user
      ref="selectRef"
      :roleId="route.params.roleId"
      @ok="handleQuery"
    />
  </div>
</template>

<script>
import { defineComponent,getCurrentInstance } from 'vue'

import PageSearch from '@/components/page-search'
import PageContent from '@/components/page-content'
// import PageModal from '@/components/page-modal'

import { searchFormConfig } from './configUser/search.config'
import { contentTableConfig } from './configUser/content.config'
import { modalConfig } from './configUser/modal.config'

import { usePageSearch } from '@/hooks/use-page-search'
import selectUser from './selectUser'
import { usePageModal } from '@/hooks/use-page-modal'
export default defineComponent({
  name: 'AuthUser',
  components: {
    PageSearch,
    PageContent,
    selectUser
    // PageModal
  },
  setup() {
    const route = useRoute()
    console.log(route.params.roleId,'route.params.roleId')
    const [pageContentRef, handleResetClick, handleQueryClick] = usePageSearch()
    const { proxy } = getCurrentInstance()
    const handleNewData = () => {
      proxy.$refs['selectRef'].show()
    }

    // 1.处理逻辑
    const newCallback = () => { }
    const editCallback = () => { }

    // 2.动态添加部门和角色列表
    const modalConfigRef = computed(() => {
      return modalConfig
    })

    // 3.调用hook获取公共变量和函数
    const [pageModalRef, defaultInfo, handleEditData] =
      usePageModal(newCallback, editCallback)
    return {
      searchFormConfig,
      contentTableConfig,
      pageContentRef,
      handleResetClick,
      handleQueryClick,
      modalConfigRef,
      pageModalRef,
      defaultInfo,
      handleNewData,
      handleEditData,
      route
    }
  }
})
</script>
