table.vue 11 KB

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