Commit 0cf28077 by Jaxon

fix(datePicker): 修复搜索事件参数问题并优化事件触发逻辑

优化emitValueChange方法,支持通过参数控制事件触发类型
改造getParams方法允许传入自定义value生成查询参数
调整内部调用逻辑,避免不必要的事件抛出
1 parent 8476b2c6
......@@ -224,7 +224,10 @@ export default {
const nextValue = this.normalizeValueByType(this.value, this.type);
this.applyValueState(nextValue, this.type);
if (this.shouldEmitNormalizedValue(this.value, nextValue)) {
this.emitValueChange(nextValue);
this.emitValueChange(nextValue, {
emitChange: false,
emitSearch: false,
});
}
},
normalizeWeekValue(value) {
......@@ -371,11 +374,10 @@ export default {
this.rightCurrent = target.isSame(dayjs().startOf("day"), "day");
this.leftCurrent = target.isSame(dayjs(this.minDate).startOf("day"), "day");
},
getParams() {
getParams(value = this.currentValue || this.normalizeValueByType(this.value, this.type)) {
const obj = {};
const currentValue = this.currentValue || this.normalizeValueByType(this.value, this.type);
obj.startDay = currentValue?.startDate || "";
obj.endDay = currentValue?.endDate || "";
obj.startDay = value?.startDate || "";
obj.endDay = value?.endDate || "";
obj.timeDimension = this.timeDimension;
return obj;
},
......@@ -394,10 +396,15 @@ export default {
|| !rawDate.isSame(normalizedValue.date, "day");
},
emitValueChange(value, extra = {}) {
const { emitChange = true, emitSearch = true, confirm = false } = extra;
this.$emit("input", value);
this.$emit("change", value);
this.$emit("search", this.getParams());
if (extra.confirm) {
if (emitChange) {
this.$emit("change", value);
}
if (emitSearch) {
this.$emit("search", this.getParams(value));
}
if (confirm) {
this.$emit("confirm", value);
}
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!