Browse Source

实现企业应用管理操作

huxz 8 years ago
parent
commit
1eb9deca21

+ 1 - 6
sso-manage-console-web/src/components/accounts/enterprises/EnterpriseAdmin.vue

@@ -114,12 +114,7 @@
         return adminInfo
       },
       enterprise () {
-        const enterprise = this.$store.state.enterprises.savedEnterprise
-        if (enterprise) {
-          this.adminUser = enterprise.admin
-        }
-
-        return enterprise
+        return this.$store.state.enterprises.savedEnterprise
       }
     },
     methods: {

+ 49 - 33
sso-manage-console-web/src/components/accounts/enterprises/EnterpriseApps.vue

@@ -5,8 +5,19 @@
 </template>
 
 <script>
+  import axios from '@/assets/js/axios'
+  import * as types from '@/store/mutation-types'
   import AppList from './common/AppList'
 
+  function bindAppWithSpace (spaceUU, appUid, success, error) {
+    console.log(appUid)
+    const params = { appUid }
+
+    axios.put(`/api/user/space/${spaceUU}/bindAppWithSpace`, {}, { params })
+      .then(success)
+      .catch(error)
+  }
+
   export default {
     name: 'enterprise-apps',
     components: {
@@ -14,37 +25,45 @@
     },
     data () {
       return {
-        apps: [
-          {
-            label: 'UAS系统',
-            status: 2
-          },
-          {
-            label: 'B2B商务平台',
-            status: 2
-          },
-          {
-            label: '优软商城',
-            status: 1
-          },
-          {
-            label: '金融服务',
-            status: 0
-          },
-          {
-            label: '优软人才网',
-            status: 0
-          },
-          {
-            label: 'UU众创',
-            status: 0
-          },
-          {
-            label: '定制商城',
-            status: 0
+      }
+    },
+    computed: {
+      apps () {
+        // 1 开通失败, 2 已开通, 0 未开通
+        const appList = this.$store.getters.enAppsList
+
+        for (const app of appList) {
+          if (app.status === 0 || app.status === 1) {
+            app.action = this.openApplication
           }
-        ]
+        }
+        console.log(this.$store.getters.enAppsList)
+        return this.$store.getters.enAppsList
+      },
+      enterprise () {
+        return this.$store.state.enterprises.savedEnterprise
+      }
+    },
+    methods: {
+      showErrorMessage (error) {
+        this.$message.error(error)
+      },
+      openApplication (app) {
+        console.log('开通')
+        const spaceUU = this.enterprise.spaceUU
+
+        const success = userSpace => {
+          this.$store.commit(types.CHOOSE_ENTERPRISE, userSpace)
+
+          this.$message.success('保存成功')
+        }
+
+        console.log(app)
+        bindAppWithSpace(spaceUU, app.uid, success, this.showErrorMessage)
       }
+    },
+    created () {
+      this.$store.dispatch('retrieveAllApps')
     }
   }
 </script>
@@ -59,8 +78,5 @@
 </style>
 
 <style>
-  .admin-message::after {
-    content: 'ABV';
-    color: black;
-  }
+
 </style>

+ 0 - 4
sso-manage-console-web/src/components/accounts/enterprises/EnterpriseAuth.vue

@@ -108,10 +108,6 @@
 </style>
 
 <style>
-  .admin-message::after {
-    content: 'ABV';
-    color: black;
-  }
   .el-dialog {
     border-radius: 5px;
   }

+ 4 - 5
sso-manage-console-web/src/components/accounts/enterprises/common/AppList.vue

@@ -10,8 +10,8 @@
         </div>
       </div>
       <div class="message-value">
-        <button class="btn btn-primary btn-open" v-if="row.status === 0" @click="() => { $message.info('开通') }">开通</button>
-        <button class="btn btn-primary btn-reopen" v-if="row.status === 1" @click="() => { $message.info('重新开通') }">重新开通</button>
+        <button class="btn btn-primary btn-open" v-if="row.status === 0" @click="row.action(row)">开通</button>
+        <button class="btn btn-primary btn-reopen" v-if="row.status === 1" @click="row.action(row)">重新开通</button>
       </div>
     </div>
   </div>
@@ -65,6 +65,7 @@
   }
   .message-panel .row .message-value button {
     height: 26px;
+    line-height: 12px;
     outline: none;
     border-radius: 0;
 
@@ -73,13 +74,11 @@
     font-weight: normal;
     font-family: "Microsoft YaHei", sans-serif;
   }
-  .message-panel .row .message-value btn-open {
+  .message-panel .row .message-value .btn-open {
     width: 50px;
-    line-height: 12px;
   }
   .message-panel .row .message-value .btn-reopen {
     width: 64px;
-    line-height: 12px;
     padding: 6px 0;
   }
 </style>

+ 36 - 2
sso-manage-console-web/src/store/modules/enterprises.js

@@ -1,8 +1,10 @@
+import axios from '@/assets/js/axios'
 import * as types from '../mutation-types'
 
 // State
 const state = {
-  savedEnterprise: {}
+  savedEnterprise: {},
+  allApps: []
 }
 
 // Getters
@@ -39,12 +41,41 @@ const getters = {
   },
   hasEnInfo: state => {
     return !!(state.savedEnterprise && state.savedEnterprise.spaceUU)
+  },
+  enAppsList: state => {
+    const apps = state.savedEnterprise.apps
+    const allApps = state.allApps
+    const appStatus = []
+
+    for (const app of allApps) {
+      let status = false
+      for (const enApp of apps) {
+        if (enApp.uid === app.uid) {
+          status = true
+          break
+        }
+      }
+
+      appStatus.push({label: app.description, uid: app.uid, status: (status ? 2 : 0)})
+    }
+
+    return appStatus
   }
 }
 
 // Actions
 const actions = {
-
+  retrieveAllApps (context) {
+    console.log(context)
+
+    return axios.get('/api/app//showAllApps')
+      .then(appList => {
+        context.commit(types.ALL_APPS, appList)
+      })
+      .catch(response => {
+        console.log(response)
+      })
+  }
 }
 
 // Mutations
@@ -56,6 +87,9 @@ const mutations = {
   },
   [types.CLEAR_ENTERPRISE] (state) {
     state.savedEnterprise = {}
+  },
+  [types.ALL_APPS] (state, appList) {
+    state.allApps = appList
   }
 }
 

+ 1 - 0
sso-manage-console-web/src/store/mutation-types.js

@@ -1,5 +1,6 @@
 export const CHOOSE_ENTERPRISE = 'CHOOSE_ENTERPRISE'
 export const CLEAR_ENTERPRISE = 'CLEAR_ENTERPRISE'
+export const ALL_APPS = 'ALL_APPS'
 export const ADD_TO_CART = 'ADD_TO_CART'
 export const SET_CART_ITEMS = 'SET_CART_ITEMS'
 export const SET_CHECKOUT_STATUS = 'SET_CHECKOUT_STATUS'