预算选择默认年份规则调整

master
weizong song 2 weeks ago
parent 905ff712be
commit 4ca6cf3c61

@ -606,9 +606,9 @@ export default {
}
if (!this.yearId && this.yearOptions.length > 0) {
// value year_id
// value year_id退退
const fromValue = await this.tryResolveYearIdByValue();
this.yearId = fromValue || this.yearOptions[0].value;
this.yearId = fromValue || this.getCurrentYearOptionValue() || this.yearOptions[0].value;
}
if (this.yearId) {
@ -629,6 +629,13 @@ export default {
this.yearLoading = false;
}
},
getCurrentYearOptionValue() {
const currentYear = new Date().getFullYear();
const matched = (this.yearOptions || []).find(
(y) => String(y.year) === String(currentYear)
);
return matched ? matched.value : null;
},
async tryResolveYearIdByValue() {
if (!this.hasValue) return null;
const idFromValue = this.budgetDataId || (this.budgetItems[0] && this.budgetItems[0].budget_data_id);
@ -1135,7 +1142,10 @@ export default {
// ID
if (!this.yearId) {
const fromValue = await this.tryResolveYearIdByValue();
this.yearId = fromValue || (this.yearOptions.length > 0 ? this.yearOptions[0].value : null);
this.yearId =
fromValue ||
this.getCurrentYearOptionValue() ||
(this.yearOptions.length > 0 ? this.yearOptions[0].value : null);
}
// ID

Loading…
Cancel
Save