Commit 729f2a23 by chenwq

fix(FilterBar): 修复日期选择器最小/最大日期限制及选择器初始值问题

- 为月份选择器添加 minDate 配置支持,避免用户选择过早日期
- 修复日期选择器初始化时未正确设置 pickerViewValue 导致显示异常
- 修复选择器选项更新时序问题,确保选项先更新后设置选中索引
- 移除调试用的 console.log 语句,清理冗余注释代码
1 parent d41c75b0
......@@ -86,15 +86,35 @@ Component({
const filter = this.properties.filters[index];
const currentValue = this.data.formData[filter.key];
let minDate = new Date(2020, 0, 1).getTime();
let maxDate = new Date(new Date().getFullYear() + 5, 11, 31).getTime();
if (filter.minDate) {
let str = filter.minDate;
if (/^\d{4}-\d{2}$/.test(str)) str += "-01";
const d = new Date(str.replace(/-/g, "/"));
if (!isNaN(d.getTime())) minDate = d.getTime();
}
if (filter.maxDate) {
let str = filter.maxDate;
if (/^\d{4}-\d{2}$/.test(str)) str += "-01";
const d = new Date(str.replace(/-/g, "/"));
if (!isNaN(d.getTime())) maxDate = d.getTime();
}
this.setData({
activeFilterIndex: index,
showPopup: true,
formData: this.data.searchObj,
minDate,
maxDate
});
if (filter.type === "month") {
this.initDatePicker(currentValue, filter.pickerType);
} else if (filter.type === "select") {
console.log('99999')
this.initSelectPicker(currentValue);
}
},
......@@ -171,7 +191,7 @@ Component({
if (isNaN(val)) val = new Date().getTime();
}
}
this.setData({ tempDateValue: val });
this.setData({ tempDateValue: val, pickerViewValue: val });
},
onDatePickChange(e) {
this.setData({ tempDateValue: e.detail });
......@@ -232,8 +252,11 @@ Component({
console.log(index, "index---");
this.setData({
tempSelectIndex: index,
currentSelectOptions: optionList, // Store current optionList to use in wxml or change handler
}, () => {
this.setData({
tempSelectIndex: index
})
});
},
......
......@@ -16,6 +16,7 @@ Page({
type: "month",
label: "月份",
key: "reviewMonth",
minDate: "2026-01",
},
{
type: "select",
......@@ -110,7 +111,6 @@ Page({
// let total = 0;
let list = [];
let { code, data, message } = res;
console.log(data)
if (code == 0) {
list = data;
// total = data.total;
......@@ -128,7 +128,7 @@ Page({
flag: true,
triggered: false,
// pageNum: pageNum + 1,
nothing: !!list.length
nothing: !!list.length,
});
});
},
......@@ -165,7 +165,6 @@ Page({
handleDetail(e) {
let { target } = e.currentTarget.dataset;
console.log(target)
wx.navigateTo({
url:
"/packageWorkspace/pages/validReferralCount/referraCountEdit/referraCountEdit?info=" +
......
<!--packageWorkspace/pages/validReferralCount/referralCountList/referralCountList.wxml-->
<!-- <view class="container">
<view class="result-area" style="padding: 20rpx; margin-top: 20rpx;">
<view>筛选结果:</view>
<view>搜索内容:{{searchObj.merchantName || '无'}}</view>
<view>选中月份:{{searchObj.reviewMonth || '无'}}</view>
<view>选中状态:{{searchObj.status || '无'}}</view>
</view>
</view> -->
<view class="list-page">
<view class="top-box">
<FilterBar searchPlaceholder="门店名称" searchKey="merchantName" filters="{{filterConfig}}" searchObj="{{searchObj}}" bind:filterChange="onFilterChange"></FilterBar>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!