fix : 完善页面细节
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
<template>
|
||||
<el-form
|
||||
:model="form"
|
||||
v-bind="$attrs"
|
||||
label-width="auto"
|
||||
ref="formInstance"
|
||||
class="search-form"
|
||||
:model="form"
|
||||
v-bind="$attrs"
|
||||
label-width="auto"
|
||||
ref="formInstance"
|
||||
class="search-form"
|
||||
>
|
||||
<el-row>
|
||||
<el-col
|
||||
v-for="(item, index) in filterConfig"
|
||||
:span="5"
|
||||
:offset="index == 0 || index / 4 ==1 ? 0 : 1"
|
||||
:key="item.prop"
|
||||
>
|
||||
<el-form-item
|
||||
v-bind="item"
|
||||
v-for="(item, index) in filterConfig"
|
||||
:span="5"
|
||||
:offset="index == 0 || index / 4 ==1 ? 0 : 1"
|
||||
:key="item.prop"
|
||||
>
|
||||
<el-form-item
|
||||
v-bind="item"
|
||||
:key="item.prop"
|
||||
>
|
||||
<template #default>
|
||||
<component
|
||||
:is="item.component"
|
||||
v-bind="item.props || {}"
|
||||
v-on="item.on || {}"
|
||||
v-model="form[item.prop]"
|
||||
<component
|
||||
:is="item.component"
|
||||
v-bind="item.props || {}"
|
||||
v-on="item.on || {}"
|
||||
v-model="form[item.prop]"
|
||||
>
|
||||
</component>
|
||||
</template>
|
||||
@@ -33,7 +33,7 @@
|
||||
<el-button v-if="searchConfig.length>=4" link type="primary" @click="showMore = !showMore">
|
||||
{{ showMore ? '收起' : '展开' }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="getValues" :icon="Search">搜索</el-button>
|
||||
<el-button @click="getValues" color="#DED0B2" :icon="Search">搜索</el-button>
|
||||
<el-button @click="handleReset" :icon="Refresh">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -58,22 +58,22 @@ const formInstance = ref(null)
|
||||
|
||||
const showMore = ref(false)
|
||||
|
||||
const filterConfig = computed(()=>{
|
||||
const arr = props.searchConfig.filter(item=>{
|
||||
if(item.prop) return true
|
||||
const filterConfig = computed(() => {
|
||||
const arr = props.searchConfig.filter(item => {
|
||||
if (item.prop) return true
|
||||
})
|
||||
return arr.length >= 4 && showMore.value ? arr : arr.slice(0, 3)
|
||||
})
|
||||
|
||||
// 搜索功能表单元素默认值
|
||||
const setDefaultFormValues = () => {
|
||||
filterConfig.value.forEach(item=>{
|
||||
filterConfig.value.forEach(item => {
|
||||
form.value[item.prop] = item.props?.defaultValue || null
|
||||
})
|
||||
}
|
||||
|
||||
watchEffect(()=>{
|
||||
if(filterConfig.value.length) {
|
||||
watchEffect(() => {
|
||||
if (filterConfig.value.length) {
|
||||
setDefaultFormValues()
|
||||
}
|
||||
})
|
||||
@@ -90,8 +90,8 @@ const handleReset = () => {
|
||||
emits('search', form.value)
|
||||
}
|
||||
|
||||
onMounted(()=>{
|
||||
emits('getInstance', Object.assign({}, unref(formInstance),{
|
||||
onMounted(() => {
|
||||
emits('getInstance', Object.assign({}, unref(formInstance), {
|
||||
getValues,
|
||||
handleReset,
|
||||
}))
|
||||
@@ -103,9 +103,10 @@ onMounted(()=>{
|
||||
.search-form {
|
||||
padding-top: 18px;
|
||||
}
|
||||
|
||||
.btn-col {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user