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
| <template>
| <PageWrapper title="代码编辑器组件嵌入Form示例">
| <CollapseContainer title="代码编辑器组件">
| <BasicForm
| :labelWidth="100"
| :schemas="schemas"
| :actionColOptions="{ span: 24 }"
| :baseColProps="{ span: 24 }"
| @submit="handleSubmit"
| />
| </CollapseContainer>
| </PageWrapper>
| </template>
| <script lang="ts" setup>
| import { h } from 'vue';
| import { BasicForm, FormSchema } from '@/components/Form';
| import { CollapseContainer } from '@/components/Container';
| import { useMessage } from '@/hooks/web/useMessage';
| import { PageWrapper } from '@/components/Page';
| import { CodeEditor, MODE } from '@/components/CodeEditor';
|
| const schemas: FormSchema[] = [
| {
| field: 'title',
| component: 'Input',
| label: 'title',
| defaultValue: '标题',
| rules: [{ required: true }],
| },
| {
| field: 'JSON',
| component: 'Input',
| label: 'JSON',
| defaultValue: `{
| "name":"BeJson",
| "url":"http://www.xxx.com",
| "page":88,
| "isNonProfit":true,"
| address:{
| "street":"科技园路.",
| "city":"江苏苏州",
| "country":"中国"
| },
| }`,
| rules: [{ required: true, trigger: 'blur' }],
| render: ({ model, field }) => {
| return h(CodeEditor, {
| value: model[field],
| mode: MODE.JSON,
| onChange: (value: string) => {
| model[field] = value;
| },
| config: {
| tabSize: 10,
| },
| });
| },
| },
| {
| field: 'PYTHON',
| component: 'Input',
| label: 'PYTHON',
| defaultValue: `def functionname( parameters ):
| "函数_文档字符串"
| function_suite
| return [expression]`,
| rules: [{ required: true, trigger: 'blur' }],
| render: ({ model, field }) => {
| return h(CodeEditor, {
| value: model[field],
| mode: MODE.PYTHON,
| onChange: (value: string) => {
| model[field] = value;
| },
| });
| },
| },
| ];
| const { createMessage } = useMessage();
|
| function handleSubmit(values: any) {
| console.log('click search,values:', values);
| createMessage.success('click search,values:' + JSON.stringify(values));
| }
| </script>
|
|