<template>
      <ContentWrap shadow="always">
        <div style="text-align: center; margin-bottom: 20px; font-weight: bold;">教师信息</div>
        <hr style="border: 1px solid #e7eaec; margin: 0;"/>
        <el-table v-loading="loading" :data="list">
          <el-table-column type="index"/>
          <!-- <el-table-column label="用户编号" align="center" key="id" prop="id" />
          <el-table-column
            label="账号"
            align="center"
            prop="username"
            :show-overflow-tooltip="true"
          /> -->
          <el-table-column
            label="姓名"
            align="center"
            prop="nickname"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="工作间"
            align="center"
            key="deptName"
            prop="deptName"
            :show-overflow-tooltip="true"
          />
          <el-table-column label="手机号码" align="center" prop="mobile"/>
          <el-table-column
            label="创建时间"
            align="center"
            prop="createTime"
            :formatter="dateFormatter"
            width="180"
          />
        <Pagination
          :total="total"
          v-model:page="queryParams.pageNo"
          v-model:limit="queryParams.pageSize"
          @pagination="getList"
        />
      </el-table>
    </ContentWrap>
</template>
<script lang="ts" setup>
import { dateFormatter } from '@/utils/formatTime'
import * as UserApi from '@/api/system/user'

defineOptions({ name: 'SystemUser' })

const props = defineProps<{
  id: string; // 根据需要修改类型
}>();

const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  username: undefined,
  mobile: undefined,
  status: undefined,
  deptId: props.id,
  createTime: []
})

const showIsGraduate = ref(false);

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    queryParams.deptId = props.id
    const data = await UserApi.getTeacherPage(queryParams)
    console.log(data, 'data');
    list.value = data.list
    total.value = data.total
    showIsGraduate.value = data.list.some(user => user.hasOwnProperty('isGraduate'));
  } finally {
    loading.value = false
  }
}

/** 初始化 */
onMounted(() => {
  getList()
})
</script>
