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

287 lines
9.3 KiB
Plaintext

<template>
<view class="finance-commission">
<!-- 筛选卡片 -->
<view class="filter-card border-shadow">
<view class="filter-row">
<view class="filter-item search-wrap">
<text class="filter-label">佣金搜索:</text>
<input class="search-input" v-model="searchKeyword" placeholder="关联单据/用户昵称/UID" @confirm="handleQuery" />
</view>
<view class="filter-item">
<text class="filter-label">收支类型:</text>
<uni-data-select v-model="pmValue" :localdata="pmOptions" class="data-select" @change="handleQuery" />
</view>
<view class="btn-query" @click="handleQuery">
<text class="btn-txt">查询</text>
</view>
</view>
</view>
<!-- 列表表格 -->
<view class="table-card border-shadow">
<view class="action-bar">
<view class="btn-export">
<text class="export-txt">导出</text>
</view>
</view>
<view class="table-container">
<view class="table-header">
<view class="th col-id"><text class="th-txt">序号</text></view>
<view class="th col-order"><text class="th-txt">关联单据</text></view>
<view class="th col-time"><text class="th-txt">时间</text></view>
<view class="th col-amount"><text class="th-txt">变动金额</text></view>
<view class="th col-user"><text class="th-txt">用户信息</text></view>
<view class="th col-type"><text class="th-txt">业务类型</text></view>
<view class="th col-remark"><text class="th-txt">备注</text></view>
</view>
<view class="table-body">
<view v-if="loading" class="table-loading" style="padding: 40px; text-align: center;">
<text>加载中...</text>
</view>
<view v-else-if="tableData.length === 0" class="table-empty" 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-order"><text class="td-txt">{{ item.link_id || '-' }}</text></view>
<view class="td col-time"><text class="td-txt">{{ item.created_at.substring(0, 16).replace('T', ' ') }}</text></view>
<view class="td col-amount">
<text :class="['td-txt', item.pm === 1 ? 'red-txt' : 'green-txt']">
{{ item.pm === 1 ? '+' : '-' }}{{ item.number.toFixed(2) }}
</text>
</view>
<view class="td col-user">
<view class="u-info-box">
<text class="u-name">{{ item.user_name || '未知' }}</text>
<text class="u-id">UID:{{ item.uid.substring(0, 8) }}</text>
</view>
</view>
<view class="td col-type"><text class="td-txt">{{ getBillTypeText(item.type) }}</text></view>
<view class="td col-remark"><text class="td-txt">{{ item.mark || '-' }}</text></view>
</view>
</view>
</view>
</view>
<!-- 分页区域 -->
<view class="pagination-footer">
<view class="page-total">
<text class="total-txt">共 {{ total }} 条</text>
</view>
<view class="page-btns">
<view class="p-btn" :class="{ disabled: page <= 1 }" @click="prevPage">
<text><</text>
</view>
<view class="p-btn active">
<text>{{ page }}</text>
</view>
<view class="p-btn" :class="{ disabled: page >= totalPages }" @click="nextPage">
<text>></text>
</view>
</view>
<view class="page-jump">
<text class="jump-txt">前往</text>
<input class="jump-input" v-model="jumpPage" type="number" @confirm="goToJumpPage" />
<text class="jump-txt">页</text>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { ref, onMounted, computed } from 'vue'
import { fetchUserBillList } from '@/services/admin/financeService.uts'
import { UserBillRecord } from '@/types/admin/finance.uts'
const pmValue = ref<string>('all')
const searchKeyword = ref('')
const page = ref(1)
const pageSize = ref(15)
const total = ref(0)
const loading = ref(false)
const jumpPage = ref('')
const pmOptions = [
{ value: 'all', text: '全部收支' },
{ value: '1', text: '获得佣金' },
{ value: '0', text: '佣金支出' }
]
const tableData = ref<UserBillRecord[]>([])
const totalPages = computed(() : number => {
if (pageSize.value <= 0) return 1
return Math.ceil(total.value / pageSize.value)
})
async function loadList() {
loading.value = true
try {
const pm = pmValue.value == 'all' ? null : parseInt(pmValue.value)
const res = await fetchUserBillList(
page.value,
pageSize.value,
'brokerage', // 佣金明细
null,
pm,
null,
null,
searchKeyword.value || null
)
tableData.value = res.items
total.value = res.total
} catch (e) {
uni.showToast({ title: '加载佣金记录失败', icon: 'none' })
} finally {
loading.value = false
}
}
onMounted(() => {
loadList()
})
const handleQuery = () => {
page.value = 1
loadList()
}
const prevPage = () => {
if (page.value > 1) {
page.value--
loadList()
}
}
const nextPage = () => {
if (page.value < totalPages.value) {
page.value++
loadList()
}
}
const goToJumpPage = () => {
const targetPage = parseInt(jumpPage.value)
if (!isNaN(targetPage) && targetPage >= 1 && targetPage <= totalPages.value) {
page.value = targetPage
loadList()
jumpPage.value = ''
} else {
uni.showToast({ title: '页码无效', icon: 'none' })
}
}
function getBillTypeText(type : string) : string {
if (type == 'extract') return '提现扣除'
if (type == 'brokerage') return '分销返佣'
if (type == 'refund') return '退款扣除'
return type
}
</script>
<style scoped lang="scss">
.finance-commission {
padding: 20px;
background-color: #f5f7fa;
min-height: 100vh;
}
.border-shadow {
background-color: #fff;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
}
.filter-card { padding: 24px; margin-bottom: 20px; }
.filter-row { display: flex; flex-direction: row; align-items: center; }
.filter-item { display: flex; flex-direction: row; align-items: center; margin-right: 28px; }
.filter-label { font-size: 14px; color: #333; margin-right: 12px; white-space: nowrap; }
.search-wrap { flex: 1; }
.search-input { flex: 1; height: 36px; border: 1px solid #dcdfe6; border-radius: 4px; padding: 0 12px; font-size: 14px; }
.data-select { width: 160px; }
.btn-query {
background-color: #1890ff;
border-radius: 4px;
height: 36px;
padding: 0 24px;
display: flex;
align-items: center;
justify-content: center;
margin-left: 10px;
cursor: pointer;
}
.btn-txt { color: #fff; font-size: 14px; }
/* 表格区域 */
.table-card { padding: 0; }
.action-bar { padding: 15px 20px; }
.btn-export { width: 60px; height: 32px; background-color: #e6f7ff; border: 1px solid #91d5ff; border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.export-txt { color: #1890ff; font-size: 14px; }
.table-container { display: flex; flex-direction: column; }
.table-header { background-color: #e6f0ff; display: flex; flex-direction: row; }
.th { padding: 14px 10px; display: flex; align-items: center; justify-content: center; }
.th-txt { font-size: 13px; font-weight: 600; color: #303133; }
.table-body { display: flex; flex-direction: column; }
.table-row { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; min-height: 60px; }
.table-row:hover { background-color: #f9f9f9; }
.td { padding: 12px 10px; display: flex; align-items: center; justify-content: center; }
.td-txt { font-size: 13px; color: #606266; }
.u-info-box {
display: flex;
flex-direction: column;
align-items: flex-start;
.u-name { font-size: 13px; color: #303133; font-weight: 500; }
.u-id { font-size: 11px; color: #909399; }
}
.red-txt { color: #f5222d; font-weight: bold; }
.green-txt { color: #52c41a; font-weight: bold; }
/* 列宽分配 */
.col-id { width: 70px; }
.col-order { width: 180px; }
.col-time { width: 160px; }
.col-amount { width: 120px; }
.col-user { width: 180px; justify-content: flex-start; }
.col-type { width: 120px; }
.col-remark { flex: 1; min-width: 150px; justify-content: flex-start; }
/* 分页 */
.pagination-footer {
padding: 24px 0;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
gap: 12px;
}
.total-txt { font-size: 14px; color: #606266; }
.page-btns { display: flex; flex-direction: row; gap: 8px; }
.p-btn {
width: 32px;
height: 32px;
border: 1px solid #dcdfe6;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
cursor: pointer;
}
.p-btn.active { background-color: #2d8cf0; border-color: #2d8cf0; color: #fff; }
.p-btn.disabled { color: #c0c4cc; background-color: #f5f7fa; cursor: not-allowed; }
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.jump-txt { font-size: 14px; color: #606266; }
.jump-input { width: 40px; height: 32px; border: 1px solid #dcdfe6; text-align: center; border-radius: 4px; font-size: 14px; }
</style>