<template>
  <el-table v-loading="loading" :data="tableData" :stripe="true" class="m-t-20px">
    <el-table-column label="岗位中文名" align="center" prop="nameCn" />
    <el-table-column label="岗位英文名" align="center" prop="nameEn" />
    <el-table-column label="排序" align="center" prop="sort" />
    <el-table-column label="是否启用" align="center" prop="status">
      <template #default="scope">
        <dict-tag :type="DICT_TYPE.MENDUNER_STATUS" :value="scope.row.status" />
      </template>
    </el-table-column>
    <el-table-column label="备注" align="center" prop="remark" />
    <el-table-column
      label="创建时间"
      align="center"
      prop="createTime"
      :formatter="dateFormatter"
      width="180px"
    />
  </el-table>

  <Pagination
    :total="total"
    v-model:page="queryParams.pageNo"
    v-model:limit="queryParams.pageSize"
    @pagination="getList"
  />
</template>

<script setup>
defineOptions({ name: 'EnterprisePostManagement'})
import { EnterpriseApi } from '@/api/menduner/system/enterprise/message'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'

const props = defineProps({
  id: String
})

const loading = ref(false)
const tableData = ref([])
const total = ref(0)
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  enterpriseId: props.id
})

const getList = async () => {
  loading.value = true
  try {
    const data = await EnterpriseApi.getEnterprisePostPage(queryParams)
    tableData.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}
getList()
</script>
