@@ -3,14 +3,17 @@ import { Row, Col, Form, Table, Input, Button, Spin, Select } from 'antd'
33import { listColumns } from './util'
44import { stockPageList , StockQuery } from '../../services/stock'
55import { data2PageData , pageData2Params } from '../../utils/tools'
6- import { Stock , marketOpts , blockOpts } from '../../types/stock'
6+ import { Stock , EMarket , EBlock } from '../../types/stock'
7+ import { object2Options } from '@utils/tools'
78
8- const StockList : React . FC = ( ) => {
9+ const StockList : React . FC < ICommonProps > = ( { history } ) => {
910
1011 const [ form ] = Form . useForm < StockQuery > ( )
1112
1213 const [ loading , setLoading ] = useState ( false )
1314 const [ pageData , setPageData ] = useState ( data2PageData < Stock > ( ) )
15+ const [ marketOpts ] = useState ( object2Options ( EMarket ) )
16+ const [ blockOpts ] = useState ( object2Options ( EBlock ) )
1417
1518 const onQuery = ( params = pageData2Params ( pageData . meta ) ) => {
1619 const vals = form . getFieldsValue ( )
@@ -21,6 +24,10 @@ const StockList: React.FC = () => {
2124 } ) . finally ( ( ) => setLoading ( false ) )
2225 }
2326
27+ const onOpts = ( data : Stock ) => {
28+ history . push ( `/home/stocks/stocks/detail/${ data . id } ` )
29+ }
30+
2431 useEffect ( ( ) => {
2532 onQuery ( )
2633 } , [ ] )
@@ -31,35 +38,33 @@ const StockList: React.FC = () => {
3138 < Row gutter = { 16 } >
3239 < Col span = { 6 } >
3340 < Form . Item name = "code" >
34- < Input allowClear placeholder = "代码 " />
41+ < Input allowClear placeholder = "Stock Code " />
3542 </ Form . Item >
3643 </ Col >
3744 < Col span = { 6 } >
3845 < Form . Item name = "name" >
39- < Input allowClear placeholder = "名称 " />
46+ < Input allowClear placeholder = "Stock Name " />
4047 </ Form . Item >
4148 </ Col >
4249 < Col span = { 6 } >
4350 < Form . Item name = "market" >
44- < Select allowClear placeholder = "请选择市场 " options = { marketOpts ( ) } />
51+ < Select allowClear placeholder = "Please Select Market " options = { marketOpts } />
4552 </ Form . Item >
4653 </ Col >
4754 < Col span = { 6 } >
4855 < Form . Item name = "block" >
49- < Select allowClear placeholder = "请选择板块 " options = { blockOpts ( ) } />
56+ < Select allowClear placeholder = "Please Select Block " options = { blockOpts } />
5057 </ Form . Item >
5158 </ Col >
5259 </ Row >
53- < Row >
54- < Col span = { 6 } offset = { 18 } >
55- < Button onClick = { ( ) => onQuery ( ) } > 查询</ Button >
56- </ Col >
60+ < Row justify = "end" >
61+ < Button type = "primary" onClick = { ( ) => onQuery ( ) } > Search</ Button >
5762 </ Row >
5863 </ Form >
5964 < Table
60- columns = { listColumns ( ) }
65+ columns = { listColumns ( onOpts ) }
6166 dataSource = { pageData . data }
62- key = "code "
67+ rowKey = "id "
6368 pagination = { {
6469 ...pageData . meta ,
6570 onChange : ( page , pageSize ) => onQuery ( { page, pageSize} )
0 commit comments