Files
im_manager/web/src/views/imSecurityPolicy/model.ts
T

89 lines
2.4 KiB
TypeScript

import { computed, ref } from 'vue';
import { FormSchema } from '@/components/Form';
import { useDictStore } from '@/store/modules/dict';
import { policyTenantOptions } from '@/views/imPolicyShared';
const dict = useDictStore();
export const schemas = ref<FormSchema[]>([
{
field: 'tenantId',
component: 'NSelect',
label: '商户',
componentProps: { options: computed(() => policyTenantOptions.value), clearable: false },
},
{
field: 'publishStatus',
component: 'NSelect',
label: '发布状态',
componentProps: {
options: dict.getOption('ImSecurityPublishStatusOptions'),
clearable: true,
},
},
]);
export const columns = [
{ title: '版本', key: 'policyVersion', width: 90 },
{ title: '策略名称', key: 'policyName', width: 180 },
{
title: '发布状态',
key: 'publishStatus',
width: 110,
render: (r) => dict.getLabel('ImSecurityPublishStatusOptions', r.publishStatus),
},
{
title: '允许加好友',
key: 'globalFriendEnabled',
width: 110,
render: (r) => (r.globalFriendEnabled ? '允许' : '禁止'),
},
{
title: '消息宵禁',
key: 'messageCurfewEnabled',
width: 100,
render: (r) => (r.messageCurfewEnabled ? '启用' : '关闭'),
},
{ title: '发布时间', key: 'publishedAt', width: 180 },
{ title: '更新时间', key: 'updatedAt', width: 180 },
{ title: '备注', key: 'remark', width: 220 },
];
export const ipColumns = [
{
title: '类型',
key: 'ruleType',
width: 100,
render: (r) => (r.ruleType === 'whitelist' ? '白名单' : '黑名单'),
},
{ title: 'IP/CIDR', key: 'ipCidr', width: 180 },
{
title: '动作',
key: 'action',
width: 110,
render: (r) => dict.getLabel('ImSecurityActionOptions', r.action),
},
{
title: '风险等级',
key: 'riskLevel',
width: 100,
render: (r) => dict.getLabel('ImRiskLevelOptions', r.riskLevel),
},
{
title: '状态',
key: 'status',
width: 90,
render: (r) => dict.getLabel('sys_normal_disable', r.status),
},
{ title: '过期时间', key: 'expiresAt', width: 180 },
{ title: '备注', key: 'remark', width: 200 },
];
export function loadOptions() {
dict.loadOptions([
'ImSecurityPublishStatusOptions',
'ImCurfewDateTypeOptions',
'ImCurfewScopeOptions',
'ImSecurityActionOptions',
'ImFriendEntryOptions',
'ImRiskLevelOptions',
'sys_normal_disable',
]);
}