Parcourir la source

合并招聘会代码

lifanagju_citu il y a 1 mois
Parent
commit
28dbedf0fe

+ 8 - 4
src/views/recruit/enterprise/positionManagement/components/add.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <v-card class="pa-5">
+    <v-card class="pa-5" v-if="show">
       <v-timeline align="start" side="end">
         <v-timeline-item
           v-for="(val, i) in list"
@@ -167,17 +167,21 @@ const handlePayClose = () => {
   router.push({ path: '/recruit/enterprise/position/index', query: { key: 0 }})
 }
 
+const show = ref(false)
 // 获取编辑的职位详情
 const getPositionDetail = async (id) => {
   const data = await getJobDetails({ id })
   if (!data && !Object.keys(data).length) return
   itemData.value = {...data, ...dealDictObjData({}, data)}
+  show.value = true
+
+  // 招聘类型为实习则获取扩展信息
+  if (data.type === '3') initPosition(id)
 }
 
 // 有id为编辑
-if (route.query && route.query.id) {
-  if (route.query.id) getPositionDetail(route.query.id)
-}
+if (route.query?.id) getPositionDetail(route.query.id)
+else show.value = true
 
 // 取消
 const handleCancel = () => {

+ 94 - 12
src/views/recruit/enterprise/positionManagement/components/baseInfo.vue

@@ -1,6 +1,21 @@
 <template>
   <div>
     <CtForm ref="formPageRef" :items="items" style="width: 650px;">
+      <template #bizId="{ item }">
+        <div>
+          <v-checkbox-btn
+            v-model="jobFairCheckbox"
+            color="primary"
+            label="设置为招聘会职位"
+            class="ml-2"
+            :disabled="false"
+            :style="`line-height: ${item.dense === 'default' ? 56 : item.dense === 'comfortable' ? 48 : 40 }px;`"
+            style="width: 174px;"
+            hide-details
+            @update:modelValue="v => jobFairCheckboxChange(v, item)"
+          ></v-checkbox-btn>
+        </div>
+      </template>
       <template #positionId="{ item }">
         <v-menu :close-delay="1" :open-delay="0" v-bind="$attrs">
           <template v-slot:activator="{  props }">
@@ -44,10 +59,15 @@ import { getRecruitPositionDetails } from '@/api/recruit/enterprise/position'
 import Confirm from '@/plugins/confirm'
 import Snackbar from '@/plugins/snackbar'
 import { useI18n } from '@/hooks/web/useI18n';
+import { getJobFairWhiteList } from '@/api/recruit/enterprise/jobFair'
 
 const { t } = useI18n()
 const props = defineProps({
-  itemData: Object
+  itemData: Object,
+  isFair: {
+    type: Boolean,
+    default: false
+  }
 })
 
 const getValue = (key) => {
@@ -60,6 +80,17 @@ let query = reactive({})
 
 const items = ref({
   options: [
+    {
+      slotName: 'bizId',
+      type: 'autocomplete',
+      key: 'bizId',
+      value: null,
+      label: '招聘会',
+      itemText: 'title',
+      itemValue: 'id',
+      disabled: true,
+      items: [],
+    },
     {
       slotName: 'positionId',
       key: 'positionId',
@@ -108,6 +139,56 @@ const items = ref({
   ]
 })
 
+// 获取企业已加入的招聘会列表
+const jobFairLoaded = ref(false)
+const jobFairWhiteList = ref([])
+const getJobFairData = async () => {
+  const data = await getJobFairWhiteList()
+  jobFairWhiteList.value = data?.length ? data : []
+  jobFairLoaded.value = true
+  // 没有加入任何招聘会则不展示招聘会
+  if (!jobFairWhiteList.value?.length) items.value.options = items.value.options.filter(e => e.key !== 'bizId')
+}
+getJobFairData()
+
+const jobFairValid = async () => {
+  if (props.isFair) {
+    // 招聘会内编辑职位,不需要展示选择招聘会
+    items.value.options = items.value.options.filter(e => e.key !== 'bizId')
+    return
+  }
+  // 加载招聘会白名单列表
+  if (!jobFairLoaded.value) await getJobFairData()
+  const bizIdObj = items.value.options.find(e => e.key === 'bizId') // 招聘会下拉框
+  if (!bizIdObj) return
+  bizIdObj.items = jobFairWhiteList.value // 下拉框内容赋值
+  if (bizIdObj.value) {
+    const index = jobFairWhiteList.value.findIndex(e => e.id === props.itemData.bizId)
+    if (index === -1) bizIdObj.value = null // 招聘会已经关闭 或者已被移除招聘会白名单
+    jobFairCheckboxChange(Boolean(bizIdObj.value), bizIdObj) // 招聘会回显
+  }
+}
+jobFairValid()
+
+// 设置为招聘会职位
+// 现有逻辑:设置为招聘会职位后,职位管理编辑再修改为去掉选中招聘会不会改变数据的jobFairIds字段(用于职位列表判断是否展示招聘会标识),只有去招聘会移除才会改变jobFairIds字段。
+const jobFairCheckbox = ref(false)
+const jobFairCheckboxChange = (bool, item) => {
+  item.value = bool ? (item?.value || null) : null
+  jobFairCheckbox.value = bool
+  item.disabled = bool ? false : true
+  item.label = bool ? '招聘会 *' : '招聘会'
+}
+
+// 长期有效
+const soFar = ref(false)
+const handleSoFarChange = (bool, item) => {
+  soFar.value = bool
+  item.value = null
+  item.disabled = bool ? true : false
+  item.label = bool ? '到期时间' : '到期时间 *'
+}
+
 // 编辑回显
 watch(
   () => props.itemData,
@@ -121,8 +202,10 @@ watch(
       }
       if (e.noParam) return
       if (e.key === 'expireTime' && !val[e.key]) return handleSoFarChange(true, e)
+      if (e.key === 'bizId' && val.source === '0') return // 非招聘会职位
       e.value = val[e.key]
     })
+    // jobFairValid()  // 招聘会回显
   },
   { immediate: true },
   { deep: true }
@@ -167,15 +250,6 @@ const useJobTemplate = async () => {
   }
 }
 
-const soFar = ref(false)
-// 长期有效
-const handleSoFarChange = (bool, item) => {
-  soFar.value = bool
-  item.value = null
-  item.disabled = bool ? true : false
-  item.label = bool ? '到期时间' : '到期时间 *'
-}
-
 const getQuery = async () => {
   const { valid } = await formPageRef.value.formRef.validate()
   if (!valid) return
@@ -188,10 +262,17 @@ const getQuery = async () => {
     if (e.noParam || e.value === null) return
     else obj[e.key] = e.value
   })
+  
+  if (jobFairCheckbox.value && !obj.bizId && jobFairWhiteList.value?.length) {
+    Snackbar.warning('请选择招聘会')
+    return 'failed'
+  }
+
   if (!obj.content) {
     Snackbar.warning('请填写岗位职责')
     return 'failed'
   }
+
   if (!obj.requirement) {
     Snackbar.warning('请填写岗位要求')
     return 'failed'
@@ -202,8 +283,9 @@ const getQuery = async () => {
     return 'failed'
   }
   
-  // query = Object.assign(query, obj)
-  // query = {...obj, ...query}
+  obj.source = jobFairCheckbox.value ? '2' : '0' // 职位来源(0职位管理|1众聘职位|2招聘会)
+  if (obj.source === '0')  obj.bizId = null
+
   Object.assign(query, obj)
   return query
 }