|
|
@@ -15,7 +15,25 @@
|
|
|
>
|
|
|
<template #header>
|
|
|
<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
|
|
|
v-model="searchForm.agentName"
|
|
|
placeholder="代理"
|
|
|
@@ -87,6 +105,15 @@
|
|
|
</template>
|
|
|
</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="agentName" header="代理" style="min-width: 130px">
|
|
|
<template #body="slotProps">
|
|
|
<span
|
|
|
@@ -360,7 +387,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, onMounted } from 'vue'
|
|
|
+import { ref, onMounted, computed, inject } from 'vue'
|
|
|
import { useDateFormat } from '@vueuse/core'
|
|
|
import Button from 'primevue/button'
|
|
|
import Column from 'primevue/column'
|
|
|
@@ -374,9 +401,15 @@ import { useConfirm } from 'primevue/useconfirm'
|
|
|
import { useToast } from 'primevue/usetoast'
|
|
|
import { listIncome, updateIncome, deleteIncome } from '@/services/api'
|
|
|
import { IncomeType, OrderType } from '@/enums'
|
|
|
+import { useTeamStore } from '@/stores/team'
|
|
|
+import { useUserStore } from '@/stores/user'
|
|
|
|
|
|
const toast = useToast()
|
|
|
const confirm = useConfirm()
|
|
|
+const teamStore = useTeamStore()
|
|
|
+const userStore = useUserStore()
|
|
|
+
|
|
|
+const isAdmin = inject('isAdmin')
|
|
|
|
|
|
// 表格数据
|
|
|
const tableData = ref({
|
|
|
@@ -411,6 +444,7 @@ const editForm = ref({
|
|
|
// 搜索表单
|
|
|
const searchForm = ref({
|
|
|
id: null,
|
|
|
+ teamId: null,
|
|
|
agentName: null,
|
|
|
incomeType: null,
|
|
|
orderType: null,
|
|
|
@@ -445,6 +479,16 @@ const payChannelOptions = [
|
|
|
{ label: '银行卡', value: 'bank' }
|
|
|
]
|
|
|
|
|
|
+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 getIncomeTypeText = (type) => {
|
|
|
return IncomeType[type] || type
|
|
|
@@ -474,6 +518,13 @@ const getPayChannelText = (channel) => {
|
|
|
return channelMap[channel] || channel
|
|
|
}
|
|
|
|
|
|
+// 获取团队名称
|
|
|
+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) => {
|
|
|
if (!amount) return '0.00'
|
|
|
@@ -499,9 +550,25 @@ const formatDateTime = (dateString) => {
|
|
|
const fetchData = async () => {
|
|
|
loading.value = true
|
|
|
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 listIncome(
|
|
|
tableData.value.metadata.page,
|
|
|
tableData.value.metadata.size,
|
|
|
+ teamId,
|
|
|
searchForm.value.agentName || undefined,
|
|
|
searchForm.value.incomeType || undefined,
|
|
|
searchForm.value.startDate ? formatDateForAPI(searchForm.value.startDate) : undefined,
|
|
|
@@ -537,6 +604,7 @@ const handleSearch = () => {
|
|
|
const handleRefresh = () => {
|
|
|
searchForm.value = {
|
|
|
id: null,
|
|
|
+ teamId: null,
|
|
|
agentName: null,
|
|
|
incomeType: null,
|
|
|
orderType: null,
|
|
|
@@ -643,7 +711,19 @@ const saveEdit = async () => {
|
|
|
}
|
|
|
|
|
|
// 初始化
|
|
|
-onMounted(() => {
|
|
|
+onMounted(async () => {
|
|
|
+ // 根据角色加载相应的数据
|
|
|
+ const userRole = userStore.userInfo?.role
|
|
|
+
|
|
|
+ if (userRole === 'admin') {
|
|
|
+ // 管理员需要加载团队列表
|
|
|
+ await teamStore.loadTeams()
|
|
|
+ } else if (userRole === 'team') {
|
|
|
+ // 队长加载自己的团队信息
|
|
|
+ await teamStore.loadTeams()
|
|
|
+ }
|
|
|
+
|
|
|
+ // 然后获取收入数据
|
|
|
fetchData()
|
|
|
})
|
|
|
</script>
|
|
|
@@ -774,4 +854,14 @@ onMounted(() => {
|
|
|
background-color: #d1d5db;
|
|
|
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>
|