ソースを参照

部门预设值为当前主部门

wangxiaoyi 10 ヶ月 前
コミット
f856118251
1 ファイル変更19 行追加11 行削除
  1. 19 11
      src/business/platform/form/utils/formUtil.js

+ 19 - 11
src/business/platform/form/utils/formUtil.js

@@ -351,7 +351,7 @@ const FormUtil = {
   },
   getCurrentDataValue({ selectorType, bindId, fieldName, storeType }) {
     const userInfo = store.getters.userInfo
-    const { level = {} } = store.getters
+    const { level = {}} = store.getters
     // 缓存用户
     if (userInfo.employee && userInfo.employee.id) {
       const selectors = [{
@@ -376,16 +376,24 @@ const FormUtil = {
     }
     // 岗位
     if (Utils.isNotEmpty(userInfo.positions)) {
-      const selectors = []
-      userInfo.positions.forEach((item) => {
-        if (Utils.isNotEmpty(item) && Utils.isNotEmpty(item.id)) {
-          selectors.push({
-            'id': item.id,
-            'name': item.name
-          })
-        }
-      })
-      this.CACHE_CURRENT_USER_DATA['position'] = selectors
+      const { mainPosition } = userInfo || {}
+      if (Utils.isNotEmpty(mainPosition)) {
+        this.CACHE_CURRENT_USER_DATA['position'] = [{
+          id: mainPosition.id,
+          name: mainPosition.name
+        }]
+      } else {
+        const selectors = []
+        userInfo.positions.forEach((item) => {
+          if (Utils.isNotEmpty(item) && Utils.isNotEmpty(item.id)) {
+            selectors.push({
+              'id': item.id,
+              'name': item.name
+            })
+          }
+        })
+        this.CACHE_CURRENT_USER_DATA['position'] = selectors
+      }
     }
     // 角色
     if (Utils.isNotEmpty(userInfo.role)) {