index.vue
2.39 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
<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';
enum ActiveKey {
RULE = 'rule',
TCP = 'tco',
}
const ruleChainTableRefEl = ref<Nullable<InstanceType<typeof RuleChainConversionScript>>>(null);
const tcpTableRefEl = ref<Nullable<InstanceType<typeof TcpConversionScript>>>(null);
const searchInfo = ref<Recordable>({});
const activeKey = ref(ActiveKey.RULE);
const [register, { getFieldsValue }] = useForm({
schemas: searchFormSchema,
labelWidth: 120,
showAdvancedButton: true,
compact: true,
fieldMapToTime: [['createTime', ['startTime', 'endTime'], 'x']],
submitFunc: async () => {
const value = getFieldsValue();
searchInfo.value = value;
console.log(searchInfo);
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" />
<main class="mt-4">
<Tabs v-model:activeKey="activeKey" type="card" class="w-full h-full bg-light-50 !p-4">
<Tabs.TabPane tab="规则链转换脚本" :key="ActiveKey.RULE">
<RuleChainConversionScript
ref="ruleChainTableRefEl"
:search-info="searchInfo"
class="p-4 bg-neutral-100"
/>
</Tabs.TabPane>
<Tabs.TabPane tab="TCP转换脚本" :key="ActiveKey.TCP">
<TcpConversionScript
ref="tcpTableRefEl"
:search-info="searchInfo"
class="p-4 bg-neutral-100"
/>
</Tabs.TabPane>
</Tabs>
</main>
</section>
</template>
<style lang="less" scoped>
.rule-script-manage-form {
:deep(.ant-row) {
@apply w-full;
}
}
</style>