config.data.ts
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { BasicColumn, FormSchema } from '/@/components/Table';
import { transformTime } from '/@/hooks/web/useDateToLocaleString';
import { isObject, isString } from '/@/utils/is';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n(); // 加载国际化
export const columns: BasicColumn[] = [
{
title: t('rule.chain.index.createTime'),
dataIndex: 'createdTime',
width: 200,
format: (_text: string, record: Recordable) => {
return transformTime(record.createdTime);
},
},
{
title: t('rule.chain.index.name'),
dataIndex: 'name',
width: 200,
},
{
title: t('rule.chain.index.isRootChain'),
dataIndex: 'root',
slots: {
customRender: 'root',
},
width: 200,
},
];
export const searchFormSchema: FormSchema[] = [
{
field: 'textSearch',
label: t('rule.chain.index.name'),
component: 'Input',
colProps: { span: 8 },
componentProps: {
placeholder: t('rule.chain.index.pleasePlaceholder'),
},
},
];
export const encode = (string: string) => {
return encodeURIComponent(string);
};
export const exportJSONFile = (value: Recordable, name: string) => {
const blob = new Blob([JSON.stringify(value, null, 2)], { type: 'text/json' });
const objectURL = URL.createObjectURL(blob);
const element = document.createElement('a');
element.href = objectURL;
element.download = `${name}.json`;
element.style.display = 'none';
document.body.appendChild(element);
element.click();
element.remove();
URL.revokeObjectURL(objectURL);
};
export const paseJSON = (string: string) => {
let data = null;
let flag = false;
try {
if (!isString(string)) return { flag: false, data };
data = JSON.parse(string);
flag = true;
if (!isObject(data)) flag = false;
} catch (error) {}
return { flag, data };
};
export enum RuleChainPermisssion {
DETAIL = 'rule:chain:detail',
}