Browse Source

滚动条固定 & 撤回简历

zhengnaiwen_citu 6 months ago
parent
commit
e883464297

+ 8 - 0
src/api/common/index.js

@@ -303,6 +303,14 @@ export const getMessageType = async (data) => {
   })
 }
 
+// 聊天记录撤回
+export const messageBack = async (data) => {
+  return await request.post({
+    url: '/app-api/im/im/messages/back',
+    data
+  })
+}
+
 
 // 求职端-根据邀请人id获取面试邀约列表
 export const getInterviewInviteListByInviteUserId = async (inviteUserId) => {

+ 15 - 3
src/views/recruit/components/message/components/chatting.vue

@@ -59,7 +59,7 @@
         <div v-for="(val, i) in items" :key="i" :id="val.id">
           <div class="time-box">{{ timesTampChange(+(val.timestamp.padEnd(13, '0'))) }}</div>
           
-          <!-- <template v-if="val.payload?.type === 102 && val.from_uid !== IM.uid"> -->
+          
           <template v-if="val.payload?.type === 102">
             <v-card
               color="teal"
@@ -99,7 +99,10 @@
               </div>
             </v-card>
           </template>
-          <div :class="['message-view_item', val.from_uid === IM.uid ? 'is-self' : 'is-other']">
+          <template v-if="val.payload?.type === 1006">
+            <div class="text-subtitle-2 text-center text-grey">{{ val.from_uid === IM.uid ? '' : '对方' }}撤回了一份简历</div>
+          </template>
+          <div v-if="val.payload?.type !== 1006" :class="['message-view_item', val.from_uid === IM.uid ? 'is-self' : 'is-other']">
             <div style="width: 40px; height: 40px;">
               <v-avatar>
                 <v-img
@@ -147,7 +150,10 @@
                 </v-card-text>
                 <v-card-actions class="justify-center">
                   <!-- <v-btn variant="tonal" flat size="small" color="error" @click="handleRejectReceive(val.payload)">拒绝</v-btn> -->
-                  <v-btn v-if="val.payload.content?.type === 1" block  variant="tonal" flat size="small" color="success" @click="handlePreview(val.payload)">点击预览附件简历</v-btn>
+                  <template v-if="val.payload.content?.type === 1">
+                    <v-btn variant="tonal" flat size="small" color="success" @click="handlePreview(val.payload)">点击预览附件简历</v-btn>
+                    <v-btn variant="tonal" flat size="small" color="error" @click="handleBack(val)">撤回简历</v-btn>
+                  </template>
                   <v-btn v-if="val.payload.content?.type === 2" block  variant="tonal" flat size="small" color="success" @click="handleSendResume(val.payload)">点击发送附件简历</v-btn>
                 </v-card-actions>
               </v-card>
@@ -386,6 +392,11 @@ const handleToCenter = () => {
 const handlePreview = (val) => {
   emits('handlePreview', val)
 }
+
+const handleBack = (val) => {
+  emits('handleBack', val)
+}
+
 // 发送简历
 const handleSendResume = (val) => {
   emits('handleSendResume', val)
@@ -400,6 +411,7 @@ const handleSendResume = (val) => {
 // }
 
 defineExpose({
+  chatRef,
   reset,
   changeLoading,
   scrollBottom,

+ 30 - 3
src/views/recruit/components/message/index.vue

@@ -97,6 +97,7 @@
         @handleRefuse="handleRefuse"
         @handlePreview="handlePreview"
         @handleSendResume="handleSendResume"
+        @handleBack="handleBack"
       >
         <template #tools>
           <v-btn
@@ -180,7 +181,7 @@ import Chatting from './components/chatting.vue'
 import { initConnect, send, initChart, getMoreMessages, checkConversation } from '@/hooks/web/useIM'
 import { useI18n } from '@/hooks/web/useI18n'
 import { getPositionDetails, jobCvRelCheckSend, jobCvRelSend, jobCvRelHireSend } from '@/api/position'
-import { getInterviewInviteListByInviteUserId, getMessageType } from '@/api/common'
+import { getInterviewInviteListByInviteUserId, getMessageType, messageBack } from '@/api/common'
 // import { getUserInfo } from '@/api/personal/user'
 import { getBaseInfo } from '@/api/common'
 import { getJobAdvertised } from '@/api/enterprise'
@@ -205,7 +206,7 @@ const chatRef = ref()
 
 const IM = useIMStore()
 // 自己的信息
-const { entBaseInfo } = useUserStore()
+const { entBaseInfo, baseInfo } = useUserStore()
 
 const isEnterprise = inject('isEnterprise')
 // 实例
@@ -415,6 +416,7 @@ async function getMessageTypeSync () {
   handleChangeSendResumeStatus(check)
 }
 
+// 修改发送状态
 function handleChangeSendResumeStatus (status) {
   if (!isEnterprise) {
     const item = userTools.value.find(e => e.key === 'sendResume')
@@ -493,6 +495,23 @@ async function handleSendResume (item) {
   }
 }
 
+// 撤回简历
+async function handleBack (val) {
+  console.log(val)
+  try {
+    // 撤回简历
+    // 撤回聊天
+    // await messageBack({
+    //   channelId: val.channel_id,
+    //   messageId: val.message_id,
+    //   nickName: baseInfo.name
+    //   // enterpriseId: ''
+    // })
+  } catch (error) {
+    console.log(error)
+  }
+}
+
 /**
  * 发送简历
  * text param
@@ -594,13 +613,21 @@ const handlePreview = (val) => {
 }
 
 const handleGetMore = async () => {
+  // 当前滚动条高度
+  const scrollHeight = chatRef.value.chatRef.scrollHeight
+  // 当前滚动条距离
+  const scrollTop = chatRef.value.chatRef.scrollTop
   try {
     chatRef.value.changeLoading(true)
     pageSize.value++
     const { list, more } = await getMoreMessages(pageSize.value, channelItem.value)
     messageItems.value.unshift(...list.value)
     hasMore.value = more
-    // chatRef.value.scrollBottom()
+    nextTick(() => {
+      // 渲染后高度
+      const _scrollHeight = chatRef.value.chatRef.scrollHeight
+      chatRef.value.chatRef.scrollTop = _scrollHeight - scrollHeight - scrollTop
+    })
   } finally {
     chatRef.value.changeLoading(false)
   }