更新了审核功能

This commit is contained in:
weipengfei 2023-09-09 16:59:19 +08:00
parent 71b5252526
commit 22f9d1b967
4 changed files with 267 additions and 7 deletions

View File

@ -39,3 +39,4 @@ export function refundLog(params?: any) {
export function refundStat(params?: any) {
return request.get({ url: '/finance.refund/stat', params })
}

View File

@ -24,3 +24,8 @@ export function apiWithdrawDelete(params: any) {
export function apiWithdrawDetail(params: any) {
return request.get({ url: '/finance.withdraw/detail', params })
}
//提现审核
export function withdrawAudit(params?: any) {
return request.post({ url: '/finance.withdraw/audit', params })
}

View File

@ -47,22 +47,24 @@
</el-form>
</el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
<el-button v-perms="['withdraw/add']" type="primary" @click="handleAdd">
<!--
<el-button v-perms="['withdraw/add']" type="primary" @click="handleAdd">
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
<el-button
</el-button>
<el-button
v-perms="['withdraw/delete']"
:disabled="!selectData.length"
@click="handleDelete(selectData)"
>
删除
</el-button>
</el-button> -->
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<!-- <el-table-column type="selection" width="55" /> -->
<el-table-column label="ID" prop="id" width="110" />
<el-table-column
label="订单编号"
prop="order_sn"
@ -89,7 +91,7 @@
/>
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
<!-- <el-button
v-perms="['withdraw/edit']"
type="primary"
link
@ -97,7 +99,7 @@
>
编辑
</el-button>
<el-button
<el-button
v-perms="['withdraw/delete']"
type="danger"
link
@ -105,6 +107,15 @@
>
删除
</el-button>
-->
<el-button
v-perms="['withdraw/audit']"
type="primary"
link
@click="handleAudit(row)"
>
审核
</el-button>
</template>
</el-table-column>
</el-table>
@ -120,6 +131,13 @@
@success="getLists"
@close="showEdit = false"
/>
<audit-popup
v-if="showAudit"
ref="auditRef"
:dict-data="dictData"
@success="getLists"
@close="showAudit = false"
/>
</div>
</template>
@ -130,10 +148,13 @@ import { apiWithdrawLists, apiWithdrawDelete } from "@/api/withdraw";
import { timeFormat } from "@/utils/util";
import feedback from "@/utils/feedback";
import EditPopup from "./edit.vue";
import AuditPopup from "./audit.vue";
const editRef = shallowRef<InstanceType<typeof EditPopup>>();
const auditRef = shallowRef<InstanceType<typeof AuditPopup>>();
//
const showEdit = ref(false);
const showAudit = ref(false);
//
const queryParams = reactive({
@ -196,6 +217,14 @@ const handleEdit = async (data: any) => {
editRef.value?.setFormData(data);
};
//
const handleAudit = async (data: any) => {
showAudit.value = true;
await nextTick();
auditRef.value?.open("edit");
auditRef.value?.setFormData(data);
};
//
const handleDelete = async (id: number | any[]) => {
await feedback.confirm("确定要删除?");

225
src/views/finance/audit.vue Normal file
View File

@ -0,0 +1,225 @@
<template>
<div class="edit-popup">
<popup
ref="popupRef"
:title="popupTitle"
:async="true"
width="550px"
@confirm="handleSubmit"
@close="handleClose"
>
<el-form
ref="formRef"
:model="formData"
label-width="90px"
:rules="formRules"
>
<el-form-item label="订单编号" prop="order_sn">
<el-input
readonly
v-model="formData.order_sn"
clearable
placeholder="请输入订单编号"
/>
</el-form-item>
<el-form-item label="提现金额" prop="amount">
<el-input
readonly
v-model="formData.amount"
clearable
placeholder="请输入提现金额"
/>
</el-form-item>
<el-form-item label="审核" prop="status">
<el-radio-group v-model="formData.status">
<el-radio :label="1">通过</el-radio>
<el-radio :label="2">拒绝</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-if="formData.status == 2" label="备注" prop="notes">
<el-input
v-model="formData.notes"
clearable
type="textarea"
placeholder="请输入备注"
/>
</el-form-item>
<el-form-item v-else label="转账凭证" prop="transfer_voucher">
<el-upload
class="upload-demo"
style="width: 100%"
drag
:headers="{ Token: userStore.token }"
:action="base_url + '/upload/file'"
:limit="1"
:on-success="handleFile"
:on-exceed="handleExceed"
:before-upload="beforeUpload"
ref="upload"
>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">文件拖入或点击上传</div>
<template #tip>
<div class="el-upload__tip">请上传JPG/JPEG/PNG/GIF/PDF文件</div>
</template>
</el-upload>
</el-form-item>
</el-form>
</popup>
</div>
</template>
<script lang="ts" setup name="withdrawEdit">
import type { FormInstance, UploadRawFile } from "element-plus";
import Popup from "@/components/popup/index.vue";
import {
apiWithdrawAdd,
apiWithdrawEdit,
apiWithdrawDetail,
withdrawAudit,
} from "@/api/withdraw";
import { timeFormat } from "@/utils/util";
import type { PropType } from "vue";
import useUserStore from "@/stores/modules/user";
import { genFileId } from "element-plus";
import { inject } from "vue";
const userStore = useUserStore();
const base_url: any = inject("base_url");
defineProps({
dictData: {
type: Object as PropType<Record<string, any[]>>,
default: () => ({}),
},
});
const emit = defineEmits(["success", "close"]);
const formRef = shallowRef<FormInstance>();
const popupRef = shallowRef<InstanceType<typeof Popup>>();
const mode = ref("add");
//
const popupTitle = computed(() => {
return mode.value == "edit" ? "审核提现申请" : "新增提现申请";
});
//
const formData = reactive({
id: "",
order_sn: "",
user_id: "",
admin_id: "",
amount: "",
status: "",
transfer_voucher: "",
notes: "",
});
//
const formRules = reactive<any>({
status: [
{
required: true,
// message: "",
validator: (rule: any, value: any, callback: any) => {
if (value == 1 || value == 2) {
callback();
} else {
callback(new Error("请选择审核是否通过!"));
}
},
trigger: ["blur"],
},
],
transfer_voucher: [
{
required: true,
message: "请先上传凭证",
trigger: ["blur"],
},
],
notes: [
{
required: true,
message: "请填写拒绝原因",
trigger: ["blur"],
},
],
});
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key];
}
}
};
const getDetail = async (row: Record<string, any>) => {
const data = await apiWithdrawDetail({
id: row.id,
});
setFormData(data);
};
const fileTypeList = [
"application/pdf",
"image/jpeg",
"image/gif",
"image/png",
];
//
const beforeUpload = (rawFile: UploadRawFile) => {
if (!fileTypeList.includes(rawFile.type)) {
ElMessage.error("请上传JPG/JPEG/PNG/GIF/PDF文件");
return false;
}
};
//
const upload = ref(null);
const handleExceed = (files: any) => {
upload.value!.clearFiles();
const file = files[0] as UploadRawFile;
file.uid = genFileId();
upload.value!.handleStart(file);
upload.value!.submit();
};
//
const handleFile = (e: any) => {
if (e.code == 0 && e.show == 1) {
formData.transfer_voucher = "";
upload.value!.clearFiles();
return ElMessage.error(e.msg || "上传失败");
}
formData.transfer_voucher = e.data.uri;
};
//
const handleSubmit = async () => {
await formRef.value?.validate();
const data = { ...formData };
mode.value == (await withdrawAudit(data));
popupRef.value?.close();
emit("success");
};
//
const open = (type = "add") => {
mode.value = type;
popupRef.value?.open();
};
//
const handleClose = () => {
emit("close");
};
defineExpose({
open,
setFormData,
getDetail,
});
</script>