mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 15:37:33 +08:00
use for-of statements to replace for and for-in
This commit is contained in:
@@ -56,6 +56,7 @@ import {
|
||||
useAccountBalanceTrendsChartBase
|
||||
} from '@/components/base/AccountBalanceTrendsChartBase.ts'
|
||||
|
||||
import { itemAndIndex } from '@/core/base.ts';
|
||||
import type { ColorStyleValue } from '@/core/color.ts';
|
||||
import { DEFAULT_CHART_COLORS } from '@/consts/color.ts';
|
||||
|
||||
@@ -88,15 +89,13 @@ const allVirtualListItems = computed<MobileAccountBalanceTrendsChartItem[]>(() =
|
||||
const ret: MobileAccountBalanceTrendsChartItem[] = [];
|
||||
let maxClosingBalance = 0;
|
||||
|
||||
for (let i = 0; i < allDataItems.value.length; i++) {
|
||||
const dataItem = allDataItems.value[i];
|
||||
|
||||
for (const [dataItem, index] of itemAndIndex(allDataItems.value)) {
|
||||
if (dataItem.closingBalance > maxClosingBalance) {
|
||||
maxClosingBalance = dataItem.closingBalance;
|
||||
}
|
||||
|
||||
const finalDataItem: MobileAccountBalanceTrendsChartItem = {
|
||||
index: i,
|
||||
index: index,
|
||||
displayDate: dataItem.displayDate,
|
||||
openingBalance: dataItem.openingBalance,
|
||||
closingBalance: dataItem.closingBalance,
|
||||
@@ -104,18 +103,18 @@ const allVirtualListItems = computed<MobileAccountBalanceTrendsChartItem[]>(() =
|
||||
averageBalance: dataItem.averageBalance,
|
||||
minimumBalance: dataItem.minimumBalance,
|
||||
maximumBalance: dataItem.maximumBalance,
|
||||
color: `#${DEFAULT_CHART_COLORS[0]}`,
|
||||
color: `#${DEFAULT_CHART_COLORS[0] as string}`,
|
||||
percent: 0.0
|
||||
};
|
||||
|
||||
ret.push(finalDataItem);
|
||||
}
|
||||
|
||||
for (let i = 0; i < ret.length; i++) {
|
||||
if (maxClosingBalance > 0 && ret[i].closingBalance > 0) {
|
||||
ret[i].percent = 100.0 * ret[i].closingBalance / maxClosingBalance;
|
||||
for (const item of ret) {
|
||||
if (maxClosingBalance > 0 && item.closingBalance > 0) {
|
||||
item.percent = 100.0 * item.closingBalance / maxClosingBalance;
|
||||
} else {
|
||||
ret[i].percent = 0.0;
|
||||
item.percent = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ import { type CommonScheduleFrequencySelectionProps, useScheduleFrequencySelecti
|
||||
|
||||
import { useUserStore } from '@/stores/user.ts';
|
||||
|
||||
import { itemAndIndex } from '@/core/base.ts';
|
||||
import { type WeekDayValue } from '@/core/datetime.ts';
|
||||
import { ScheduledTemplateFrequencyType } from '@/core/template.ts';
|
||||
import { sortNumbersArray } from '@/lib/common.ts';
|
||||
@@ -117,20 +118,20 @@ function changeFrequencyType(value: number): void {
|
||||
}
|
||||
|
||||
function changeFrequencyValue(e: Event): void {
|
||||
const value = parseInt((e.target as HTMLInputElement).value);
|
||||
const currentValue = parseInt((e.target as HTMLInputElement).value);
|
||||
|
||||
if ((e.target as HTMLInputElement).checked) {
|
||||
for (let i = 0; i < currentFrequencyValue.value.length; i++) {
|
||||
if (currentFrequencyValue.value[i] === value) {
|
||||
for (const value of currentFrequencyValue.value) {
|
||||
if (value === currentValue) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
currentFrequencyValue.value.push(value);
|
||||
currentFrequencyValue.value.push(currentValue);
|
||||
} else {
|
||||
for (let i = 0; i < currentFrequencyValue.value.length; i++) {
|
||||
if (currentFrequencyValue.value[i] === value) {
|
||||
currentFrequencyValue.value.splice(i, 1);
|
||||
for (const [value, index] of itemAndIndex(currentFrequencyValue.value)) {
|
||||
if (value === currentValue) {
|
||||
currentFrequencyValue.value.splice(index, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,9 +103,7 @@ function isPrimaryItemHasSecondaryValue(primaryItem: Record<string, unknown>): b
|
||||
|
||||
const lowerCaseFilterContent = filterContent.value?.toLowerCase() ?? '';
|
||||
|
||||
for (let i = 0; i < subItems.length; i++) {
|
||||
const secondaryItem = subItems[i];
|
||||
|
||||
for (const secondaryItem of subItems) {
|
||||
if (props.secondaryHiddenField && (secondaryItem as Record<string, unknown>)[props.secondaryHiddenField]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user