pc_vue_admin/src/components/DynamicSearchForm/index.vue

57 lines
1.1 KiB
Vue

<template>
<a-form :model="model" :rules="rules" layout="vertical" ref="searchFormRef">
<a-row :gutter="16">
<a-col :span="6" v-for="(item, index) in formItems" :key="index">
<a-form-item :label="item.label" :name="item.name" :rules="item.rules">
<component
style="width: 100%"
:is="item.type"
v-model:value="model[item.name]"
:disabled="allDisabled"
v-bind="item.attrs"
/>
</a-form-item>
</a-col>
<a-col :span="6">
<a-button type="primary">查询</a-button>
<a-button style="margin: 0 8px">重置</a-button>
</a-col>
</a-row>
</a-form>
</template>
<script setup>
import { ref, watch } from 'vue'
const props = defineProps({
formItems: {
type: Array,
required: true
},
model: {
type: Object,
required: true
},
rules: {
type: Object,
default: () => ({})
},
allDisabled: {
type: Boolean,
default: false
}
})
const searchFormRef = ref(null)
// Expose validate method
defineExpose({
validate: () => searchFormRef.value.validate(),
resetFields: () => searchFormRef.value.resetFields()
})
</script>
<style scoped>
/* Add your styles here */
</style>