Sfoglia il codice sorgente

添加创建租户管理员和初始化租户菜单请求

lph 1 anno fa
parent
commit
baa064c2b0

+ 17 - 0
ruoyi-ui/src/api/system/tenant.js

@@ -59,3 +59,20 @@ export function selectAllUser() {
     method: 'get'
   })
 }
+
+// 创建租户管理员
+export function createTenant(data) {
+  return request({
+    url: '/system/user',
+    method: 'post',
+    data
+  })
+}
+
+// 初始化租户菜单
+export function initTenantMenuData(tenantId) {
+  return request({
+    url: `/system/tenant/initTenantMenuData/${tenantId}`,
+    method: 'get'
+  })
+}

+ 28 - 3
ruoyi-ui/src/views/system/tenant/index.vue

@@ -311,8 +311,11 @@ import {
   updateTenant,
   bindDatasource,
   selectAllUser,
+  createTenant,
+  initTenantMenuData,
 } from "@/api/system/tenant";
 import { getDataSourceInfo, insertDataSource } from "@/api/system/data";
+import { async } from "@/components/updateModule/k-form-design/lib/k-form-design.common";
 
 export default {
   name: "Tenant",
@@ -355,6 +358,8 @@ export default {
         contactInfo: null,
         address: null,
       },
+      // 当前编辑租户的信息
+      currentTenantInfo: {},
       // 表单参数
       form: {},
       // 表单校验
@@ -525,6 +530,8 @@ export default {
     },
     /** 绑定数据源按钮操作 */
     bindDatasource(row) {
+      this.currentTenantInfo = row;
+      console.log(row);
       this.reset1();
       this.dataSourceOpen = true;
       this.dataSourceTitle = "配置数据库";
@@ -574,9 +581,27 @@ export default {
               dataSource: this.dataSourceForm,
             };
             bindDatasource(query).then((response) => {
-              this.$modal.msgSuccess("新增成功");
-              this.dataSourceOpen = false;
-              this.getList();
+              if (response.code == 200) {
+                let data = {
+                  userName: this.dataSourceForm.tenantAccount,
+                  nickName: this.currentTenantInfo.tenantName,
+                  userType: "01",
+                  tenantId: this.currentTenantInfo.tenantId,
+                  password: "123456",
+                };
+                createTenant(data).then(async (res) => {
+                  if (res.code == 200) {
+                    let resp = await initTenantMenuData(
+                      this.currentTenantInfo.tenantId
+                    );
+                    if ((resp.code = 200)) {
+                      this.$modal.msgSuccess("新增成功");
+                      this.dataSourceOpen = false;
+                      this.getList();
+                    }
+                  }
+                });
+              }
             });
           }
         }