Browse Source

查询字典数据

lifanagju_citu 7 months ago
parent
commit
3a6ffabc3e
2 changed files with 6 additions and 4 deletions
  1. 2 2
      src/plugins/necessaryInfo/components/infoForm.vue
  2. 4 2
      src/store/user.js

+ 2 - 2
src/plugins/necessaryInfo/components/infoForm.vue

@@ -195,8 +195,8 @@ const items = ref({
 const getDictData = async (dictTypeName, key) => {
   const item = items.value.options.find(e => e.key === key)
   if (item) {
-    const apiFn = dictTypeName === 'positionSecondData' ? 'positionSecondData' : null
-    const { data } = await getDict(dictTypeName, {}, apiFn)
+    const apiType = dictTypeName === 'positionSecondData' ? 'positionSecondData' : 'dict'
+    const { data } = await getDict(dictTypeName, apiType === 'dict' ? null : {}, apiType)
     item.items = data
     // console.log(dictTypeName, '字典内容', data)
   }

+ 4 - 2
src/store/user.js

@@ -111,8 +111,9 @@ export const useUserStore = defineStore('user',
       async getUserBaseInfos (userId = null) {
         try {
           // const api = getIsEnterprise() ? null : getBaseInfo
-          const data = await getBaseInfo({ userId: userId || this.accountInfo.userId })
-          if (!data) return localStorage.setItem('baseInfo', '{}')
+          let data = await getBaseInfo({ userId: userId || this.accountInfo.userId })
+          data = data || {}
+          // if (!data) return localStorage.setItem('baseInfo', '{}')
           this.baseInfo = await this.getFieldText(data)
           localStorage.setItem('baseInfo', JSON.stringify(this.baseInfo))
           localStorage.setItem('necessaryInfoReady', checkPersonBaseInfo(this.baseInfo) ? 'ready' : 'fddeaddc47868b') // 校验是否完善人才必填信息
@@ -122,6 +123,7 @@ export const useUserStore = defineStore('user',
       },
       // 字典对应中文
       async getFieldText (data) {
+        if (!data || !Object.keys(data).length) return {}
         if (data.birthday && data.birthday !== 0) data.birthdayText = timesTampChange(data.birthday, 'Y-M-D') // 出生日期
         if (data.firstWorkTime && data.firstWorkTime !== 0) data.firstWorkTimeText = timesTampChange(data.firstWorkTime, 'Y-M-D') // 首次工作时间
         if (data.areaId && data.areaId !== 0) await getBaseInfoDictOfName(0, data, data.areaId, 'areaName') // 现居住地text