提交 271c6e95 编写于 作者: 吴上海's avatar 吴上海 🤡

update

上级 15a7f651
<script setup> <script setup>
import { resolveComponent, h } from 'vue' import { resolveComponent, h, reactive, ref } from 'vue'
const ElForm = resolveComponent('ElForm') const ElForm = resolveComponent('ElForm')
const ElFormItem = resolveComponent('ElFormItem') const ElFormItem = resolveComponent('ElFormItem')
const ElInput = resolveComponent('ElInput')
const ElButton = resolveComponent('ElButton')
const props = defineProps({ const props = defineProps({
schema: Object, schema: Object,
}) })
const emit = defineEmits(['click']) const emit = defineEmits(['event'])
const { const {
table: { column }, table: { column },
search, search,
} = props.schema } = props.schema
const list = [...search, ...column.filter((item) => item.search)]
const render = () => { let formAttrs = {}
search.forEach((item) => {
if (item.prop) formAttrs[item.prop] = ''
})
let form = reactive(formAttrs)
const components = search.map((item) => {
return h(ElFormItem, item, () => {
return h( return h(
ElForm, resolveComponent(item.typedef),
{ {
inline: true, ...item,
modelValue: form[item.prop],
onInput: function (value) {
if (item.typedef === 'ElInput') form[item.prop] = value
}, },
() => [ // onChange: function (value) {
...list.map((item) => h(ElFormItem, item, () => h(ElInput, item))), // form[item.prop] = value
h(ElFormItem, null, () => // },
h( onClick: function () {
ElButton, if (item.typedef === 'ElButton')
{ emit('event', {
type: 'primary',
onClick() {
emit('click', {
handle: item.handle, handle: item.handle,
}) })
}, },
}, },
() => '查询' () => (item.typedef === 'ElButton' ? item.label : '')
) )
), })
] })
const render = () => {
return h(
ElForm,
{
inline: true,
},
() => components
) )
} }
</script> </script>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
}) })
const { tools } = props.schema const { tools } = props.schema
const emit = defineEmits(['click']) const emit = defineEmits(['event'])
const render = () => { const render = () => {
return h( return h(
'div', 'div',
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
{ {
...item, ...item,
onClick() { onClick() {
emit('click', { emit('event', {
handle: item.handle, handle: item.handle,
}) })
}, },
......
<template> <template>
<ElSearch :schema="schema" /> <ElSearch :schema="schema" @event="handles" />
<ElTools :schema="schema" @click="handles" /> <ElTools :schema="schema" @event="handles" />
<ElTable :schema="schema" :data="data" /> <ElTable :schema="schema" :data="data" />
</template> </template>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册