Browse Source

feat: 企业信息获取优化

cuiyalong 3 years ago
parent
commit
a2b0f9385e

+ 0 - 4
src/router/router.js

@@ -10,11 +10,7 @@ if (process.env.NODE_ENV !== 'production') {
 
 
 const router = new VueRouter({
 const router = new VueRouter({
   mode: 'history',
   mode: 'history',
-<<<<<<< HEAD
   base: window.__POWERED_BY_QIANKUN__ ? window.__QIANKUN_ROUTER_BASE : process.env.VUE_APP_BASE_URL,
   base: window.__POWERED_BY_QIANKUN__ ? window.__QIANKUN_ROUTER_BASE : process.env.VUE_APP_BASE_URL,
-=======
-  base: window.__POWERED_BY_QIANKUN__ ? (window.__QIANKUN_ROUTER_BASE || window.__RouterBase) : process.env.VUE_APP_BASE_URL,
->>>>>>> master
   routes: [
   routes: [
     ...routers,
     ...routers,
     ...workspace,
     ...workspace,

+ 39 - 0
src/store/user.js

@@ -5,6 +5,7 @@ import {
   getFreeUserSubscribeList,
   getFreeUserSubscribeList,
   getSVIPBuyInfo,
   getSVIPBuyInfo,
   getEntNicheSubKeyList,
   getEntNicheSubKeyList,
+  entBaseInfo,
   getBigMemberInfo
   getBigMemberInfo
 } from '@/api/modules'
 } from '@/api/modules'
 import { formatKeywordsList } from '@/utils/format'
 import { formatKeywordsList } from '@/utils/format'
@@ -35,6 +36,8 @@ export default {
     isDeleteAllBuyClass: defaultLocalPageData('bigmember-login-clear-DELETE_BUY_CLASS', false),
     isDeleteAllBuyClass: defaultLocalPageData('bigmember-login-clear-DELETE_BUY_CLASS', false),
     // 用户订阅关键词列表(包含免费订阅/超级订阅/大会员/商机管理)
     // 用户订阅关键词列表(包含免费订阅/超级订阅/大会员/商机管理)
     subscribeKeyList: [],
     subscribeKeyList: [],
+    // entInfo企业相关信息
+    entInfo: {},
     // 用户访问灰显记录列表
     // 用户访问灰显记录列表
     visitedList: defaultLocalPageData('visited-path-list', [])
     visitedList: defaultLocalPageData('visited-path-list', [])
   }),
   }),
@@ -51,6 +54,30 @@ export default {
       state.power = power
       state.power = power
       localStorage.setItem('bigmember-login-clear-power', JSON.stringify(power))
       localStorage.setItem('bigmember-login-clear-power', JSON.stringify(power))
     },
     },
+    setEntInfo (state, obj = {}) {
+      // obj = {
+      //   admin_department: false,
+      //   admin_system: false,
+      //   dept_eid: '4656485c0140',
+      //   dept_id: 2982,
+      //   dept_name: '部门C',
+      //   dept_pid: 2979,
+      //   dept_subdis: 1,
+      //   enddate: 1857484799,
+      //   ent_auth_status: 1,
+      //   ent_id: '455645580138',
+      //   ent_model: 1,
+      //   ent_name: '洛阳市洛西建筑有限公司',
+      //   ent_status: 1,
+      //   startdate: 1604993069,
+      //   user_id: 'xxxxxxxx',
+      //   user_name: 'xxxxxxxxx',
+      //   user_power: 1
+      // }
+      if (Object.keys(obj).length) {
+        state.entInfo = obj
+      }
+    },
     // 设置的业务范围
     // 设置的业务范围
     setScope (state, data) {
     setScope (state, data) {
       state.scope = data
       state.scope = data
@@ -111,6 +138,18 @@ export default {
         return {}
         return {}
       }
       }
     },
     },
+    // 获取企业信息
+    async getEntInfo ({ commit }) {
+      try {
+        const { data = {}, error_code: code } = await entBaseInfo()
+        if (code === 0 && data) {
+          commit('setEntInfo', data)
+        }
+        return data
+      } catch (error) {
+        console.log(error)
+      }
+    },
     async getUserPower ({ commit, state }, payload) {
     async getUserPower ({ commit, state }, payload) {
       try {
       try {
         const { data, error_code: code } = await getUserPower()
         const { data, error_code: code } = await getUserPower()

+ 9 - 27
src/store/workspace/business-profile.js

@@ -1,39 +1,17 @@
-import { entBaseInfo, getEmployeeDataOverview } from '@/api/modules'
+import { getEmployeeDataOverview } from '@/api/modules'
 import { dateFormatter } from '@/utils'
 import { dateFormatter } from '@/utils'
 
 
 export default {
 export default {
   namespaced: true,
   namespaced: true,
   state: () => ({
   state: () => ({
-    entInfo: {
-      admin_department: false,
-      admin_system: false,
-      dept_name: '',
-      ent_name: '',
-      user_name: ''
-    },
     boardInfo: {}
     boardInfo: {}
   }),
   }),
   mutations: {
   mutations: {
-    setEntInfo (state, obj = {}) {
-      Object.assign(state.entInfo, obj)
-    },
     setBoardInfo (state, obj = {}) {
     setBoardInfo (state, obj = {}) {
       Object.assign(state.boardInfo, obj)
       Object.assign(state.boardInfo, obj)
     }
     }
   },
   },
   actions: {
   actions: {
-    async getEntInfo ({ commit, dispatch }) {
-      try {
-        const { data = {}, error_code: code } = await entBaseInfo()
-        if (code === 0 && data) {
-          commit('setEntInfo', data)
-        }
-        dispatch('getBoardInfo')
-        return data
-      } catch (error) {
-        console.log(error)
-      }
-    },
     async getBoardInfo ({ dispatch }) {
     async getBoardInfo ({ dispatch }) {
       const now = Date.now()
       const now = Date.now()
       const day7 = 7 * 24 * 60 * 60 * 1000
       const day7 = 7 * 24 * 60 * 60 * 1000
@@ -56,14 +34,18 @@ export default {
     }
     }
   },
   },
   getters: {
   getters: {
-    isAdmin (state) {
-      const { entInfo } = state
+    entInfo (state, getters, rootState) {
+      const { user = {} } = rootState
+      const { entInfo = {} } = user
+      return entInfo
+    },
+    isAdmin (state, getters) {
+      const { entInfo = {} } = getters
       const isAdmin = entInfo.admin_system || entInfo.admin_department
       const isAdmin = entInfo.admin_system || entInfo.admin_department
       return isAdmin
       return isAdmin
     },
     },
     myLocationInEnt (state, getters) {
     myLocationInEnt (state, getters) {
-      const { entInfo } = state
-      const { isAdmin } = getters
+      const { isAdmin, entInfo = {} } = getters
       const locationArr = []
       const locationArr = []
       if (entInfo.ent_name) {
       if (entInfo.ent_name) {
         locationArr.push(entInfo.ent_name)
         locationArr.push(entInfo.ent_name)

+ 13 - 5
src/views/SubPush.vue

@@ -82,10 +82,9 @@ import PriceSelector from '@/components/selector/PriceSelector.vue'
 import RadioGroup from '@/components/selector/RadioGroup.vue'
 import RadioGroup from '@/components/selector/RadioGroup.vue'
 import Dialog from '@/components/dialog/Dialog.vue'
 import Dialog from '@/components/dialog/Dialog.vue'
 import FollowOfficialAccountDialog from '@/components/dialog/FollowOfficialAccountDialog.vue'
 import FollowOfficialAccountDialog from '@/components/dialog/FollowOfficialAccountDialog.vue'
-
 import { getFreeUserPushInfo } from '@/api/modules/'
 import { getFreeUserPushInfo } from '@/api/modules/'
-
 import { mapState, mapGetters, mapActions } from 'vuex'
 import { mapState, mapGetters, mapActions } from 'vuex'
+import { tryCallHooks } from '@jianyu/easy-inject-qiankun'
 
 
 export default {
 export default {
   name: 'SubPush',
   name: 'SubPush',
@@ -161,7 +160,8 @@ export default {
       // 免费f / 商机管理s / 超级订阅v / 大会员m
       // 免费f / 商机管理s / 超级订阅v / 大会员m
       // 商机管理不显示
       // 商机管理不显示
       if (this.vt === 's') {
       if (this.vt === 's') {
-        return false
+        const { admin_system: adminSystem, admin_department: adminDepartment } = this.entInfo
+        return adminSystem || adminDepartment
       }
       }
       // 子账号不显示
       // 子账号不显示
       if (this.vt === 'm' && this.isSubCount) {
       if (this.vt === 'm' && this.isSubCount) {
@@ -170,6 +170,7 @@ export default {
       return true
       return true
     },
     },
     ...mapState({
     ...mapState({
+      entInfo: state => state.user.entInfo,
       subscribeKeyList: state => state.user.subscribeKeyList
       subscribeKeyList: state => state.user.subscribeKeyList
     }),
     }),
     ...mapGetters('user', {
     ...mapGetters('user', {
@@ -199,6 +200,7 @@ export default {
   },
   },
   methods: {
   methods: {
     ...mapActions('user', [
     ...mapActions('user', [
+      'getEntInfo',
       'getSubScribeKeyList'
       'getSubScribeKeyList'
     ]),
     ]),
     getParams () {
     getParams () {
@@ -210,6 +212,8 @@ export default {
     getInitInfo () {
     getInitInfo () {
       if (this.vt === 'f') {
       if (this.vt === 'f') {
         this.getFreeUserPushInfo()
         this.getFreeUserPushInfo()
+      } else if (this.vt === 's') {
+        this.getEntInfo()
       }
       }
     },
     },
     async getFreeUserPushInfo () {
     async getFreeUserPushInfo () {
@@ -310,8 +314,12 @@ export default {
         this.dialog.toFollowOfficialAccount = true
         this.dialog.toFollowOfficialAccount = true
       } else if (this.vt === 'm') {
       } else if (this.vt === 'm') {
         this.$router.push('/set_subscribe/config')
         this.$router.push('/set_subscribe/config')
-      } else {
-        // 商机管理该按钮被隐藏,无操作
+      } else if (this.vt === 's') {
+        // 商机管理跳转老页面(框架内打开)
+        const url = '/entpc/newBus/set_subscribe'
+        tryCallHooks(this.$BraceHooks, 'openLink', { url }, () => {
+          window.open(url)
+        })
       }
       }
     },
     },
     toBuySvip () {
     toBuySvip () {

+ 6 - 2
src/views/workspace/components/BusinessProfile.vue

@@ -36,11 +36,15 @@ export default {
       'overviewList'
       'overviewList'
     ])
     ])
   },
   },
-  created () {
-    this.getEntInfo()
+  async created () {
+    await this.getEntInfo()
+    this.getBoardInfo()
   },
   },
   methods: {
   methods: {
     ...mapActions('workspace/profile', [
     ...mapActions('workspace/profile', [
+      'getBoardInfo'
+    ]),
+    ...mapActions('user', [
       'getEntInfo'
       'getEntInfo'
     ]),
     ]),
     seeMore () {
     seeMore () {