index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858
  1. <template>
  2. <div class="default-width message" :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" :style="{'color': val.channel.channelID === info?.channel?.channelID ? '#00897B' : '#666'}">
  49. {{ 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">{{ 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)"></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. <CtForm ref="CtFormRef" :items="formItems">
  137. <template #uploadFile="{ item }">
  138. <TextInput v-model="item.value" :item="item" @click="openFileInput"></TextInput>
  139. <File ref="uploadFile" @success="handleUploadResume"></File>
  140. </template>
  141. </CtForm>
  142. <div class="color-666" style="font-size: 13px;">* 仅支持.doc, .docx, .pdf文件且大小不能超过20MB</div>
  143. </CtDialog>
  144. <!-- 面试邀请 -->
  145. <CtDialog :visible="showInvite" :widthType="4" titleClass="text-h6" title="邀请面试" @close="showInvite = false" @submit="handleSubmit">
  146. <InvitePage v-if="showInvite" ref="inviteRef" :item-data="itemData" :position="positionList"></InvitePage>
  147. </CtDialog>
  148. <TipDialog :visible="showTip" icon="mdi-check-circle-outline" message="面试邀请发送成功" @close="showTip = false">
  149. <div class="color-primary text-decoration-underline cursor-pointer" @click="handleToInterviewManagement">点击到面试中查看。</div>
  150. </TipDialog>
  151. <!-- 求简历-选择求简历的职位 -->
  152. <CtDialog :visible="showSelectPosition" :widthType="2" titleClass="text-h6" title="选择要求简历的职位" @close="showSelectPosition = false" @submit="handleRequestResumeSubmit">
  153. <CtForm v-if="showSelectPosition" ref="requestFromRef" :items="requestFormItems"></CtForm>
  154. </CtDialog>
  155. <!-- 选择附件简历投递 -->
  156. <CtDialog :visible="showResume" :widthType="2" titleClass="text-h6" title="发送简历" @close="showResume = false; selectResume = null; enRequestPositionInfo = {}" @submit="handleSubmitResume">
  157. <div style="position: relative; min-height: 200px">
  158. <v-radio-group v-model="selectResume">
  159. <div v-for="val in resumeList" :key="val.id" class="d-flex align-center radioBox">
  160. <v-radio :label="val.title" :value="val.id" color="primary"></v-radio>
  161. <span class="defaultLink mx-3" style="font-size: 14px;" @click.stop="previewFile(val.url)">预览</span>
  162. </div>
  163. </v-radio-group>
  164. </div>
  165. </CtDialog>
  166. </template>
  167. <script setup>
  168. defineOptions({ name: 'personal-message-index'})
  169. import InvitePage from '@/views/recruit/enterprise/interviewManagement/components/invite'
  170. import { ref, inject, watch, nextTick, computed } from 'vue'
  171. import { useRoute } from 'vue-router'
  172. import Chatting from './components/chatting.vue'
  173. import { initConnect, send, initChart, getMoreMessages, checkConversation } from '@/hooks/web/useIM'
  174. import { useI18n } from '@/hooks/web/useI18n'
  175. import { getPositionDetails, jobCvRelCheckSend, jobCvRelSend, jobCvRelHireSend } from '@/api/position'
  176. import { getInterviewInviteListByInviteUserId, getMessageType } from '@/api/common'
  177. // import { getUserInfo } from '@/api/personal/user'
  178. import { getBaseInfo } from '@/api/common'
  179. import { getJobAdvertised } from '@/api/enterprise'
  180. import { saveInterviewInvite } from '@/api/recruit/enterprise/interview'
  181. import { savePersonResumeCv } from '@/api/recruit/personal/resume'
  182. import { userInterviewInviteReject, userInterviewInviteConsent } from '@/api/recruit/personal/personalCenter'
  183. import { getPersonResumeCv } from '@/api/recruit/personal/resume'
  184. import { useIMStore } from '@/store/im'
  185. import { useUserStore } from '@/store/user'
  186. import Snackbar from '@/plugins/snackbar'
  187. import Confirm from '@/plugins/confirm'
  188. import { getUserAvatar } from '@/utils/avatar'
  189. import { dealDictArrayData } from '@/utils/position'
  190. import { previewFile } from '@/utils'
  191. import { timesTampChange } from '@/utils/date'
  192. import { useRouter } from 'vue-router'
  193. const { t } = useI18n()
  194. const chatRef = ref()
  195. const IM = useIMStore()
  196. // 自己的信息
  197. const { entBaseInfo } = useUserStore()
  198. const isEnterprise = inject('isEnterprise')
  199. // 实例
  200. const route = useRoute()
  201. const channelItem = ref(null)
  202. const messageItems = ref([])
  203. const pageSize = ref(1)
  204. const hasMore = ref(false)
  205. const positionList = ref([])
  206. const showTip = ref(false)
  207. const showInvite = ref(false)
  208. // 企业-求简历
  209. const showSelectPosition = ref(false)
  210. const requestFromRef = ref()
  211. const requestFormItems = ref({
  212. options: [
  213. {
  214. type: 'autocomplete',
  215. key: 'jobId',
  216. value: null,
  217. label: '招聘职位 *',
  218. outlined: true,
  219. clearable: false,
  220. itemText: 'label',
  221. itemValue: 'value',
  222. rules: [v => !!v || '请选择招聘职位'],
  223. items: positionList
  224. }
  225. ]
  226. })
  227. const showDelete = ref(false)
  228. const itemData = ref({})
  229. const inviteRef = ref()
  230. // 发送简历
  231. const showResume = ref(false)
  232. const resumeList = ref([])
  233. const selectResume = ref(null)
  234. // 众聘 介绍人个人id
  235. const isEmployment = ref('-1')
  236. // 上传附件简历
  237. const CtFormRef = ref()
  238. const formItems = ref({
  239. options: [
  240. {
  241. type: 'text',
  242. key: 'title',
  243. value: '',
  244. label: '附件简历名称 *',
  245. rules: [v => !!v || '请输入附件简历名称']
  246. },
  247. {
  248. slotName: 'uploadFile',
  249. key: 'url',
  250. value: '',
  251. truthValue: '',
  252. label: '点击上传附件简历 *',
  253. outline: true,
  254. accept: '.doc, .docx, .pdf',
  255. prependInnerIcon: 'mdi-file-document-outline',
  256. rules: [v => !!v || '请上传您的附件简历']
  257. }
  258. ]
  259. })
  260. // 求职者面试列表
  261. const interview = ref([])
  262. const showRightNoData = ref(false)
  263. const info = ref({})
  264. const enterpriseTools = ref([
  265. { name: '求简历', key: 'requestResume', icon: 'mdi-email', color:"primary", loading: false, handle: handleInvite, disabled: false, disabledText: '简历已接收' },
  266. { name: '面试邀约', key: 'interviewInvite', icon: 'mdi-email', color:"primary", loading: false, handle: handleInvite, disabled: false, disabledText: '面试邀约' }
  267. ])
  268. const userTools = ref([
  269. {
  270. name: '发送简历',
  271. key: 'sendResume',
  272. icon: 'mdi-email',
  273. color:"primary",
  274. loading: false,
  275. handle: handleSendResume,
  276. disabled: false,
  277. disabledText: '简历已投递'
  278. }
  279. ])
  280. // const tools = isEnterprise ? enterpriseTools.value : userTools.value
  281. const tools = computed(() => {
  282. return isEnterprise ? enterpriseTools.value : userTools.value
  283. })
  284. const positionInfo = ref({})
  285. // const isSendResume = ref(false)
  286. if (!IM) {
  287. console.log('IM is disconnected')
  288. }
  289. // 职位进入
  290. if (route.query.id) {
  291. const api = route.query.enterprise ? getPositionDetails : getBaseInfo // getBaseInfo getUserInfo
  292. // const res = await api({ id: route.query.id })
  293. const res = await api(route.query.enterprise ? { id: route.query.id } : { userId: route.query.id })
  294. if (!res) {
  295. Snackbar.error('个人资料为空')
  296. } else {
  297. const query = route.query.enterprise ? [res.contact?.userId, res.contact?.enterpriseId] : [res?.userId]
  298. nextTick(async () => {
  299. const { channel } = await checkConversation(...query)
  300. const items = [
  301. {
  302. channel,
  303. userInfoVo: {
  304. userInfoResp: route.query.enterprise ? res.contact : { ...res, userId: res?.userId}
  305. }
  306. }
  307. ]
  308. handleChange(items)
  309. })
  310. }
  311. }
  312. const {
  313. conversationList,
  314. updateConversation,
  315. updateUnreadCount,
  316. deleteConversations,
  317. resetUnread
  318. } = initConnect(async (successful) => {
  319. if (!successful) {
  320. Snackbar.error('发送失败')
  321. return
  322. }
  323. chatRef.value.reset()
  324. // 发送成功
  325. const { list } = await getMoreMessages(1, channelItem.value)
  326. // updateConversation()
  327. messageItems.value = list.value
  328. chatRef.value.scrollBottom()
  329. })
  330. const getInterviewInviteList = async () => {
  331. if (!info.value.userId) return
  332. const data = await getInterviewInviteListByInviteUserId(info.value.userId)
  333. interview.value = data.slice(0, 1)
  334. }
  335. // 在当前频道中有新消息时更新未读消息数量
  336. const updateUnreadMessageCount = (val) => {
  337. const obj = val.find(e => e.userInfoVo.userId === info.value.userId)
  338. if (!obj?.unread || obj.unread === 0) return
  339. delete info.value.unread
  340. Object.assign(info.value, { unread: obj.unread, enterpriseId: entBaseInfo?.enterpriseId })
  341. }
  342. watch(
  343. () => conversationList.value,
  344. async (val) => {
  345. // 数据发生变化
  346. if (channelItem.value && IM.fromChannel === channelItem.value.channelID) {
  347. // 更新
  348. const { list } = await getMoreMessages(1, channelItem.value)
  349. messageItems.value = list.value
  350. if (Object.keys(info.value).length) updateUnreadMessageCount(val)
  351. chatRef.value.scrollBottom()
  352. }
  353. },
  354. {
  355. deep: true,
  356. immediate: true
  357. }
  358. )
  359. // 获取职位信息
  360. async function getMessageTypeSync () {
  361. const data = await getMessageType({
  362. fromUid: IM.uid,
  363. channelId: channelItem.value?.channelID,
  364. type: 102,
  365. page: {
  366. current: 1,
  367. size: 1,
  368. orders: [
  369. { column: 'message_seq', asc: false }
  370. ]
  371. }
  372. })
  373. if (!data.records || !data.records.length) {
  374. return
  375. }
  376. const _item = data.records.pop()
  377. const _itemJSON = JSON.parse(_item.payload)
  378. const _content = JSON.parse(_itemJSON.content)
  379. positionInfo.value = _content.positionInfo
  380. const check = await jobCvRelCheckSend({ jobId: _content.positionInfo.id })
  381. handleChangeSendResumeStatus(check)
  382. }
  383. // 修改发送状态
  384. function handleChangeSendResumeStatus (status) {
  385. if (!isEnterprise) {
  386. const item = userTools.value.find(e => e.key === 'sendResume')
  387. item.disabled = status
  388. }
  389. }
  390. async function handleChange (items) {
  391. try {
  392. chatRef.value.changeOverlay(true)
  393. const { userInfoVo, channel: myChannel, unread } = items.pop()
  394. info.value = userInfoVo?.userInfoResp ?? { name: '系统消息' }
  395. Object.assign(info.value, {
  396. channel: myChannel,
  397. unread
  398. })
  399. if (myChannel.channelID === 'system') {
  400. channelItem.value = myChannel
  401. const { list, more } = await getMoreMessages(1, channelItem.value)
  402. messageItems.value = list.value
  403. hasMore.value = more
  404. chatRef.value.scrollBottom()
  405. // 点开窗口消除未读数量
  406. await resetUnread(channelItem.value, entBaseInfo?.enterpriseId)
  407. await updateConversation()
  408. updateUnreadCount()
  409. return
  410. }
  411. // 个人端获取面试信息
  412. if (!isEnterprise) getInterviewInviteList()
  413. const userId = userInfoVo.userInfoResp.userId
  414. const enterpriseId = userInfoVo.userInfoResp.enterpriseId || undefined
  415. const { channel, list, more } = await initChart(userId, enterpriseId)
  416. // console.log('--------',list)
  417. channelItem.value = channel.value
  418. // 获取最近职位记录
  419. getMessageTypeSync()
  420. messageItems.value = list.value
  421. hasMore.value = more
  422. chatRef.value.scrollBottom()
  423. // 点开窗口消除未读数量
  424. await resetUnread(channel.value, entBaseInfo?.enterpriseId)
  425. await updateConversation()
  426. updateUnreadCount()
  427. } catch (error) {
  428. messageItems.value = []
  429. } finally {
  430. chatRef.value.changeOverlay(false)
  431. }
  432. }
  433. // 普通消息
  434. const handleUpdate = (val) => {
  435. send(val.value, channelItem.value)
  436. }
  437. // 选择文件
  438. const uploadFile = ref()
  439. const openFileInput = () => {
  440. uploadFile.value.trigger()
  441. }
  442. // 上传附件
  443. const handleUploadResume = async (url, title, filename) => {
  444. const obj = formItems.value.options.find(e => e.key === 'url')
  445. obj.value = filename
  446. obj.truthValue = url
  447. }
  448. // 获取简历
  449. const showUploadDialog = ref(false)
  450. const enRequestPositionInfo = ref({}) // 企业求简历时选中的职位信息
  451. async function handleSendResume (item) {
  452. try {
  453. item.loading = true
  454. // 获取简历列表
  455. const result = await getPersonResumeCv()
  456. if (result.length === 0) {
  457. Snackbar.warning(t('resume.resumeYetSubmit'))
  458. showUploadDialog.value = true
  459. return
  460. }
  461. resumeList.value = result
  462. if (item?.content?.query?.positionInfo?.data && Object.keys(item?.content?.query?.positionInfo?.data).length) enRequestPositionInfo.value = item?.content?.query?.positionInfo?.data
  463. showResume.value = true
  464. } finally {
  465. item.loading = false
  466. }
  467. }
  468. // 撤回简历
  469. async function handleBack (val) {
  470. console.log(val)
  471. try {
  472. // 撤回简历
  473. // 撤回聊天
  474. // await messageBack({
  475. // channelId: val.channel_id,
  476. // messageId: val.message_id,
  477. // nickName: baseInfo.name
  478. // // enterpriseId: ''
  479. // })
  480. } catch (error) {
  481. console.log(error)
  482. }
  483. }
  484. /**
  485. * 发送简历
  486. * text param
  487. * {
  488. * remark: 备注
  489. * query: {} 自定义参数 access -1 未确定 0 拒绝 1 同意
  490. * type: 1 => 发送简历
  491. * 2 => 索要简历
  492. * 3 => 信息描述
  493. * }
  494. */
  495. // 没有上传过简历的弹窗上传并发送给对方
  496. const handleSubmitAttachment = async () => {
  497. const { valid } = await CtFormRef.value.formRef.validate()
  498. if (!valid) return
  499. const obj = {}
  500. formItems.value.options.forEach(e => {
  501. obj[e.key] = e.truthValue || e.value
  502. })
  503. if (!obj.title || !obj.url) return
  504. await savePersonResumeCv(obj)
  505. const text = {
  506. remark: '发送简历',
  507. query: {
  508. src: obj.url,
  509. title: obj.title
  510. },
  511. type: 1
  512. }
  513. if (enRequestPositionInfo.value) text.query.positionInfo = enRequestPositionInfo.value
  514. send (JSON.stringify(text), channelItem.value, 105)
  515. // 简历投递至简历库
  516. if (isEmployment.value !== '-1') {
  517. await jobCvRelHireSend({
  518. jobId: positionInfo.value.id,
  519. url: obj.url,
  520. recommendUserId: isEmployment.value
  521. })
  522. } else {
  523. const jobId = enRequestPositionInfo.value && enRequestPositionInfo.value?.id ? enRequestPositionInfo.value?.id : positionInfo.value.id
  524. const type = (enRequestPositionInfo.value && Object.keys(enRequestPositionInfo.value).length ? enRequestPositionInfo.value.hire : positionInfo.value.hire) ? 1 : 0
  525. await jobCvRelSend({
  526. jobId,
  527. title: obj.title,
  528. url: obj.url,
  529. type
  530. })
  531. }
  532. handleChangeSendResumeStatus(true)
  533. showUploadDialog.value = false
  534. enRequestPositionInfo.value = {}
  535. }
  536. async function handleSubmitResume () {
  537. if (!selectResume.value) {
  538. Snackbar.error(t('resume.selectResumeToSubmit'))
  539. return
  540. }
  541. const _info = resumeList.value.find((item) => item.id === selectResume.value)
  542. const text = {
  543. remark: '发送简历',
  544. query: {
  545. src: _info.url,
  546. title: _info.title,
  547. id: _info.id,
  548. },
  549. type: 1
  550. }
  551. if (enRequestPositionInfo.value) text.query.positionInfo = enRequestPositionInfo.value
  552. send (JSON.stringify(text), channelItem.value, 105)
  553. // 简历投递至简历库
  554. if (isEmployment.value !== '-1') {
  555. await jobCvRelHireSend({
  556. jobId: positionInfo.value.id,
  557. url: _info.url,
  558. recommendUserId: isEmployment.value
  559. })
  560. } else {
  561. const jobId = enRequestPositionInfo.value && enRequestPositionInfo.value?.id ? enRequestPositionInfo.value?.id : positionInfo.value.id
  562. const type = (enRequestPositionInfo.value && Object.keys(enRequestPositionInfo.value).length ? enRequestPositionInfo.value.hire : positionInfo.value.hire) ? 1 : 0
  563. await jobCvRelSend({
  564. jobId,
  565. title: _info.title,
  566. url: _info.url,
  567. type
  568. })
  569. }
  570. handleChangeSendResumeStatus(true)
  571. showResume.value = false
  572. enRequestPositionInfo.value = {}
  573. }
  574. // 简历预览
  575. const handlePreview = (val) => {
  576. previewFile(val.content.query.src)
  577. }
  578. const handleGetMore = async () => {
  579. // 当前滚动条高度
  580. const scrollHeight = chatRef.value.chatRef.scrollHeight
  581. // 当前滚动条距离
  582. const scrollTop = chatRef.value.chatRef.scrollTop
  583. try {
  584. chatRef.value.changeLoading(true)
  585. pageSize.value++
  586. const { list, more } = await getMoreMessages(pageSize.value, channelItem.value)
  587. messageItems.value.unshift(...list.value)
  588. hasMore.value = more
  589. nextTick(() => {
  590. // 渲染后高度
  591. const _scrollHeight = chatRef.value.chatRef.scrollHeight
  592. chatRef.value.chatRef.scrollTop = _scrollHeight - scrollHeight - scrollTop
  593. })
  594. } finally {
  595. chatRef.value.changeLoading(false)
  596. }
  597. }
  598. const handleDelete = async ({ channel }) => {
  599. await deleteConversations(channel, entBaseInfo?.enterpriseId)
  600. await updateConversation()
  601. updateUnreadCount()
  602. }
  603. // 没有企业ID则enterpriseId为undefined
  604. // 发送消息体 { text, type: 2 }
  605. // 面试邀约
  606. const getPositionList = async () => {
  607. const data = await getJobAdvertised({ status: 0 }) // 0开启 1关闭 不带则全部
  608. if (!data.length) return
  609. const list = dealDictArrayData([], data)
  610. positionList.value = list.map(e => {
  611. const salary = e.payFrom && e.payTo ? `${e.payFrom ? e.payFrom + '-' : ''}${e.payTo}${e.payName ? '/' + e.payName : ''}` : '面议'
  612. return {
  613. label: `${e.name}${e.areaName ? '_' + e.areaName : ''} ${salary}`,
  614. value: e.id,
  615. data: e
  616. }
  617. })
  618. }
  619. async function handleInvite (item) {
  620. item.loading = true
  621. positionList.value = []
  622. try {
  623. await getPositionList()
  624. if (!positionList.value.length) return Snackbar.warning('请先发布职位')
  625. if (item.key === 'requestResume') return showSelectPosition.value = true
  626. showInvite.value = true
  627. } catch (error) {
  628. console.log(error)
  629. } finally {
  630. item.loading = false
  631. }
  632. }
  633. // 企业-发送面试邀请
  634. const handleSubmit = async () => {
  635. const { valid } = await inviteRef.value.CtFormRef.formRef.validate()
  636. if (!valid) {
  637. return
  638. }
  639. const query = inviteRef.value.getQuery()
  640. if (!query.time) {
  641. Snackbar.warning('时间不能为空')
  642. return
  643. }
  644. query.userId = info.value.userId
  645. query.positionInfo = positionList.value.find(e => e.value === query.jobId)
  646. // 需要id
  647. const data = await saveInterviewInvite(query)
  648. // 保留邀请id
  649. query.id = data.id
  650. showTip.value = true
  651. send(JSON.stringify(query), channelItem.value, 101)
  652. showInvite.value = false
  653. }
  654. const router = useRouter()
  655. const handleToInterviewManagement = () => {
  656. router.push('/recruit/enterprise/interviewManagement')
  657. }
  658. // 企业-求简历
  659. const handleRequestResumeSubmit = async () => {
  660. const { valid } = await requestFromRef.value.formRef.validate()
  661. if (!valid) return
  662. const jobId = requestFormItems.value.options.find(e => e.key === 'jobId').value
  663. const positionInfo = positionList.value.find(e => e.value === jobId)
  664. const text = {
  665. remark: '求简历',
  666. query: {
  667. src: '',
  668. title: '',
  669. id: '',
  670. positionInfo
  671. },
  672. type: 2
  673. }
  674. send (JSON.stringify(text), channelItem.value, 105)
  675. showSelectPosition.value = false
  676. }
  677. const handleAgree = (val) => {
  678. if (!val.id) return
  679. const query = {
  680. id: val.id
  681. }
  682. const type = route?.meta?.loginType === 'enterprise' ? 'entBaseInfo' : 'baseInfo'
  683. const baseInfo = localStorage.getItem(type)
  684. if (baseInfo) {
  685. const { phone } = JSON.parse(baseInfo)
  686. query.phone = phone
  687. }
  688. Confirm(t('common.confirmTitle'), '是否确定接收此面试邀请?').then(async () => {
  689. await userInterviewInviteConsent(query)
  690. Snackbar.success(t('common.operationSuccessful'))
  691. getInterviewInviteList()
  692. send(JSON.stringify({ id: val.id }), channelItem.value, 104)
  693. })
  694. }
  695. // 拒绝面试邀请
  696. const handleRefuse = (val) => {
  697. if (!val.id) return
  698. Confirm(t('common.confirmTitle'), '您是否确定要拒绝此面试邀请?').then(async () => {
  699. await userInterviewInviteReject(val.id)
  700. Snackbar.success(t('common.operationSuccessful'))
  701. getInterviewInviteList()
  702. send(JSON.stringify({ id: val.id }), channelItem.value, 103)
  703. })
  704. }
  705. </script>
  706. <style scoped lang="scss">
  707. .message {
  708. display: flex;
  709. &-left {
  710. position: relative;
  711. flex-shrink: 0;
  712. height: 100%;;
  713. width: 360px;
  714. background-color: #fff;
  715. border-radius: 8px;
  716. margin-right: 12px;
  717. .message-left-search {
  718. width: 100%;
  719. height: 60px;
  720. background: linear-gradient(90deg, #f5fcfc, #fcfbfa);
  721. border-radius: 8px 8px 0 0;
  722. }
  723. .message-chat-box {
  724. height: 0;
  725. flex: 1;
  726. overflow: auto;
  727. padding-bottom: 20px;
  728. .chat-item {
  729. position: relative;
  730. width: 100%;
  731. height: 78px;
  732. padding: 14px 12px;
  733. cursor: pointer;
  734. &:hover {
  735. background-color: #f8f8f8;
  736. }
  737. .chat-item-time {
  738. position: absolute;
  739. right: 12px;
  740. top: 50%;
  741. transform: translateY(-50%);
  742. }
  743. .title-box {
  744. max-width: 114px;
  745. overflow: hidden;
  746. white-space: nowrap;
  747. text-overflow: ellipsis;
  748. display: inline-block;
  749. }
  750. }
  751. }
  752. .message-no-more-text {
  753. color: var(--color-999);
  754. font-size: 14px;
  755. text-align: center
  756. }
  757. .left-noData {
  758. position: absolute;
  759. top: 50%;
  760. left: 50%;
  761. transform: translate(-50%, -50%);
  762. }
  763. }
  764. &-right {
  765. height: 100%;
  766. flex: 1;
  767. width: 0;
  768. position: relative;
  769. background-color: #fff;
  770. border-radius: 8px;
  771. .right-noData {
  772. position: absolute;
  773. top: 50%;
  774. left: 50%;
  775. transform: translate(-50%, -50%);
  776. }
  777. }
  778. }
  779. .enterprise-name {
  780. max-width: 150px;
  781. .line {
  782. display: inline-block;
  783. width: 1px;
  784. height: 12px;
  785. vertical-align: middle;
  786. background-color: #e0e0e0;
  787. margin: 0 3px;
  788. }
  789. }
  790. .radioBox {
  791. &:hover {
  792. border-radius: 2px;
  793. background-color: var(--color-f8);
  794. }
  795. }
  796. </style>