zhengyiming
2025-12-03 3704e11b86fa50bf9f670de268a18e6de3b5d48a
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<template>
  <ProDialog title="充值" v-model="visible" @close="onDialogClose" destroy-on-close draggable>
    <PortraitTableWithAttachment v-bind="portraitTableWithAttachmentProps">
      <template #title>
        <el-row class="portrait-table-with-attachment-title">
          <el-text style="color: #333333">打款信息</el-text>
          <el-button type="primary" link @click="handleApply">复制</el-button>
        </el-row>
      </template>
    </PortraitTableWithAttachment>
    <ProForm :model="form" ref="dialogForm" label-width="90px" style="margin-top: 20px">
      <ProFormItemV2 label="开户名:" prop="receiveName" mode="read">
        <ProFormText v-model.trim="form.receiveName" />
      </ProFormItemV2>
      <ProFormCol>
        <ProFormColItem :span="12">
          <ProFormItemV2
            label="汇款账号:"
            prop="receiveAccount"
            :check-rules="[{ message: '请输入汇款账号' }]"
          >
            <ProFormText v-model.trim="form.receiveAccount" placeholder="请输入汇款账号" />
          </ProFormItemV2>
        </ProFormColItem>
        <ProFormColItem :span="12">
          <ProFormItemV2 label="" label-width="0"> 请使用同名汇款账号汇款 </ProFormItemV2>
        </ProFormColItem>
      </ProFormCol>
 
      <ProFormItemV2 label="充值金额:" prop="amount" :check-rules="[{ message: '请输入充值金额' }]">
        <ProFormInputNumber
          v-model="form.amount"
          unit="元"
          placeholder="请输入充值金额"
          :controls="false"
        />
      </ProFormItemV2>
      <ProFormItemV2
        label="上传凭证:"
        prop="files"
        :check-rules="[{ message: '请上传凭证', type: 'upload' }]"
      >
        <ProFormUpload
          v-model:file-url="form.files"
          :limit="1"
          :limitFileSize="10"
          accept="jpg/jpeg,png,pdf"
        ></ProFormUpload>
      </ProFormItemV2>
    </ProForm>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="emit('onCancel')">取 消</el-button>
        <el-button type="primary" @click="handleConfirm">确 定</el-button>
      </span>
    </template>
  </ProDialog>
</template>
 
<script setup lang="ts">
import { FormInstance } from 'element-plus';
import {
  ProDialog,
  ProForm,
  ProFormInputNumber,
  ProFormItemV2,
  ProFormUpload,
  ProFormText,
  UploadUserFile,
  ProFormCol,
  ProFormColItem,
} from '@bole-core/components';
import { usePortraitTableWithAttachment } from '@/hooks';
import { convertApi2FormUrl } from '@/utils';
import { useQuery } from '@tanstack/vue-query';
import * as enterpriseCooperationWalletServices from '@/services/api/enterpriseCooperationWallet';
import _ from 'lodash';
import { Message } from '@bole-core/core';
 
defineOptions({
  name: 'BalanceRechargeDialog',
});
 
const visible = defineModel({ type: Boolean });
 
type Form = {
  title?: string;
  id: string;
  receiveName?: string;
  receiveAccount: string;
  amount: number;
  files: UploadUserFile[];
};
 
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({
      cooperationId: form.value.id,
    });
  },
  placeholderData: () => ({} as API.GetCooperationWalletRechargeTransactionQueryResult),
  onSuccess(data) {},
  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: 'receiveName',
    },
    {
      label: '开户银行',
      key: 'receiveBank',
    },
    {
      label: '开户账号',
      key: 'receiveAccount',
    },
  ],
});
 
function handleApply() {
  copyTextToClipboard(
    `进账单位:${detail.value?.receiveUnit}\n开户名称:${detail.value?.receiveName}\n开户银行:${detail.value?.receiveBank}\n开户账号:${detail.value?.receiveAccount}`
  );
  Message.successMessage('复制成功');
}
 
const dialogForm = ref<FormInstance>();
 
function onDialogClose() {
  if (!dialogForm.value) return;
  dialogForm.value.resetFields();
}
 
const handleConfirm = _.debounce(
  () => {
    if (!dialogForm.value) return;
    dialogForm.value.validate((valid) => {
      if (valid) {
        emit('onConfirm');
      } else {
        return;
      }
    });
  },
  1000,
  {
    leading: true,
    trailing: false,
  }
);
</script>
<style lang="scss" scoped>
@use '@/style/common.scss' as *;
 
.portrait-table-with-attachment-title {
  justify-content: space-between;
}
</style>