选择器筛选条件,页面无法展示所选内容
<div class="search">
<div class="select">
<span class="demonstration">选择省份:</span>
<el-select
v-model="selectProv"
clearable
placeholder="选择查询的省份"
style="width: 240px"
@change="provChange"
>
<el-option
v-for="item in prov"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<span class="demonstration">选择月份:</span>
<el-date-picker
v-model="selectMonth"
type="months"
placeholder="选择月份"
@change="monthChange"
/>
<button class="btn1" @change="handleQuery">查询</button>
<button class="btn1" @change="handleReset">重置</button>
</div>
</div>
const selectProv = ref<string | null>(null);
const prov = computed(() => {
const options = new Set(tableData.value.map((item) => item.prov_nm));
return Array.from(options).map((option) => ({
label: option,
value: option,
}));
});
const selectMonth = ref<any | null>(null);
const months = computed(() => {
const options = new Set(tableData.value.map((item) => item.month));
return Array.from(options).map((option) => ({
label: option,
value: option,
}));
});
const data = computed(() => {
if (!selectMonth.value) {
return tableData.value;
}
return tableData.value.filter((item) => item.month === selectProv.value);
});
const monthChange = (value: any) => {
selectMonth.value = value;
};
const data = computed(() => {
if (!selectProv.value) {
return tableData.value;
}
return tableData.value.filter((item) => item.prov_nm === selectProv.value);
});
const provChange = () => {
currentPage.value = 1;
};
const handleQuery = () => {
// 当点击查询按钮时,重置分页到第一页
currentPage.value = 1;
// 确保DOM更新完成
nextTick(() => {
console.log("查询完成,当前页数据:", currentPageData.value);
});
};
const handleReset = () => {
// 当点击重置按钮时,清除选择器的值并重置分页到第一页
selectProv.value = null;
currentPage.value = 1;
// 确保DOM更新完成
nextTick(() => {
console.log("重置完成,当前页数据:", currentPageData.value);
});
};
const handlePageChange = (newPage: number) => {
currentPage.value = newPage;
};