lifanagju_citu 10 mesiacov pred
rodič
commit
b5d02a8573

+ 2 - 0
src/hooks/web/useDictionaries.js

@@ -3,6 +3,7 @@ import {
   getIndustryListData,
   getIndustryTreeData,
   getAreaListData,
+  getAreaMapData,
   getPositionTreeData,
   getAreaTreeData,
   getPositionData
@@ -39,6 +40,7 @@ export const getDict = (type, params, apiType = 'dict') => {
         industryTreeData: getIndustryTreeData, // 行业tree
         industryList: getIndustryListData,
         areaList: getAreaListData,
+        areaMap: getAreaMapData,
         positionData: getPositionData
       }
       apiFn[apiType](query).then(data => {

+ 17 - 0
src/utils/areaDeal.js

@@ -0,0 +1,17 @@
+import { getDict } from '@/hooks/web/useDictionaries'
+
+// 根据市获取省份 
+export const cityToProvince = async (cityId, query, parentList = []) => {
+  if (!cityId) return cityId
+  query = { pid: true, cityList: true, ...query }
+  const obj = {}
+  if (query.cityList || query.pid) {
+    const areaMap = await getDict('areaMap', {}, 'areaMap')
+    obj.pid = areaMap?.data && areaMap?.data[cityId]?.parentId
+    if (query.cityList && obj.pid) {
+      const parent = parentList.find(pv => pv.id === obj.pid)
+      obj.cityList = parent?.children.length ? parent.children : []
+    }
+  }
+  return obj
+}

+ 20 - 7
src/views/recruit/personal/remuse/components/jobIntention.vue

@@ -95,6 +95,7 @@ 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 isAdd = ref(false)
 const formPageRef = ref()
@@ -176,7 +177,7 @@ const items = ref({
       returnSelect: true,
       col: 6,
       flexStyle: 'mr-3',
-      rules: [v => !!v || '请选择工作城市:省'],
+      rules: [v => !!v || '请选择工作城市省'],
       items: [],
       change: null
     },
@@ -189,8 +190,9 @@ const items = ref({
       itemText: 'name',
       itemValue: 'id',
       col: 6,
-      rules: [v => !!v || '请选择工作城市:市'],
-      items: []
+      rules: [v => !!v || '请选择工作城市:市'],
+      items: [],
+      change: null
     },
     {
       type: 'autocomplete',
@@ -215,8 +217,9 @@ const items = ref({
 
 const provinceChange = (value, val, obj) => {
   const item = items.value.options.find(e => e.key === 'workAreaId')
-  if (item?.items && obj?.children?.length) item.items = obj.children
-  else item.items = []
+  if (!item) return
+  item.items = obj.children || []
+  item.value = null
 }
 getDict('areaTreeData', null, 'areaTreeData').then(({ data }) => {
   data = data?.length && data || []
@@ -232,7 +235,6 @@ getDict('areaTreeData', null, 'areaTreeData').then(({ data }) => {
     item.change = provinceChange
   }
 })
-getDict()
 
 // 获取求职意向
 const interestList = ref([])
@@ -297,15 +299,26 @@ const handleSave = async () => {
   getJobInterested()
 }
 
-const handleEdit = (item) => {
+const handleEdit = async (item) => {
   editId.value = item.id
+  let workAreaId = ''
   items.value.options.forEach(e => {
     query[e.key] = item[e.key] 
     if (e.valueKey) {
       e.value = item[e.valueKey]
     } else e.value = item[e.key]
     if (e.key === 'industryIdList') e.value = item.industry.map(e => e.nameCn).join('、')
+    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
   isAdd.value = true
 }