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