refactor: merge tenant configuration into tenant registry
This commit is contained in:
@@ -42,20 +42,6 @@
|
||||
/>
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
<n-gi span="1" v-if="isAdminSuper && formValue.id > 0">
|
||||
<n-form-item label="业务库名" path="dbName">
|
||||
<n-input placeholder="请输入业务库名" v-model:value="formValue.dbName" />
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
<n-gi span="2" v-if="isAdminSuper && formValue.id > 0">
|
||||
<n-form-item label="独立连接串" path="dbDsn">
|
||||
<n-input
|
||||
type="textarea"
|
||||
placeholder="为空时使用业务库名路由"
|
||||
v-model:value="formValue.dbDsn"
|
||||
/>
|
||||
</n-form-item>
|
||||
</n-gi>
|
||||
<n-gi span="1" v-if="formValue.id > 0">
|
||||
<n-form-item label="管理员账号">
|
||||
<n-input :value="formValue.adminUsername" disabled placeholder="未创建" />
|
||||
@@ -171,7 +157,7 @@
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useDictStore } from '@/store/modules/dict';
|
||||
import { Add, Edit, View } from '@/api/imTenant';
|
||||
import { isAdminSuper, newState, rules, State } from './model';
|
||||
import { newState, rules, State } from './model';
|
||||
import { useProjectSettingStore } from '@/store/modules/projectSetting';
|
||||
import { useMessage } from 'naive-ui';
|
||||
import { adaModalWidth } from '@/utils/hotgo';
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
import { useDictStore } from '@/store/modules/dict';
|
||||
import { List, Restore, Status } from '@/api/imTenant';
|
||||
import { PlusOutlined } from '@vicons/antd';
|
||||
import { buildColumns, isAdminSuper, loadOptions, schemas, State } from './model';
|
||||
import { buildColumns, loadOptions, schemas, State } from './model';
|
||||
import { adaTableScrollX } from '@/utils/hotgo';
|
||||
import Edit from './edit.vue';
|
||||
import UsageModal from './usage.vue';
|
||||
@@ -116,8 +116,7 @@
|
||||
},
|
||||
});
|
||||
|
||||
// 业务库名列仅admin超管可见
|
||||
const columns = computed(() => buildColumns(isAdminSuper.value));
|
||||
const columns = computed(() => buildColumns());
|
||||
|
||||
const scrollX = computed(() => {
|
||||
return adaTableScrollX(columns.value, actionColumn.width);
|
||||
@@ -126,8 +125,7 @@
|
||||
const [register, {}] = useForm({
|
||||
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
|
||||
labelWidth: 90,
|
||||
// 业务库名搜索项仅admin超管可见
|
||||
schemas: schemas.value.filter((item) => item.field !== 'dbName' || isAdminSuper.value),
|
||||
schemas: schemas.value,
|
||||
});
|
||||
|
||||
// 加载表格数据
|
||||
|
||||
@@ -1,25 +1,18 @@
|
||||
import { computed, h, ref } from 'vue';
|
||||
import { h, ref } from 'vue';
|
||||
import { NTag } from 'naive-ui';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { FormSchema } from '@/components/Form';
|
||||
import { defRangeShortcuts } from '@/utils/dateUtil';
|
||||
import { renderPopoverMemberSumma, MemberSumma } from '@/utils';
|
||||
import { useDictStore } from '@/store/modules/dict';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
const dict = useDictStore();
|
||||
const userStore = useUserStore();
|
||||
|
||||
// 是否admin超管(业务库名/独立连接串仅超管可见可编辑)
|
||||
export const isAdminSuper = computed(() => userStore.getUserInfo?.username === 'admin');
|
||||
|
||||
export class State {
|
||||
public id = 0; // ID
|
||||
public code = ''; // 商户编码
|
||||
public name = ''; // 商户名称
|
||||
public tenantDesc = ''; // 商户描述
|
||||
public dbName = ''; // 业务库名
|
||||
public dbDsn = ''; // 独立连接串
|
||||
public adminUsername = ''; // 新增商户时创建的后台管理员账号
|
||||
public adminPassword = ''; // 新增商户时创建的后台管理员初始密码
|
||||
public state = 1; // 状态
|
||||
@@ -30,7 +23,6 @@ export class State {
|
||||
public localModerationEnabled = 0; // 是否启用本地内容审核
|
||||
public messageEncryptionEnabled = 0; // 是否启用消息加密
|
||||
public realnameReviewPolicy = 0; // 实名审核策略
|
||||
public dbDsnConfigured = false; // 是否配置独立连接串
|
||||
public createdBy = 0; // 创建者
|
||||
public createdBySumma?: null | MemberSumma = null; // 创建者摘要信息
|
||||
public updatedBy = 0; // 更新者
|
||||
@@ -49,8 +41,6 @@ export class UsageState {
|
||||
public id = 0;
|
||||
public code = '';
|
||||
public name = '';
|
||||
public dbName = '';
|
||||
public dbDsnConfigured = false;
|
||||
public dbReachable = false;
|
||||
public dbCheckError = '';
|
||||
public schemaVersion = '';
|
||||
@@ -126,14 +116,6 @@ export const schemas = ref<FormSchema[]>([
|
||||
placeholder: '请输入商户名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'dbName',
|
||||
component: 'NInput',
|
||||
label: '业务库名',
|
||||
componentProps: {
|
||||
placeholder: '请输入业务库名',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'state',
|
||||
component: 'NSelect',
|
||||
@@ -185,25 +167,6 @@ const baseColumns = [
|
||||
return dict.getLabel('ImTenantStateOptions', row.state);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '业务库名',
|
||||
key: 'dbName',
|
||||
align: 'left',
|
||||
width: 160,
|
||||
},
|
||||
{
|
||||
title: '独立连接串',
|
||||
key: 'dbDsnConfigured',
|
||||
align: 'left',
|
||||
width: 120,
|
||||
render(row: State) {
|
||||
return h(
|
||||
NTag,
|
||||
{ type: row.dbDsnConfigured ? 'success' : 'default', bordered: false },
|
||||
{ default: () => (row.dbDsnConfigured ? '已配置' : '未配置') }
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '最大用户',
|
||||
key: 'maxUsers',
|
||||
@@ -297,12 +260,8 @@ const baseColumns = [
|
||||
},
|
||||
];
|
||||
|
||||
// 业务库名与独立连接串列仅admin超管可见
|
||||
export function buildColumns(isAdmin: boolean) {
|
||||
if (isAdmin) {
|
||||
return baseColumns;
|
||||
}
|
||||
return baseColumns.filter((item) => item.key !== 'dbName' && item.key !== 'dbDsnConfigured');
|
||||
export function buildColumns() {
|
||||
return baseColumns;
|
||||
}
|
||||
|
||||
// 加载字典数据选项
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
<n-descriptions label-placement="left" bordered :column="settingStore.isMobile ? 1 : 2">
|
||||
<n-descriptions-item label="商户">{{ usage.name || current.name }}</n-descriptions-item>
|
||||
<n-descriptions-item label="商户编码">{{ usage.code || current.code }}</n-descriptions-item>
|
||||
<n-descriptions-item label="业务库">{{ usage.dbName || '-' }}</n-descriptions-item>
|
||||
<n-descriptions-item label="独立连接串">
|
||||
{{ usage.dbDsnConfigured ? '已配置' : '未配置' }}
|
||||
</n-descriptions-item>
|
||||
<n-descriptions-item label="业务库状态">
|
||||
<n-tag :type="usage.dbReachable ? 'success' : 'error'" :bordered="false">
|
||||
{{ usage.dbReachable ? '可达' : '不可达' }}
|
||||
|
||||
Reference in New Issue
Block a user