index.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986
  1. <template>
  2. <div class="message" :class="{'default-width': !isEnterprise}" :style="`height: calc(100vh - ${isEnterprise ? '130px' : '50px'});`">
  3. <div class="message-left d-flex flex-column">
  4. <div class="message-left-search d-flex align-center px-3 justify-space-between" >
  5. <div>
  6. <v-icon class="mr-3">mdi-history</v-icon>
  7. 最近联系人
  8. </div>
  9. <div>
  10. <v-btn
  11. density="compact"
  12. :color="showDelete ? '' : 'red'"
  13. :icon="showDelete ? 'mdi-close' : 'mdi-trash-can-outline'"
  14. variant="text"
  15. @click="showDelete = !showDelete"
  16. >
  17. </v-btn>
  18. </div>
  19. <!-- {{ connected ? '连接成功': '连接失败' }} -->
  20. </div>
  21. <div class="message-chat-box mt-5">
  22. <v-overlay
  23. :model-value="!IM.connected"
  24. contained
  25. class="align-center justify-center"
  26. >
  27. <v-progress-circular
  28. color="primary"
  29. size="64"
  30. indeterminate
  31. ></v-progress-circular>
  32. </v-overlay>
  33. <div v-if="conversationList.length">
  34. <v-list density="compact" mandatory @update:selected="handleChange">
  35. <v-list-item
  36. v-for="(val, i) in conversationList"
  37. :key="i"
  38. :value="val"
  39. color="primary"
  40. class="mb-2"
  41. :active="val.channel.channelID === info?.channel?.channelID"
  42. :title="val.userInfoVo ? (val.userInfoVo.userInfoResp?.name ? val.userInfoVo.userInfoResp.name : val.userInfoVo.userInfoResp?.phone) : '系统消息'"
  43. :subtitle="timesTampChange(+val.timestamp.padEnd(13, '0'))"
  44. >
  45. <template v-slot:title="{ title }">
  46. <div v-if="!isEnterprise" class="mt-2 d-flex align-center">
  47. {{ title }}
  48. <div class="ml-3 color-666 font-size-14 enterprise-name ellipsis" v-ellipse-tooltip :style="{'color': val.channel.channelID === info?.channel?.channelID ? '#00B760' : '#666'}">
  49. {{ formatName(val.userInfoVo?.userInfoResp?.enterpriseAnotherName) }}
  50. <span class="line" v-if="val.userInfoVo?.userInfoResp?.postNameCn && val.userInfoVo?.userInfoResp?.enterpriseAnotherName"></span>
  51. {{ val.userInfoVo?.userInfoResp?.postNameCn }}
  52. </div>
  53. </div>
  54. <div v-else class="mt-2" v-ellipse-tooltip>{{ title }}</div>
  55. </template>
  56. <template v-slot:subtitle="{ subtitle }">
  57. <div class="mt-2">{{ subtitle }}</div>
  58. </template>
  59. <template v-slot:prepend>
  60. <v-avatar :image="getUserAvatar(val?.userInfoVo?.userInfoResp?.avatar, val?.userInfoVo?.userInfoResp?.sex, !val.userInfoVo ? true : false)"></v-avatar>
  61. </template>
  62. <template v-slot:append>
  63. <v-badge
  64. v-if="val.unread > 0"
  65. color="error"
  66. :content="val.unread"
  67. inline
  68. ></v-badge>
  69. <v-btn v-show="showDelete" density="compact" icon="mdi-trash-can-outline" variant="text" color="red" @click.stop="handleDelete(val)"></v-btn>
  70. </template>
  71. </v-list-item>
  72. </v-list>
  73. <div class="message-no-more-text mt-3">没有更多了</div>
  74. </div>
  75. <div v-else class="left-noData">
  76. <Empty :elevation="false" message="暂无30天内联系人" width="300" height="150"></Empty>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="message-right">
  81. <div v-if="showRightNoData" class="right-noData">
  82. <Empty :elevation="false" message="与您进行过沟通的 Boss 都会在左侧列表中显示"></Empty>
  83. </div>
  84. <Chatting
  85. ref="chatRef"
  86. :items="messageItems"
  87. :info="info"
  88. :interview="interview"
  89. :has-more="hasMore"
  90. :updateConversation="updateConversation"
  91. :updateUnreadCount="updateUnreadCount"
  92. :resetUnread="resetUnread"
  93. @handleSend="handleUpdate"
  94. @handleMore="handleGetMore"
  95. @handleAgree="handleAgree"
  96. @handleRefuse="handleRefuse"
  97. @handlePreview="handlePreview"
  98. @handleSendResume="handleSendResume"
  99. @handleBack="handleBack"
  100. >
  101. <template #tools>
  102. <v-btn
  103. v-for="tool in tools"
  104. :key="tool.name"
  105. size="small"
  106. class="mr-3"
  107. :disabled="tool.disabled"
  108. :color="tool.color"
  109. @click="tool.handle(tool)"
  110. >
  111. <v-progress-circular
  112. v-if="tool.loading"
  113. :width="2"
  114. :size="16"
  115. color="white"
  116. class="mr-2"
  117. indeterminate
  118. ></v-progress-circular>
  119. <v-icon v-else class="mr-2">{{ tool.icon }}</v-icon>
  120. {{ tool.disabled ? tool.disabledText : tool.name }}
  121. </v-btn>
  122. </template>
  123. </Chatting>
  124. </div>
  125. </div>
  126. <!-- 附件上传 -->
  127. <CtDialog
  128. :visible="showUploadDialog"
  129. :widthType="2"
  130. :footer="true"
  131. title="附件简历上传"
  132. titleClass="text-h6"
  133. @close="showUploadDialog = false"
  134. @submit="handleSubmitAttachment"
  135. >
  136. <div class="color-warning mb-3" style="font-size: 13px;">* 仅支持.doc, .docx, .pdf文件且大小不能超过20MB</div>
  137. <CtForm ref="CtFormRef" :items="formItems">
  138. <template #uploadFile="{ item }">
  139. <TextInput v-model="item.value" :item="item" @click="openFileInput"></TextInput>
  140. <File ref="uploadFile" @success="handleUploadResume"></File>
  141. </template>
  142. </CtForm>
  143. <!-- 学生-实习到岗信息 -->
  144. <studentDeliveryForm v-if="baseInfo?.type && Number(baseInfo.type) === 1" ref="studentDeliveryFormRef" />
  145. </CtDialog>
  146. <!-- 面试邀请 -->
  147. <CtDialog :visible="showInvite" :widthType="4" titleClass="text-h6" title="邀请面试" @close="showInvite = false" @submit="handleSubmit">
  148. <InvitePage v-if="showInvite" ref="inviteRef" :item-data="itemData" :position="positionList"></InvitePage>
  149. </CtDialog>
  150. <TipDialog :visible="showTip" icon="mdi-check-circle-outline" message="面试邀请发送成功" @close="showTip = false">
  151. <div class="color-primary text-decoration-underline cursor-pointer" @click="handleToInterviewManagement">点击到面试中查看。</div>
  152. </TipDialog>
  153. <!-- 求简历-选择求简历的职位 -->
  154. <CtDialog :visible="showSelectPosition" :widthType="2" titleClass="text-h6" title="选择要求简历的职位" @close="showSelectPosition = false" @submit="handleRequestResumeSubmit">
  155. <CtForm v-if="showSelectPosition" ref="requestFromRef" :items="requestFormItems"></CtForm>
  156. </CtDialog>
  157. <!-- 发送简历-选择要发送的职位 -->
  158. <CtDialog :visible="openPositionSelectDialog" :widthType="2" titleClass="text-h6" title="请选择要投递的职位" @close="openPositionSelectDialog = false" @submit="selectPositionSubmit">
  159. <div style="position: relative; min-height: 200px">
  160. <v-radio-group v-model="selectJobId">
  161. <div v-for="val in entPositionList" :key="val.value" class="d-flex align-center radioBox" >
  162. <v-radio :label="val.label" :value="val.value" color="primary"></v-radio>
  163. <span class="defaultLink mx-3" style="font-size: 14px;" @click.stop="positionDetail(val)">预览</span>
  164. </div>
  165. </v-radio-group>
  166. </div>
  167. <v-btn
  168. v-if="entPositionTotal > 5"
  169. variant="text"
  170. color="primary"
  171. @click="changePositionData"
  172. >
  173. {{ entPositionListLastData ? '没有更多职位了~ 再选一遍' : '换一批'}} <v-icon size="16">mdi-refresh</v-icon>
  174. </v-btn>
  175. </CtDialog>
  176. <!-- 选择附件简历投递 -->
  177. <CtDialog :visible="showResume" :widthType="2" titleClass="text-h6" title="发送简历" @close="showResume = false; selectResume = null; enRequestPositionInfo = {}" @submit="handleSubmitResume">
  178. <div style="position: relative;">
  179. <v-radio-group v-model="selectResume">
  180. <div v-for="val in resumeList" :key="val.id" class="d-flex align-center radioBox">
  181. <v-radio :label="val.title" :value="val.id" color="primary"></v-radio>
  182. <span class="defaultLink mx-3" style="font-size: 14px;" @click.stop="previewFile(val.url)">预览</span>
  183. </div>
  184. </v-radio-group>
  185. </div>
  186. <studentDeliveryForm v-if="isStudent" ref="studentDeliveryFormRef" />
  187. </CtDialog>
  188. <Loading :visible="pageLoading" />
  189. </template>
  190. <script setup>
  191. defineOptions({ name: 'personal-message-index'})
  192. import InvitePage from '@/views/recruit/enterprise/interviewManagement/components/invite'
  193. import { ref, inject, watch, nextTick, computed } from 'vue'
  194. import { useRoute } from 'vue-router'
  195. import Chatting from './components/chatting.vue'
  196. import { initConnect, send, initChart, getMoreMessages, checkConversation } from '@/hooks/web/useIM'
  197. import { useI18n } from '@/hooks/web/useI18n'
  198. import { getPositionDetails, jobCvRelCheckSend, jobCvRelSend, jobCvRelHireSend, getJobAdvertisedSearch } from '@/api/position'
  199. import { getInterviewInviteListByInviteUserId, getMessageType } from '@/api/common'
  200. // import { getUserInfo } from '@/api/personal/user'
  201. import { getBaseInfo } from '@/api/common'
  202. import { getJobAdvertised } from '@/api/enterprise'
  203. import { saveInterviewInvite } from '@/api/recruit/enterprise/interview'
  204. import { savePersonResumeCv } from '@/api/recruit/personal/resume'
  205. import { userInterviewInviteReject, userInterviewInviteConsent } from '@/api/recruit/personal/personalCenter'
  206. import { getPersonResumeCv } from '@/api/recruit/personal/resume'
  207. import { formatName } from '@/utils/getText'
  208. import { useIMStore } from '@/store/im'
  209. import { useUserStore } from '@/store/user'
  210. import Snackbar from '@/plugins/snackbar'
  211. import Confirm from '@/plugins/confirm'
  212. import { getUserAvatar } from '@/utils/avatar'
  213. import { dealDictArrayData } from '@/utils/position'
  214. import { previewFile } from '@/utils'
  215. import { timesTampChange } from '@/utils/date'
  216. import { useRouter } from 'vue-router'
  217. import studentDeliveryForm from '@/views/recruit/personal/components/studentDeliveryForm.vue'
  218. const { t } = useI18n()
  219. const chatRef = ref()
  220. const IM = useIMStore()
  221. // 自己的信息
  222. const { entBaseInfo } = useUserStore()
  223. const isEnterprise = inject('isEnterprise')
  224. // 实例
  225. const route = useRoute()
  226. const channelItem = ref(null)
  227. const messageItems = ref([])
  228. const pageSize = ref(1)
  229. const hasMore = ref(false)
  230. const studentDeliveryFormRef = ref()
  231. const baseInfo = ref(localStorage.getItem('baseInfo') ? JSON.parse(localStorage.getItem('baseInfo')) : {})
  232. const isStudent = ref(baseInfo.value?.type && Number(baseInfo.value.type) === 1)
  233. const positionList = ref([])
  234. const showTip = ref(false)
  235. const showInvite = ref(false)
  236. // 企业-求简历
  237. const showSelectPosition = ref(false)
  238. const requestFromRef = ref()
  239. const requestFormItems = ref({
  240. options: [
  241. {
  242. type: 'autocomplete',
  243. key: 'jobId',
  244. value: null,
  245. label: '招聘职位 *',
  246. outlined: true,
  247. clearable: false,
  248. itemText: 'label',
  249. itemValue: 'value',
  250. rules: [v => !!v || '请选择招聘职位'],
  251. items: positionList
  252. }
  253. ]
  254. })
  255. const showDelete = ref(false)
  256. const itemData = ref({})
  257. const inviteRef = ref()
  258. // 发送简历
  259. const showResume = ref(false)
  260. const resumeList = ref([])
  261. const selectResume = ref(null)
  262. // 众聘 介绍人个人id
  263. const isEmployment = ref('-1')
  264. // 上传附件简历
  265. const CtFormRef = ref()
  266. const formItems = ref({
  267. options: [
  268. {
  269. type: 'text',
  270. key: 'title',
  271. value: '',
  272. label: '附件简历名称 *',
  273. rules: [v => !!v || '请输入附件简历名称']
  274. },
  275. {
  276. slotName: 'uploadFile',
  277. key: 'url',
  278. value: '',
  279. truthValue: '',
  280. label: '点击上传附件简历 *',
  281. outline: true,
  282. accept: '.doc, .docx, .pdf',
  283. prependInnerIcon: 'mdi-file-document-outline',
  284. rules: [v => !!v || '请上传您的附件简历']
  285. }
  286. ]
  287. })
  288. // 求职者面试列表
  289. const interview = ref([])
  290. const showRightNoData = ref(false)
  291. const info = ref({})
  292. const enterpriseTools = ref([
  293. { name: '求简历', key: 'requestResume', icon: 'mdi-email', color:"primary", loading: false, handle: handleInvite, disabled: false, disabledText: '简历已接收' },
  294. { name: '面试邀约', key: 'interviewInvite', icon: 'mdi-email', color:"primary", loading: false, handle: handleInvite, disabled: false, disabledText: '面试邀约' }
  295. ])
  296. const userTools = ref([
  297. {
  298. name: '发送简历',
  299. key: 'sendResume',
  300. icon: 'mdi-email',
  301. color:"primary",
  302. loading: false,
  303. handle: handleSendResume,
  304. disabled: false,
  305. disabledText: '简历已投递'
  306. }
  307. ])
  308. // const tools = isEnterprise ? enterpriseTools.value : userTools.value
  309. const tools = computed(() => {
  310. return isEnterprise ? enterpriseTools.value : userTools.value
  311. })
  312. const positionInfo = ref({})
  313. // const isSendResume = ref(false)
  314. if (!IM) {
  315. console.log('IM is disconnected')
  316. }
  317. // 参与招聘会的职位进入需传递招聘会id
  318. // const jobFairId = ref('')
  319. // if (route.query?.jobFairId) jobFairId.value = route.query.jobFairId
  320. // 职位进入
  321. if (route.query.id) {
  322. const api = route.query.enterprise ? getPositionDetails : getBaseInfo // getBaseInfo getUserInfo
  323. // const res = await api({ id: route.query.id })
  324. const res = await api(route.query.enterprise ? { id: route.query.id } : { userId: route.query.id })
  325. if (!res) {
  326. Snackbar.error('个人资料为空')
  327. } else {
  328. const query = route.query.enterprise ? [res.contact?.userId, res.contact?.enterpriseId] : [res?.userId]
  329. nextTick(async () => {
  330. const { channel } = await checkConversation(...query)
  331. const items = [
  332. {
  333. channel,
  334. userInfoVo: {
  335. userInfoResp: route.query.enterprise ? res.contact : { ...res, userId: res?.userId}
  336. }
  337. }
  338. ]
  339. handleChange(items)
  340. })
  341. }
  342. }
  343. const {
  344. conversationList,
  345. updateConversation,
  346. updateUnreadCount,
  347. deleteConversations,
  348. resetUnread
  349. } = initConnect(async (successful) => {
  350. if (!successful) {
  351. Snackbar.error('发送失败')
  352. return
  353. }
  354. chatRef.value.reset()
  355. // 发送成功
  356. const { list } = await getMoreMessages(1, channelItem.value)
  357. // updateConversation()
  358. messageItems.value = list.value
  359. chatRef.value.scrollBottom()
  360. })
  361. const getInterviewInviteList = async () => {
  362. if (!info.value.userId) return
  363. const data = await getInterviewInviteListByInviteUserId(info.value.userId)
  364. interview.value = data.slice(0, 1)
  365. }
  366. // 在当前频道中有新消息时更新未读消息数量
  367. const updateUnreadMessageCount = (val) => {
  368. const obj = val.find(e => e.userInfoVo.userId === info.value.userId)
  369. if (!obj?.unread || obj.unread === 0) return
  370. delete info.value.unread
  371. Object.assign(info.value, { unread: obj.unread, enterpriseId: entBaseInfo?.enterpriseId })
  372. }
  373. watch(
  374. () => conversationList.value,
  375. async (val) => {
  376. // 数据发生变化
  377. if (channelItem.value && IM.fromChannel === channelItem.value.channelID) {
  378. // 更新
  379. const { list } = await getMoreMessages(1, channelItem.value)
  380. messageItems.value = list.value
  381. if (Object.keys(info.value).length) updateUnreadMessageCount(val)
  382. chatRef.value.scrollBottom()
  383. }
  384. },
  385. {
  386. deep: true,
  387. immediate: true
  388. }
  389. )
  390. // 获取职位信息
  391. async function getMessageTypeSync () {
  392. const data = await getMessageType({
  393. fromUid: IM.uid,
  394. channelId: channelItem.value?.channelID,
  395. type: 102,
  396. page: {
  397. current: 1,
  398. size: 1,
  399. orders: [
  400. { column: 'message_seq', asc: false }
  401. ]
  402. }
  403. })
  404. if (!data.records || !data.records.length) {
  405. positionInfo.value = {}
  406. handleChangeSendResumeStatus(false)
  407. return
  408. }
  409. const _item = data.records.pop()
  410. const _itemJSON = JSON.parse(_item.payload)
  411. const _content = JSON.parse(_itemJSON.content)
  412. positionInfo.value = _content.positionInfo
  413. const check = await jobCvRelCheckSend({ jobId: _content.positionInfo.id })
  414. handleChangeSendResumeStatus(check)
  415. }
  416. // 修改发送状态
  417. function handleChangeSendResumeStatus (status) {
  418. if (!isEnterprise) {
  419. const item = userTools.value.find(e => e.key === 'sendResume')
  420. item.disabled = status
  421. }
  422. }
  423. async function handleChange (items) {
  424. try {
  425. chatRef.value.changeOverlay(true)
  426. const { userInfoVo, channel: myChannel, unread } = items.pop()
  427. info.value = userInfoVo?.userInfoResp ?? { name: '系统消息' }
  428. Object.assign(info.value, {
  429. channel: myChannel,
  430. unread
  431. })
  432. if (myChannel.channelID === 'system') {
  433. channelItem.value = myChannel
  434. const { list, more } = await getMoreMessages(1, channelItem.value)
  435. messageItems.value = list.value
  436. hasMore.value = more
  437. chatRef.value.scrollBottom()
  438. // 点开窗口消除未读数量
  439. await resetUnread(channelItem.value, entBaseInfo?.enterpriseId)
  440. await updateConversation()
  441. updateUnreadCount()
  442. return
  443. }
  444. // 个人端获取面试信息
  445. if (!isEnterprise) getInterviewInviteList()
  446. const userId = userInfoVo.userInfoResp.userId
  447. const enterpriseId = userInfoVo.userInfoResp.enterpriseId || undefined
  448. const { channel, list, more } = await initChart(userId, enterpriseId)
  449. // console.log('--------',list)
  450. channelItem.value = channel.value
  451. messageItems.value = list.value
  452. hasMore.value = more
  453. chatRef.value.scrollBottom()
  454. // 点开窗口消除未读数量
  455. await resetUnread(channel.value, entBaseInfo?.enterpriseId)
  456. await updateConversation()
  457. updateUnreadCount()
  458. // 获取最近职位记录
  459. getMessageTypeSync()
  460. } catch (error) {
  461. messageItems.value = []
  462. } finally {
  463. chatRef.value.changeOverlay(false)
  464. }
  465. }
  466. // 普通消息
  467. const handleUpdate = (val) => {
  468. send(val.value, channelItem.value)
  469. }
  470. // 选择文件
  471. const uploadFile = ref()
  472. const openFileInput = () => {
  473. uploadFile.value.trigger()
  474. }
  475. // 上传附件
  476. const handleUploadResume = async (url, title, filename) => {
  477. const obj = formItems.value.options.find(e => e.key === 'url')
  478. obj.value = filename
  479. obj.truthValue = url
  480. }
  481. const changePositionData = () => {
  482. entPositionListParams.value.pageNo = entPositionListLastData.value ? 1 : entPositionListParams.value.pageNo + 1
  483. selectJobId.value = ''
  484. getRecruitPositionList()
  485. }
  486. const positionDetail = (val) => {
  487. const id = val.value
  488. if (!id) return
  489. window.open(`/recruit/personal/position/details/${id}`)
  490. }
  491. // 选中职位并投递
  492. const selectJobId = ref('')
  493. const selectPositionSubmit = async () => {
  494. // 投递
  495. openPositionSelectDialog.value = false
  496. handleSendResume(handleSendResumeItem)
  497. }
  498. const pageLoading = ref(false)
  499. const entPositionTotal = ref(0)
  500. const entPositionList = ref([])
  501. const entPositionListParams = ref({ pageNo: 1, pageSize: 5 })
  502. const openPositionSelectDialog = ref(false)
  503. const entPositionListLastData = computed(() => entPositionListParams.value.pageNo * entPositionListParams.value.pageSize >= entPositionTotal.value)
  504. // 职位列表
  505. const getRecruitPositionList = async () => {
  506. const enterpriseId = info.value?.enterpriseId || null
  507. if (!enterpriseId) return Snackbar.warning('访问企业错误!')
  508. pageLoading.value = true
  509. const { list, total: number } = await getJobAdvertisedSearch({ ...entPositionListParams.value, enterpriseId })
  510. if (!list.length) return Snackbar.warning('企业暂无招聘中的职位,无法进行投递!')
  511. entPositionTotal.value = number
  512. entPositionList.value = list.map(j => {
  513. const e = j?.job || null
  514. if (!e) return e
  515. const salary = e.payFrom && e.payTo ? `${e.payFrom ? e.payFrom + '-' : ''}${e.payTo}${e.payName ? '/' + e.payName : ''}` : '面议'
  516. return {
  517. label: `${formatName(e.name)}_${e.areaName ? e.area?.str : '全国'} ${salary}`,
  518. value: e.id,
  519. data: e
  520. }
  521. }).filter(Boolean)
  522. setTimeout(() => { pageLoading.value = false }, 300)
  523. }
  524. // 获取简历
  525. const showUploadDialog = ref(false)
  526. const enRequestPositionInfo = ref({}) // 企业求简历时选中的职位信息
  527. let handleSendResumeItem = null
  528. async function handleSendResume (item) {
  529. const jobId = enRequestPositionInfo.value && enRequestPositionInfo.value?.id ? enRequestPositionInfo.value?.id : positionInfo.value.id
  530. if (!jobId && !selectJobId.value && import.meta.env.VITE_NODE_ENV !== 'production') {
  531. // 没有基于职位接收到的沟通,弹出职位列表让求职者选择。否则无法投递简历。
  532. handleSendResumeItem = item
  533. await getRecruitPositionList()
  534. if (entPositionTotal.value) openPositionSelectDialog.value = true
  535. return
  536. }
  537. try {
  538. item.loading = true
  539. // 获取简历列表
  540. const result = await getPersonResumeCv()
  541. if (result.length === 0) {
  542. Snackbar.warning(t('resume.resumeYetSubmit'))
  543. showUploadDialog.value = true
  544. return
  545. }
  546. resumeList.value = result
  547. if (item?.content?.query?.positionInfo?.data && Object.keys(item?.content?.query?.positionInfo?.data).length) enRequestPositionInfo.value = item?.content?.query?.positionInfo?.data
  548. showResume.value = true
  549. } finally {
  550. item.loading = false
  551. }
  552. }
  553. // 撤回简历
  554. async function handleBack (val) {
  555. console.log(val)
  556. try {
  557. // 撤回简历
  558. // 撤回聊天
  559. // await messageBack({
  560. // channelId: val.channel_id,
  561. // messageId: val.message_id,
  562. // nickName: baseInfo.name
  563. // // enterpriseId: ''
  564. // })
  565. } catch (error) {
  566. console.log(error)
  567. }
  568. }
  569. /**
  570. * 发送简历
  571. * text param
  572. * {
  573. * remark: 备注
  574. * query: {} 自定义参数 access -1 未确定 0 拒绝 1 同意
  575. * type: 1 => 发送简历
  576. * 2 => 索要简历
  577. * 3 => 信息描述
  578. * }
  579. */
  580. // 没有上传过简历的弹窗上传并发送给对方
  581. const handleSubmitAttachment = async () => {
  582. const { valid } = await CtFormRef.value.formRef.validate()
  583. if (!valid) return
  584. const obj = {}
  585. formItems.value.options.forEach(e => {
  586. obj[e.key] = e.truthValue || e.value
  587. })
  588. if (!obj.title || !obj.url) return
  589. // 学生实习到岗信息
  590. let practice = {}
  591. if (isStudent.value) {
  592. practice = studentDeliveryFormRef.value.getQueryParams()
  593. console.log(practice, '上传简历-到岗信息')
  594. }
  595. if (isStudent.value && (!practice?.practiceStartTime || !practice?.practiceEndTime)) return Snackbar.warning('请完善实习到岗信息')
  596. // 保存附件
  597. await savePersonResumeCv(obj)
  598. // 简历投递至简历库
  599. if (isEmployment.value !== '-1') {
  600. let params = {
  601. jobId: positionInfo.value.id || selectJobId.value,
  602. url: obj.url,
  603. recommendUserId: isEmployment.value
  604. }
  605. // 如果是学生则需要带上实习信息
  606. if (practice && Object.keys(practice).length > 0) params = Object.assign(params, practice)
  607. await jobCvRelHireSend(params)
  608. } else {
  609. const jobId = enRequestPositionInfo.value && enRequestPositionInfo.value?.id ? enRequestPositionInfo.value?.id : positionInfo.value.id || selectJobId.value
  610. const type = (enRequestPositionInfo.value && Object.keys(enRequestPositionInfo.value).length ? enRequestPositionInfo.value.hire : positionInfo.value.hire) ? 1 : 0
  611. let params = {
  612. jobId,
  613. title: obj.title,
  614. url: obj.url,
  615. type
  616. }
  617. // 如果是学生则需要带上实习信息
  618. if (practice && Object.keys(practice).length > 0) params = Object.assign(params, practice)
  619. await jobCvRelSend(params)
  620. }
  621. handleChangeSendResumeStatus(true)
  622. showUploadDialog.value = false
  623. const text = {
  624. remark: '发送简历',
  625. query: {
  626. src: obj.url,
  627. title: obj.title
  628. },
  629. type: 1
  630. }
  631. if (enRequestPositionInfo.value) text.query.positionInfo = enRequestPositionInfo.value
  632. send (JSON.stringify(text), channelItem.value, 105)
  633. enRequestPositionInfo.value = {}
  634. }
  635. async function handleSubmitResume () {
  636. if (!selectResume.value) {
  637. Snackbar.warning(t('resume.selectResumeToSubmit'))
  638. return
  639. }
  640. const _info = resumeList.value.find((item) => item.id === selectResume.value)
  641. // 学生实习到岗信息
  642. let practice = {}
  643. if (isStudent.value) {
  644. practice = studentDeliveryFormRef.value.getQueryParams()
  645. console.log(practice, '选择简历-到岗信息')
  646. }
  647. if (isStudent.value && (!practice?.practiceStartTime || !practice?.practiceEndTime)) return Snackbar.warning('请完善实习到岗信息')
  648. // 简历投递至简历库
  649. if (isEmployment.value !== '-1') {
  650. let params = {
  651. jobId: positionInfo.value.id || selectJobId.value,
  652. url: _info.url,
  653. recommendUserId: isEmployment.value
  654. }
  655. // 如果是学生则需要带上实习信息
  656. if (practice && Object.keys(practice).length > 0) params = Object.assign(params, practice)
  657. await jobCvRelHireSend(params)
  658. } else {
  659. const jobId = enRequestPositionInfo.value && enRequestPositionInfo.value?.id ? enRequestPositionInfo.value?.id : positionInfo.value.id || selectJobId.value
  660. const type = (enRequestPositionInfo.value && Object.keys(enRequestPositionInfo.value).length ? enRequestPositionInfo.value.hire : positionInfo.value.hire) ? 1 : 0
  661. let params = {
  662. jobId,
  663. title: _info.title,
  664. url: _info.url,
  665. type
  666. }
  667. // 如果是学生则需要带上实习信息
  668. if (practice && Object.keys(practice).length > 0) params = Object.assign(params, practice)
  669. await jobCvRelSend(params)
  670. }
  671. handleChangeSendResumeStatus(true)
  672. showResume.value = false
  673. const text = {
  674. remark: '发送简历',
  675. query: {
  676. src: _info.url,
  677. title: _info.title,
  678. id: _info.id,
  679. },
  680. type: 1
  681. }
  682. if (enRequestPositionInfo.value) text.query.positionInfo = enRequestPositionInfo.value
  683. send (JSON.stringify(text), channelItem.value, 105)
  684. enRequestPositionInfo.value = {}
  685. }
  686. // 简历预览
  687. const handlePreview = (val) => {
  688. previewFile(val.content.query.src)
  689. }
  690. const handleGetMore = async () => {
  691. // 当前滚动条高度
  692. const scrollHeight = chatRef.value.chatRef.scrollHeight
  693. // 当前滚动条距离
  694. const scrollTop = chatRef.value.chatRef.scrollTop
  695. try {
  696. chatRef.value.changeLoading(true)
  697. pageSize.value++
  698. const { list, more } = await getMoreMessages(pageSize.value, channelItem.value)
  699. messageItems.value.unshift(...list.value)
  700. hasMore.value = more
  701. nextTick(() => {
  702. // 渲染后高度
  703. const _scrollHeight = chatRef.value.chatRef.scrollHeight
  704. chatRef.value.chatRef.scrollTop = _scrollHeight - scrollHeight - scrollTop
  705. })
  706. } finally {
  707. chatRef.value.changeLoading(false)
  708. }
  709. }
  710. const handleDelete = async ({ channel }) => {
  711. await deleteConversations(channel, entBaseInfo?.enterpriseId)
  712. await updateConversation()
  713. updateUnreadCount()
  714. }
  715. // 没有企业ID则enterpriseId为undefined
  716. // 发送消息体 { text, type: 2 }
  717. // 面试邀约
  718. const getPositionList = async () => {
  719. const data = await getJobAdvertised({ status: 0 }) // 0开启 1关闭 不带则全部
  720. if (!data.length) return
  721. const list = dealDictArrayData([], data)
  722. positionList.value = list.map(e => {
  723. const salary = e.payFrom && e.payTo ? `${e.payFrom ? e.payFrom + '-' : ''}${e.payTo}${e.payName ? '/' + e.payName : ''}` : '面议'
  724. return {
  725. label: `${formatName(e.name)}_${e.areaName ? e.area?.str : '全国'} ${salary}`,
  726. value: e.id,
  727. data: e
  728. }
  729. })
  730. }
  731. async function handleInvite (item) {
  732. item.loading = true
  733. positionList.value = []
  734. try {
  735. await getPositionList()
  736. if (!positionList.value.length) return Snackbar.warning('请先发布职位')
  737. if (item.key === 'requestResume') return showSelectPosition.value = true
  738. showInvite.value = true
  739. } catch (error) {
  740. console.log(error)
  741. } finally {
  742. item.loading = false
  743. }
  744. }
  745. // 企业-发送面试邀请
  746. const handleSubmit = async () => {
  747. const { valid } = await inviteRef.value.CtFormRef.formRef.validate()
  748. if (!valid) {
  749. return
  750. }
  751. const query = inviteRef.value.getQuery()
  752. if (!query.time) {
  753. Snackbar.warning('时间不能为空')
  754. return
  755. }
  756. query.userId = info.value.userId
  757. query.positionInfo = positionList.value.find(e => e.value === query.jobId)
  758. // 需要id
  759. const data = await saveInterviewInvite(query)
  760. // 保留邀请id
  761. query.id = data.id
  762. showTip.value = true
  763. send(JSON.stringify(query), channelItem.value, 101)
  764. showInvite.value = false
  765. }
  766. const router = useRouter()
  767. const handleToInterviewManagement = () => {
  768. router.push('/recruit/enterprise/invite/interviewManagement')
  769. }
  770. // 企业-求简历
  771. const handleRequestResumeSubmit = async () => {
  772. const { valid } = await requestFromRef.value.formRef.validate()
  773. if (!valid) return
  774. const jobId = requestFormItems.value.options.find(e => e.key === 'jobId').value
  775. const positionInfo = positionList.value.find(e => e.value === jobId)
  776. const text = {
  777. remark: '求简历',
  778. query: {
  779. src: '',
  780. title: '',
  781. id: '',
  782. positionInfo
  783. },
  784. type: 2
  785. }
  786. send (JSON.stringify(text), channelItem.value, 105)
  787. showSelectPosition.value = false
  788. }
  789. const handleAgree = (val) => {
  790. if (!val.id) return
  791. const query = {
  792. id: val.id
  793. }
  794. const type = route?.meta?.loginType === 'enterprise' ? 'entBaseInfo' : 'baseInfo'
  795. const baseInfo = localStorage.getItem(type)
  796. if (baseInfo) {
  797. const { phone } = JSON.parse(baseInfo)
  798. query.phone = phone
  799. }
  800. Confirm(t('common.confirmTitle'), '是否确定接收此面试邀请?').then(async () => {
  801. await userInterviewInviteConsent(query)
  802. Snackbar.success(t('common.operationSuccessful'))
  803. getInterviewInviteList()
  804. send(JSON.stringify({ id: val.id }), channelItem.value, 104)
  805. })
  806. }
  807. // 拒绝面试邀请
  808. const handleRefuse = (val) => {
  809. if (!val.id) return
  810. Confirm(t('common.confirmTitle'), '您是否确定要拒绝此面试邀请?').then(async () => {
  811. await userInterviewInviteReject(val.id)
  812. Snackbar.success(t('common.operationSuccessful'))
  813. getInterviewInviteList()
  814. send(JSON.stringify({ id: val.id }), channelItem.value, 103)
  815. })
  816. }
  817. </script>
  818. <style scoped lang="scss">
  819. .message {
  820. display: flex;
  821. &-left {
  822. position: relative;
  823. flex-shrink: 0;
  824. height: 100%;;
  825. width: 360px;
  826. background-color: #fff;
  827. border-radius: 8px;
  828. margin-right: 12px;
  829. .message-left-search {
  830. width: 100%;
  831. height: 60px;
  832. background: linear-gradient(90deg, #f5fcfc, #fcfbfa);
  833. border-radius: 8px 8px 0 0;
  834. }
  835. .message-chat-box {
  836. height: 0;
  837. flex: 1;
  838. overflow: auto;
  839. padding-bottom: 20px;
  840. .chat-item {
  841. position: relative;
  842. width: 100%;
  843. height: 78px;
  844. padding: 14px 12px;
  845. cursor: pointer;
  846. &:hover {
  847. background-color: #f8f8f8;
  848. }
  849. .chat-item-time {
  850. position: absolute;
  851. right: 12px;
  852. top: 50%;
  853. transform: translateY(-50%);
  854. }
  855. .title-box {
  856. max-width: 114px;
  857. overflow: hidden;
  858. white-space: nowrap;
  859. text-overflow: ellipsis;
  860. display: inline-block;
  861. }
  862. }
  863. }
  864. .message-no-more-text {
  865. color: var(--color-999);
  866. font-size: 14px;
  867. text-align: center
  868. }
  869. .left-noData {
  870. position: absolute;
  871. top: 50%;
  872. left: 50%;
  873. transform: translate(-50%, -50%);
  874. }
  875. }
  876. &-right {
  877. height: 100%;
  878. flex: 1;
  879. width: 0;
  880. position: relative;
  881. background-color: #fff;
  882. border-radius: 8px;
  883. .right-noData {
  884. position: absolute;
  885. top: 50%;
  886. left: 50%;
  887. transform: translate(-50%, -50%);
  888. }
  889. }
  890. }
  891. .enterprise-name {
  892. max-width: 150px;
  893. .line {
  894. display: inline-block;
  895. width: 1px;
  896. height: 12px;
  897. vertical-align: middle;
  898. background-color: #e0e0e0;
  899. margin: 0 3px;
  900. }
  901. }
  902. .radioBox {
  903. &:hover {
  904. border-radius: 2px;
  905. background-color: var(--color-f8);
  906. }
  907. }
  908. </style>