<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>
|