bug fix in rec money

This commit is contained in:
Hesabix 2025-04-03 23:14:40 +00:00
parent 0c40629df2
commit 2d0305f918
2 changed files with 121 additions and 84 deletions

View file

@ -1,92 +1,129 @@
<template> <template>
<div class="block block-content-full "> <div>
<div id="fixed-header" class="block-header block-header-default bg-gray-light pt-2 pb-1"> <v-toolbar
<h3 class="block-title text-primary-dark"> color="toolbar"
<button @click="$router.back()" type="button" class="float-start d-none d-sm-none d-md-block btn btn-sm btn-link text-warning"> title="اسناد حسابداری"
<i class="fa fw-bold fa-arrow-right"></i>
</button>
<i class="fa fa-book-open-reader"></i>
اسناد حسابداری</h3>
</div>
<div class="block-content pt-1 pb-3">
<div class="row">
<div class="col-sm-12 col-md-12 m-0 p-0">
<div class="mb-1">
<div class="input-group input-group-sm">
<span class="input-group-text"><i class="fa fa-search"></i></span>
<input v-model="searchValue" class="form-control" type="text" placeholder="جست و جو ...">
</div>
</div>
<EasyDataTable table-class-name="customize-table"
show-index
alternating
:search-value="searchValue"
:headers="headers"
:items="items"
theme-color="#1d90ff"
header-text-direction="center"
body-text-direction="center"
rowsPerPageMessage="تعداد سطر"
emptyMessage="اطلاعاتی برای نمایش وجود ندارد"
rowsOfPageSeparatorMessage="از"
:loading = "loading"
> >
<template #item-state="{ type }"> <template v-slot:prepend>
<i v-if="type != 'accounting'" class="fa fa-lock text-danger"></i> <v-tooltip :text="$t('dialog.back')" location="bottom">
<i v-else class="fa fa-lock-open text-success"></i> <template v-slot:activator="{ props }">
<v-btn v-bind="props" @click="$router.back()" class="d-none d-sm-flex" variant="text"
icon="mdi-arrow-right" />
</template> </template>
<template #item-operation="{ code,type }"> </v-tooltip>
<router-link class="btn btn-sm btn-link text-success" :to="'/acc/accounting/view/' + code">
<i class="fa fa-eye px-1"></i>
</router-link>
</template> </template>
</EasyDataTable> </v-toolbar>
</div>
</div> <v-text-field
</div> v-model="searchValue"
prepend-inner-icon="mdi-magnify"
density="compact"
hide-details
:rounded="false"
placeholder="جست و جو ..."
></v-text-field>
<v-data-table
:headers="headers"
:items="filteredItems"
:search="searchValue"
:loading="loading"
:header-props="{ class: 'custom-header' }"
hover
>
<template v-slot:item.state="{ item }">
<v-icon
:color="item.type !== 'accounting' ? 'error' : 'success'"
>
{{ item.type !== 'accounting' ? 'mdi-lock' : 'mdi-lock-open' }}
</v-icon>
</template>
<template v-slot:item.operation="{ item }">
<v-tooltip text="مشاهده سند" location="bottom">
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
icon
variant="text"
color="success"
:to="'/acc/accounting/view/' + item.code"
>
<v-icon>mdi-eye</v-icon>
</v-btn>
</template>
</v-tooltip>
</template>
</v-data-table>
</div> </div>
</template> </template>
<script> <script setup>
import axios from "axios"; import { ref, onMounted, computed } from 'vue'
import Swal from "sweetalert2"; import axios from 'axios'
import {ref} from "vue";
export default { const searchValue = ref('')
name: "list", const loading = ref(true)
data: ()=>{return { const items = ref([])
searchValue: '',
loading: ref(true), const headers = [
items:[], { title: 'وضعیت', key: 'state', sortable: true },
headers: [ { title: 'عملیات', key: 'operation' },
{ text: "وضعیت", value: "state" , sortable: true}, { title: 'کد', key: 'code', sortable: true },
{ text: "عملیات", value: "operation"}, { title: 'تاریخ', key: 'date', sortable: true },
{ text: "کد", value: "code" , sortable: true}, { title: 'شرح', key: 'des', sortable: true },
{ text: "تاریخ", value: "date", sortable: true}, { title: 'مبلغ', key: 'amount', sortable: true },
{ text: "شرح", value: "des", sortable: true}, { title: 'ثبت کننده', key: 'submitter', sortable: true }
{ text: "مبلغ", value: "amount", sortable: true},
{ text: "ثبت کننده", value: "submitter", sortable: true},
] ]
}},
methods: { const loadData = async () => {
loadData(){ try {
axios.post('/api/accounting/search',{ const response = await axios.post('/api/accounting/search', {
type: 'all' type: 'all'
}) })
.then((response)=>{ items.value = response.data.map(item => ({
this.items = response.data; ...item,
this.items.forEach((item)=>{ amount: item.amount.toLocaleString(),
item.amount = this.$filters.formatNumber(item.amount) amountRaw: item.amount
}))
loading.value = false
} catch (error) {
console.error('Error loading data:', error)
loading.value = false
}
}
const filteredItems = computed(() => {
if (!searchValue.value) return items.value
const search = searchValue.value.toLowerCase()
const searchWithoutComma = search.replace(/,/g, '')
const searchNumber = parseInt(searchWithoutComma)
const isNumberSearch = !isNaN(searchNumber)
return items.value.filter(item => {
const formattedAmount = item.amount.toLocaleString()
return (
item.code.toLowerCase().includes(search) ||
item.date.toLowerCase().includes(search) ||
item.des.toLowerCase().includes(search) ||
item.submitter.toLowerCase().includes(search) ||
(isNumberSearch && (
item.amount.toString().includes(searchWithoutComma) ||
formattedAmount.includes(search)
))
)
}) })
this.loading = false;
}) })
}
}, onMounted(() => {
beforeMount() { loadData()
this.loadData(); })
}
}
</script> </script>
<style scoped> <style scoped>
.v-data-table {
direction: rtl;
}
</style> </style>

View file

@ -219,7 +219,7 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, ref } from 'vue' import { defineComponent, ref } from 'vue'
import axios from 'axios' import axios from 'axios'
import { VDataTable } from 'vuetify/components' import { VDataTable as DataTable } from 'vuetify/components'
import Hdatepicker from '@/components/forms/Hdatepicker.vue' import Hdatepicker from '@/components/forms/Hdatepicker.vue'
import Hnumberinput from '@/components/forms/Hnumberinput.vue' import Hnumberinput from '@/components/forms/Hnumberinput.vue'
@ -243,7 +243,7 @@ interface Item {
export default defineComponent({ export default defineComponent({
name: 'Rec', name: 'Rec',
components: { components: {
VDataTable, DataTable,
Hdatepicker, Hdatepicker,
Hnumberinput Hnumberinput
}, },