Эх сурвалжийг харах

添加团队收入页面展示个人分润

wilhelm wong 2 сар өмнө
parent
commit
70fbcd72e7

+ 2 - 1
src/enums/index.js

@@ -38,7 +38,8 @@ export const FinanceStatus = {
 
 export const IncomeType = {
   tip: '打赏收入',
-  commission: '返佣收入'
+  commission: '返佣收入',
+  share_single: '分享单片'
 }
 
 export const OrderType = {

+ 87 - 7
src/views/IncomeView.vue

@@ -122,10 +122,34 @@
         </template>
       </Column>
 
+      <Column
+        field="personalIncomeAmount"
+        header="个人收入"
+        style="min-width: 100px"
+        :pt="{
+          columnHeaderContent: {
+            class: 'justify-center'
+          }
+        }"
+      >
+        <template #body="slotProps">
+          <span class="amount-text font-semibold text-blue-600">{{ formatAmount(slotProps.data.personalIncomeAmount) }} </span>
+        </template>
+      </Column>
+
+      <Column field="personalAgentId" header="个人代理" style="min-width: 120px">
+        <template #body="slotProps">
+          <span v-if="slotProps.data.personalAgentId" class="text-sm agent-name-text">
+            {{ getPersonalAgentName(slotProps.data.personalAgentId) }}
+          </span>
+          <span v-else class="text-gray-400 text-sm">-</span>
+        </template>
+      </Column>
+
       <Column field="incomeType" header="收入类型" style="min-width: 100px">
         <template #body="slotProps">
           <span class="income-type-text" :class="getIncomeTypeClass(slotProps.data.incomeType)">
-            {{ getIncomeTypeText(slotProps.data.incomeType) }}
+            {{ getIncomeTypeText(slotProps.data.incomeType, slotProps.data.incomeAmount, slotProps.data.payChannel) }}
           </span>
         </template>
       </Column>
@@ -278,6 +302,18 @@
               class="w-full"
             />
           </div>
+
+          <div class="field">
+            <label for="edit-personalIncomeAmount" class="font-medium text-sm mb-2 block">个人收入</label>
+            <InputNumber
+              id="edit-personalIncomeAmount"
+              v-model="editForm.personalIncomeAmount"
+              mode="decimal"
+              :min-fraction-digits="2"
+              :max-fraction-digits="2"
+              class="w-full"
+            />
+          </div>
         </div>
 
         <div class="grid grid-cols-2 gap-4 mt-4">
@@ -351,7 +387,7 @@ import InputText from 'primevue/inputtext'
 import InputNumber from 'primevue/inputnumber'
 import { useConfirm } from 'primevue/useconfirm'
 import { useToast } from 'primevue/usetoast'
-import { listIncome, updateIncome, deleteIncome } from '@/services/api'
+import { listIncome, updateIncome, deleteIncome, listMembers } from '@/services/api'
 import { IncomeType, OrderType } from '@/enums'
 import { useTeamStore } from '@/stores/team'
 import { useUserStore } from '@/stores/user'
@@ -373,6 +409,9 @@ const tableData = ref({
   }
 })
 
+// 团队成员列表数据
+const membersList = ref([])
+
 // 加载状态
 const loading = ref(false)
 
@@ -383,6 +422,8 @@ const editForm = ref({
   id: null,
   agentId: null,
   incomeAmount: null,
+  personalIncomeAmount: null,
+  personalAgentId: null,
   incomeType: null,
   orderType: null,
   orderPrice: null,
@@ -406,7 +447,8 @@ const searchForm = ref({
 const incomeTypeOptions = [
   { label: '全部', value: null },
   { label: IncomeType.tip, value: 'tip' },
-  { label: IncomeType.commission, value: 'commission' }
+  { label: IncomeType.commission, value: 'commission' },
+  { label: IncomeType.share_single, value: 'share_single' }
 ]
 
 // 订单类型选项
@@ -427,7 +469,8 @@ const payChannelOptions = [
   { label: '全部', value: null },
   { label: '支付宝', value: 'alipay' },
   { label: '微信支付', value: 'wechat' },
-  { label: '银行卡', value: 'bank' }
+  { label: '银行卡', value: 'bank' },
+  { label: '分享', value: 'system' }
 ]
 
 const teamOptions = computed(() => {
@@ -441,7 +484,11 @@ const teamOptions = computed(() => {
 })
 
 // 获取收入类型文本
-const getIncomeTypeText = (type) => {
+const getIncomeTypeText = (type, incomeAmount, payChannel) => {
+  // 特殊业务逻辑:金额为0且支付渠道为system时,显示分享单片
+  if (incomeAmount === 0 && payChannel === 'system') {
+    return IncomeType.share_single
+  }
   return IncomeType[type] || type
 }
 
@@ -449,7 +496,8 @@ const getIncomeTypeText = (type) => {
 const getIncomeTypeClass = (type) => {
   const classMap = {
     tip: 'income-type-tip',
-    commission: 'income-type-commission'
+    commission: 'income-type-commission',
+    share_single: 'income-type-share'
   }
   return classMap[type] || ''
 }
@@ -466,12 +514,28 @@ const getTeamName = (agentId) => {
   return team ? team.name : `-`
 }
 
+// 获取个人代理用户名
+const getPersonalAgentName = (personalAgentId) => {
+  if (!personalAgentId) return '-'
+  
+  // 从团队成员列表中查找
+  if (membersList.value.length > 0) {
+    const member = membersList.value.find(m => m.userId === personalAgentId)
+    if (member) {
+      return member.name
+    }
+  }
+  
+  return personalAgentId
+}
+
 // 获取支付渠道文本
 const getPayChannelText = (channel) => {
   const channelMap = {
     alipay: '支付宝',
     wechat: '微信支付',
-    bank: '银行卡'
+    bank: '银行卡',
+    system: '分享'
   }
   return channelMap[channel] || channel
 }
@@ -497,6 +561,17 @@ const formatDateTime = (dateString) => {
   return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
 }
 
+// 获取团队成员列表
+const fetchMembers = async () => {
+  try {
+    // 获取所有团队成员(不分页)
+    const response = await listMembers(0, 1000) // 获取大量数据
+    membersList.value = response.content || []
+  } catch (error) {
+    console.error('获取团队成员列表失败:', error)
+  }
+}
+
 // 获取数据
 const fetchData = async () => {
   loading.value = true
@@ -618,6 +693,8 @@ const openEditDialog = (income) => {
     id: income.id,
     agentId: income.agentId || null,
     incomeAmount: income.incomeAmount || null,
+    personalIncomeAmount: income.personalIncomeAmount || null,
+    personalAgentId: income.personalAgentId || null,
     incomeType: income.incomeType || null,
     orderType: income.orderType || null,
     orderPrice: income.orderPrice || null,
@@ -655,6 +732,9 @@ const saveEdit = async () => {
 
 // 初始化
 onMounted(async () => {
+  // 获取团队成员列表
+  await fetchMembers()
+  
   // 根据角色加载相应的数据
   const userRole = userStore.userInfo?.role