ApproveTable.tsx
4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import type { ColumnsType } from 'antd/es/table';
import { UTag } from '@uj/ui';
import { DataTable, type RowActionSchema } from '@/components';
import type { DataTableProps } from '@/components/DataTable';
import { StatusTag } from '@/components/StatusTag';
import type { ApprovalRow, ApproveTab } from '@/api';
import type { StoreDictionaries } from '@/features/store/dictionaries';
import { dictionaryLabel, formatDateTime, formatMoney } from '@/features/store/formatters';
interface Props extends Omit<DataTableProps<ApprovalRow>, 'columns'> {
tab: ApproveTab;
spec?: StoreDictionaries;
rowActions: RowActionSchema<ApprovalRow>[];
}
export function ApproveTable({ tab, spec, ...props }: Props) {
const columns: ColumnsType<ApprovalRow> = [
{
title: '门店名称',
dataIndex: 'storeName',
width: 220,
fixed: 'left',
render: (value) => <strong>{value}</strong>,
},
{
title: '门店商户号',
dataIndex: 'merchantNo',
width: 140,
render: (value) => <span className="store-code">{value}</span>,
},
{
title: '产品分类',
key: 'categories',
width: 180,
render: (_, row) => {
const categories = row.productCategories ?? [];
const count = row.categoryCount ?? categories.length;
return (
<>
{categories[0] ? (
<UTag>{dictionaryLabel(spec?.productCategories, categories[0])}</UTag>
) : (
'—'
)}
{count > 1 && <span className="store-subtext">等 {count} 个分类</span>}
</>
);
},
},
{
title: '业务场景',
dataIndex: 'businessScene',
width: 200,
render: (value) => <UTag color="blue">{dictionaryLabel(spec?.businessScenes, value)}</UTag>,
},
];
if (tab === 'todo')
columns.push(
{
title: '运营成本合计',
dataIndex: 'costTotal',
width: 150,
align: 'right',
render: formatMoney,
},
{
title: '提交人 / 提交时间',
width: 180,
render: (_, row) => (
<>
{row.submitUserName || '—'}
<span className="store-subtext">{formatDateTime(row.submitTime)}</span>
</>
),
},
{
title: '停留时长',
width: 110,
render: (_, row) => {
const level =
row.timeoutLevel ??
(row.pendingHours != null && row.pendingHours > 48
? 'DANGER'
: row.pendingHours != null && row.pendingHours > 24
? 'WARNING'
: 'NORMAL');
return (
<span
style={{
color:
level === 'DANGER'
? 'var(--uj-error)'
: level === 'WARNING'
? 'var(--uj-warning)'
: undefined,
}}
>
{row.pendingHours == null ? '—' : `${row.pendingHours} 小时`}
</span>
);
},
},
);
if (tab === 'done')
columns.push(
{
title: '我的动作',
width: 100,
render: (_, row) => (
<UTag
color={
row.myAction === 'PASS' ? 'green' : row.myAction === 'REJECT' ? 'red' : undefined
}
>
{row.myActionLabel ||
({ PASS: '通过', REJECT: '打回' }[row.myAction ?? ''] ?? row.myAction ?? '—')}
</UTag>
),
},
{ title: '处理时间', dataIndex: 'handleTime', width: 180, render: formatDateTime },
{
title: '处理意见',
width: 220,
render: (_, row) => row.handleOpinion || row.rejectReason || '—',
},
{ title: '记录状态', width: 110, render: (_, row) => <StatusTag status={row.status} /> },
);
if (tab === 'mine')
columns.push(
{ title: '状态', width: 110, render: (_, row) => <StatusTag status={row.status} /> },
{
title: '审批进度',
width: 170,
render: (_, row) =>
row.status === 'PENDING'
? (row.totalLevel ?? 2) === 1 || row.currentLevel === 2
? '待优加财务经理审批'
: '待优加商务经理审批'
: row.status === 'REJECTED'
? '退回发起人'
: row.status === 'REVOKED'
? '发起人已撤回'
: row.status === 'APPROVED'
? '已完成'
: '—',
},
{ title: '提交时间', dataIndex: 'submitTime', width: 180, render: formatDateTime },
);
return (
<DataTable<ApprovalRow>
{...props}
columns={columns}
rowKey="listingId"
scroll={{ x: tab === 'done' ? 1500 : 1410 }}
actionColumnWidth={200}
actionColumnFixed="right"
/>
);
}