wupengfei
2025-11-12 10089efc8a1417e20f741259d839883abf30d1c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<template>
  <ProDialog title="充值详情" v-model="visible" @close="onDialogClose" destroy-on-close draggable>
    <PortraitTableWithAttachment v-bind="portraitTableWithAttachmentProps" />
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="emit('onCancel')">取 消</el-button>
        <el-button type="primary" @click="emit('onCancel')">确 定</el-button>
      </span>
    </template>
  </ProDialog>
</template>
 
<script setup lang="ts">
import { FormInstance } from 'element-plus';
import { ProDialog } from '@bole-core/components';
import { usePortraitTableWithAttachment } from '@/hooks';
import { useQuery } from '@tanstack/vue-query';
import { EnumEnterpriseCooperationWalletTransactionStatusText } from '@/constants';
import * as enterpriseCooperationWalletServices from '@/services/api/enterpriseCooperationWallet';
import { convertApi2FormUrl } from '@/utils';
 
defineOptions({
  name: 'RechargeRecordialog',
});
 
const visible = defineModel({ type: Boolean });
 
type Form = {
  title?: string;
  id: string;
};
 
const form = defineModel<Form>('form');
 
const emit = defineEmits<{
  (e: 'onConfirm'): void;
  (e: 'onCancel'): void;
}>();
 
watch(
  () => visible.value,
  (val) => {
    if (val) {
      refetch();
    }
  }
);
 
const { data: detail, refetch } = useQuery({
  queryKey: [
    'enterpriseCooperationWalletServices/getCooperationWalletRechargeTransaction',
    form.value.id,
  ],
  queryFn: async () => {
    return await enterpriseCooperationWalletServices.getCooperationWalletRechargeTransaction({
      id: form.value.id,
    });
  },
  placeholderData: () => ({} as API.GetCooperationWalletRechargeTransactionQueryResult),
  enabled: computed(() => !!form.value.id),
});
 
const { portraitTableWithAttachmentProps } = usePortraitTableWithAttachment({
  data: detail,
  annexList: computed(() =>
    detail.value?.files ? detail.value?.files.map((item) => convertApi2FormUrl(item)) : []
  ),
  columns: [
    {
      label: '充值单位',
      key: 'receiveUnit',
    },
    {
      label: '开户账号',
      key: 'receiveAccount',
    },
    {
      label: '充值金额',
      key: 'amount',
      type: 'money',
    },
    {
      label: '充值时间',
      key: 'createdTime',
      type: 'date',
    },
    {
      label: '充值状态',
      key: 'transactionStatus',
      type: 'enum',
      valueEnum: EnumEnterpriseCooperationWalletTransactionStatusText,
    },
  ],
});
 
const dialogForm = ref<FormInstance>();
 
function onDialogClose() {
  if (!dialogForm.value) return;
  dialogForm.value.resetFields();
}
</script>