table.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div>
  3. <div class="text-end">
  4. <v-btn v-if="tab === '0'" color="primary" :disabled="selected.length ? false : true" variant="tonal" @click="handleAction('all', 0)">不合适</v-btn>
  5. <v-btn v-if="tab === '1'" color="primary" :disabled="selected.length ? false : true" variant="tonal" @click="handleAction('all', 1)">入职</v-btn>
  6. </div>
  7. <v-data-table
  8. class="mt-3"
  9. v-model="selected"
  10. :items="items"
  11. :headers="headers"
  12. hover
  13. show-select
  14. :disable-sort="true"
  15. height="60vh"
  16. item-value="id"
  17. >
  18. <template #bottom></template>
  19. <template v-slot:item.name="{ item }">
  20. <div class="d-flex align-center cursor-pointer" @click="handleToPersonDetail(item)">
  21. <v-badge
  22. bordered
  23. offset-y="6"
  24. :color="badgeColor(item)"
  25. :icon="badgeIcon(item)">
  26. <v-avatar size="40" :image="item.person.avatar || 'https://minio.citupro.com/dev/menduner/7.png'"></v-avatar>
  27. </v-badge>
  28. <span class="defaultLink ml-3">{{ item?.person?.name }}</span>
  29. </div>
  30. </template>
  31. <template v-slot:item.actions="{ item }">
  32. <div v-if="tab === '0'">
  33. <v-btn color="primary" variant="text" @click="previewFile(item.url)">查看简历</v-btn>
  34. <v-btn color="primary" variant="text" @click="handleAction('', 0, item)">不合适</v-btn>
  35. </div>
  36. <div v-if="tab === '1'">
  37. <v-btn color="primary" variant="text" @click="handleAction('', 1, item)">入职</v-btn>
  38. </div>
  39. </template>
  40. </v-data-table>
  41. </div>
  42. </template>
  43. <script setup>
  44. defineOptions({ name: 'table-page'})
  45. import { ref, computed } from 'vue'
  46. import { previewFile } from '@/utils'
  47. import { joinEliminate, personEntryByEnterprise } from '@/api/enterprise'
  48. import { useI18n } from '@/hooks/web/useI18n'
  49. import Snackbar from '@/plugins/snackbar'
  50. const { t } = useI18n()
  51. const emit = defineEmits(['refresh'])
  52. defineProps({
  53. tab: String,
  54. items: Array
  55. })
  56. const badgeColor = computed(() => (item) => {
  57. return (item.person && item.person.sex) ? (item.person.sex === '1' ? '#1867c0' : 'error') : 'error'
  58. })
  59. const badgeIcon = computed(() => (item) => {
  60. return (item.person && item.person.sex) ? (item.person.sex === '1' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'
  61. })
  62. const selected = ref([])
  63. const headers = ref([
  64. { title: '姓名', value: 'name' },
  65. { title: '应聘职位', value: 'job.name' },
  66. { title: '求职状态', key: 'person.jobStatusName' },
  67. { title: '工作经验', key: 'person.expName' },
  68. { title: '最高学历', key: 'person.eduName' },
  69. { title: '岗位薪资', key: 'job', value: item => `${item.job.payFrom}-${item.job.payTo}/${item.job.payName}`, sortable: false },
  70. { title: '操作', value: 'actions' }
  71. ])
  72. // 人才详情
  73. const handleToPersonDetail = ({ userId, id }) => {
  74. if (!userId || !id) return
  75. window.open(`/recruit/enterprise/talentPool/details/${userId}?id=${id}`)
  76. }
  77. const apiList = [
  78. joinEliminate, // 不合适
  79. personEntryByEnterprise // 入职
  80. ]
  81. // 不合适、入职
  82. const handleAction = async (type, index, item) => {
  83. const ids = type ? selected.value : [item?.id]
  84. if (!ids) return
  85. await apiList[index](ids)
  86. Snackbar.success(t('common.operationSuccessful'))
  87. emit('refresh')
  88. }
  89. </script>
  90. <style scoped lang="scss">
  91. :deep(.v-table > .v-table__wrapper > table > thead) {
  92. background-color: #f7f8fa !important;
  93. }
  94. :deep(.v-selection-control__input) {
  95. // color: var(--v-primary-base) !important;
  96. color: #767778;
  97. }
  98. </style>