index.vue 26 KB

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