lifanagju_citu 11 月之前
父節點
當前提交
62de3f03e7
共有 3 個文件被更改,包括 7 次插入9 次删除
  1. 1 1
      components.d.ts
  2. 2 2
      src/store/user.js
  3. 4 6
      src/utils/getText.js

+ 1 - 1
components.d.ts

@@ -20,7 +20,7 @@ declare module 'vue' {
     CtPagination: typeof import('./src/components/CtPagination/index.vue')['default']
     CtSearch: typeof import('./src/components/CtSearch/index.vue')['default']
     CtTextField: typeof import('./src/components/CtVuetify/CtTextField/index.vue')['default']
-    DatePicker: typeof import('./src/components/FormUI/datePicker/index.vue')['default']
+    DatePicker: typeof import('./src/components/DatePicker/index.vue')['default']
     Details: typeof import('./src/components/Enterprise/details.vue')['default']
     Empty: typeof import('./src/components/Empty/index.vue')['default']
     HeadSearch: typeof import('./src/components/headSearch/index.vue')['default']

+ 2 - 2
src/store/user.js

@@ -6,7 +6,7 @@ import { logout } from '@/api/common/index'
 import { getUserInfo } from '@/api/personal/user'
 import Snackbar from '@/plugins/snackbar'
 import { timesTampChange } from '@/utils/date'
-import { getAreaName } from '@/utils/getText'
+import { getDictName } from '@/utils/getText'
 
 
 export const useUserStore = defineStore('user',
@@ -71,7 +71,7 @@ export const useUserStore = defineStore('user',
     }
     // 字典对应中文
     const getFieldText = async (data) => {
-      if (data.areaId && data.areaId !== 0) data.areaName = await getAreaName(data.areaId) // 现居住地text
+      if (data.areaId && data.areaId !== 0) await getDictName(data, data.areaId, 'areaName') // 现居住地text
       if (data.birthday && data.birthday !== 0) data.birthdayText = timesTampChange(data.birthday).slice(0, 10) // 出生日期
       if (data.eduType && data.eduType !== 0) data.eduTypeText = '硕士' // 学历
       if (data.expType && data.expType !== 0) data.expTypeText = '1-3年' // 工作经验

+ 4 - 6
src/utils/getText.js

@@ -9,13 +9,11 @@ export const getText = (value, arr, itemText = 'label', itemValue = 'value') =>
 }
 
 
-export const getAreaName = async (value, arr, itemText = 'name', itemValue = 'id') => { // 一维数组
-  let str = '暂无'
-  if (!value && value !== 0) return
+export const getDictName = async (obj, value, addKey, itemText = 'name', itemValue = 'id') => { // 一维数组
+  if (!value && value !== 0) obj[addKey] = '暂无'
   const { data } = await getDict('menduner_area_type', {}, 'areaList')
-  const item = data.find(formItem => formItem[itemValue] === Number(value))
-  str = item[itemText]
-  return str
+  const item = data.find(formItem => Number(formItem[itemValue]) === Number(value))
+  obj[addKey] = item ? item[itemText] : '暂无'
 }
 
 export const dealCanBeInputtedValueAndLabel = (formItem, item) => {