From bc642e91ed3632c5a982112a983d701f9328077e Mon Sep 17 00:00:00 2001 From: adonis Date: Tue, 21 Jul 2026 10:57:54 +0330 Subject: [PATCH] fix bugs --- src/api/physicalreceive.ts | 14 ++++++-- .../components/PhysicalReceiveCartRow.vue | 10 +++++- .../components/RequestList.vue | 23 ++++++++++-- src/views/base/physicalReceive/index.vue | 6 ++++ .../mobile/MobileRequestListView.vue | 30 +++++++++++++--- .../transactions/BoursecuTransactionsPage.vue | 16 +++++++-- .../composables/useTransactionsPage.ts | 12 +++++++ .../composables/useTransactionsPageData.ts | 36 ++++++++++++++++--- .../base/transactions/config/boursecuTabs.ts | 18 +++++----- .../DesktopBoursecuTransactionsView.vue | 27 ++++++++++---- 10 files changed, 159 insertions(+), 33 deletions(-) diff --git a/src/api/physicalreceive.ts b/src/api/physicalreceive.ts index add815a..d99a956 100644 --- a/src/api/physicalreceive.ts +++ b/src/api/physicalreceive.ts @@ -1,4 +1,12 @@ import useAxios from '@/utils/useAxios' -import type {Physicalreceive} from "@/models/physicalreceive"; -export const physicalReceiveApi = async (obj:Object) => await useAxios.post(`/customer/wallet/withdraw_physical`, obj) -export const getPhysicalReceiveList = async (obj?:Object) => await useAxios.post(`/customer/wallet/withdraw_physical/table`, obj) \ No newline at end of file +import type { Physicalreceive } from '@/models/physicalreceive' +import type { TableEngineInput, TableEngineOutput } from '@/models/table' + +export const physicalReceiveApi = async (obj: Object) => + await useAxios.post(`/customer/wallet/withdraw_physical`, obj) + +export const getPhysicalReceiveList = async (obj?: TableEngineInput) => + await useAxios.post>( + `/customer/wallet/withdraw_physical/table`, + obj, + ) diff --git a/src/views/base/physicalReceive/components/PhysicalReceiveCartRow.vue b/src/views/base/physicalReceive/components/PhysicalReceiveCartRow.vue index 8184724..547370d 100644 --- a/src/views/base/physicalReceive/components/PhysicalReceiveCartRow.vue +++ b/src/views/base/physicalReceive/components/PhysicalReceiveCartRow.vue @@ -30,13 +30,14 @@
@@ -91,6 +92,13 @@ const displayGold = computed(() => { const config = useConfigStore() +function selectCountInput(e: FocusEvent) { + const el = e.target as HTMLInputElement | null + if (!el || el.tagName !== 'INPUT' || typeof el.select !== 'function') return + // تا کاربر با تایپ عدد جدید، مقدار قبلی را جایگزین کند + requestAnimationFrame(() => el.select()) +} + function onCountInput(raw: string | number) { countError.value = '' const normalized = persianToEnglishDigits(String(raw ?? '').trim()) diff --git a/src/views/base/physicalReceive/components/RequestList.vue b/src/views/base/physicalReceive/components/RequestList.vue index 12ee934..b3ffa8f 100644 --- a/src/views/base/physicalReceive/components/RequestList.vue +++ b/src/views/base/physicalReceive/components/RequestList.vue @@ -1,6 +1,8 @@ + + diff --git a/src/views/base/physicalReceive/index.vue b/src/views/base/physicalReceive/index.vue index 388fe6d..18f0be5 100644 --- a/src/views/base/physicalReceive/index.vue +++ b/src/views/base/physicalReceive/index.vue @@ -44,6 +44,12 @@ const { isDesktop } = usePhysicalReceiveShell() overflow: hidden; } +.physical-receive-page-root__content > :deep(.physical-receive-list-root), +.physical-receive-page-root__content > :deep(.physical-new-request) { + flex: 1 1 0; + min-height: 0; +} + .physical-receive-page-root--desktop { height: auto; min-height: 0; diff --git a/src/views/base/physicalReceive/mobile/MobileRequestListView.vue b/src/views/base/physicalReceive/mobile/MobileRequestListView.vue index be0c7f7..6c3598c 100644 --- a/src/views/base/physicalReceive/mobile/MobileRequestListView.vue +++ b/src/views/base/physicalReceive/mobile/MobileRequestListView.vue @@ -1,9 +1,11 @@ -
+

{{ emptyText }}

@@ -72,6 +81,7 @@ import ListAnim from '@/components/ListAnim.vue' import TransactionSkeleton from '@/components/TransactionSkeleton.vue' import emptyImage from '@/assets/img/cash_empty.svg' import Item from './components/Item.vue' +import RequestItem from '@/views/base/physicalReceive/components/RequestItem.vue' import BoursecuTransactionFilters from './components/BoursecuTransactionFilters.vue' import { BOURSECU_TRANSACTION_TABS } from './config/boursecuTabs' import { useTransactionsPageContext } from './composables/useTransactionsPage' @@ -80,10 +90,12 @@ const listRef = ref(null) const { items, + physicalItems, activeTabId, tradeSide, activeTab, emptyText, + listEmpty, setActiveTab, setTradeSide, bindMobileObserver, diff --git a/src/views/base/transactions/composables/useTransactionsPage.ts b/src/views/base/transactions/composables/useTransactionsPage.ts index 8c35384..61ba087 100644 --- a/src/views/base/transactions/composables/useTransactionsPage.ts +++ b/src/views/base/transactions/composables/useTransactionsPage.ts @@ -27,6 +27,7 @@ import { transactionDateFromFilter, transactionDateToFilter, transactionItems, + physicalReceiveItems, transactionPagination, transactionStatusFilter, transactionProductFilter, @@ -37,6 +38,7 @@ import { export interface TransactionsPageContext { pagination: typeof transactionPagination items: typeof transactionItems + physicalItems: typeof physicalReceiveItems tableOutput: typeof transactionTableOutput showFilter: ReturnType> dateFilter: typeof transactionDateFilter @@ -53,6 +55,7 @@ export interface TransactionsPageContext { activeTab: ReturnType> statusOptions: ReturnType>> emptyText: ReturnType> + listEmpty: ReturnType> resetPagination: typeof resetTransactionsPagination initTable: () => Promise reloadTable: typeof reloadTransactionsTable @@ -111,6 +114,13 @@ export function useTransactionsPageProvider() { return activeTab.value.emptyText }) + const listEmpty = computed(() => { + if (activeTab.value.fetchMode === 'physical') { + return physicalReceiveItems.value.length === 0 + } + return transactionItems.value.length === 0 + }) + async function initTable() { await reloadTransactionsTable() } @@ -207,6 +217,7 @@ export function useTransactionsPageProvider() { const context: TransactionsPageContext = { pagination: transactionPagination, items: transactionItems, + physicalItems: physicalReceiveItems, tableOutput: transactionTableOutput, showFilter, dateFilter: transactionDateFilter, @@ -223,6 +234,7 @@ export function useTransactionsPageProvider() { activeTab, statusOptions, emptyText, + listEmpty, resetPagination: resetTransactionsPagination, initTable, reloadTable: reloadTransactionsTable, diff --git a/src/views/base/transactions/composables/useTransactionsPageData.ts b/src/views/base/transactions/composables/useTransactionsPageData.ts index 01520c2..ef5286b 100644 --- a/src/views/base/transactions/composables/useTransactionsPageData.ts +++ b/src/views/base/transactions/composables/useTransactionsPageData.ts @@ -1,7 +1,9 @@ import { ref } from 'vue' import { getTransactionTable, getTransactionTable2 } from '@/api/transaction' +import { getPhysicalReceiveList } from '@/api/physicalreceive' import type { TableEngineInput, TableEngineOutput } from '@/models/table' import type { Transaction } from '@/models/transaction' +import type { Physicalreceive } from '@/models/physicalreceive' import { loading, loadingMore } from '@/utils' import { BOURSECU_TRANSACTION_TABS, @@ -17,7 +19,10 @@ let activeFetchId = 0 export const transactionsBoursecuMode = ref(true) export const transactionPagination = ref({ filters: [], limit: 7, page: 0 }) export const transactionItems = ref([]) -export const transactionTableOutput = ref | null>(null) +export const physicalReceiveItems = ref([]) +export const transactionTableOutput = ref | null>( + null, +) export const transactionDateFilter = ref() export const transactionDateFromFilter = ref() export const transactionDateToFilter = ref() @@ -46,12 +51,19 @@ export function resetTransactionsPagination() { function resolveTransactionFetcher() { const activeTab = getActiveBoursecuTab() - return activeTab.fetchMode === 'deposit' ? getTransactionTable2 : getTransactionTable + if (activeTab.fetchMode === 'deposit') { + return getTransactionTable2 + } + if (activeTab.fetchMode === 'physical') { + return getPhysicalReceiveList + } + return getTransactionTable } async function fetchTransactionsPage(append: boolean): Promise { const fetchId = ++activeFetchId const isFirstPage = transactionPagination.value.page === 0 && !append + const isPhysical = getActiveBoursecuTab().fetchMode === 'physical' if (isFirstPage) { loading.value = true @@ -69,10 +81,22 @@ async function fetchTransactionsPage(append: boolean): Promise { transactionTableOutput.value = output const rows = output.rows ?? [] - if (isFirstPage) { - transactionItems.value = [...rows] + if (isPhysical) { + const physicalRows = rows as Physicalreceive[] + if (isFirstPage) { + physicalReceiveItems.value = [...physicalRows] + transactionItems.value = [] + } else { + physicalReceiveItems.value.push(...physicalRows) + } } else { - transactionItems.value.push(...rows) + const txRows = rows as Transaction[] + if (isFirstPage) { + transactionItems.value = [...txRows] + physicalReceiveItems.value = [] + } else { + transactionItems.value.push(...txRows) + } } return true @@ -93,6 +117,7 @@ async function fetchTransactionsPage(append: boolean): Promise { export async function reloadTransactionsTable() { transactionPagination.value.page = 0 transactionItems.value = [] + physicalReceiveItems.value = [] transactionTableOutput.value = null resetTransactionsPagination() await fetchTransactionsPage(false) @@ -128,6 +153,7 @@ export function resetTransactionsPageData() { transactionsBoursecuMode.value = true transactionPagination.value = { filters: [], limit: 7, page: 0 } transactionItems.value = [] + physicalReceiveItems.value = [] transactionTableOutput.value = null transactionDateFilter.value = undefined transactionDateFromFilter.value = undefined diff --git a/src/views/base/transactions/config/boursecuTabs.ts b/src/views/base/transactions/config/boursecuTabs.ts index 0ac07f6..04f1345 100644 --- a/src/views/base/transactions/config/boursecuTabs.ts +++ b/src/views/base/transactions/config/boursecuTabs.ts @@ -8,7 +8,7 @@ export type BoursecuTransactionTabId = export type BoursecuTradeSide = 'buy' | 'sell' -export type BoursecuTransactionFetchMode = 'transaction' | 'deposit' +export type BoursecuTransactionFetchMode = 'transaction' | 'deposit' | 'physical' export type BoursecuTradeStatusFilter = 'completed' | 'pending' | 'cancelled' export type BoursecuFulfillmentStatusFilter = 'delivered' | 'registered' | 'cancelled' @@ -38,10 +38,11 @@ export const BOURSECU_TRADE_STATUS_OPTIONS: BoursecuTransactionStatusOption[] = { value: 'cancelled', label: 'لغو شده', sts: 3 }, ] +/** وضعیت‌های سند برداشت فیزیکی (Withdraw::$STS) */ export const BOURSECU_FULFILLMENT_STATUS_OPTIONS: BoursecuTransactionStatusOption[] = [ - { value: 'delivered', label: 'تحویل شده', sts: 2 }, - { value: 'registered', label: 'ثبت درخواست', sts: 1 }, - { value: 'cancelled', label: 'لغو شده', sts: 3 }, + { value: 'registered', label: 'در انتظار ارسال', sts: 50 }, + { value: 'delivered', label: 'ارسال شده', sts: 51 }, + { value: 'cancelled', label: 'لغو شده', sts: 52 }, ] /** @deprecated Use getBoursecuStatusOptionsForTab instead */ @@ -74,8 +75,8 @@ export const BOURSECU_TRANSACTION_TABS: BoursecuTransactionTab[] = [ id: 'physical', label: 'تحویل فیزیکی', emptyText: 'درخواست تحویل فیزیکی برای شما ثبت نشده است', + fetchMode: 'physical', showAdvancedFilters: true, - typeFilters: [9], }, ] @@ -97,11 +98,12 @@ export function getBoursecuStatusOptionsForTab( } export function boursecuTabSupportsProductFilter(tab: BoursecuTransactionTab): boolean { - return tab.id === 'trades' || tab.id === 'physical' + // فیلتر محصول روی جدول سند برداشت فیزیکی (hasMany Transaction) قابل‌اعتماد نیست + return tab.id === 'trades' } function getBoursecuStatusFilterField(tab: BoursecuTransactionTab): string { - if (tab.fetchMode === 'deposit') { + if (tab.fetchMode === 'deposit' || tab.fetchMode === 'physical') { return 'sts' } @@ -129,7 +131,7 @@ export function buildBoursecuTransactionPagination( ): TableEngineInput { const filters: TableEngineInput['filters'] = [] - if (tab.fetchMode !== 'deposit' && tab.typeFilters?.length) { + if (tab.fetchMode !== 'deposit' && tab.fetchMode !== 'physical' && tab.typeFilters?.length) { const typeValue = tab.showTradeToggle && tab.typeFilters.includes(TRADE_TYPE_BY_SIDE[tradeSide]) ? TRADE_TYPE_BY_SIDE[tradeSide] diff --git a/src/views/base/transactions/desktop/DesktopBoursecuTransactionsView.vue b/src/views/base/transactions/desktop/DesktopBoursecuTransactionsView.vue index a88bb0a..9214f79 100644 --- a/src/views/base/transactions/desktop/DesktopBoursecuTransactionsView.vue +++ b/src/views/base/transactions/desktop/DesktopBoursecuTransactionsView.vue @@ -42,12 +42,22 @@
- + +
در حال بارگذاری @@ -59,7 +69,7 @@ -
+

{{ emptyText }}

@@ -76,6 +86,7 @@ import ListAnim from '@/components/ListAnim.vue' import TransactionSkeleton from '@/components/TransactionSkeleton.vue' import emptyImage from '@/assets/img/cash_empty.svg' import Item from '../components/Item.vue' +import RequestItem from '@/views/base/physicalReceive/components/RequestItem.vue' import BoursecuTransactionFilters from '../components/BoursecuTransactionFilters.vue' import { BOURSECU_TRANSACTION_TABS } from '../config/boursecuTabs' import { useTransactionsPageContext } from '../composables/useTransactionsPage' @@ -84,10 +95,12 @@ const listRef = ref(null) const { items, + physicalItems, activeTabId, tradeSide, activeTab, emptyText, + listEmpty, setActiveTab, setTradeSide, bindDesktopObserver,