新建租户自动创建租户顶级部门,更新租户自动更新顶级部门名称,登录页根据后缀tenantCode值自动获取登录租户

This commit is contained in:
Vinjor 2024-08-01 18:05:11 +08:00
parent b1c0139906
commit 9b4e2c1011
4 changed files with 20 additions and 8 deletions

View File

@ -11,6 +11,17 @@ export function getTenantIdByName(name) {
}) })
} }
// 使用租户域名(标识),获得租户编号
export function getTenantIdByWebsite(website) {
return request({
url: '/system/tenant/get-by-website',
method: 'get',
params: {
website
}
})
}
// 创建租户 // 创建租户
export function createTenant(data) { export function createTenant(data) {
return request({ return request({

View File

@ -140,7 +140,6 @@ export default {
/** 查询列表 */ /** 查询列表 */
async getList() { async getList() {
try { try {
debugger
this.loading = true this.loading = true
const res = await CompanyApi.getCompanyPage(this.queryParams) const res = await CompanyApi.getCompanyPage(this.queryParams)
this.list = res.data.records this.list = res.data.records

View File

@ -110,7 +110,7 @@
<script> <script>
import {sendSmsCode, socialAuthRedirect} from "@/api/login"; import {sendSmsCode, socialAuthRedirect} from "@/api/login";
import {getTenantIdByName} from "@/api/system/tenant"; import {getTenantIdByWebsite,getTenantIdByName} from "@/api/system/tenant";
import {SystemUserSocialTypeEnum} from "@/utils/constants"; import {SystemUserSocialTypeEnum} from "@/utils/constants";
import {getCaptchaEnable, getTenantEnable} from "@/utils/ruoyi"; import {getCaptchaEnable, getTenantEnable} from "@/utils/ruoyi";
import { import {
@ -133,6 +133,7 @@ export default {
}, },
data() { data() {
return { return {
tenantCode:"lighting",
codeUrl: "", codeUrl: "",
// //
captchaEnable: false, captchaEnable: false,
@ -199,7 +200,8 @@ export default {
// //
this.tenantEnable = getTenantEnable(); this.tenantEnable = getTenantEnable();
if (this.tenantEnable) { if (this.tenantEnable) {
getTenantIdByName(this.loginForm.tenantName).then(res => { // this.tenantCode = this.$route.query.tenantCode; // John
getTenantIdByWebsite(this.tenantCode).then(res => { //
const tenantId = res.data; const tenantId = res.data;
if (tenantId && tenantId >= 0) { if (tenantId && tenantId >= 0) {
setTenantId(tenantId) setTenantId(tenantId)

View File

@ -63,7 +63,7 @@
<span>{{ parseTime(scope.row.expireTime) }}</span> <span>{{ parseTime(scope.row.expireTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="绑定域名" align="center" prop="domain" width="180" /> <el-table-column label="绑定域名" align="center" prop="website" width="180" />
<el-table-column label="租户状态" align="center" prop="status"> <el-table-column label="租户状态" align="center" prop="status">
<template v-slot="scope"> <template v-slot="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/> <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
@ -117,8 +117,8 @@
<el-date-picker clearable size="small" v-model="form.expireTime" type="date" <el-date-picker clearable size="small" v-model="form.expireTime" type="date"
value-format="timestamp" placeholder="请选择过期时间" /> value-format="timestamp" placeholder="请选择过期时间" />
</el-form-item> </el-form-item>
<el-form-item label="绑定域名" prop="domain"> <el-form-item label="绑定域名" prop="website">
<el-input v-model="form.domain" placeholder="请输入绑定域名" /> <el-input v-model="form.website" placeholder="请输入绑定域名" />
</el-form-item> </el-form-item>
<el-form-item label="租户状态" prop="status"> <el-form-item label="租户状态" prop="status">
<el-radio-group v-model="form.status"> <el-radio-group v-model="form.status">
@ -182,7 +182,7 @@ export default {
status: [{ required: true, message: "租户状态不能为空", trigger: "blur" }], status: [{ required: true, message: "租户状态不能为空", trigger: "blur" }],
accountCount: [{ required: true, message: "账号额度不能为空", trigger: "blur" }], accountCount: [{ required: true, message: "账号额度不能为空", trigger: "blur" }],
expireTime: [{ required: true, message: "过期时间不能为空", trigger: "blur" }], expireTime: [{ required: true, message: "过期时间不能为空", trigger: "blur" }],
domain: [{ required: true, message: "绑定域名不能为空", trigger: "blur" }], website: [{ required: true, message: "绑定域名不能为空", trigger: "blur" }],
username: [{ required: true, message: "用户名称不能为空", trigger: "blur" }], username: [{ required: true, message: "用户名称不能为空", trigger: "blur" }],
password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }], password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }],
} }
@ -221,7 +221,7 @@ export default {
contactMobile: undefined, contactMobile: undefined,
accountCount: undefined, accountCount: undefined,
expireTime: undefined, expireTime: undefined,
domain: undefined, website: undefined,
status: CommonStatusEnum.ENABLE, status: CommonStatusEnum.ENABLE,
}; };
this.resetForm("form"); this.resetForm("form");