|
|
|
@ -1,27 +1,58 @@
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { reactive } from 'vue'
|
|
|
|
import { reactive, ref, onMounted } from 'vue'
|
|
|
|
import { ElConfigProvider, ElIcon } from 'element-plus'
|
|
|
|
import { ElConfigProvider, ElIcon } from 'element-plus'
|
|
|
|
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
|
|
|
|
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
|
|
|
|
// import en from 'element-plus/lib/locale/lang/en'
|
|
|
|
// import en from 'element-plus/lib/locale/lang/en'
|
|
|
|
import { VFrom } from '@/components/Form'
|
|
|
|
import { VFrom } from '@/components/Form'
|
|
|
|
import Calendar from '~icons/ep/calendar'
|
|
|
|
import Calendar from '~icons/ep/calendar'
|
|
|
|
|
|
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const restaurants = ref<Recordable[]>([])
|
|
|
|
|
|
|
|
const querySearch = (queryString: string, cb: Fn) => {
|
|
|
|
|
|
|
|
const results = queryString
|
|
|
|
|
|
|
|
? restaurants.value.filter(createFilter(queryString))
|
|
|
|
|
|
|
|
: restaurants.value
|
|
|
|
|
|
|
|
// call callback function to return suggestions
|
|
|
|
|
|
|
|
cb(results)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const createFilter = (queryString: string) => {
|
|
|
|
|
|
|
|
return (restaurant: Recordable) => {
|
|
|
|
|
|
|
|
return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const loadAll = () => {
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
|
|
|
{ value: 'vue', link: 'https://github.com/vuejs/vue' },
|
|
|
|
|
|
|
|
{ value: 'element', link: 'https://github.com/ElemeFE/element' },
|
|
|
|
|
|
|
|
{ value: 'cooking', link: 'https://github.com/ElemeFE/cooking' },
|
|
|
|
|
|
|
|
{ value: 'mint-ui', link: 'https://github.com/ElemeFE/mint-ui' },
|
|
|
|
|
|
|
|
{ value: 'vuex', link: 'https://github.com/vuejs/vuex' },
|
|
|
|
|
|
|
|
{ value: 'vue-router', link: 'https://github.com/vuejs/vue-router' },
|
|
|
|
|
|
|
|
{ value: 'babel', link: 'https://github.com/babel/babel' }
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const handleSelect = (item: Recordable) => {
|
|
|
|
|
|
|
|
console.log(item)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
|
|
restaurants.value = loadAll()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const schema = reactive<VFormSchema[]>([
|
|
|
|
const schema = reactive<VFormSchema[]>([
|
|
|
|
{
|
|
|
|
{
|
|
|
|
field: 'field1',
|
|
|
|
field: 'field1',
|
|
|
|
component: 'Divider',
|
|
|
|
label: t('formDemo.input'),
|
|
|
|
componentProps: {
|
|
|
|
component: 'Divider'
|
|
|
|
text: 'Input'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
field: 'field2',
|
|
|
|
field: 'field2',
|
|
|
|
label: 'default',
|
|
|
|
label: t('formDemo.default'),
|
|
|
|
component: 'Input'
|
|
|
|
component: 'Input'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
field: 'field3',
|
|
|
|
field: 'field3',
|
|
|
|
label: 'input-icon1',
|
|
|
|
label: `${t('formDemo.icon')}1`,
|
|
|
|
component: 'Input',
|
|
|
|
component: 'Input',
|
|
|
|
componentProps: {
|
|
|
|
componentProps: {
|
|
|
|
suffixIcon: Calendar,
|
|
|
|
suffixIcon: Calendar,
|
|
|
|
@ -30,7 +61,7 @@ const schema = reactive<VFormSchema[]>([
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
field: 'field4',
|
|
|
|
field: 'field4',
|
|
|
|
label: 'input-icon2',
|
|
|
|
label: `${t('formDemo.icon')}2`,
|
|
|
|
component: 'Input',
|
|
|
|
component: 'Input',
|
|
|
|
componentProps: {
|
|
|
|
componentProps: {
|
|
|
|
slots: {
|
|
|
|
slots: {
|
|
|
|
@ -41,7 +72,7 @@ const schema = reactive<VFormSchema[]>([
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
field: 'field5',
|
|
|
|
field: 'field5',
|
|
|
|
label: 'input-mixed',
|
|
|
|
label: t('formDemo.mixed'),
|
|
|
|
component: 'Input',
|
|
|
|
component: 'Input',
|
|
|
|
componentProps: {
|
|
|
|
componentProps: {
|
|
|
|
slots: {
|
|
|
|
slots: {
|
|
|
|
@ -52,7 +83,7 @@ const schema = reactive<VFormSchema[]>([
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
field: 'field6',
|
|
|
|
field: 'field6',
|
|
|
|
label: 'textarea',
|
|
|
|
label: t('formDemo.textarea'),
|
|
|
|
component: 'Input',
|
|
|
|
component: 'Input',
|
|
|
|
componentProps: {
|
|
|
|
componentProps: {
|
|
|
|
type: 'textarea',
|
|
|
|
type: 'textarea',
|
|
|
|
@ -61,10 +92,152 @@ const schema = reactive<VFormSchema[]>([
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
field: 'field7',
|
|
|
|
field: 'field7',
|
|
|
|
|
|
|
|
label: t('formDemo.autocomplete'),
|
|
|
|
|
|
|
|
component: 'Divider'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
field: 'field8',
|
|
|
|
|
|
|
|
label: t('formDemo.default'),
|
|
|
|
|
|
|
|
component: 'Autocomplete',
|
|
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
|
|
fetchSuggestions: querySearch,
|
|
|
|
|
|
|
|
onSelect: handleSelect
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
field: 'field9',
|
|
|
|
|
|
|
|
label: t('formDemo.slot'),
|
|
|
|
|
|
|
|
component: 'Autocomplete',
|
|
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
|
|
fetchSuggestions: querySearch,
|
|
|
|
|
|
|
|
onSelect: handleSelect,
|
|
|
|
|
|
|
|
slots: {
|
|
|
|
|
|
|
|
default: true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
field: 'field10',
|
|
|
|
component: 'Divider',
|
|
|
|
component: 'Divider',
|
|
|
|
componentProps: {
|
|
|
|
componentProps: {
|
|
|
|
text: 'Autocomplete'
|
|
|
|
text: t('formDemo.inputNumber')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
field: 'field11',
|
|
|
|
|
|
|
|
label: t('formDemo.default'),
|
|
|
|
|
|
|
|
component: 'InputNumber'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
field: 'field11',
|
|
|
|
|
|
|
|
label: t('formDemo.position'),
|
|
|
|
|
|
|
|
component: 'InputNumber',
|
|
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
|
|
controlsPosition: 'right'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
field: 'field12',
|
|
|
|
|
|
|
|
label: t('formDemo.select'),
|
|
|
|
|
|
|
|
component: 'Divider'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
field: 'field13',
|
|
|
|
|
|
|
|
label: t('formDemo.default'),
|
|
|
|
|
|
|
|
component: 'Select',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项1',
|
|
|
|
|
|
|
|
value: '1'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项2',
|
|
|
|
|
|
|
|
value: '2'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
field: 'field14',
|
|
|
|
|
|
|
|
label: t('formDemo.slot'),
|
|
|
|
|
|
|
|
component: 'Select',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项1',
|
|
|
|
|
|
|
|
value: '1'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项2',
|
|
|
|
|
|
|
|
value: '2'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
optionsSlot: true
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
field: 'field15',
|
|
|
|
|
|
|
|
label: t('formDemo.group'),
|
|
|
|
|
|
|
|
component: 'Select',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项1',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项1-1',
|
|
|
|
|
|
|
|
value: '1-1'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项1-2',
|
|
|
|
|
|
|
|
value: '1-2'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项2',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项2-1',
|
|
|
|
|
|
|
|
value: '2-1'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项2-2',
|
|
|
|
|
|
|
|
value: '2-2'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
field: 'field16',
|
|
|
|
|
|
|
|
label: `${t('formDemo.group')}${t('formDemo.slot')}`,
|
|
|
|
|
|
|
|
component: 'Select',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项1',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项1-1',
|
|
|
|
|
|
|
|
value: '1-1'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项1-2',
|
|
|
|
|
|
|
|
value: '1-2'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项2',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项2-1',
|
|
|
|
|
|
|
|
value: '2-1'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '选项2-2',
|
|
|
|
|
|
|
|
value: '2-2'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
optionsSlot: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])
|
|
|
|
])
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
@ -81,6 +254,25 @@ const schema = reactive<VFormSchema[]>([
|
|
|
|
|
|
|
|
|
|
|
|
<template #field5-prepend> Http:// </template>
|
|
|
|
<template #field5-prepend> Http:// </template>
|
|
|
|
<template #field5-append> .com </template>
|
|
|
|
<template #field5-append> .com </template>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template #field9-default="{ item }">
|
|
|
|
|
|
|
|
<div class="value">{{ item.value }}</div>
|
|
|
|
|
|
|
|
<span class="link">{{ item.link }}</span>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template #field14-option="item">
|
|
|
|
|
|
|
|
<span style="float: left">{{ item.label }}</span>
|
|
|
|
|
|
|
|
<span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">{{
|
|
|
|
|
|
|
|
item.value
|
|
|
|
|
|
|
|
}}</span>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template #field16-option="item">
|
|
|
|
|
|
|
|
<span style="float: left">{{ item.label }}</span>
|
|
|
|
|
|
|
|
<span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">{{
|
|
|
|
|
|
|
|
item.value
|
|
|
|
|
|
|
|
}}</span>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
</VFrom>
|
|
|
|
</VFrom>
|
|
|
|
</ElConfigProvider>
|
|
|
|
</ElConfigProvider>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|