|
|
@@ -8,6 +8,9 @@ |
|
|
|
<n-form-item v-if="['select'].includes(item.type) " :label="item.label"> |
|
|
|
<n-select v-model:value="getFormOptions.form[item.key]" v-bind="item.props" /> |
|
|
|
</n-form-item> |
|
|
|
<n-form-item v-if="['cascader'].includes(item.type) " :label="item.label"> |
|
|
|
<AreaCascader :ref="el=>{itemRefs[item.refIndex] = el}" v-model:value="getFormOptions.form[item.key]" v-bind="item.props" @selectd="handleSelect" /> |
|
|
|
</n-form-item> |
|
|
|
<n-form-item v-if="['date'].includes(item.type) " :label="item.label"> |
|
|
|
<n-date-picker v-model="getFormOptions.form[item.key]" v-bind="item.props" /> |
|
|
|
</n-form-item> |
|
|
@@ -28,8 +31,10 @@ |
|
|
|
<script> |
|
|
|
import { computed, reactive, ref, unref, toRaw } from 'vue' |
|
|
|
import { NForm } from 'naive-ui' |
|
|
|
import AreaCascader from '@/components/AreaCascader/index.vue' |
|
|
|
export default { |
|
|
|
name: 'SearchPage', |
|
|
|
components: { AreaCascader }, |
|
|
|
props: { |
|
|
|
...NForm.props, |
|
|
|
info: { |
|
|
@@ -41,6 +46,7 @@ export default { |
|
|
|
setup(props, { emit }) { |
|
|
|
const showItemNum = ref(3) |
|
|
|
const len = ref(props.info.length - 1) |
|
|
|
const itemRefs = ref([]) |
|
|
|
const showButton = ref(!!(showItemNum.value < len.value)) |
|
|
|
/* 获取传递的props */ |
|
|
|
const data = reactive({ |
|
|
@@ -50,10 +56,18 @@ export default { |
|
|
|
/* 初始化搜索表单信息 */ |
|
|
|
function initForm() { |
|
|
|
data.info.forEach((item) => { |
|
|
|
form.value[item.key] = null |
|
|
|
if (item.key) form.value[item.key] = '' |
|
|
|
}) |
|
|
|
itemRefs.value.forEach((item) => { |
|
|
|
item.clearValue() |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
function handleSelect(data) { |
|
|
|
form.value = { |
|
|
|
...form.value, |
|
|
|
...data |
|
|
|
} |
|
|
|
} |
|
|
|
const getFormOptions = computed(() => { |
|
|
|
return { |
|
|
|
form: unref(form), |
|
|
@@ -79,6 +93,8 @@ export default { |
|
|
|
getFormOptions, |
|
|
|
handleSearch, |
|
|
|
handleReset, |
|
|
|
handleSelect, |
|
|
|
itemRefs, |
|
|
|
showMoreItem |
|
|
|
} |
|
|
|
} |
|
|
@@ -96,6 +112,9 @@ export default { |
|
|
|
.n-select{ |
|
|
|
width: 200px; |
|
|
|
} |
|
|
|
.n-cascader{ |
|
|
|
width: 200px; |
|
|
|
} |
|
|
|
transition: all 10s; |
|
|
|
} |
|
|
|
.form__button{ |