2020-09-28 20:19:10 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="m-4">
|
|
|
|
|
<CollapseContainer title="基础示例">
|
|
|
|
|
<BasicForm
|
|
|
|
|
:labelWidth="100"
|
|
|
|
|
:schemas="schemas"
|
|
|
|
|
:actionColOptions="{ span: 24 }"
|
|
|
|
|
@submit="handleSubmit"
|
|
|
|
|
/>
|
|
|
|
|
</CollapseContainer>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script lang="ts">
|
2020-11-13 00:42:52 +08:00
|
|
|
import { defineComponent, ref } from 'vue';
|
2020-09-28 20:19:10 +08:00
|
|
|
import { BasicForm, FormSchema } from '/@/components/Form/index';
|
|
|
|
|
import { CollapseContainer } from '/@/components/Container/index';
|
|
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
2020-11-13 00:42:52 +08:00
|
|
|
|
2020-09-28 20:19:10 +08:00
|
|
|
const schemas: FormSchema[] = [
|
|
|
|
|
{
|
|
|
|
|
field: 'field1',
|
|
|
|
|
component: 'Input',
|
|
|
|
|
label: '字段1',
|
|
|
|
|
colProps: {
|
|
|
|
|
span: 8,
|
|
|
|
|
},
|
2020-11-13 00:42:52 +08:00
|
|
|
// componentProps:{},
|
|
|
|
|
// can func
|
|
|
|
|
componentProps: ({ schema, formModel }) => {
|
|
|
|
|
console.log('form:', schema);
|
|
|
|
|
console.log('formModel:', formModel);
|
2020-11-10 22:30:52 +08:00
|
|
|
return {
|
|
|
|
|
placeholder: '自定义placeholder',
|
|
|
|
|
onChange: (e: any) => {
|
|
|
|
|
console.log(e);
|
|
|
|
|
},
|
|
|
|
|
};
|
2020-09-28 20:19:10 +08:00
|
|
|
},
|
2020-11-13 00:42:52 +08:00
|
|
|
renderComponentContent: () => {
|
|
|
|
|
return {
|
|
|
|
|
prefix: () => 'pSlot',
|
|
|
|
|
suffix: () => 'sSlot',
|
|
|
|
|
};
|
|
|
|
|
},
|
2020-09-28 20:19:10 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'field2',
|
|
|
|
|
component: 'Input',
|
|
|
|
|
label: '字段2',
|
2020-11-13 00:42:52 +08:00
|
|
|
defaultValue: '111',
|
2020-09-28 20:19:10 +08:00
|
|
|
colProps: {
|
|
|
|
|
span: 8,
|
|
|
|
|
},
|
2020-11-13 00:42:52 +08:00
|
|
|
componentProps: {
|
|
|
|
|
onChange: (e: any) => {
|
|
|
|
|
console.log(e);
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-09-28 20:19:10 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'field3',
|
|
|
|
|
component: 'DatePicker',
|
|
|
|
|
label: '字段3',
|
|
|
|
|
colProps: {
|
|
|
|
|
span: 8,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'field4',
|
|
|
|
|
component: 'Select',
|
|
|
|
|
label: '字段4',
|
|
|
|
|
colProps: {
|
|
|
|
|
span: 8,
|
|
|
|
|
},
|
|
|
|
|
componentProps: {
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: '选项1',
|
|
|
|
|
value: '1',
|
|
|
|
|
key: '1',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '选项2',
|
|
|
|
|
value: '2',
|
|
|
|
|
key: '2',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'field5',
|
|
|
|
|
component: 'CheckboxGroup',
|
|
|
|
|
label: '字段5',
|
|
|
|
|
colProps: {
|
|
|
|
|
span: 8,
|
|
|
|
|
},
|
|
|
|
|
componentProps: {
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: '选项1',
|
|
|
|
|
value: '1',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '选项2',
|
|
|
|
|
value: '2',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'field7',
|
|
|
|
|
component: 'RadioGroup',
|
|
|
|
|
label: '字段7',
|
|
|
|
|
colProps: {
|
|
|
|
|
span: 8,
|
|
|
|
|
},
|
|
|
|
|
componentProps: {
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: '选项1',
|
|
|
|
|
value: '1',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '选项2',
|
|
|
|
|
value: '2',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-11-13 00:42:52 +08:00
|
|
|
{
|
|
|
|
|
field: 'field8',
|
|
|
|
|
component: 'Checkbox',
|
|
|
|
|
label: '字段8',
|
|
|
|
|
colProps: {
|
|
|
|
|
span: 8,
|
|
|
|
|
},
|
|
|
|
|
renderComponentContent: 'Check',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'field9',
|
|
|
|
|
component: 'Switch',
|
|
|
|
|
label: '字段9',
|
|
|
|
|
colProps: {
|
|
|
|
|
span: 8,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'field10',
|
|
|
|
|
component: 'RadioButtonGroup',
|
|
|
|
|
label: '字段10',
|
|
|
|
|
colProps: {
|
|
|
|
|
span: 8,
|
|
|
|
|
},
|
|
|
|
|
componentProps: {
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: '选项1',
|
|
|
|
|
value: '1',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '选项2',
|
|
|
|
|
value: '2',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'field11',
|
|
|
|
|
component: 'Cascader',
|
|
|
|
|
label: '字段11',
|
|
|
|
|
colProps: {
|
|
|
|
|
span: 8,
|
|
|
|
|
},
|
|
|
|
|
componentProps: {
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
value: 'zhejiang',
|
|
|
|
|
label: 'Zhejiang',
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
value: 'hangzhou',
|
|
|
|
|
label: 'Hangzhou',
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
value: 'xihu',
|
|
|
|
|
label: 'West Lake',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'jiangsu',
|
|
|
|
|
label: 'Jiangsu',
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
value: 'nanjing',
|
|
|
|
|
label: 'Nanjing',
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
value: 'zhonghuamen',
|
|
|
|
|
label: 'Zhong Hua Men',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-09-28 20:19:10 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
components: { BasicForm, CollapseContainer },
|
|
|
|
|
setup() {
|
2020-11-13 00:42:52 +08:00
|
|
|
const check = ref(null);
|
2020-09-28 20:19:10 +08:00
|
|
|
const { createMessage } = useMessage();
|
|
|
|
|
return {
|
|
|
|
|
schemas,
|
|
|
|
|
handleSubmit: (values: any) => {
|
|
|
|
|
createMessage.success('click search,values:' + JSON.stringify(values));
|
|
|
|
|
},
|
2020-11-13 00:42:52 +08:00
|
|
|
check,
|
2020-09-28 20:19:10 +08:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
</script>
|