price calulator changed 6
This commit is contained in:
@@ -235,6 +235,7 @@ import { calcFeeInGrams, calcPayablePriceRial, calcSellGoldDebit, feeDeductFromG
|
||||
import { formatCashWalletBalanceText, formatGoldWalletBalanceText } from '@/utils/productDealMethod'
|
||||
import { getCashWalletBalance } from '@/utils/productAssets'
|
||||
import { isStoreClosed, getStoreClosedMessage } from '@/utils/storeHours'
|
||||
import { resetTransactionsPageData } from '@/views/base/transactions/composables/useTransactionsPageData'
|
||||
|
||||
const infoVisible = ref(false)
|
||||
const walletStore = useWalletStore()
|
||||
@@ -658,6 +659,7 @@ async function ok() {
|
||||
})
|
||||
confirmAction.value = false
|
||||
await walletStore.getMyWallet()
|
||||
resetTransactionsPageData()
|
||||
await router.push({ name: 'transactions' })
|
||||
form.value = {
|
||||
goldValue: undefined,
|
||||
|
||||
@@ -345,6 +345,7 @@ import {
|
||||
type TradeInputLock,
|
||||
} from '@/utils/serviceFee'
|
||||
import { isStoreClosed, getStoreClosedMessage } from '@/utils/storeHours'
|
||||
import { resetTransactionsPageData } from '@/views/base/transactions/composables/useTransactionsPageData'
|
||||
import { formatCashWalletBalanceText, getWeightUnit } from '@/utils/productDealMethod'
|
||||
import { formatProductWalletBalanceText, getCashWalletBalance, getProductInventoryQuantity } from '@/utils/productAssets'
|
||||
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||
@@ -816,6 +817,7 @@ async function ok() {
|
||||
confirmAction.value = false
|
||||
await walletStore.getMyWallet()
|
||||
await loadWalletAssets(true)
|
||||
resetTransactionsPageData()
|
||||
await router.push({ name: 'transactions' })
|
||||
form.value = {
|
||||
goldValue: undefined,
|
||||
|
||||
@@ -286,6 +286,7 @@ import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
|
||||
import Bg_main from '@/components/bg_main.vue'
|
||||
import { useFundUserStore } from '@/store/fundStore'
|
||||
import { getProductsCatalogRef } from '@/composables/useProductsCatalog'
|
||||
import { resetTransactionsPageData } from '@/views/base/transactions/composables/useTransactionsPageData'
|
||||
import {
|
||||
getDefaultProductDealMethod,
|
||||
getProductDealMethodOptions,
|
||||
@@ -898,6 +899,7 @@ async function ok() {
|
||||
await loadWalletAssets(true)
|
||||
await fundStore.getMyFund()
|
||||
message.success('سفارش شما با موفقیت انجام شد')
|
||||
resetTransactionsPageData()
|
||||
await router.push({ name: 'transactions' })
|
||||
form.value = {
|
||||
goldValue: undefined,
|
||||
|
||||
@@ -166,7 +166,7 @@ export function useTransactionsPageProvider(options?: { boursecu?: boolean }) {
|
||||
useIntersectionObserver(
|
||||
activeObserverEl,
|
||||
async ([entry]) => {
|
||||
if (entry?.isIntersecting) {
|
||||
if (entry?.isIntersecting && !loading.value && !loadingMore.value) {
|
||||
await loadMoreTransactions()
|
||||
}
|
||||
},
|
||||
@@ -181,7 +181,14 @@ export function useTransactionsPageProvider(options?: { boursecu?: boolean }) {
|
||||
if (isBoursecu) {
|
||||
await getProductsCatalog()
|
||||
}
|
||||
await initTransactionsPageData(isBoursecu)
|
||||
|
||||
const modeMatches = transactionsBoursecuMode.value === isBoursecu
|
||||
if (!initialized.value || !modeMatches) {
|
||||
await initTransactionsPageData(isBoursecu, !modeMatches)
|
||||
return
|
||||
}
|
||||
|
||||
await reloadTransactionsTable()
|
||||
})
|
||||
|
||||
const context: TransactionsPageContext = {
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
|
||||
/** Shared transactions datasets — mobile/desktop views read this module state only. */
|
||||
let initPromise: Promise<void> | null = null
|
||||
let fetchSeq = 0
|
||||
const initialized = ref(false)
|
||||
|
||||
export const transactionsBoursecuMode = ref(false)
|
||||
@@ -66,6 +67,7 @@ export function resetTransactionsPagination() {
|
||||
}
|
||||
|
||||
async function fetchTransactionsPage(append: boolean) {
|
||||
const seq = ++fetchSeq
|
||||
const isFirstPage = transactionPagination.value.page === 0 && !append
|
||||
|
||||
if (isFirstPage) {
|
||||
@@ -81,8 +83,13 @@ async function fetchTransactionsPage(append: boolean) {
|
||||
? getTransactionTable2
|
||||
: getTransactionTable
|
||||
|
||||
transactionTableOutput.value = await fetcher(transactionPagination.value)
|
||||
const rows = transactionTableOutput.value.rows ?? []
|
||||
const output = await fetcher(transactionPagination.value)
|
||||
if (seq !== fetchSeq) {
|
||||
return
|
||||
}
|
||||
|
||||
transactionTableOutput.value = output
|
||||
const rows = output.rows ?? []
|
||||
|
||||
if (isFirstPage) {
|
||||
transactionItems.value = [...rows]
|
||||
@@ -90,21 +97,31 @@ async function fetchTransactionsPage(append: boolean) {
|
||||
transactionItems.value.push(...rows)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching transactions:', error)
|
||||
if (seq === fetchSeq) {
|
||||
console.error('Error fetching transactions:', error)
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
loadingMore.value = false
|
||||
if (seq === fetchSeq) {
|
||||
loading.value = false
|
||||
loadingMore.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function reloadTransactionsTable() {
|
||||
fetchSeq += 1
|
||||
transactionPagination.value.page = 0
|
||||
transactionItems.value = []
|
||||
transactionTableOutput.value = null
|
||||
resetTransactionsPagination()
|
||||
await fetchTransactionsPage(false)
|
||||
}
|
||||
|
||||
export async function loadMoreTransactions() {
|
||||
if (loading.value || loadingMore.value) {
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
!transactionTableOutput.value
|
||||
|| (transactionPagination.value.page + 1) * transactionPagination.value.limit
|
||||
@@ -149,6 +166,7 @@ export async function initTransactionsPageData(boursecu: boolean, force = false)
|
||||
}
|
||||
|
||||
export function resetTransactionsPageData() {
|
||||
fetchSeq += 1
|
||||
initialized.value = false
|
||||
initPromise = null
|
||||
transactionsBoursecuMode.value = false
|
||||
|
||||
Reference in New Issue
Block a user