index.vue
3.24 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<script lang="ts" setup>
import { Tabs } from 'ant-design-vue';
import { RuleChainConversionScript } from './RuleChainConversionScript';
import { TcpConversionScript } from './TcpConversionScript';
import { BasicForm, useForm } from '/@/components/Form';
import { searchFormSchema } from './config/config.data';
import { nextTick, ref, unref } from 'vue';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n(); // 加载国际化
import { usePermission } from '/@/hooks/web/usePermission';
enum ActiveKey {
RULE = 'rule',
TCP = 'tco',
}
enum ActiveKeyName {
RULE = t('rule.script.index.ruleChainConversionScript') as any,
TCP = t('rule.script.index.tcpChainConversionScript') as any,
}
const { hasPermission } = usePermission();
const ruleChainTableRefEl = ref<Nullable<InstanceType<typeof RuleChainConversionScript>>>(null);
const tcpTableRefEl = ref<Nullable<InstanceType<typeof TcpConversionScript>>>(null);
const searchInfo = ref<Recordable>({});
const activeKey = ref(ActiveKey.TCP);
const syncValue = (value: Recordable) => {
searchInfo.value = { ...unref(searchInfo), ...value };
};
const [register, { getFieldsValue }] = useForm({
schemas: searchFormSchema(syncValue),
labelWidth: 120,
showAdvancedButton: true,
compact: true,
actionColOptions: { span: 4 },
fieldMapToTime: [['createTime', ['startTime', 'endTime'], 'x']],
submitFunc: async () => {
const value = getFieldsValue();
searchInfo.value = value;
await nextTick();
if (unref(activeKey) === ActiveKey.RULE) {
unref(ruleChainTableRefEl)?.reload();
} else {
unref(tcpTableRefEl)?.reload();
}
},
resetFunc: async () => {
searchInfo.value = {};
await nextTick();
if (unref(activeKey) === ActiveKey.RULE) {
unref(ruleChainTableRefEl)?.reload();
} else {
unref(tcpTableRefEl)?.reload();
}
},
});
</script>
<template>
<section class="w-full h-full p-4">
<BasicForm
@register="register"
class="rule-script-manage-form w-full bg-light-50 !pt-4 dark:bg-dark-900"
/>
<main class="mt-4">
<Tabs
v-model:activeKey="activeKey"
type="card"
class="w-full h-full bg-light-50 !p-4 dark:bg-dark-900"
>
<Tabs.TabPane :tab="ActiveKeyName.TCP" :key="ActiveKey.TCP">
<TcpConversionScript
ref="tcpTableRefEl"
:search-info="searchInfo"
class="p-4 bg-neutral-100 dark:bg-dark-700"
/>
</Tabs.TabPane>
<Tabs.TabPane
:tab="ActiveKeyName.RULE"
v-if="
hasPermission([
'api:yt:convert:js:delete',
'api:yt:convert:js:post',
'api:yt:convert:js:update',
'api:yt:convert:js:get',
])
"
:key="ActiveKey.RULE"
>
<RuleChainConversionScript
ref="ruleChainTableRefEl"
:search-info="searchInfo"
class="p-4 bg-neutral-100 dark:bg-dark-700"
/>
</Tabs.TabPane>
</Tabs>
</main>
</section>
</template>
<style lang="less" scoped>
.rule-script-manage-form {
:deep(.ant-row) {
@apply w-full;
}
}
</style>