index.vue
4.87 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<script lang="ts" setup>
import { BasicDrawer } from '/@/components/Drawer';
import { Tabs, Spin, Empty } from 'ant-design-vue';
import { TabsPanelEnum, TabsPanelNameEnum } from './config';
import { useAwaitPopupWindowBindData } from '../../../hook/useAwaitPopupWindowBindData';
import HelpMessage from './HelpMessage.vue';
import { DataActionModeEnum } from '/@/enums/toolEnum';
import { ElementsTypeEnum } from '../../../enum';
import { useForm, BasicForm } from '/@/components/Form';
import { BottomFormSchemas, TopFormSchemas } from '../CreateNodeModal/config';
import { toRaw, unref } from 'vue';
import { BasicEvents } from './BasicEvents';
const [topFormRegister, topFormActionType] = useForm({
schemas: TopFormSchemas,
showActionButtonGroup: false,
});
const [bottomFormRegister, bottomFormActionType] = useForm({
schemas: BottomFormSchemas,
showActionButtonGroup: false,
});
const {
visible,
spinning,
nodeData,
elementInfo,
getComponentKey,
shadowComponent,
createComponentEl,
open,
handleCancel,
handleSubmit,
handleOnMounted,
} = useAwaitPopupWindowBindData({ mode: DataActionModeEnum.UPDATE, type: ElementsTypeEnum.NODE });
const handleTopFormMounted = () => {
const data = unref(nodeData)?.data || {};
topFormActionType.setFieldsValue(toRaw(unref(data)));
};
const handleBottomFormMounted = () => {
const data = unref(nodeData)?.data || {};
bottomFormActionType.setFieldsValue(toRaw(unref(data)));
};
const validate = async () => {
await topFormActionType.validate();
await bottomFormActionType.validate();
};
const getFieldsValue = () => {
const topValue = topFormActionType.getFieldsValue() || {};
const bottomValue = bottomFormActionType.getFieldsValue() || {};
return {
...topValue,
...bottomValue,
};
};
const resetFieldsValue = () => {
topFormActionType.resetFields();
bottomFormActionType.resetFields();
};
const handleModalOk = async () => {
await validate();
const data = getFieldsValue();
await handleSubmit(data);
resetFieldsValue();
};
defineExpose({
open,
});
</script>
<template>
<BasicDrawer
v-model:visible="visible"
width="40%"
showFooter
showCancelBtn
showOkBtn
@ok="handleModalOk"
@close="handleCancel"
wrapper-class-name="rule-node-update-drawer"
>
<template #title>
<h2 class="font-bold text-2xl truncate">{{ nodeData?.data?.name }}</h2>
<p class="mb-0 text-gray-700">
<span> {{ nodeData?.categoryConfig?.title }}</span>
<span class="mx-1">-</span>
<span>{{ nodeData?.config?.name }}</span>
</p>
</template>
<Tabs>
<Tabs.TabPane :tab="TabsPanelNameEnum[TabsPanelEnum.DETAIL]" :key="TabsPanelEnum.DETAIL">
<Spin :spinning="spinning">
<section v-if="shadowComponent" class="w-full h-full overflow-y-auto pr-4">
<BasicForm @register="topFormRegister" @vue:mounted="handleTopFormMounted" />
<component
class="rule-node-form"
:is="shadowComponent"
ref="createComponentEl"
:config="nodeData"
:key="getComponentKey"
@vue:mounted="handleOnMounted"
/>
<BasicForm @register="bottomFormRegister" @vue:mounted="handleBottomFormMounted" />
</section>
<Empty v-if="!shadowComponent" description="未找到链接组件" />
</Spin>
</Tabs.TabPane>
<Tabs.TabPane
v-if="nodeData?.created"
:tab="TabsPanelNameEnum[TabsPanelEnum.EVENT]"
:key="TabsPanelEnum.EVENT"
>
<BasicEvents :elementInfo="elementInfo" />
</Tabs.TabPane>
<Tabs.TabPane :tab="TabsPanelNameEnum[TabsPanelEnum.HELP]" :key="TabsPanelEnum.HELP">
<HelpMessage :nodeData="nodeData" />
</Tabs.TabPane>
</Tabs>
</BasicDrawer>
</template>
<style lang="less" scoped>
.rule-node-form {
:deep(.ant-input-number) {
width: 100%;
min-width: none;
}
}
</style>
<style lang="less">
.rule-node-update-drawer {
.ant-drawer-wrapper-body {
@apply flex flex-col;
.ant-drawer-body {
@apply flex flex-auto overflow-hidden;
.ant-tabs-bar {
box-shadow: 6px -1px 9px 3px #00000040;
}
.scroll-container {
.scrollbar__wrap {
.scrollbar__view {
@apply h-full;
.ant-tabs {
@apply h-full flex flex-col;
.ant-tabs-content {
height: calc(100% - 61px);
}
.ant-spin-nested-loading,
.ant-spin-container {
@apply h-full;
}
}
}
}
}
}
.vben-basic-drawer-footer {
box-shadow: 6px -1px 9px 3px #00000040;
}
}
}
</style>