浏览代码

个人中心-公司收藏:取消收藏

Xiao_123 8 月之前
父节点
当前提交
a16e358842

+ 21 - 5
src/components/Position/longCompany.vue

@@ -1,16 +1,16 @@
 <template>
   <div>
     <div class="sub-li mb-3" v-for="item in list" :key="item.id" @mouseenter="item.active = true" @mouseleave="item.active = false">
-      <div class="company-info-top" @click="handleClickEnterprise(item, 'briefIntroduction')">
+      <div class="company-info-top">
         <div class="company-info">
           <div class="float-left mr-5">
             <v-img :src="item.logoUrl || 'https://minio.citupro.com/dev/menduner/company-avatar.png'" :alt="item.anotherName" :width="40" style="height: 40px;border-radius: 4px;"/>
           </div>
-          <h3 :class="{'default-active': item.active }">{{ item.anotherName }}</h3>
+          <h3 :class="{'default-active': item.active }" class="cursor-pointer" @click="handleClickEnterprise(item, 'briefIntroduction')">{{ item.anotherName }}</h3>
           <p>{{ item.financingName }}<span class="mx-2">|</span>{{ item.industryName }}<span class="mx-2">|</span>{{ item.scaleName }}</p>
         </div>
-        <div>
-          <v-chip color="primary" size="small" label>已收藏</v-chip>
+        <div v-if="item.active">
+          <v-btn class="half-button ml-3" color="primary" size="small" @click.stop="handleCancel(item)">取消收藏</v-btn>
         </div>
       </div>
       <div class="company-info-bottom">
@@ -31,12 +31,29 @@
 
 <script setup>
 defineOptions({ name: 'long-company-card'})
+import Snackbar from '@/plugins/snackbar'
+import { useI18n } from '@/hooks/web/useI18n'
+import { getEnterpriseUnsubscribe } from '@/api/enterprise'
+
+const emits = defineEmits(['refresh'])
 defineProps({
   list: Array
 })
+
+const { t } = useI18n()
+
 const handleClickEnterprise = (item, key) => {
   window.open(`/recruit/personal/company/details/${item.id}?key=${key}`)
 }
+
+// 取消收藏
+const handleCancel = async (item) => {
+  if (!item.id) return Snackbar.warning(t('sys.api.operationFailed'))
+  await getEnterpriseUnsubscribe(item.id)
+  emits('refresh')
+  Snackbar.success(t('common.operationSuccessful'))
+}
+
 </script>
 
 <style scoped lang="scss">
@@ -48,7 +65,6 @@ const handleClickEnterprise = (item, key) => {
   overflow: hidden;
   transition: all .2s linear;
   background-color: #fff;
-  cursor: pointer;
   &:nth-child(4n) {
     margin-right: 0;
   }

+ 1 - 1
src/components/Position/longStrip.vue

@@ -3,7 +3,7 @@
     <div class="position-item mb-3 job-closed" v-for="(val, i) in props.items" :key="i" @mouseenter="val.active = true" @mouseleave="val.active = false">
       <div class="info-header">
         <div v-if="val.active" class="header-btn">
-          <v-btn v-if="props.showCancelBtn" class="half-button ml-3" color="primary" size="small" @click="handleCancel(val)">取消感兴趣</v-btn>
+          <v-btn v-if="props.showCancelBtn" class="half-button ml-3" color="primary" size="small" @click="handleCancel(val)">取消收藏</v-btn>
         </div>
         <div class="img-box">
           <v-avatar :image="getUserAvatar(val.contact.avatar, val.contact.sex)" size="x-small"></v-avatar>

+ 1 - 1
src/views/recruit/personal/PersonalCenter/components/companyCollection.vue

@@ -1,7 +1,7 @@
 <template>
   <div>
     <div v-if="items.length">
-      <LongCompany :list="items"></LongCompany>
+      <LongCompany :list="items" @refresh="getPositionList"></LongCompany>
       <CtPagination
         :total="total"
         :page="page.pageNo"