Browse Source

Merge pull request #44 from wenjianzhang/dev

Fix "Personal Center" Department and role are empty
wenjianzhang 5 years ago
parent
commit
0c3bda0cd1
3 changed files with 45 additions and 6 deletions
  1. 8 0
      src/api/tools/gen.js
  2. 24 5
      src/views/profile/index.vue
  3. 13 1
      src/views/tools/gen/index.vue

+ 8 - 0
src/api/tools/gen.js

@@ -57,3 +57,11 @@ export function delTable(tableId) {
   })
 }
 
+// 生成代码到项目
+export function toProjectTable(tableId) {
+  return request({
+    url: '/api/v1/gen/toproject/' + tableId,
+    method: 'get'
+  })
+}
+

+ 24 - 5
src/views/profile/index.vue

@@ -25,11 +25,11 @@
               </li>
               <li class="list-group-item">
                 <svg-icon icon-class="tree" />所属部门
-                <div v-if="user.dept" class="pull-right">{{ user.dept.deptName }} / {{ postGroup }}</div>
+                <div class="pull-right">{{ deptName }}</div>
               </li>
               <li class="list-group-item">
                 <svg-icon icon-class="peoples" />所属角色
-                <div class="pull-right">{{ roleGroup }}</div>
+                <div class="pull-right">{{ roleName }}</div>
               </li>
               <li class="list-group-item">
                 <svg-icon icon-class="date" />创建日期
@@ -72,7 +72,14 @@ export default {
       user: {},
       roleGroup: {},
       postGroup: {},
-      activeTab: 'userinfo'
+      deptGroup: {},
+      activeTab: 'userinfo',
+      roleIds: undefined,
+      postIds: undefined,
+      roleName: undefined,
+      postName: undefined,
+      dept: {},
+      deptName: undefined
     }
   },
   created() {
@@ -82,8 +89,20 @@ export default {
     getUser() {
       getUserProfile().then(response => {
         this.user = response.data
-        this.roleGroup = response.roleGroup
-        this.postGroup = response.postGroup
+        this.roleIds = response.roleIds
+        this.roleGroup = response.roles
+
+        if (this.roleIds[0]) {
+          for (const key in this.roleGroup) {
+            if (this.roleIds[0] === this.roleGroup[key].roleId) {
+              this.roleName = this.roleGroup[key].roleName
+            }
+          }
+        } else {
+          this.roleName = '暂无'
+        }
+        this.dept = response.dept
+        this.deptName = this.dept.deptName
       })
     }
   }

+ 13 - 1
src/views/tools/gen/index.vue

@@ -108,6 +108,13 @@
             icon="el-icon-view"
             @click="handlePreview(scope.row)"
           >预览</el-button>
+          <el-button
+
+            type="text"
+            size="small"
+            icon="el-icon-view"
+            @click="handleToProject(scope.row)"
+          >生成到项目</el-button>
           <el-button
 
             type="text"
@@ -150,7 +157,7 @@
 </template>
 
 <script>
-import { listTable, previewTable, delTable } from '@/api/tools/gen'
+import { listTable, previewTable, delTable, toProjectTable } from '@/api/tools/gen'
 import importTable from './importTable'
 import { downLoadFile } from '@/utils/zipdownload'
 export default {
@@ -244,6 +251,11 @@ export default {
         this.preview.open = true
       })
     },
+    handleToProject(row) {
+      toProjectTable(row.tableId).then(response => {
+        this.msgSuccess(response.msg)
+      })
+    },
     // 多选框选中数据
     handleSelectionChange(selection) {
       this.ids = selection.map(item => item.tableId)