import { NTabPane, NTabs } from 'naive-ui'
import { defineComponent, reactive } from 'vue'
import CategoryList from './component/category-list'
import MaterialList from './component/material-list'
import styles from './index.module.less'
import { getTabsCache, setTabsCaches } from '@/hooks/use-async'
import { useRoute } from 'vue-router'
export default defineComponent({
  name: 'educational-manage',
  setup() {
    const state = reactive({
      tabName: 'MaterialList' as 'MaterialList' | 'CategoryList'
    })
    const route = useRoute()

    getTabsCache((val: any) => {
      if (val.form.tabName) {
        state.tabName = val.form.tabName
      }
    })
    const setTabs = (val: any) => {
      setTabsCaches(val, 'tabName', route)
    }

    return () => {
      return (
        <div class="system-menu-container">
          <div class={['section-container']} style="padding-top: 0">
            <NTabs
              size="large"
              v-model:value={state.tabName}
              onUpdate:value={(val: any) => setTabs(val)}
            >
              <NTabPane
                name="MaterialList"
                tab="素材列表"
                //v-auth="cityFeeSetting/page1597885815002091522"
              >
                <MaterialList />
              </NTabPane>
              <NTabPane
                name="CategoryList"
                tab="素材分类"
                //v-auth="orchestraSubsidyStandard/page1597886618878201858"
              >
                <CategoryList />
              </NTabPane>
            </NTabs>
          </div>
        </div>
      )
    }
  }
})
