Browse Source

传入工作经验或者查询工作经验接口

lifanagju_citu 2 tuần trước cách đây
mục cha
commit
c5047bb3e4

+ 20 - 13
src/views/menduner/system/person/details/components/expExtend.vue

@@ -40,8 +40,8 @@ import { timesTampChange, getTimeDifferenceInChinese } from '@/utils/transform/d
 import { formatName } from '@/utils'
 
 const props = defineProps({
-  userId: [String, Number],
-  data: Array,
+  userId: [String, Number], // 通过userId调用接口查询工作经验列表
+  data: Array, // 传入工作经验列表
   defaultShowAll: Boolean // 展示所有工作经验
 })
 
@@ -53,28 +53,35 @@ const queryParams = reactive({
 const expandAll = ref(props.defaultShowAll) // 展开/折叠
 const foldNum = ref(2) // 折叠时展示个数-1
 
-const list = ref(props.data || [])
+const deal = (list) => {
+  const arr = list.map(exp => {
+    exp.startTimeStr = exp.startTime ? timesTampChange(exp.startTime, 'Y-M') : '未填写工作时间'
+    exp.endTimeStr = exp.startTime ? exp.endTime ? timesTampChange(exp.endTime, 'Y-M') : '至今' : ''
+    exp.year = exp.endTimeStr ? getTimeDifferenceInChinese(exp.startTime, exp.endTime) : ''
+    // 未填写工作经验相关内容,不展示
+    exp.show = (exp.startTimeStr !== '未填写工作时间') || Boolean(exp.enterpriseName) || Boolean(exp.positionName)
+    return exp
+  }).filter(i => i.show)
+  return arr
+}
+
+const list = ref(props.data?.length ? deal(props.data) : [])
 const total = ref(props.data?.length || 0)
 const loading = ref(false)
-const getList = async () => {
+const getExpList = async () => {
   if (!queryParams.userId) return
+
   loading.value = true
   try {
     const data = await PersonInfoApi.getPersonExpPage(queryParams)
-    list.value = data.list?.length ? data.list.map(exp => {
-      exp.startTimeStr = exp.startTime ? timesTampChange(exp.startTime, 'Y-M') : '未填写工作时间'
-      exp.endTimeStr = exp.startTime ? exp.endTime ? timesTampChange(exp.endTime, 'Y-M') : '至今' : ''
-      exp.year = exp.endTimeStr ? getTimeDifferenceInChinese(exp.startTime, exp.endTime) : ''
-      // 未填写工作经验内容,不展示
-      exp.show = Boolean(exp.year) || Boolean(exp.enterpriseName) || Boolean(exp.positionName)
-      return exp
-    }) : []
+    list.value = data.list?.length ? deal(data.list) : []
+    
     total.value = data.total
   } finally {
     loading.value = false
   }
 }
-getList()
+getExpList()
 </script>
 <style lang="scss" scoped>
 .exp {

+ 1 - 1
src/views/menduner/system/talentMap/maintenance/gather/components/personCard.vue

@@ -29,7 +29,7 @@
       </div>
     </div>
     <!-- 工作经验 -->
-    <expExtend :user-id="info?.userId" />
+    <expExtend :data="info?.workExpList" />
     <div class="button">
       <el-button type="success" plain @click="personClick">{{ props.detailButTxt || '加入人才地图' }}</el-button>
     </div>