table.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div>
  3. <CtTable
  4. class="mt-3"
  5. :items="items"
  6. :headers="headers"
  7. :loading="false"
  8. :elevation="0"
  9. :disableSort="true"
  10. :isTools="false"
  11. height="calc(100vh - 360px)"
  12. :showPage="true"
  13. :total="total"
  14. :page-info="pageInfo"
  15. itemKey="id"
  16. @pageHandleChange="e => emit('page', e)"
  17. >
  18. <template #name="{ item }">
  19. <div class="d-flex align-center cursor-pointer" @click="handleToPersonDetail(item)">
  20. <v-badge
  21. v-if="item?.person?.sex === '1' || item?.person?.sex === '2'"
  22. bordered
  23. offset-y="6"
  24. :color="badgeColor(item)"
  25. :icon="badgeIcon(item)">
  26. <v-avatar size="40" :image="getUserAvatar(item.person.avatar, item.person.sex)"></v-avatar>
  27. </v-badge>
  28. <v-avatar v-else size="40" :image="getUserAvatar(item.person?.avatar, item.person?.sex)"></v-avatar>
  29. <span class="defaultLink ml-3">{{ item?.person?.name || item?.phone }}</span>
  30. </div>
  31. </template>
  32. <template #status="{ item }">
  33. <span v-if="tab === 0">{{ item.status && item.status === '0' ? '未查看' : '已查看' }}</span>
  34. <span v-else>{{ item.status ? props.statusList.find(i => i.value === item.status)?.label : '' }}</span>
  35. </template>
  36. <template #actions="{ item }">
  37. <v-btn color="primary" variant="text" @click="handlePreviewResume(item)">查看附件</v-btn>
  38. <v-menu v-if="actionItems(item).length">
  39. <template v-slot:activator="{ props }">
  40. <v-icon v-bind="props" class="mx-3" size="20" color="primary">mdi-dots-horizontal</v-icon>
  41. </template>
  42. <v-list>
  43. <v-list-item
  44. v-for="(k, index) in actionItems(item)"
  45. :key="index"
  46. :value="index"
  47. color="primary"
  48. @click="k.click(item)"
  49. >
  50. <v-list-item-title>
  51. <span :class="{'disabledItem': tab === 0 && ['邀请面试', '立即沟通'].includes(k.title) && item.jobClosed}">{{ k.title }}</span>
  52. <v-tooltip v-if="tab === 0 && ['邀请面试', '立即沟通'].includes(k.title) && item.jobClosed" activator="parent" location="top">职位已关闭</v-tooltip>
  53. </v-list-item-title>
  54. </v-list-item>
  55. </v-list>
  56. </v-menu>
  57. </template>
  58. </CtTable>
  59. <!-- 邀请面试 -->
  60. <CtDialog :visible="showInvite" :widthType="4" titleClass="text-h6" title="面试信息" @close="handleEditClose" @submit="handleEditSubmit">
  61. <InvitePage v-if="showInvite" ref="inviteRef" :itemData="itemData"></InvitePage>
  62. </CtDialog>
  63. <TipDialog :visible="showTip" icon="mdi-check-circle-outline" message="面试邀请发送成功" @close="showTip = false">
  64. <div class="color-primary text-decoration-underline cursor-pointer" @click="handleToInterviewManagement">点击到面试中查看。</div>
  65. </TipDialog>
  66. </div>
  67. </template>
  68. <script setup>
  69. defineOptions({ name: 'table-page'})
  70. import { ref, computed, watch } from 'vue'
  71. import { previewFile } from '@/utils'
  72. import { personJobCvLook, joinEliminate, personEntryByEnterprise, personCvUnfitCancel, joinToTalentPool } from '@/api/recruit/enterprise/personnel'
  73. import { saveInterviewInvite } from '@/api/recruit/enterprise/interview'
  74. import { hireJobCvRelSettlement } from '@/api/recruit/public/delivery'
  75. import { useI18n } from '@/hooks/web/useI18n'
  76. import { useUserStore } from '@/store/user'
  77. import Snackbar from '@/plugins/snackbar'
  78. import InvitePage from './invite.vue'
  79. import { getUserAvatar } from '@/utils/avatar'
  80. import { getBlob, saveAs } from '@/utils'
  81. import { talkToUser, defaultTextEnt } from '@/hooks/web/useIM'
  82. import { useRouter } from 'vue-router'; const router = useRouter()
  83. import { formatName } from '@/utils/getText'
  84. const showTip = ref(false)
  85. const { t } = useI18n()
  86. const emit = defineEmits(['refresh', 'page'])
  87. const props = defineProps({
  88. tab: Number,
  89. items: Array,
  90. statusList: Array,
  91. pageInfo: Object,
  92. total: Number
  93. })
  94. const badgeColor = computed(() => (item) => {
  95. return (item.person && item.person.sex) ? (item.person.sex === '1' ? '#1867c0' : 'error') : 'error'
  96. })
  97. const badgeIcon = computed(() => (item) => {
  98. return (item.person && item.person.sex) ? (item.person.sex === '1' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'
  99. })
  100. const userStore = useUserStore()
  101. const inviteRef = ref()
  102. const showInvite = ref(false)
  103. const headers = ref([
  104. { title: '姓名', value: 'name', sortable: false },
  105. { title: '求职状态', key: 'person.jobStatusName', sortable: false },
  106. { title: '工作经验', key: 'person.expName', sortable: false },
  107. { title: '最高学历', key: 'person.eduName', sortable: false },
  108. { title: '应聘职位', key: 'job.name', sortable: false, value: item => formatName(item.job.name) },
  109. { title: '投递简历时间', key: 'createTime', sortable: false },
  110. { title: '状态', key: 'status', sortable: false },
  111. { title: '操作', value: 'actions', sortable: false }
  112. ])
  113. const unfit = { title: '类型', key: 'unfitType', sortable: false, value: item => item.type && item.type === '0' ? '简历不适合' : '面试不适合' }
  114. const delivery = { title: '类型', key: 'deliveryType', sortable: false, value: item => item?.job?.hire ? '赏金职位' : '普通职位' }
  115. watch(
  116. () => props.tab,
  117. (val) => {
  118. const obj = val !== 4 ? delivery : unfit
  119. const index = headers.value.indexOf(obj)
  120. if (index === -1) headers.value.splice(-1, 0, obj)
  121. else headers.value.splice(index, 1)
  122. // 不合适不需要展示状态
  123. if (val === 4) {
  124. const obj = headers.value.find(e => e.key === 'status')
  125. const i = headers.value.indexOf(obj)
  126. if (i !== -1) headers.value.splice(i, 1)
  127. }
  128. },
  129. { immediate: true }
  130. )
  131. // 人才详情
  132. const handleToPersonDetail = async ({ userId, id }) => {
  133. if (!userId || !id) return
  134. // 改变状态
  135. try {
  136. const res = await personJobCvLook(id)
  137. if (res) {
  138. emit('refresh')
  139. }
  140. } catch (err) {
  141. console.log(err)
  142. }
  143. window.open(`/recruit/enterprise/talentPool/details/${userId}`)
  144. }
  145. // 加入人才库
  146. const handleJoinToTalentPool = async (item) => {
  147. if (!item.userId) return Snackbar.warning('数据异常')
  148. await joinToTalentPool(item.userId)
  149. Snackbar.success(t('common.operationSuccessful'))
  150. emit('refresh')
  151. }
  152. // 入职
  153. const handleEnterByEnterprise = async (item) => {
  154. if (!item.id) return
  155. await personEntryByEnterprise(item.id)
  156. Snackbar.success(t('common.operationSuccessful'))
  157. emit('refresh')
  158. }
  159. // 不合适
  160. const handleEliminate = async (item) => {
  161. if (!item.id || !item?.job?.id) return
  162. const query = {
  163. bizId: item.id,
  164. jobId: item.job.id,
  165. userId: item.userId,
  166. type: props.tab === 0 ? '0' : '1' // 投递简历0 已邀约1
  167. }
  168. await joinEliminate(query)
  169. Snackbar.success(t('common.operationSuccessful'))
  170. emit('refresh')
  171. }
  172. // 取消不合适
  173. const handleCancelEliminate = async (item) => {
  174. if (!item.id) return
  175. await personCvUnfitCancel(item.id)
  176. Snackbar.success(t('common.operationSuccessful'))
  177. emit('refresh')
  178. }
  179. // 查看简历
  180. const handlePreviewResume = async ({ url, id }) => {
  181. if (!url || !id) return
  182. try {
  183. const res = await personJobCvLook(id)
  184. if (res) {
  185. emit('refresh')
  186. previewFile(url)
  187. }
  188. } catch (err) {
  189. console.log(err)
  190. }
  191. }
  192. // 邀请面试
  193. const itemData = ref({})
  194. const handleInterviewInvite = (item) => {
  195. if (item?.jobClosed) return // 职位已关闭
  196. itemData.value = item
  197. showInvite.value = true
  198. }
  199. const handleToCommunicate = async (item) => {
  200. if (item?.jobClosed) return // 职位已关闭
  201. const userId = item.userId
  202. await talkToUser({userId, text: defaultTextEnt})
  203. let url = `/recruit/enterprise/invite/chatTools?id=${userId}`
  204. router.push(url)
  205. }
  206. const handleEditClose = () => {
  207. showInvite.value = false
  208. itemData.value = {}
  209. }
  210. const handleEditSubmit = async () => {
  211. const { valid } = await inviteRef.value.CtFormRef.formRef.validate()
  212. if (!valid) return
  213. const query = inviteRef.value.getQuery()
  214. if (!query?.time) return Snackbar.warning('请选择面试时间')
  215. await saveInterviewInvite(query)
  216. showTip.value = true
  217. handleEditClose()
  218. emit('refresh')
  219. }
  220. // 结算
  221. const handleSettlement = async (item) => {
  222. if (!item.id) return
  223. await hireJobCvRelSettlement(item.id)
  224. Snackbar.success(t('common.operationSuccessful'))
  225. emit('refresh')
  226. // 更新账户信息
  227. setTimeout(async () => {
  228. await userStore.getEnterpriseUserAccountInfo()
  229. }, 2000)
  230. }
  231. const handleToInterviewManagement = () => {
  232. router.push('/recruit/enterprise/invite/interviewManagement')
  233. }
  234. // 下载附件
  235. const handleDownloadAttachment = (k) => {
  236. if (!k.url) return
  237. getBlob(k.url).then(blob => {
  238. saveAs(blob, k.title)
  239. })
  240. }
  241. const actionItems = (item) => {
  242. const arr = []
  243. if (props.tab === 0) arr.push({ title: '邀请面试', click: handleInterviewInvite }, { title: '立即沟通', click: handleToCommunicate })
  244. if (props.tab === 1 && ['3', '4'].includes(item.status)) arr.push({ title: '入职', click: handleEnterByEnterprise })
  245. if (!item.inTalentPool) arr.push({ title: '加入储备', click: handleJoinToTalentPool })
  246. if ([0, 1].includes(props.tab)) arr.push({ title: '不合适', click: handleEliminate })
  247. if (props.tab === 4) arr.push({ title: '取消不合适', click: handleCancelEliminate })
  248. if (props.tab === 2 && item?.job?.hire) arr.push({ title: '结算', click: handleSettlement })
  249. return [{ title: '下载附件', click: handleDownloadAttachment }, ...arr]
  250. }
  251. </script>
  252. <style scoped lang="scss">
  253. :deep(.v-table > .v-table__wrapper > table > thead) {
  254. background-color: #f7f8fa !important;
  255. }
  256. :deep(.v-selection-control__input) {
  257. color: var(--v-primary-base) !important;
  258. }
  259. .disabledItem {
  260. cursor: auto;
  261. opacity: .5;
  262. }
  263. </style>