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

88 lines
2.1 KiB
TypeScript

import { h, ref } from 'vue';
import { NTag } from 'naive-ui';
import { FormSchema } from '@/components/Form';
export class State {
public tenantId = 0;
public tenantCode = '';
public tenantName = '';
public messageEncryptionEnabled = 0;
public activeVersion = 0;
public pendingVersion = 0;
public keyCount = 0;
public lastRotatedAt = '';
}
export const schemas = ref<FormSchema[]>([
{
field: 'keyword',
component: 'NInput',
label: '商户',
componentProps: {
clearable: true,
placeholder: '商户编码/名称',
},
},
{
field: 'enabled',
component: 'NSelect',
label: '加密状态',
componentProps: {
clearable: true,
options: [
{ label: '已启用', value: 1 },
{ label: '未启用', value: 0 },
],
placeholder: '全部',
},
},
]);
export const columns = [
{ title: '商户编码', key: 'tenantCode', align: 'left', width: 150 },
{ title: '商户名称', key: 'tenantName', align: 'left', width: 180 },
{
title: '消息加密',
key: 'messageEncryptionEnabled',
align: 'left',
width: 110,
render(row: State) {
return h(
NTag,
{ type: row.messageEncryptionEnabled ? 'success' : 'default', bordered: false },
{ default: () => (row.messageEncryptionEnabled ? '已启用' : '未启用') }
);
},
},
{
title: '当前版本',
key: 'activeVersion',
align: 'left',
width: 110,
render(row: State) {
return row.activeVersion > 0 ? `v${row.activeVersion}` : '--';
},
},
{
title: '待激活版本',
key: 'pendingVersion',
align: 'left',
width: 120,
render(row: State) {
return row.pendingVersion > 0
? h(NTag, { type: 'warning', bordered: false }, { default: () => `v${row.pendingVersion}` })
: '--';
},
},
{ title: '版本数', key: 'keyCount', align: 'left', width: 90 },
{
title: '最后轮换时间',
key: 'lastRotatedAt',
align: 'left',
width: 180,
render(row: State) {
return row.lastRotatedAt || '--';
},
},
];