Files
medical-mall/pages/mall/admin/finance/withdrawal.uvue

551 lines
14 KiB
Plaintext

<template>
<view class="finance-withdrawal">
<!-- 头部筛选区 -->
<view class="filter-card">
<view class="filter-row">
<view class="filter-item">
<text class="filter-label">时间选择:</text>
<uni-datetime-picker v-model="timeRange" type="daterange" class="dt-picker" />
</view>
<view class="filter-item">
<text class="filter-label">提现状态:</text>
<uni-data-select v-model="statusValue" :localdata="statusOptions" class="data-select" />
</view>
<view class="filter-item">
<text class="filter-label">提现方式:</text>
<uni-data-select v-model="methodValue" :localdata="methodOptions" class="data-select" />
</view>
<view class="filter-item search-wrap">
<text class="filter-label">搜索:</text>
<uni-easyinput v-model="searchKeyword" placeholder="微信昵称/姓名/支付宝账号/银行卡号" class="search-input" />
</view>
<button class="btn-query" @click="handleQuery">查询</button>
</view>
</view>
<!-- 统计指标网格 -->
<view class="stats-grid">
<view class="stat-card" v-for="(item, index) in statsItems" :key="index">
<view class="icon-circle" :class="item.colorClass">
<text class="stat-icon">{{ item.icon }}</text>
</view>
<view class="stat-info">
<text class="stat-value">{{ item.value }}</text>
<text class="stat-label">{{ item.label }}</text>
</view>
</view>
</view>
<!-- 操作按钮区 -->
<view class="action-section">
<view class="btn-record">
<text class="btn-record-txt">佣金记录</text>
</view>
</view>
<!-- 数据表格 -->
<view class="table-container">
<view class="table-header">
<view class="th col-id"><text class="th-txt">ID</text></view>
<view class="th col-user"><text class="th-txt">用户信息</text></view>
<view class="th col-amount"><text class="th-txt">提现金额</text></view>
<view class="th col-fee"><text class="th-txt">手续费</text></view>
<view class="th col-net"><text class="th-txt">到账金额</text></view>
<view class="th col-method"><text class="th-txt">提现方式</text></view>
<view class="th col-time"><text class="th-txt">申请时间</text></view>
<view class="th col-status"><text class="th-txt">审核状态</text></view>
<view class="th col-ops"><text class="th-txt">操作</text></view>
</view>
<view class="table-body">
<view v-if="loading" class="loading-state" style="padding: 40px; text-align: center;">
<text>加载中...</text>
</view>
<view v-else-if="tableData.length === 0" class="empty-state" style="padding: 40px; text-align: center;">
<text>暂无提现申请</text>
</view>
<view v-else class="table-row" v-for="(item, index) in tableData" :key="item.id">
<view class="td col-id"><text class="td-txt">{{ (page - 1) * pageSize + index + 1 }}</text></view>
<view class="td col-user">
<view class="user-info-box">
<view class="avatar-box">
<text class="avatar-placeholder">U</text>
</view>
<view class="user-detail">
<text class="user-nickname">{{ item.user_name || '未知' }}</text>
<text class="user-id">UID:{{ item.uid.substring(0, 8) }}</text>
</view>
</view>
</view>
<view class="td col-amount"><text class="td-txt">¥{{ item.extract_price.toFixed(2) }}</text></view>
<view class="td col-fee"><text class="td-txt">¥{{ item.service_fee.toFixed(2) }}</text></view>
<view class="td col-net"><text class="td-txt green-txt">¥{{ (item.extract_price - item.service_fee).toFixed(2) }}</text></view>
<view class="td col-method">
<view class="method-box">
<text class="m-line">{{ getMethodText(item.extract_type) }}</text>
<text class="m-line">账号:{{ item.alipay_code || item.wechat_code || item.bank_code || '-' }}</text>
</view>
</view>
<view class="td col-time"><text class="td-txt">{{ item.created_at.substring(0, 16).replace('T', ' ') }}</text></view>
<view class="td col-status">
<text class="td-txt" :class="{ 'red-txt': item.status == -1, 'green-txt': item.status == 1 }">
{{ getStatusText(item.status) }}
</text>
</view>
<view class="td col-ops">
<view class="ops-box" v-if="item.status == 0">
<text class="op-btn blue" @click="handleReview(item.id, 1)">通过</text>
<text class="op-sep">|</text>
<text class="op-btn blue" @click="handleReview(item.id, -1)">驳回</text>
</view>
<text v-else class="td-txt">-</text>
</view>
</view>
</view>
</view>
<!-- 分页区域 -->
<view class="pagination-footer" style="padding: 24px 0; display: flex; flex-direction: row; align-items: center; justify-content: flex-end; gap: 12px;">
<view class="page-total">
<text class="total-txt">共 {{ total }} 条</text>
</view>
<view class="page-btns" style="display: flex; flex-direction: row; gap: 8px;">
<view class="p-btn" :class="{ disabled: page <= 1 }" @click="prevPage" style="width: 32px; height: 32px; border: 1px solid #dcdfe6; display: flex; align-items: center; justify-content: center; cursor: pointer;">
<text><</text>
</view>
<view class="p-btn active" style="width: 32px; height: 32px; background-color: #2d8cf0; color: #fff; display: flex; align-items: center; justify-content: center;">
<text>{{ page }}</text>
</view>
<view class="p-btn" :class="{ disabled: page >= totalPages }" @click="nextPage" style="width: 32px; height: 32px; border: 1px solid #dcdfe6; display: flex; align-items: center; justify-content: center; cursor: pointer;">
<text>></text>
</view>
</view>
<view class="page-jump" style="display: flex; flex-direction: row; align-items: center; gap: 8px;">
<text class="jump-txt">前往</text>
<input class="jump-input" v-model="jumpPage" type="number" @confirm="goToJumpPage" style="width: 40px; height: 32px; border: 1px solid #dcdfe6; text-align: center;" />
<text class="jump-txt">页</text>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { ref, onMounted, reactive } from 'vue'
import { fetchExtractList, fetchFinanceOverview, reviewExtract } from '@/services/admin/financeService.uts'
import { ExtractRecord } from '@/types/admin/finance.uts'
const timeRange = ref<string[]>([])
const statusValue = ref('all')
const methodValue = ref('all')
const searchKeyword = ref('')
const statusOptions = ref([
{ value: 'all', text: '全部' },
{ value: '0', text: '待审核' },
{ value: '1', text: '已通过' },
{ value: '-1', text: '已驳回' }
])
const methodOptions = ref([
{ value: 'all', text: '全部' },
{ value: 'alipay', text: '支付宝' },
{ value: 'bank', text: '银行卡' },
{ value: 'weixin', text: '微信' }
])
const statsItems = ref([
{ label: '佣金总金额', value: '0.00', icon: '¥', colorClass: 'blue' },
{ label: '待提现金额', value: '0.00', icon: '¥', colorClass: 'orange' },
{ label: '已提现金额', value: '0.00', icon: '¥', colorClass: 'green' },
{ label: '未提现金额', value: '0.00', icon: '¥', colorClass: 'pink' }
])
const tableData = ref<ExtractRecord[]>([])
const total = ref(0)
const page = ref(1)
const pageSize = ref(15)
const loading = ref(false)
async function loadStats() {
const endTime = new Date().toISOString()
const startTime = new Date(Date.now() - 365 * 24 * 60 * 60 * 1000).toISOString()
const res = await fetchFinanceOverview(startTime, endTime)
if (res != null) {
statsItems.value[0].value = res.total_user_brokerage.toFixed(2)
statsItems.value[1].value = res.extract_amount.toFixed(2) // 示例逻辑,根据实际汇总调整
statsItems.value[2].value = res.extract_amount.toFixed(2)
statsItems.value[3].value = (res.total_user_brokerage - res.extract_amount).toFixed(2)
}
}
async function loadList() {
loading.value = true
try {
const status = statusValue.value == 'all' ? null : parseInt(statusValue.value)
let startTime : string | null = null
let endTime : string | null = null
if (timeRange.value.length == 2) {
startTime = timeRange.value[0]
endTime = timeRange.value[1]
}
const res = await fetchExtractList(
page.value,
pageSize.value,
status,
startTime,
endTime,
searchKeyword.value || null
)
tableData.value = res.items
total.value = res.total
} catch (e) {
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
onMounted(() => {
loadStats()
loadList()
})
const handleQuery = () => {
page.value = 1
loadList()
}
async function handleReview(id : string, status : number) {
const action = status == 1 ? '通过' : '驳回'
uni.showModal({
title: '提示',
content: `确认要${action}该提现申请吗?`,
success: async (res) => {
if (res.confirm) {
const ok = await reviewExtract(id, status)
if (ok) {
uni.showToast({ title: '操作成功' })
loadList()
loadStats()
} else {
uni.showToast({ title: '操作失败', icon: 'none' })
}
}
}
})
}
function getStatusText(status : number) : string {
if (status == 0) return '待审核'
if (status == 1) return '已通过'
if (status == -1) return '已驳回'
return '未知'
}
function getMethodText(type : string) : string {
if (type == 'alipay') return '支付宝'
if (type == 'bank') return '银行卡'
if (type == 'wechat') return '微信'
return type
}
</script>
<style scoped lang="scss">
.finance-withdrawal {
padding: 20px;
background-color: #f5f7fa;
min-height: 100vh;
}
/* 筛选样式更新 */
.filter-card {
background-color: #fff;
padding: 24px;
border-radius: 4px;
margin-bottom: 20px;
}
.filter-row {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
}
.filter-item {
display: flex;
flex-direction: row;
align-items: center;
margin-right: 24px;
margin-bottom: 16px;
}
.filter-label {
font-size: 14px;
color: #606266;
margin-right: 12px;
white-space: nowrap;
}
.dt-picker {
width: 260px;
}
.data-select {
width: 140px;
}
.search-wrap {
flex: 1;
min-width: 320px;
}
.search-input {
flex: 1;
}
.btn-query {
background-color: #1890ff;
color: #fff;
font-size: 14px;
height: 36px;
line-height: 36px;
padding: 0 24px;
border-radius: 4px;
border: none;
margin-bottom: 16px;
}
/* 统计卡片样式 */
.stats-grid {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-bottom: 20px;
}
.stat-card {
width: 24%;
background-color: #fff;
padding: 24px 20px;
border-radius: 4px;
display: flex;
flex-direction: row;
align-items: center;
box-shadow: 0 2px 12px 0 rgba(0,0,0,0.05);
}
.icon-circle {
width: 52px;
height: 52px;
border-radius: 26px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16px;
}
.blue { background-color: #e6f7ff; color: #1890ff; }
.orange { background-color: #fff7e1; color: #fa8c16; }
.green { background-color: #f6ffed; color: #52c41a; }
.pink { background-color: #fff0f6; color: #eb2f96; }
.stat-icon { font-size: 24px; font-weight: bold; }
.stat-info {
display: flex;
flex-direction: column;
}
.stat-value {
font-size: 22px;
font-weight: 700;
color: #303133;
line-height: 1.1;
}
.stat-label {
font-size: 13px;
color: #909399;
margin-top: 6px;
}
/* 操作区域 */
.action-section {
margin-bottom: 12px;
display: flex;
flex-direction: row;
}
.btn-record {
background-color: #1890ff;
border-radius: 4px;
padding: 6px 16px;
display: flex;
align-items: center;
justify-content: center;
}
.btn-record-txt {
color: #fff;
font-size: 13px;
}
/* 表格容器样式 (Flex 模拟) */
.table-container {
background-color: #fff;
border-radius: 4px;
overflow: hidden;
display: flex;
flex-direction: column;
}
.table-header {
background-color: #f8f9fb;
display: flex;
flex-direction: row;
border-bottom: 1px solid #ebeef5;
}
.th {
padding: 12px 8px;
display: flex;
align-items: center;
justify-content: center;
}
.th-txt {
font-size: 14px;
font-weight: 600;
color: #909399;
}
.table-body {
display: flex;
flex-direction: column;
}
.table-row {
display: flex;
flex-direction: row;
border-bottom: 1px solid #ebeef5;
}
.td {
padding: 12px 8px;
display: flex;
align-items: center;
justify-content: center;
}
.td-txt {
font-size: 13px;
color: #606266;
}
/* 列宽定义 (与截图匹配) */
.col-id { width: 60px; }
.col-user { width: 180px; justify-content: flex-start; }
.col-amount { width: 100px; }
.col-fee { width: 100px; }
.col-net { width: 100px; }
.col-method { flex: 1; min-width: 220px; justify-content: flex-start; }
.col-qr { width: 80px; }
.col-time { width: 150px; }
.col-remark { width: 80px; }
.col-status { width: 100px; }
.col-ops { width: 160px; }
/* 用户信息单元格 */
.user-info-box {
display: flex;
flex-direction: row;
align-items: center;
}
.avatar-box {
width: 32px;
height: 32px;
border-radius: 16px;
background-color: #f0f2f5;
display: flex;
align-items: center;
justify-content: center;
margin-right: 10px;
}
.avatar-placeholder {
font-size: 14px;
color: #999;
}
.user-detail {
display: flex;
flex-direction: column;
}
.user-nickname {
font-size: 13px;
color: #303133;
margin-bottom: 2px;
}
.user-id {
font-size: 11px;
color: #909399;
}
/* 提现方式单元格 */
.method-box {
display: flex;
flex-direction: column;
}
.m-line {
font-size: 12px;
color: #666;
margin-bottom: 2px;
}
.green-txt {
color: #52c41a;
font-weight: 600;
}
/* 收款码 */
.qr-box {
width: 40px;
height: 40px;
background-color: #1a1a1a;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
}
.qr-icon-txt {
color: #fff;
font-size: 16px;
}
/* 操作项 */
.ops-box {
display: flex;
flex-direction: row;
align-items: center;
}
.op-btn {
font-size: 13px;
margin: 0 4px;
}
.blue { color: #1890ff; }
.op-sep {
color: #ebeef5;
font-size: 12px;
}
</style>