fix: years in monalisa type 2

This commit is contained in:
kur0nek-o 2024-04-23 23:28:05 +07:00
parent 428292372e
commit aa16111cc0
3 changed files with 17 additions and 6 deletions

View File

@ -9,8 +9,7 @@ import {
itemsUp3, itemsUp3,
itemsUlp, itemsUlp,
itemsRegional, itemsRegional,
months, months
years
} from './reference' } from './reference'
import { onMounted, ref, watch } from 'vue' import { onMounted, ref, watch } from 'vue'
import { getMonthName } from '@/utils/texts' import { getMonthName } from '@/utils/texts'
@ -37,7 +36,16 @@ if (bulanIndex !== -1) {
months.splice(bulanIndex, 1) months.splice(bulanIndex, 1)
} }
// Find index of current year // Find index of current year
const tahunIndex = years.value.findIndex((year) => year.id === tahun.value.id) const year = new Date().getFullYear()
const years = ref<any>([])
for (let i = 0; i < 5; i++) {
if (i == 0) {
years.value.push({ id: year, name: year })
}
years.value.push({ id: year - i, name: year - i })
}
const tahunIndex = years.value.findIndex((year: any) => year.id === tahun.value.id)
if (tahunIndex !== -1) { if (tahunIndex !== -1) {
years.value.splice(tahunIndex, 1) years.value.splice(tahunIndex, 1)
} }
@ -210,7 +218,7 @@ onMounted(() => {
:data="months" :data="months"
:placeholder="bulanPlaceholder" :placeholder="bulanPlaceholder"
/> />
<Select @update:selected="setYear($event)" :data="years" :placeholder="tahunPlaceholder" /> <Select @update:selected="setYear($event)" :data="years" />
</div> </div>
</div> </div>
</div> </div>

View File

@ -24,6 +24,9 @@ const months = [
const year = new Date().getFullYear() const year = new Date().getFullYear()
const years = ref<Item[]>([]) const years = ref<Item[]>([])
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
if (i == 0) {
years.value.push({ id: year, name: year })
}
years.value.push({ id: year - i, name: year - i }) years.value.push({ id: year - i, name: year - i })
} }
const itemsUid = ref<Item[]>([]) const itemsUid = ref<Item[]>([])

View File

@ -268,7 +268,7 @@
<script setup lang="ts"> <script setup lang="ts">
import Filters from '@/components/Form/Filters.vue' import Filters from '@/components/Form/Filters.vue'
import Type2 from '@/components/Form/FiltersType/Type2.vue' import Type2 from '@/components/Form/FiltersType/Type2.vue'
import { onMounted, ref } from 'vue' import { onMounted, ref, watch } from 'vue'
import { DxDataGrid } from 'devextreme-vue' import { DxDataGrid } from 'devextreme-vue'
import { getMonthName } from '@/utils/texts' import { getMonthName } from '@/utils/texts'
import { import {
@ -323,6 +323,7 @@ const reportMeta = ref({
currentYear: new Date().getFullYear(), currentYear: new Date().getFullYear(),
lastYear: new Date().getFullYear() - 1 lastYear: new Date().getFullYear() - 1
}) })
const filters: any = ref()
const grouping = ref<any[]>([ const grouping = ref<any[]>([
{ {
@ -566,7 +567,6 @@ const onDataSubSelectionChanged = ({ selectedRowsData }: any) => {
dataSubSelected.value = data dataSubSelected.value = data
} }
const filters = ref()
onMounted(() => { onMounted(() => {
if (import.meta.env.DEV) { if (import.meta.env.DEV) {
data.value = [ data.value = [