index.vue 25 KB

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