Skip to content

Commit a9b6de0

Browse files
committed
doc: add form demo
1 parent 72f8277 commit a9b6de0

File tree

2 files changed

+114
-1
lines changed

2 files changed

+114
-1
lines changed
+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<docs>
2+
---
3+
order: 13
4+
title:
5+
zh-CN: 高级搜索
6+
en-US: Advanced search
7+
---
8+
9+
## zh-CN
10+
11+
三列栅格式的表单排列方式,常用于数据表格的高级搜索。
12+
13+
有部分定制的样式代码,由于输入标签长度不确定,需要根据具体情况自行调整。
14+
15+
## en-US
16+
17+
Three columns layout is often used for advanced searching of data table.
18+
19+
Because the width of label is not fixed, you may need to adjust it by customizing its style.
20+
21+
</docs>
22+
<template>
23+
<div>
24+
<a-form
25+
ref="formRef"
26+
name="advanced_search"
27+
class="ant-advanced-search-form"
28+
:model="formState"
29+
@finish="onFinish"
30+
>
31+
<a-row :gutter="24">
32+
<template v-for="i in 10" :key="i">
33+
<a-col v-show="expand || i <= 6" :span="8">
34+
<a-form-item
35+
:name="`field-${i}`"
36+
:label="`field-${i}`"
37+
:rules="[{ required: true, message: 'input something' }]"
38+
>
39+
<a-input v-model:value="formState[`field-${i}`]" placeholder="placeholder"></a-input>
40+
</a-form-item>
41+
</a-col>
42+
</template>
43+
</a-row>
44+
<a-row>
45+
<a-col :span="24" style="text-align: right">
46+
<a-button type="primary" html-type="submit">Search</a-button>
47+
<a-button style="margin: 0 8px" @click="() => formRef.resetFields()">Clear</a-button>
48+
<a style="font-size: 12px" @click="expand = !expand">
49+
<template v-if="expand">
50+
<UpOutlined />
51+
</template>
52+
<template v-else>
53+
<DownOutlined />
54+
</template>
55+
Collapse
56+
</a>
57+
</a-col>
58+
</a-row>
59+
</a-form>
60+
<div class="search-result-list">Search Result List</div>
61+
</div>
62+
</template>
63+
<script lang="ts">
64+
import { defineComponent, reactive, ref } from 'vue';
65+
import { DownOutlined, UpOutlined } from '@ant-design/icons-vue';
66+
import type { FormInstance } from 'ant-design-vue';
67+
export default defineComponent({
68+
components: {
69+
DownOutlined,
70+
UpOutlined,
71+
},
72+
setup() {
73+
const expand = ref(false);
74+
const formRef = ref<FormInstance>();
75+
const formState = reactive({});
76+
const onFinish = (values: any) => {
77+
console.log('Received values of form: ', values);
78+
console.log('formState: ', formState);
79+
};
80+
return {
81+
formRef,
82+
formState,
83+
expand,
84+
onFinish,
85+
};
86+
},
87+
});
88+
</script>
89+
90+
<style>
91+
#components-form-demo-advanced-search .ant-form {
92+
max-width: none;
93+
}
94+
#components-form-demo-advanced-search .search-result-list {
95+
margin-top: 16px;
96+
border: 1px dashed #e9e9e9;
97+
border-radius: 2px;
98+
background-color: #fafafa;
99+
min-height: 200px;
100+
text-align: center;
101+
padding-top: 80px;
102+
}
103+
[data-theme='dark'] .ant-advanced-search-form {
104+
background: rgba(255, 255, 255, 0.04);
105+
border: 1px solid #434343;
106+
padding: 24px;
107+
border-radius: 2px;
108+
}
109+
[data-theme='dark'] #components-form-demo-advanced-search .search-result-list {
110+
border: 1px dashed #434343;
111+
background: rgba(255, 255, 255, 0.04);
112+
}
113+
</style>

site/debugger/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// debugger tsx
2-
import Demo from './demo/demo.vue';
2+
import Demo from '../../components/form/demo/advanced-search.vue';
33

44
export default {
55
setup() {},

0 commit comments

Comments
 (0)