Commit 49568dac11891129bbaf3073886b0a9557c5a649
1 parent
c7c19fe2
feat(OrderList): 为 InvoicingDrawerForm 组件添加表格组件并实现行选择功能
- 在 InvoicingDrawerForm 组件中引入并使用 Table 组件 - 添加行选择功能,包括全选、反选和自定义选择项 - 实现表格警报渲染,显示已选行数、容器数量和调用量 - 添加表格警报选项,提供批量删除和导出数据功能
Showing
1 changed file
with
39 additions
and
1 deletions
src/pages/Order/OrderList/InvoicingDrawerForm.tsx
... | ... | @@ -31,7 +31,7 @@ import { |
31 | 31 | ProFormText, |
32 | 32 | ProFormTextArea, |
33 | 33 | } from '@ant-design/pro-components'; |
34 | -import { Button, Divider, Form, Space, Tooltip, message } from 'antd'; | |
34 | +import { Button, Divider, Form, Space, Table, Tooltip, message } from 'antd'; | |
35 | 35 | import { useEffect, useRef, useState } from 'react'; |
36 | 36 | |
37 | 37 | export default ({ |
... | ... | @@ -141,6 +141,44 @@ export default ({ |
141 | 141 | drawerProps={{ |
142 | 142 | destroyOnClose: true, |
143 | 143 | }} |
144 | + rowSelection={{ | |
145 | + // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom | |
146 | + // 注释该行则默认不显示下拉选项 | |
147 | + selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT], | |
148 | + }} | |
149 | + tableAlertRender={({ | |
150 | + selectedRowKeys, | |
151 | + selectedRows, | |
152 | + onCleanSelected, | |
153 | + }) => { | |
154 | + console.log(selectedRowKeys, selectedRows); | |
155 | + return ( | |
156 | + <Space size={24}> | |
157 | + <span> | |
158 | + 已选 {selectedRowKeys.length} 项 | |
159 | + <a style={{ marginInlineStart: 8 }} onClick={onCleanSelected}> | |
160 | + 取消选择 | |
161 | + </a> | |
162 | + </span> | |
163 | + <span>{`容器数量: ${selectedRows.reduce( | |
164 | + (pre, item) => pre + item.containers, | |
165 | + 0, | |
166 | + )} 个`}</span> | |
167 | + <span>{`调用量: ${selectedRows.reduce( | |
168 | + (pre, item) => pre + item.callNumber, | |
169 | + 0, | |
170 | + )} 次`}</span> | |
171 | + </Space> | |
172 | + ); | |
173 | + }} | |
174 | + tableAlertOptionRender={() => { | |
175 | + return ( | |
176 | + <Space size={16}> | |
177 | + <a>批量删除</a> | |
178 | + <a>导出数据</a> | |
179 | + </Space> | |
180 | + ); | |
181 | + }} | |
144 | 182 | submitter={{ |
145 | 183 | render: (props, defaultDoms) => { |
146 | 184 | return [ | ... | ... |