diff --git a/src/api/credit/creditMpCustomer/model/index.ts b/src/api/credit/creditMpCustomer/model/index.ts index 7c2d181..a8cc303 100644 --- a/src/api/credit/creditMpCustomer/model/index.ts +++ b/src/api/credit/creditMpCustomer/model/index.ts @@ -55,5 +55,6 @@ export interface CreditMpCustomer { */ export interface CreditMpCustomerParam extends PageParam { id?: number; + step?: number; keywords?: string; } diff --git a/src/credit/mp-customer/index.tsx b/src/credit/mp-customer/index.tsx index c73110d..8b2e6f2 100644 --- a/src/credit/mp-customer/index.tsx +++ b/src/credit/mp-customer/index.tsx @@ -27,11 +27,16 @@ import { hasRole } from '@/utils/permission' const PAGE_SIZE = 10 -type FollowStatus = '全部' | '未联系' | '加微前沟通' | '跟进中' | '已成交' | '无意向' +const STEP_STATUS_TEXT: Record = { + 0: '未受理', + 1: '已受理', + 2: '材料提交', + 3: '合同签订', + 4: '执行回款', + 5: '完结' +} -const FOLLOW_STATUS_OPTIONS: FollowStatus[] = ['全部', '未联系', '加微前沟通', '跟进中', '已成交', '无意向'] - -const FOLLOW_MAP_STORAGE_KEY = 'credit_company_follow_status_map' +const STEP_OPTIONS = [0, 1, 2, 3, 4, 5].map(code => ({ code, text: STEP_STATUS_TEXT[code] })) const safeParseJSON = (v: any): T | null => { try { @@ -44,8 +49,6 @@ const safeParseJSON = (v: any): T | null => { } } -const getRowIdKey = (c: CreditMpCustomer) => String(c?.id || '') - const splitPhones = (raw?: string) => { const text = String(raw || '').trim() if (!text) return [] @@ -68,6 +71,42 @@ const getRowStatus = (c: CreditMpCustomer) => { return String((c as any)?.statusTxt || (c as any)?.statusText || '').trim() } +const getStepCode = (row: CreditMpCustomer): number | null => { + const anyRow = row as any + const raw = + anyRow?.step ?? + anyRow?.stepStatus ?? + anyRow?.statusStep ?? + anyRow?.stepNum ?? + anyRow?.stepCode ?? + anyRow?.stepId ?? + undefined + + const n = Number(raw) + if (Number.isInteger(n) && n in STEP_STATUS_TEXT) return n + + // 兼容:后端直接返回文字到 statusTxt + const txt = getRowStatus(row) + if (!txt) return null + const found = Object.entries(STEP_STATUS_TEXT).find(([, t]) => t === txt) + return found ? Number(found[0]) : null +} + +const getStepText = (row: CreditMpCustomer) => { + const code = getStepCode(row) + if (code != null) return STEP_STATUS_TEXT[code] || '处理中' + const txt = getRowStatus(row) + return txt || '处理中' +} + +const getStepTagType = (code: number | null): any => { + if (code === 5) return 'success' + if (code === 0) return 'primary' + if (code === 4) return 'warning' + if (code === 3) return 'danger' + return 'primary' +} + export default function CreditCompanyPage() { const serverPageRef = useRef(1) const staffLoadingPromiseRef = useRef | null>(null) @@ -81,8 +120,8 @@ export default function CreditCompanyPage() { const [cityVisible, setCityVisible] = useState(false) const [cityText, setCityText] = useState('全部') - const [followVisible, setFollowVisible] = useState(false) - const [followStatus, setFollowStatus] = useState('全部') + const [stepVisible, setStepVisible] = useState(false) + const [stepCode, setStepCode] = useState(null) const [statusVisible, setStatusVisible] = useState(false) const [statusText, setStatusText] = useState('全部') @@ -96,11 +135,6 @@ export default function CreditCompanyPage() { const [staffSelectedId, setStaffSelectedId] = useState(undefined) const [assigning, setAssigning] = useState(false) - const [followMap, setFollowMap] = useState>(() => { - const raw = Taro.getStorageSync(FOLLOW_MAP_STORAGE_KEY) - return safeParseJSON>(raw) || {} - }) - const currentUser = useMemo(() => { return safeParseJSON(Taro.getStorageSync('User')) || ({} as User) }, []) @@ -139,49 +173,11 @@ export default function CreditCompanyPage() { return map }, [staffList]) - const getFollowStatus = useCallback( - (c: CreditMpCustomer): FollowStatus => { - const k = getRowIdKey(c) - const stored = k ? followMap[k] : undefined - if (stored) return stored - return '未联系' - }, - [followMap] - ) - - const setFollowStatusFor = async (c: CreditMpCustomer) => { - if (!c?.id) return - try { - const res = await Taro.showActionSheet({ - itemList: FOLLOW_STATUS_OPTIONS.filter(s => s !== '全部') - }) - const next = FOLLOW_STATUS_OPTIONS.filter(s => s !== '全部')[res.tapIndex] as FollowStatus | undefined - if (!next) return - - setFollowMap(prev => { - const k = getRowIdKey(c) - const merged = { ...prev, [k]: next } - Taro.setStorageSync(FOLLOW_MAP_STORAGE_KEY, merged) - return merged - }) - - // 若当前正在按状态筛选,则即时移除不匹配项,避免“改完状态但列表不变”的割裂感。 - if (followStatus !== '全部' && next !== followStatus && c.id) { - const cid = Number(c.id) - setList(prev => prev.filter(x => Number(x.id) !== cid)) - setSelectedIds(prev => prev.filter(id => id !== cid)) - } - } catch (e) { - const msg = String((e as any)?.errMsg || (e as any)?.message || e || '') - if (msg.includes('cancel')) return - } - } - const applyFilters = useCallback( (incoming: CreditMpCustomer[]) => { const city = cityText === '全部' ? '' : cityText const status = statusText === '全部' ? '' : statusText - const follow = followStatus === '全部' ? '' : followStatus + const step = stepCode == null ? null : stepCode return incoming.filter(c => { if (c?.deleted === 1) return false @@ -196,14 +192,15 @@ export default function CreditCompanyPage() { if (!txt.includes(status)) return false } - if (follow) { - if (getFollowStatus(c) !== follow) return false + if (step != null) { + const code = getStepCode(c) + if (code == null || code !== step) return false } return true }) }, - [cityText, followStatus, getFollowStatus, statusText] + [cityText, statusText, stepCode] ) const reload = useCallback( @@ -437,12 +434,12 @@ export default function CreditCompanyPage() { - - + {/**/}