58 lines
2.2 KiB
TypeScript
58 lines
2.2 KiB
TypeScript
import { isCorpGoodsType } from './detail'
|
|
|
|
export const STATUS_CONFIG: Record<string, { color: string, bg: string, result: string }> = {
|
|
'4': { color: '#0261FC', bg: '#E5EFFE', result: '办理中' },
|
|
'1': { color: '#FF2E2E', bg: '#FFEAEA', result: '待办理' },
|
|
'3': { color: '#FF2E2E', bg: '#FFEAEA', result: '待办理' },
|
|
'2': { color: '#07C160', bg: '#E6F8EF', result: '已完成' },
|
|
'5': { color: '#07C160', bg: '#E6F8EF', result: '已完成' },
|
|
'7': { color: '#07C160', bg: '#E6F8EF', result: '已完成' },
|
|
'8': { color: '#07C160', bg: '#E6F8EF', result: '已完成' },
|
|
'6': { color: '#FC6202', bg: '#FEEFE5', result: '待处理' },
|
|
}
|
|
|
|
export const PAY_ICON: Record<string, string> = {
|
|
alipay: 'https://cdn.u8t.cn/frontend-static/corp-h5/static/images/alipay.png',
|
|
weixin: 'https://cdn.u8t.cn/frontend-static/corp-h5/static/images/weixin.png',
|
|
}
|
|
|
|
export const ORDER_TABS = [
|
|
{ key: 'all', label: '全部', statuses: null },
|
|
{ key: 'doing', label: '办理中', statuses: ['4'] },
|
|
{ key: 'rejected', label: '待处理', statuses: ['6'] },
|
|
{ key: 'waiting', label: '待办理', statuses: ['1', '3'] },
|
|
{ key: 'done', label: '已完成', statuses: ['2', '5', '7', '8'] },
|
|
] as const
|
|
|
|
export type OrderTabKey = (typeof ORDER_TABS)[number]['key']
|
|
|
|
const DONE_STATUSES = new Set(['2', '5', '7', '8'])
|
|
const SUBMIT_STATUSES = new Set(['4', '6'])
|
|
|
|
export function getStatusMeta (status?: string, name?: string) {
|
|
const config = STATUS_CONFIG[String(status || '')]
|
|
if (config) return { ...config }
|
|
return {
|
|
color: '#666666',
|
|
bg: '#F5F5F5',
|
|
result: name || '未知',
|
|
}
|
|
}
|
|
|
|
export function filterOrdersByTab<T extends Record<string, any>> (orders: T[] = [], tab: OrderTabKey) {
|
|
const current = ORDER_TABS.find((item) => item.key === tab)
|
|
if (!current || !current.statuses) return orders
|
|
const statuses = new Set<string>(current.statuses)
|
|
return orders.filter((order) => statuses.has(String(order.process_status || '')))
|
|
}
|
|
|
|
export function getOrderCardActions (order: { process_status?: string, goods_type?: string }) {
|
|
const status = String(order.process_status || '')
|
|
const detail = DONE_STATUSES.has(status)
|
|
return {
|
|
complaint: !detail,
|
|
submit: SUBMIT_STATUSES.has(status) && !isCorpGoodsType(order.goods_type),
|
|
detail,
|
|
}
|
|
}
|