fix some bug
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<span class="min-w-0 truncate">{{ sheetTitle }}</span>
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
<MobileIconButton
|
||||
v-if="!row.tracked_number"
|
||||
v-if="needsTrackingConfirmation(row)"
|
||||
plain
|
||||
icon="vuesax-linear:tick-circle"
|
||||
color="#16A34A"
|
||||
@@ -120,6 +120,7 @@ import { status } from '@/pages/menuPages/withdraw/information/hooks/status'
|
||||
import {
|
||||
formatWithdrawAmountDisplay,
|
||||
isMoneyWithdraw,
|
||||
needsTrackingConfirmation,
|
||||
withdrawAmountValue,
|
||||
withdrawTypeLabel
|
||||
} from '@/pages/menuPages/withdraw/utils/withdrawDisplay'
|
||||
|
||||
@@ -11,9 +11,12 @@
|
||||
</template>
|
||||
<template #tracked="{ column, record }">
|
||||
<div v-if="record.tracked_number">{{ record.tracked_number }}</div>
|
||||
<div v-else>
|
||||
<BaseButton @click="emits('withdraw', record)">{{ confirmButtonLabel }}</BaseButton>
|
||||
<div v-else-if="needsTrackingConfirmation(record)">
|
||||
<BaseButton @click="emits('withdraw', record)">
|
||||
{{ confirmLabelForRecord(record, props.flowType) }}
|
||||
</BaseButton>
|
||||
</div>
|
||||
<div v-else>-</div>
|
||||
</template>
|
||||
<template #action="{ column, record }">
|
||||
<div class="gap-2 flex justify-center">
|
||||
@@ -114,6 +117,10 @@ import {getWithdrawTable, updateSts} from '@/api/wallet'
|
||||
import WithdrawMobileCardList from './WithdrawMobileCardList.vue'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import type { WithdrawFlowType } from '../types'
|
||||
import {
|
||||
confirmLabelForRecord,
|
||||
needsTrackingConfirmation
|
||||
} from '@/pages/menuPages/withdraw/utils/withdrawDisplay'
|
||||
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
||||
import { initTahesabSettingFromApi, tahesabEnabledSetting } from '@/utils/config'
|
||||
|
||||
@@ -149,10 +156,6 @@ function checkPermission(temp: string) {
|
||||
const table = ref(null)
|
||||
const lastTableParams = ref<TableInput & { flow_type?: string }>({})
|
||||
|
||||
const confirmButtonLabel = computed(() =>
|
||||
props.flowType === 'deposit' ? 'تایید واریز' : 'تایید برداشت'
|
||||
)
|
||||
|
||||
const tblProps = computed(() => ({
|
||||
columns: getWithdrawColumns(),
|
||||
api: async (params: TableInput) => {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<BasicModal
|
||||
v-model:visible="confirmWithdrawVisible"
|
||||
width="15rem"
|
||||
title="تایید برداشت"
|
||||
:title="confirmModalTitle"
|
||||
wrap-class-name="withdraw-stack-modal"
|
||||
@ok="okWithdraw"
|
||||
:loading="loading"
|
||||
@@ -117,6 +117,7 @@ import type { Wallet, Withdraw } from '@/model/wallet'
|
||||
import {completeWithdraw, exportWithdrawReport, getWithdrawById, sendWeights} from '@/api/wallet'
|
||||
import Button from "@core/components/BaseButton";
|
||||
import type { WithdrawFlowType } from '@/pages/menuPages/withdraw/types'
|
||||
import { confirmLabelForRecord } from '@/pages/menuPages/withdraw/utils/withdrawDisplay'
|
||||
import { openHtmlPrintWindow } from '@/pages/menuPages/withdraw/utils/openHtmlPrintWindow'
|
||||
//import DatePicker from '@core/components/_sample/components/datePicker.vue'
|
||||
|
||||
@@ -283,6 +284,11 @@ const confirmWithdrawVisible = ref<boolean>(false)
|
||||
const confirmWeightVisible = ref<boolean>(false)
|
||||
const confirmWithdraw = ref<Withdraw | null>(null)
|
||||
|
||||
const confirmModalTitle = computed(() => {
|
||||
if (!confirmWithdraw.value) return 'تایید تراکنش'
|
||||
return confirmLabelForRecord(confirmWithdraw.value, flowType.value)
|
||||
})
|
||||
|
||||
const weightTransactions = computed(() => {
|
||||
const tx = confirmWithdraw.value?.transaction
|
||||
return Array.isArray(tx) ? tx : []
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Withdraw } from '@/model/wallet'
|
||||
import type { WithdrawFlowType } from '@/pages/menuPages/withdraw/types'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
import { getMainMetal } from '@/utils/metalLabels'
|
||||
import {
|
||||
@@ -61,3 +62,50 @@ export function withdrawAmountColorClass(record: Pick<Withdraw, 'cash' | 'gold'>
|
||||
if (!value) return ''
|
||||
return value > 0 ? 'text-green' : 'text-red'
|
||||
}
|
||||
|
||||
type WithdrawFlowRecord = Pick<
|
||||
Withdraw,
|
||||
'sts' | 'note' | 'cash' | 'gold' | 'bank_account_id' | 'type'
|
||||
>
|
||||
|
||||
/** همان منطق scopeWithdrawals / scopeDeposits در بکاند — برای برچسب دکمه در تب «همه» */
|
||||
export function resolveRecordFlowType(record: WithdrawFlowRecord): Exclude<WithdrawFlowType, 'all'> {
|
||||
const sts = Number(record.sts ?? 0)
|
||||
const note = String(record.note ?? '')
|
||||
const cash = Number(record.cash ?? 0)
|
||||
const gold = Number(record.gold ?? 0)
|
||||
|
||||
if (
|
||||
note.includes('برداشت') ||
|
||||
record.type === 2 ||
|
||||
(sts >= 50 && sts <= 52) ||
|
||||
(sts === 1 && record.bank_account_id != null) ||
|
||||
(sts === 2 && note.includes('برداشت')) ||
|
||||
cash < 0 ||
|
||||
gold < 0
|
||||
) {
|
||||
return 'withdraw'
|
||||
}
|
||||
|
||||
return 'deposit'
|
||||
}
|
||||
|
||||
export function confirmLabelForRecord(
|
||||
record: WithdrawFlowRecord,
|
||||
tabFlowType: WithdrawFlowType = 'all'
|
||||
): string {
|
||||
const flowType = tabFlowType === 'all' ? resolveRecordFlowType(record) : tabFlowType
|
||||
return flowType === 'deposit' ? 'تایید واریز' : 'تایید برداشت'
|
||||
}
|
||||
|
||||
/** فقط تراکنشهای در انتظار پیگیری — نه واریز/کسر ادمین (sts=4) */
|
||||
export function needsTrackingConfirmation(record: Pick<Withdraw, 'sts' | 'tracked_number'>): boolean {
|
||||
if (record.tracked_number) return false
|
||||
|
||||
const sts = Number(record.sts ?? 0)
|
||||
if ([2, 4, 5, 9].includes(sts)) return false
|
||||
if (sts === 1) return true
|
||||
if (sts >= 50 && sts <= 52) return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user