wallet fix 2
This commit is contained in:
@@ -5,6 +5,24 @@
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip
|
||||
v-if="showTahesab && record.tahesab_record_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openTahesabDetail(record)"
|
||||
>
|
||||
<template #title><span>جزئیات تهحساب</span></template>
|
||||
<Icon icon="vuesax-linear:document-text" color="#10913A" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="showTahesab && record.tahesab_failed_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openTahesabRetry(record)"
|
||||
>
|
||||
<template #title><span>ارسال به تهحساب</span></template>
|
||||
<Icon icon="vuesax-linear:refresh-circle" color="#CA8A04" />
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<template #title><span>برداشت و واریز</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
@@ -25,22 +43,53 @@
|
||||
@orders="emits('orders', $event)"
|
||||
/>
|
||||
</BasicShowContext>
|
||||
|
||||
<TahesabRetryModal
|
||||
v-if="showTahesab"
|
||||
v-model="tahesabRetryVisible"
|
||||
mode="retry-sanad"
|
||||
:tahesab-id="selectedTahesabId"
|
||||
@success="fetch"
|
||||
/>
|
||||
|
||||
<BasicModal
|
||||
v-if="showTahesab"
|
||||
v-model:visible="tahesabDetailVisible" title="جزئیات سند تهحساب" width="36rem" :footer="null">
|
||||
<div class="space-y-2 text-sm">
|
||||
<div v-for="item in tahesabDetailItems" :key="item.label" class="flex justify-between gap-3 border-b border-gray-100 py-2">
|
||||
<span class="text-gray-500">{{ item.label }}</span>
|
||||
<span class="break-all text-left">{{ item.value ?? '-' }}</span>
|
||||
</div>
|
||||
<div v-if="tahesabDetail?.sync_log" class="rounded-lg bg-red-50 p-3 text-red-700 whitespace-pre-wrap">
|
||||
{{ tahesabDetail.sync_log }}
|
||||
</div>
|
||||
</div>
|
||||
</BasicModal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { getTotalAccountingTable } from '@/api/accounting'
|
||||
import { getTahesabDetail, type TahesabRecord } from '@/api/tahesab'
|
||||
import { getAccountingColumns } from '@/pages/menuPages/accounting/hooks/accountingColumns'
|
||||
import AccountingMobileCardList from '@/pages/menuPages/accounting/components/AccountingMobileCardList.vue'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
||||
import type { TableInput } from '@core/type/baseTable'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
|
||||
defineProps<{
|
||||
customerId?: number
|
||||
}>()
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
customerId?: number
|
||||
showTahesab?: boolean
|
||||
}>(),
|
||||
{
|
||||
showTahesab: false
|
||||
}
|
||||
)
|
||||
|
||||
const emits = defineEmits<{
|
||||
(e: 'info', record: unknown): void
|
||||
@@ -49,12 +98,45 @@ const emits = defineEmits<{
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
||||
const tahesabRetryVisible = ref(false)
|
||||
const tahesabDetailVisible = ref(false)
|
||||
const selectedTahesabId = ref<number>()
|
||||
const tahesabDetail = ref<TahesabRecord | null>(null)
|
||||
|
||||
const tahesabDetailItems = computed(() => {
|
||||
const row = tahesabDetail.value
|
||||
if (!row) return []
|
||||
return [
|
||||
{ label: 'شناسه', value: row.id },
|
||||
{ label: 'مشتری', value: row.customer?.name },
|
||||
{ label: 'نوع', value: row.type },
|
||||
{ label: 'مقدار', value: row.amount },
|
||||
{ label: 'شرح', value: row.desc },
|
||||
{ label: 'وضعیت', value: tahesabStatusLabel(row) },
|
||||
{ label: 'کد تهحساب', value: row.tahesab_id }
|
||||
]
|
||||
})
|
||||
|
||||
function tahesabStatusLabel(row?: TahesabRecord | null) {
|
||||
if (!row) return '-'
|
||||
if (row.tahesab_id) return 'موفق'
|
||||
if (row.sync_status === 'failed') return 'ناموفق'
|
||||
if (row.sync_status === 'success') return 'موفق'
|
||||
return 'در انتظار'
|
||||
}
|
||||
|
||||
const tblProps = ref({
|
||||
columns: getAccountingColumns(),
|
||||
columns: getAccountingColumns(props.showTahesab),
|
||||
api: (params: TableInput) => getTotalAccountingTable(params)
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.showTahesab,
|
||||
(enabled) => {
|
||||
tblProps.value.columns = getAccountingColumns(enabled)
|
||||
}
|
||||
)
|
||||
|
||||
async function fetch() {
|
||||
if (isMobile.value) {
|
||||
await mobileListRef.value?.fetch?.()
|
||||
@@ -63,5 +145,22 @@ async function fetch() {
|
||||
await reload()
|
||||
}
|
||||
|
||||
function openTahesabRetry(record: { tahesab_failed_id?: number }) {
|
||||
if (!record.tahesab_failed_id) return
|
||||
selectedTahesabId.value = record.tahesab_failed_id
|
||||
tahesabRetryVisible.value = true
|
||||
}
|
||||
|
||||
async function openTahesabDetail(record: { tahesab_record_id?: number }) {
|
||||
if (!record.tahesab_record_id) return
|
||||
selectedTahesabId.value = record.tahesab_record_id
|
||||
try {
|
||||
tahesabDetail.value = await getTahesabDetail(record.tahesab_record_id)
|
||||
tahesabDetailVisible.value = true
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ fetch })
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
<template>
|
||||
<div class="min-w-0 w-full max-w-full overflow-x-hidden">
|
||||
<BasicShowContext title="اسناد تهحساب">
|
||||
<div v-if="!isMobile" class="min-w-0 w-full max-w-full overflow-x-auto">
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openDetail(record)">
|
||||
<template #title><span>جزئیات</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="canRetry(record)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRetry(record)"
|
||||
>
|
||||
<template #title><span>ارسال به تهحساب</span></template>
|
||||
<Icon icon="vuesax-linear:refresh-circle" color="#CA8A04" />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</BaseTable>
|
||||
</div>
|
||||
</BasicShowContext>
|
||||
|
||||
<BasicModal v-model:visible="detailVisible" title="جزئیات سند تهحساب" width="36rem" :footer="null">
|
||||
<div class="space-y-2 text-sm">
|
||||
<div v-for="item in detailItems" :key="item.label" class="flex justify-between gap-3 border-b border-gray-100 py-2">
|
||||
<span class="text-gray-500">{{ item.label }}</span>
|
||||
<span class="break-all text-left">{{ item.value ?? '-' }}</span>
|
||||
</div>
|
||||
<div v-if="selected?.sync_log" class="rounded-lg bg-red-50 p-3 text-red-700 whitespace-pre-wrap">
|
||||
{{ selected.sync_log }}
|
||||
</div>
|
||||
</div>
|
||||
</BasicModal>
|
||||
|
||||
<TahesabRetryModal
|
||||
v-model="retryVisible"
|
||||
mode="retry-sanad"
|
||||
:tahesab-id="selected?.id"
|
||||
@success="fetch"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
||||
import type { TableInput } from '@core/type/baseTable'
|
||||
import { getTahesabTable, type TahesabRecord } from '@/api/tahesab'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const detailVisible = ref(false)
|
||||
const retryVisible = ref(false)
|
||||
const selected = ref<TahesabRecord | null>(null)
|
||||
|
||||
const columns = [
|
||||
{ title: 'ردیف', dataIndex: 'id', key: 'id', filterable: false, sortable: false, customRender: (r: any) => r.index + 1 },
|
||||
{ title: 'مشتری', dataIndex: 'customer.name', key: 'customer.name', type: 'Text' },
|
||||
{ title: 'نوع', dataIndex: 'type', key: 'type', type: 'Text' },
|
||||
{ title: 'مقدار', dataIndex: 'amount', key: 'amount', type: 'Number' },
|
||||
{ title: 'شرح', dataIndex: 'desc', key: 'desc', type: 'Text' },
|
||||
{
|
||||
title: 'وضعیت',
|
||||
dataIndex: 'sync_status',
|
||||
key: 'sync_status',
|
||||
type: 'Text',
|
||||
customRender: (r: any) => statusLabel(r.record.sync_status, r.record.tahesab_id)
|
||||
},
|
||||
{
|
||||
title: 'زمان',
|
||||
dataIndex: 'created_at',
|
||||
key: 'created_at',
|
||||
type: 'Text',
|
||||
customRender: (r: any) => toJalali(r.record.created_at)
|
||||
},
|
||||
{ title: 'عملیات', dataIndex: 'action', key: 'action', slot: 'action', filterable: false }
|
||||
]
|
||||
|
||||
const tblProps = ref({
|
||||
columns,
|
||||
api: (params: TableInput) => getTahesabTable(params)
|
||||
})
|
||||
|
||||
const detailItems = computed(() => {
|
||||
const row = selected.value
|
||||
if (!row) return []
|
||||
return [
|
||||
{ label: 'شناسه', value: row.id },
|
||||
{ label: 'مشتری', value: row.customer?.name },
|
||||
{ label: 'موبایل', value: row.customer?.mobile },
|
||||
{ label: 'نوع', value: row.type },
|
||||
{ label: 'مقدار', value: row.amount },
|
||||
{ label: 'شرح', value: row.desc },
|
||||
{ label: 'وضعیت', value: statusLabel(row.sync_status, row.tahesab_id) },
|
||||
{ label: 'کد تهحساب', value: row.tahesab_id },
|
||||
{ label: 'پاسخ API', value: row.res }
|
||||
]
|
||||
})
|
||||
|
||||
function statusLabel(status?: string, tahesabId?: string | null) {
|
||||
if (tahesabId) return 'موفق'
|
||||
if (status === 'failed') return 'ناموفق'
|
||||
if (status === 'success') return 'موفق'
|
||||
return 'در انتظار'
|
||||
}
|
||||
|
||||
function canRetry(record: TahesabRecord) {
|
||||
return !record.tahesab_id || record.sync_status === 'failed'
|
||||
}
|
||||
|
||||
function openDetail(record: TahesabRecord) {
|
||||
selected.value = record
|
||||
detailVisible.value = true
|
||||
}
|
||||
|
||||
function openRetry(record: TahesabRecord) {
|
||||
selected.value = record
|
||||
retryVisible.value = true
|
||||
}
|
||||
|
||||
async function fetch() {
|
||||
await reload()
|
||||
}
|
||||
|
||||
defineExpose({ fetch })
|
||||
</script>
|
||||
Reference in New Issue
Block a user