Browse Source

求职意向-所在城市改为级联组件

lifanagju_citu 7 months ago
parent
commit
74be150010

+ 12 - 51
src/views/recruit/personal/PersonalCenter/resume/online/components/jobIntention.vue

@@ -106,7 +106,6 @@ import Confirm from '@/plugins/confirm'
 import { saveResumeJobInterested, getResumeJobInterested, deleteResumeJobInterested } from '@/api/recruit/personal/resume'
 import { dealJobData } from './dict'
 import { getDict } from '@/hooks/web/useDictionaries'
-import { cityToProvince } from '@/utils/areaDeal'
 const emit = defineEmits(['complete'])
 
 const isAdd = ref(false)
@@ -141,7 +140,8 @@ const items = ref({
       key: 'payFrom',
       value: null,
       label: '期望薪资(最低要求) *',
-      col: 4,
+      col: 6,
+      flexStyle: 'mr-3',
       suffix: '元',
       outlined: true,
       rules: [v => !!v || '请输入薪资最低要求']
@@ -151,10 +151,9 @@ const items = ref({
       key: 'payTo',
       value: null,
       label: '期望薪资(最高要求) *',
-      col: 4,
+      col: 6,
       suffix: '元',
       outlined: true,
-      flexStyle: 'mx-3',
       rules: [v => !!v || '请输入薪资最高要求']
     },
     {
@@ -164,7 +163,8 @@ const items = ref({
       label: '求职类型 *',
       outlined: true,
       itemText: 'label',
-      col: 4,
+      col: 6,
+      flexStyle: 'mr-3',
       itemValue: 'value',
       rules: [v => !!v || '请选择求职类型'],
       items: [
@@ -175,32 +175,17 @@ const items = ref({
       ]
     },
     {
-      type: 'autocomplete',
-      key: 'workAreaProvinceId',
-      value: null,
-      label: '工作城市:省 *',
-      outlined: true,
-      itemText: 'name',
-      itemValue: 'id',
-      returnSelect: true,
-      col: 6,
-      flexStyle: 'mr-3',
-      rules: [v => !!v || '请选择工作城市:省'],
-      items: [],
-      change: null
-    },
-    {
-      type: 'autocomplete',
+      type: 'cascade',
       key: 'workAreaId',
       value: null,
-      label: '工作城市:市 *',
-      outlined: true,
+      default: null,
+      label: '所在城市',
       itemText: 'name',
       itemValue: 'id',
+      required: true,
+      clearable: false,
       col: 6,
-      rules: [v => !!v || '请选择工作城市:市'],
       items: [],
-      change: null
     },
     {
       slotName: 'interestedAreaIdList',
@@ -212,26 +197,13 @@ const items = ref({
   ]
 })
 
-const provinceChange = (value, val, obj) => {
-  const item = items.value.options.find(e => e.key === 'workAreaId')
-  if (!item) return
-  item.items = obj.children || []
-  item.value = null
-}
 getDict('areaTreeData', null, 'areaTreeData').then(({ data }) => {
   data = data?.length && data || []
   if (!data?.length) return console.error('areaTreeData获取失败!')
-  //
-  // const china = data.find(e => e.id === '1')
-  // const chinaTreeData = china?.children?.length ? china.children : []
   const chinaTreeData = data
-  //
   if (!chinaTreeData?.length) return console.error('chinaTreeData获取失败!')
-  const item = items.value.options.find(e => e.key === 'workAreaProvinceId')
-  if (item?.items) {
-    item.items = chinaTreeData
-    item.change = provinceChange
-  }
+  const item = items.value.options.find(e => e.key === 'workAreaId')
+  if (item?.items) item.items = chinaTreeData
 })
 
 // 获取求职意向
@@ -316,7 +288,6 @@ const handleSave = async () => {
 
 const handleEdit = async (item) => {
   editId.value = item.id
-  let workAreaId = ''
   items.value.options.forEach(e => {
     query[e.key] = item[e.key] 
     if (e.valueKey) {
@@ -327,17 +298,7 @@ const handleEdit = async (item) => {
       e.value = null
       query.interestedAreaIdList = item.interestedAreaIdList && item.interestedAreaIdList.length ? item.interestedAreaIdList : []
     }
-    if (e.key === 'workAreaId' && item[e.key]) workAreaId = item[e.key]
   })
-  if (workAreaId) { // 省份回显
-    const province = items.value.options.find(pv => pv.key === 'workAreaProvinceId')
-    if (province) {
-      const dealReturnObj = await cityToProvince(workAreaId, {}, province.items || [])
-      const city = items.value.options.find(pv => pv.key === 'workAreaId')
-      if (city) city.items = dealReturnObj.cityList || []
-      province.value = dealReturnObj.pid || ''
-    }
-  }
   currentSelect = item.industry
   areaSelect = item.interestedArea && item.interestedArea.length ? item.interestedArea : []
   isAdd.value = true