fix(finance): 客服只能使用自己的备用金账户
This commit is contained in:
@@ -4,7 +4,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
import { createAdminManualOrderCost, fetchAdminFundAccounts } from '@/services/admin'
|
||||
import { hasAdminPermission } from '@/utils/admin-auth'
|
||||
import { getAdminRole, hasAdminPermission } from '@/utils/admin-auth'
|
||||
|
||||
export type ManualOrderCostItem = {
|
||||
orderItemId: number
|
||||
@@ -77,6 +77,8 @@ export default function ManualOrderCostModal({
|
||||
})
|
||||
const fundAccounts = fundAccountsQuery.data?.data.items || []
|
||||
const soleFundAccountId = fundAccounts.length === 1 ? fundAccounts[0]?.id : undefined
|
||||
const isSupport = getAdminRole() === 'support'
|
||||
const ownFundAccount = isSupport ? fundAccounts[0] : undefined
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
@@ -161,25 +163,45 @@ export default function ManualOrderCostModal({
|
||||
<Form.Item label="订单号">
|
||||
<Input value={orderNo} readOnly />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="fundAccountId"
|
||||
label="备用金账户"
|
||||
rules={[{ required: true, message: '请选择备用金账户' }]}
|
||||
extra="人工支出会直接从该客服的备用金余额扣减"
|
||||
>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
loading={fundAccountsQuery.isLoading}
|
||||
placeholder="请选择这笔支出从哪个客服备用金账户出"
|
||||
options={fundAccounts.map((account) => ({
|
||||
value: account.id,
|
||||
label: `${account.ownerName} · ${account.accountNo} · 余额 ¥${(
|
||||
account.balanceFen / 100
|
||||
).toFixed(2)}`,
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
{isSupport ? (
|
||||
<>
|
||||
<Form.Item label="备用金账户" extra="只能使用自己的备用金账户">
|
||||
<Input
|
||||
readOnly
|
||||
value={
|
||||
ownFundAccount
|
||||
? `${ownFundAccount.ownerName} · ${ownFundAccount.accountNo} · 余额 ¥${(
|
||||
ownFundAccount.balanceFen / 100
|
||||
).toFixed(2)}`
|
||||
: '当前账号还没有备用金账户'
|
||||
}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="fundAccountId" hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</>
|
||||
) : (
|
||||
<Form.Item
|
||||
name="fundAccountId"
|
||||
label="备用金账户"
|
||||
rules={[{ required: true, message: '请选择备用金账户' }]}
|
||||
extra="人工支出会直接从该客服的备用金余额扣减"
|
||||
>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
loading={fundAccountsQuery.isLoading}
|
||||
placeholder="请选择这笔支出从哪个客服备用金账户出"
|
||||
options={fundAccounts.map((account) => ({
|
||||
value: account.id,
|
||||
label: `${account.ownerName} · ${account.accountNo} · 余额 ¥${(
|
||||
account.balanceFen / 100
|
||||
).toFixed(2)}`,
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
)}
|
||||
{!fundAccountsQuery.isLoading && fundAccounts.length === 0 ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
|
||||
Reference in New Issue
Block a user