68 lines
1.9 KiB
Vue
68 lines
1.9 KiB
Vue
<template>
|
|||
|
|
<MobileCardList
|
||
|
|
v-model:search="search"
|
||
|
|
:loading="loading"
|
||
|
|
:has-more="hasMore"
|
||
|
|
:show-empty="!loading && items.length === 0"
|
||
|
|
empty-text="کیف پولی یافت نشد"
|
||
|
|
search-placeholder="جستجو کیف پول"
|
||
|
|
show-refresh
|
||
|
|
@search="reload"
|
||
|
|
@refresh="reload"
|
||
|
|
@load-more="loadMore"
|
||
|
|
>
|
||
|
|
<WalletMobileListItem
|
||
|
|
v-for="item in items"
|
||
|
|
:key="item.id"
|
||
|
|
:item="item"
|
||
|
|
@open="openSheet"
|
||
|
|
/>
|
||
|
|
</MobileCardList>
|
||
|
|
|
||
|
|
<WalletMobileDetailSheet
|
||
|
|
v-model:visible="sheetVisible"
|
||
|
|
:item="selectedItem"
|
||
|
|
/>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script setup lang="ts">
|
||
|
|
import { getWalletTable } from '@/api/wallet'
|
||
|
|
import type { Wallet } from '@/model/wallet'
|
||
|
|
import MobileCardList from '@/components/mobile/MobileCardList.vue'
|
||
|
|
import { useMobileDetailSheet } from '@/components/mobile/composables/useMobileDetailSheet'
|
||
|
|
import { useMobileTableList } from '@/components/mobile/composables/useMobileTableList'
|
||
|
|
import type { TableInput, TableOutput } from '@core/type/baseTable'
|
||
|
|
import WalletMobileDetailSheet from './WalletMobileDetailSheet.vue'
|
||
|
|
import WalletMobileListItem from './WalletMobileListItem.vue'
|
||
|
|
|
||
|
|
type WalletTableResponse = TableOutput<Wallet> & {
|
||
|
|
sums?: {
|
||
|
|
cash?: number
|
||
|
|
gold?: number
|
||
|
|
cashToGold?: number
|
||
|
|
goldToCash?: number
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
const emit = defineEmits<{
|
||
|
|
(e: 'sums', sums: WalletTableResponse['sums']): void
|
||
|
|
}>()
|
||
|
|
|
||
|
|
const { sheetVisible, selectedItem, openSheet, syncSelectedItem } = useMobileDetailSheet<Wallet>()
|
||
|
|
|
||
|
|
async function fetchWallet(params: TableInput) {
|
||
|
|
const data = (await getWalletTable(params)) as WalletTableResponse
|
||
|
|
emit('sums', data?.sums)
|
||
|
|
return data
|
||
|
|
}
|
||
|
|
|
||
|
|
const { loading, search, items, hasMore, reload, loadMore, fetch } = useMobileTableList<Wallet>({
|
||
|
|
fetchApi: fetchWallet,
|
||
|
|
onFetched: (rows) => syncSelectedItem(rows)
|
||
|
|
})
|
||
|
|
|
||
|
|
onMounted(() => reload())
|
||
|
|
|
||
|
|
defineExpose({ fetch, openSheet })
|
||
|
|
</script>
|