feat(credit): 重构客户管理模块并新增信用客户功能

- 将公司相关页面重命名为客户管理页面
- 新增信用客户详情、编辑、跟进页面
- 实现客户状态跟踪和跟进流程
- 更新应用配置中的页面路由映射
- 优化订单详情页面的时间轴显示逻辑
This commit is contained in:
2026-03-19 23:06:30 +08:00
parent addb53f9c5
commit f306e7a9f7
22 changed files with 1350 additions and 60 deletions

View File

@@ -1,28 +1,53 @@
import { useCallback, useState } from 'react'
import { useCallback, useMemo, useState } from 'react'
import Taro, { useDidShow } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { Button, Cell, CellGroup, ConfigProvider, Empty, Space } from '@nutui/nutui-react-taro'
import { ArrowRight, CheckNormal, Checked } from '@nutui/icons-react-taro'
import type { CreditMpCustomer } from '@/api/credit/creditMpCustomer/model'
import { listCreditMpCustomer, removeCreditMpCustomer, updateCreditMpCustomer } from '@/api/credit/creditMpCustomer'
import { pageCreditMpCustomer, removeCreditMpCustomer, updateCreditMpCustomer } from '@/api/credit/creditMpCustomer'
export default function CreditMpCustomerListPage() {
const [list, setList] = useState<CreditMpCustomer[]>([])
const [count, setCount] = useState(0)
const [page, setPage] = useState(1)
const limit = 20
const [loading, setLoading] = useState(false)
const [loadingMore, setLoadingMore] = useState(false)
const hasMore = useMemo(() => list.length < count, [count, list.length])
const fetchPage = useCallback(
async (opts: { nextPage: number; replace: boolean }) => {
try {
if (opts.replace) setLoading(true)
else setLoadingMore(true)
const res = await pageCreditMpCustomer({ page: opts.nextPage, limit } as any)
const incoming = (res?.list || []) as CreditMpCustomer[]
const total = Number(res?.count || 0)
setCount(Number.isFinite(total) ? total : 0)
setPage(opts.nextPage)
setList(prev => (opts.replace ? incoming : prev.concat(incoming)))
} catch (e) {
console.error('获取数据失败:', e)
Taro.showToast({ title: (e as any)?.message || '获取数据失败', icon: 'none' })
} finally {
setLoading(false)
setLoadingMore(false)
}
},
[limit]
)
const reload = useCallback(async () => {
setLoading(true)
try {
const data = await listCreditMpCustomer()
setList(data || [])
} catch (e) {
console.error('获取数据失败:', e)
Taro.showToast({ title: (e as any)?.message || '获取数据失败', icon: 'none' })
} finally {
setLoading(false)
}
}, [])
await fetchPage({ nextPage: 1, replace: true })
}, [fetchPage])
const loadMore = useCallback(async () => {
if (loading || loadingMore || !hasMore) return
await fetchPage({ nextPage: page + 1, replace: false })
}, [fetchPage, hasMore, loading, loadingMore, page])
useDidShow(() => {
reload()
@@ -83,6 +108,12 @@ export default function CreditMpCustomerListPage() {
</View>
) : (
<View className="px-3 pt-3 pb-6">
<View className="mb-2 text-xs text-gray-500 flex items-center justify-between">
<Text>{count}</Text>
<Text>
{list.length}
</Text>
</View>
<CellGroup>
{list.map(row => {
const recommended = row.recommend === 1
@@ -118,6 +149,11 @@ export default function CreditMpCustomerListPage() {
)
})}
</CellGroup>
<View className="mt-3 flex justify-center">
<Button fill="none" size="small" style={{ color: '#bdbdbd' }} disabled={!hasMore || loadingMore} onClick={loadMore}>
{hasMore ? (loadingMore ? '加载中...' : '加载更多') : '没有更多了'}
</Button>
</View>
<View className="mt-2 text-xs text-gray-400">
</View>