added pdf in withdraw and deposit and fix bug
This commit is contained in:
@@ -32,13 +32,24 @@
|
||||
import { message } from 'ant-design-vue'
|
||||
import { getWithdrawTable, updateSts } from '@/api/wallet'
|
||||
import type { Withdraw } from '@/model/wallet'
|
||||
import type { TableInput } from '@core/type/baseTable'
|
||||
import MobileCardList from '@/components/mobile/MobileCardList.vue'
|
||||
import { useMobileDetailSheet } from '@/components/mobile/composables/useMobileDetailSheet'
|
||||
import { useMobileTableList } from '@/components/mobile/composables/useMobileTableList'
|
||||
import { status } from '@/pages/menuPages/withdraw/information/hooks/status'
|
||||
import type { WithdrawFlowType } from '@/pages/menuPages/withdraw/types'
|
||||
import WithdrawMobileDetailSheet from './WithdrawMobileDetailSheet.vue'
|
||||
import WithdrawMobileListItem from './WithdrawMobileListItem.vue'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
flowType?: WithdrawFlowType
|
||||
}>(),
|
||||
{
|
||||
flowType: 'all'
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'withdraw', item: Withdraw): void
|
||||
(e: 'weight', item: Withdraw): void
|
||||
@@ -47,10 +58,17 @@ const emit = defineEmits<{
|
||||
const { sheetVisible, selectedItem, openSheet, syncSelectedItem } = useMobileDetailSheet<Withdraw>()
|
||||
|
||||
const { loading, search, items, hasMore, reload, loadMore, fetch } = useMobileTableList<Withdraw>({
|
||||
fetchApi: getWithdrawTable,
|
||||
fetchApi: (params: TableInput) => getWithdrawTable({ ...params, flow_type: props.flowType }),
|
||||
onFetched: (rows) => syncSelectedItem(rows)
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.flowType,
|
||||
() => {
|
||||
reload()
|
||||
}
|
||||
)
|
||||
|
||||
async function changeStatusHandler(
|
||||
item: Withdraw,
|
||||
statusEntry: [string, (typeof status)[keyof typeof status]]
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<MobileDetailRow label="کد کاربر" :value="row.customer_id ?? '-'" />
|
||||
<MobileDetailRow label="نام و نام خانوادگی" full-width :value="row.customer?.name || '-'" />
|
||||
<MobileDetailRow label="شماره کارت" full-width :value="row.bank_account?.cart_number || '-'" />
|
||||
<MobileDetailRow label="شماره شبا" full-width :value="row.bank_account?.shaba_number || '-'" />
|
||||
<MobileDetailRow label="تاریخ ثبت" full-width :value="dateLabel(row)" />
|
||||
</MobileInfoGrid>
|
||||
</template>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="h-full min-h-0 min-w-0 max-w-full overflow-hidden">
|
||||
<BasicShowContext title="لیست برداشت و واریز">
|
||||
<div class="flex h-full min-h-0 flex-col">
|
||||
<BaseTable v-if="!isMobile" class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<BaseTable v-if="!isMobile" :key="flowType" class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #extraHeader>
|
||||
<!-- <BaseButton type="primary" size="small" class="flex" @click="emits('add')">
|
||||
<div>افزودن مشتری عمده</div>
|
||||
@@ -12,7 +12,7 @@
|
||||
<template #tracked="{ column, record }">
|
||||
<div v-if="record.tracked_number">{{ record.tracked_number }}</div>
|
||||
<div v-else>
|
||||
<BaseButton @click="emits('withdraw', record.id)">تایید برداشت</BaseButton>
|
||||
<BaseButton @click="emits('withdraw', record)">{{ confirmButtonLabel }}</BaseButton>
|
||||
</div>
|
||||
</template>
|
||||
<template #action="{ column, record }">
|
||||
@@ -67,6 +67,7 @@
|
||||
v-else
|
||||
ref="mobileListRef"
|
||||
class="min-h-0 flex-1"
|
||||
:flow-type="props.flowType"
|
||||
@withdraw="(row) => emits('withdraw', row)"
|
||||
@weight="(row) => emits('weight', row)"
|
||||
/>
|
||||
@@ -88,6 +89,16 @@ import { getOrderTable } from '@/api/order'
|
||||
import {getWithdrawTable, updateSts} from '@/api/wallet'
|
||||
import WithdrawMobileCardList from './WithdrawMobileCardList.vue'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import type { WithdrawFlowType } from '../types'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
flowType?: WithdrawFlowType
|
||||
}>(),
|
||||
{
|
||||
flowType: 'all'
|
||||
}
|
||||
)
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
||||
@@ -107,14 +118,28 @@ function checkPermission(temp: string) {
|
||||
|
||||
//define table
|
||||
const table = ref(null)
|
||||
const lastTableParams = ref<TableInput & { flow_type?: string }>({})
|
||||
|
||||
const tblProps = ref<any>({
|
||||
const confirmButtonLabel = computed(() =>
|
||||
props.flowType === 'deposit' ? 'تایید واریز' : 'تایید برداشت'
|
||||
)
|
||||
|
||||
const tblProps = computed(() => ({
|
||||
columns: cols,
|
||||
api: (params: TableInput) => {
|
||||
return getWithdrawTable(params)
|
||||
api: async (params: TableInput) => {
|
||||
const payload = { ...params, flow_type: props.flowType }
|
||||
lastTableParams.value = payload
|
||||
return getWithdrawTable(payload)
|
||||
}
|
||||
//bordered: true
|
||||
})
|
||||
}))
|
||||
|
||||
watch(
|
||||
() => props.flowType,
|
||||
() => {
|
||||
reload()
|
||||
},
|
||||
{ flush: 'post' }
|
||||
)
|
||||
const loading = ref<boolean>(false)
|
||||
|
||||
async function changeCustomerActivationFunction(id: number) {
|
||||
@@ -138,8 +163,8 @@ async function fetch() {
|
||||
// table?.value?.loading.value = val
|
||||
// }
|
||||
defineExpose({
|
||||
fetch
|
||||
// spinTable
|
||||
fetch,
|
||||
getExportParams: () => ({ ...lastTableParams.value, flow_type: props.flowType })
|
||||
})
|
||||
|
||||
import { status } from '@/pages/menuPages/withdraw/information/hooks/status'
|
||||
|
||||
@@ -96,6 +96,15 @@ export const cols: BaseTableColumn[] = [
|
||||
return data.record.bank_account?.cart_number ?? '_'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'شماره شبا',
|
||||
dataIndex: 'bank_account.shaba_number',
|
||||
key: 'bank_account.shaba_number',
|
||||
type: 'Text',
|
||||
customRender: (data) => {
|
||||
return data.record.bank_account?.shaba_number ?? '_'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'وضعیت',
|
||||
dataIndex: 'sts',
|
||||
|
||||
@@ -1,10 +1,25 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicMainCard>
|
||||
<div class="flex w-full h-full">
|
||||
<div class="flex w-full h-full flex-col">
|
||||
<div class="mb-3 flex shrink-0 flex-wrap items-center justify-between gap-3 px-1">
|
||||
<ARadioGroup v-model:value="flowType" button-style="solid">
|
||||
<ARadioButton value="all">همه</ARadioButton>
|
||||
<ARadioButton value="withdraw">برداشت</ARadioButton>
|
||||
<ARadioButton value="deposit">واریز</ARadioButton>
|
||||
</ARadioGroup>
|
||||
<BaseButton
|
||||
icon="vuesax-linear:document-download"
|
||||
:loading="exportLoading"
|
||||
@click="exportPdf"
|
||||
>
|
||||
خروجی PDF
|
||||
</BaseButton>
|
||||
</div>
|
||||
<tbl
|
||||
ref="table"
|
||||
class="w-full h-full"
|
||||
class="min-h-0 flex-1 w-full"
|
||||
:flow-type="flowType"
|
||||
@edit="edit"
|
||||
@delete="deleteItem"
|
||||
@withdraw="openWithdraw"
|
||||
@@ -28,7 +43,7 @@
|
||||
<a-form :model="form" ref="formRef" autocomplete="off">
|
||||
<div class="">
|
||||
<a-form-item label="شماره پیگیری" name="tracked_number" :rules="inputRules()">
|
||||
<BasicInput v-model:value="form.tracked_number" type="number" />
|
||||
<BasicInput v-model:value="form.tracked_number" />
|
||||
</a-form-item>
|
||||
<a-form-item label="تاریخ" name="date_at">
|
||||
<BaseDatePicker v-model:value="form.date_at" show-time format="YYYY-MM-DD HH:mm" />
|
||||
@@ -99,8 +114,10 @@ import type { Customer } from '@/model/customer'
|
||||
import { createCustomer, deleteCustomer, updateCustomer } from '@/api/customer'
|
||||
import type { Order } from '@/model/order'
|
||||
import type { Wallet, Withdraw } from '@/model/wallet'
|
||||
import {completeWithdraw, getWithdrawById, sendWeights} from '@/api/wallet'
|
||||
import {completeWithdraw, exportWithdrawReport, getWithdrawById, sendWeights} from '@/api/wallet'
|
||||
import Button from "@core/components/BaseButton";
|
||||
import type { WithdrawFlowType } from '@/pages/menuPages/withdraw/types'
|
||||
import { openHtmlPrintWindow } from '@/pages/menuPages/withdraw/utils/openHtmlPrintWindow'
|
||||
//import DatePicker from '@core/components/_sample/components/datePicker.vue'
|
||||
|
||||
//loading
|
||||
@@ -110,9 +127,29 @@ const loading = ref<boolean>(false)
|
||||
const store = useStaticApiListsStore()
|
||||
|
||||
//define tbl
|
||||
const table = ref(null)
|
||||
const table = ref<{ fetch: () => Promise<void>; getExportParams?: () => Record<string, unknown> } | null>(null)
|
||||
const refreshTable = () => table?.value?.fetch()
|
||||
|
||||
const flowType = ref<WithdrawFlowType>('all')
|
||||
const exportLoading = ref(false)
|
||||
|
||||
async function exportPdf() {
|
||||
try {
|
||||
exportLoading.value = true
|
||||
const params = {
|
||||
...(table.value?.getExportParams?.() ?? {}),
|
||||
flow_type: flowType.value
|
||||
}
|
||||
const html = await exportWithdrawReport(params as any)
|
||||
openHtmlPrintWindow(html)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
message.error('خطا در تهیه خروجی PDF')
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
let updateKey = ref<number>(0)
|
||||
|
||||
//form
|
||||
@@ -215,8 +252,8 @@ async function edit(record: Customer) {
|
||||
loading.value = false
|
||||
}*/
|
||||
|
||||
function openWithdraw(val: Withdraw) {
|
||||
confirmWithdraw.value = val
|
||||
function openWithdraw(val: Withdraw | number) {
|
||||
confirmWithdraw.value = typeof val === 'number' ? { id: val } : val
|
||||
resetData()
|
||||
confirmWithdrawVisible.value = true
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export type WithdrawFlowType = 'all' | 'withdraw' | 'deposit'
|
||||
@@ -0,0 +1,11 @@
|
||||
export function openHtmlPrintWindow(html: string) {
|
||||
const printWindow = window.open('', '_blank')
|
||||
if (!printWindow) {
|
||||
throw new Error('popup blocked')
|
||||
}
|
||||
|
||||
printWindow.document.open()
|
||||
printWindow.document.write(html)
|
||||
printWindow.document.close()
|
||||
printWindow.focus()
|
||||
}
|
||||
Reference in New Issue
Block a user