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

update

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