|
@@ -15,7 +15,25 @@
|
|
|
>
|
|
>
|
|
|
<template #header>
|
|
<template #header>
|
|
|
<div class="flex flex-wrap items-center gap-2">
|
|
<div class="flex flex-wrap items-center gap-2">
|
|
|
- <InputText v-model="searchForm.id" placeholder="ID" size="small" class="w-32" @keyup.enter="handleSearch" />
|
|
|
|
|
|
|
+ <InputText
|
|
|
|
|
+ v-if="isAdmin"
|
|
|
|
|
+ v-model="searchForm.id"
|
|
|
|
|
+ placeholder="ID"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ class="w-32"
|
|
|
|
|
+ @keyup.enter="handleSearch"
|
|
|
|
|
+ />
|
|
|
|
|
+ <Select
|
|
|
|
|
+ v-if="isAdmin"
|
|
|
|
|
+ v-model="searchForm.teamId"
|
|
|
|
|
+ :options="teamOptions"
|
|
|
|
|
+ optionLabel="label"
|
|
|
|
|
+ optionValue="value"
|
|
|
|
|
+ placeholder="选择团队"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ class="w-32"
|
|
|
|
|
+ :showClear="true"
|
|
|
|
|
+ />
|
|
|
<InputText
|
|
<InputText
|
|
|
v-model="searchForm.paymentName"
|
|
v-model="searchForm.paymentName"
|
|
|
placeholder="收款名称"
|
|
placeholder="收款名称"
|
|
@@ -81,6 +99,15 @@
|
|
|
</template>
|
|
</template>
|
|
|
</Column>
|
|
</Column>
|
|
|
|
|
|
|
|
|
|
+ <Column v-if="isAdmin" field="teamId" header="团队" style="min-width: 120px">
|
|
|
|
|
+ <template #body="slotProps">
|
|
|
|
|
+ <span v-if="slotProps.data.teamId" class="text-sm team-name-text">
|
|
|
|
|
+ {{ getTeamName(slotProps.data.teamId) }}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ <span v-else class="text-gray-400 text-sm">-</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </Column>
|
|
|
|
|
+
|
|
|
<Column field="reminderAmount" header="提现金额" style="min-width: 120px">
|
|
<Column field="reminderAmount" header="提现金额" style="min-width: 120px">
|
|
|
<template #body="slotProps">
|
|
<template #body="slotProps">
|
|
|
<span class="amount-text font-semibold"> {{ formatAmount(slotProps.data.reminderAmount) }} </span>
|
|
<span class="amount-text font-semibold"> {{ formatAmount(slotProps.data.reminderAmount) }} </span>
|
|
@@ -362,7 +389,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, onMounted } from 'vue'
|
|
|
|
|
|
|
+import { ref, onMounted, computed, inject } from 'vue'
|
|
|
import { useDateFormat } from '@vueuse/core'
|
|
import { useDateFormat } from '@vueuse/core'
|
|
|
import Button from 'primevue/button'
|
|
import Button from 'primevue/button'
|
|
|
import Column from 'primevue/column'
|
|
import Column from 'primevue/column'
|
|
@@ -378,9 +405,15 @@ import { useConfirm } from 'primevue/useconfirm'
|
|
|
import { useToast } from 'primevue/usetoast'
|
|
import { useToast } from 'primevue/usetoast'
|
|
|
import { listFinance, updateFinance, deleteFinance, updateFinanceStatus, uploadImage } from '@/services/api'
|
|
import { listFinance, updateFinance, deleteFinance, updateFinanceStatus, uploadImage } from '@/services/api'
|
|
|
import { FinanceStatus } from '@/enums'
|
|
import { FinanceStatus } from '@/enums'
|
|
|
|
|
+import { useTeamStore } from '@/stores/team'
|
|
|
|
|
+import { useUserStore } from '@/stores/user'
|
|
|
|
|
|
|
|
const toast = useToast()
|
|
const toast = useToast()
|
|
|
const confirm = useConfirm()
|
|
const confirm = useConfirm()
|
|
|
|
|
+const teamStore = useTeamStore()
|
|
|
|
|
+const userStore = useUserStore()
|
|
|
|
|
+
|
|
|
|
|
+const isAdmin = inject('isAdmin')
|
|
|
|
|
|
|
|
// 表格数据
|
|
// 表格数据
|
|
|
const tableData = ref({
|
|
const tableData = ref({
|
|
@@ -426,6 +459,7 @@ const qrCodeImage = ref('')
|
|
|
// 搜索表单
|
|
// 搜索表单
|
|
|
const searchForm = ref({
|
|
const searchForm = ref({
|
|
|
id: null,
|
|
id: null,
|
|
|
|
|
+ teamId: null,
|
|
|
paymentName: null,
|
|
paymentName: null,
|
|
|
paymentAccount: null,
|
|
paymentAccount: null,
|
|
|
bankName: null,
|
|
bankName: null,
|
|
@@ -442,6 +476,16 @@ const statusOptions = [
|
|
|
{ label: FinanceStatus.processing, value: 'processing' }
|
|
{ label: FinanceStatus.processing, value: 'processing' }
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
|
|
+const teamOptions = computed(() => {
|
|
|
|
|
+ const options = [{ label: '全部团队', value: null }]
|
|
|
|
|
+ if (teamStore.teams && teamStore.teams.length > 0) {
|
|
|
|
|
+ teamStore.teams.forEach((team) => {
|
|
|
|
|
+ options.push({ label: team.name, value: team.id })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ return options
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
// 获取状态文本
|
|
// 获取状态文本
|
|
|
const getStatusText = (status) => {
|
|
const getStatusText = (status) => {
|
|
|
return FinanceStatus[status] || status
|
|
return FinanceStatus[status] || status
|
|
@@ -457,6 +501,13 @@ const getStatusClass = (status) => {
|
|
|
return classMap[status] || ''
|
|
return classMap[status] || ''
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 获取团队名称
|
|
|
|
|
+const getTeamName = (teamId) => {
|
|
|
|
|
+ if (!teamId || !teamStore.teams) return ''
|
|
|
|
|
+ const team = teamStore.teams.find((t) => t.id === teamId)
|
|
|
|
|
+ return team ? team.name : `团队${teamId}`
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 格式化金额
|
|
// 格式化金额
|
|
|
const formatAmount = (amount) => {
|
|
const formatAmount = (amount) => {
|
|
|
if (!amount) return '0.00'
|
|
if (!amount) return '0.00'
|
|
@@ -482,9 +533,25 @@ const formatSize = (bytes) => {
|
|
|
const fetchData = async () => {
|
|
const fetchData = async () => {
|
|
|
loading.value = true
|
|
loading.value = true
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // 根据用户角色确定teamId
|
|
|
|
|
+ let teamId = undefined
|
|
|
|
|
+ const userRole = userStore.userInfo?.role
|
|
|
|
|
+
|
|
|
|
|
+ if (userRole === 'admin') {
|
|
|
|
|
+ // 管理员使用选择的teamId
|
|
|
|
|
+ teamId = searchForm.value.teamId || undefined
|
|
|
|
|
+ } else if (userRole === 'team') {
|
|
|
|
|
+ // 队长不传teamId,直接调用list接口
|
|
|
|
|
+ teamId = undefined
|
|
|
|
|
+ } else if (userRole === 'user') {
|
|
|
|
|
+ // 队员不传teamId,直接调用list接口
|
|
|
|
|
+ teamId = undefined
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const response = await listFinance(
|
|
const response = await listFinance(
|
|
|
tableData.value.metadata.page,
|
|
tableData.value.metadata.page,
|
|
|
tableData.value.metadata.size,
|
|
tableData.value.metadata.size,
|
|
|
|
|
+ teamId,
|
|
|
searchForm.value.status || undefined,
|
|
searchForm.value.status || undefined,
|
|
|
searchForm.value.paymentName || undefined,
|
|
searchForm.value.paymentName || undefined,
|
|
|
searchForm.value.startDate ? formatDateForAPI(searchForm.value.startDate) : undefined,
|
|
searchForm.value.startDate ? formatDateForAPI(searchForm.value.startDate) : undefined,
|
|
@@ -520,6 +587,7 @@ const handleSearch = () => {
|
|
|
const handleRefresh = () => {
|
|
const handleRefresh = () => {
|
|
|
searchForm.value = {
|
|
searchForm.value = {
|
|
|
id: null,
|
|
id: null,
|
|
|
|
|
+ teamId: null,
|
|
|
paymentName: null,
|
|
paymentName: null,
|
|
|
paymentAccount: null,
|
|
paymentAccount: null,
|
|
|
bankName: null,
|
|
bankName: null,
|
|
@@ -796,7 +864,19 @@ const previewQrCode = (qrCodeData) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 初始化
|
|
// 初始化
|
|
|
-onMounted(() => {
|
|
|
|
|
|
|
+onMounted(async () => {
|
|
|
|
|
+ // 根据角色加载相应的数据
|
|
|
|
|
+ const userRole = userStore.userInfo?.role
|
|
|
|
|
+
|
|
|
|
|
+ if (userRole === 'admin') {
|
|
|
|
|
+ // 管理员需要加载团队列表
|
|
|
|
|
+ await teamStore.loadTeams()
|
|
|
|
|
+ } else if (userRole === 'team') {
|
|
|
|
|
+ // 队长加载自己的团队信息
|
|
|
|
|
+ await teamStore.loadTeams()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 然后获取财务数据
|
|
|
fetchData()
|
|
fetchData()
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
@@ -948,4 +1028,14 @@ onMounted(() => {
|
|
|
background-color: #d1d5db;
|
|
background-color: #d1d5db;
|
|
|
transform: scale(0.98);
|
|
transform: scale(0.98);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+.team-name-text {
|
|
|
|
|
+ color: #6b7280;
|
|
|
|
|
+ font-weight: 500;
|
|
|
|
|
+ max-width: 120px;
|
|
|
|
|
+ overflow: hidden;
|
|
|
|
|
+ text-overflow: ellipsis;
|
|
|
|
|
+ white-space: nowrap;
|
|
|
|
|
+ display: inline-block;
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|