Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
inclass-partners
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
趣选课
inclass-partners
Commits
4d0e82f3
Commit
4d0e82f3
authored
Jul 30, 2020
by
翁佳瑞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加可配置的columns
parent
a024108a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
66 deletions
+85
-66
list.tsx
src/pages/orderList/list.tsx
+19
-66
tableColumnsSetting.tsx
src/pages/orderList/tableColumnsSetting.tsx
+66
-0
No files found.
src/pages/orderList/list.tsx
View file @
4d0e82f3
import
React
from
'react'
;
import
React
from
'react'
;
import
{
Table
}
from
'antd'
;
import
{
Table
}
from
'antd'
;
const
{
Column
}
=
Table
;
import
{
ColumnsType
}
from
'antd/es/table'
;
import
tableColumnsSetting
from
'./tableColumnsSetting'
interface
DeatilI
{
interface
DeatilI
{
id
:
string
|
number
;
id
:
string
|
number
;
...
@@ -11,12 +13,6 @@ interface DeatilI {
...
@@ -11,12 +13,6 @@ interface DeatilI {
pay_time
:
string
;
pay_time
:
string
;
}
}
interface
ColsI
{
title
:
string
;
dataIndex
:
string
;
key
:
string
|
number
;
}
interface
DataSourceI
{
interface
DataSourceI
{
dataSource
:
DeatilI
[];
dataSource
:
DeatilI
[];
pageSize
:
number
;
pageSize
:
number
;
...
@@ -24,66 +20,22 @@ interface DataSourceI {
...
@@ -24,66 +20,22 @@ interface DataSourceI {
totalCount
:
number
;
totalCount
:
number
;
handleTableChange
:
any
;
handleTableChange
:
any
;
}
}
interface
IColumnsValue
{
const
columns
=
[
title
:
string
;
{
dataIndex
:
string
;
title
:
'订单号'
,
key
:
string
|
number
;
dataIndex
:
'order_no'
,
render
?:
Function
key
:
'order_no'
}
},
const
columns
:
Array
<
any
>
=
[]
{
let
userColumnsKeys
:
Array
<
string
>
=
[
'order_no'
,
'class_name'
,
'name'
,
'address'
,
'phone'
,
'pay'
,
'pay_time'
]
title
:
'已购课程名称'
,
userColumnsKeys
.
map
((
item
)
=>
{
dataIndex
:
'class_name'
,
for
(
let
key
in
tableColumnsSetting
)
{
key
:
'class_name'
if
(
key
===
item
)
{
},
columns
.
push
(
tableColumnsSetting
[
key
])
{
title
:
'用户姓名'
,
dataIndex
:
'address'
,
key
:
'address'
,
render
:
(
row
:
any
)
=>
{
return
<
span
>
{
row
.
name
}
</
span
>;
}
},
{
title
:
'收货地址'
,
dataIndex
:
'address'
,
key
:
'address'
,
render
:
(
row
:
any
)
=>
{
return
(
<
span
>
{
row
.
province
}
{
row
.
city
}
{
row
.
area
}
{
row
.
address
}
</
span
>
);
}
},
{
title
:
'联系电话'
,
dataIndex
:
'address'
,
key
:
'address'
,
render
:
(
row
:
any
)
=>
{
return
<
span
>
{
row
.
phone
}
</
span
>;
}
}
},
{
title
:
'付款金额(元)'
,
dataIndex
:
'pay'
,
key
:
'pay'
},
{
title
:
'下单时间'
,
dataIndex
:
'pay_time'
,
key
:
'pay_time'
}
}
];
return
null
})
const
Cols
=
(
list
:
ColsI
[])
=>
{
return
list
.
map
((
item
:
any
)
=>
{
return
<
Column
{
...
item
}
key=
{
item
.
key
}
/>;
});
};
const
List
:
React
.
FC
<
DataSourceI
>
=
props
=>
{
const
List
:
React
.
FC
<
DataSourceI
>
=
props
=>
{
return
(
return
(
...
@@ -100,8 +52,9 @@ const List: React.FC<DataSourceI> = props => {
...
@@ -100,8 +52,9 @@ const List: React.FC<DataSourceI> = props => {
showTotal
:
(
total
,
range
)
=>
showTotal
:
(
total
,
range
)
=>
`每页${range[1] - range[0] + 1}条,总计${total} 条`
`每页${range[1] - range[0] + 1}条,总计${total} 条`
}
}
}
}
columns=
{
columns
}
>
>
{
Cols
(
columns
)
}
</
Table
>
</
Table
>
</
div
>
</
div
>
);
);
...
...
src/pages/orderList/tableColumnsSetting.tsx
0 → 100644
View file @
4d0e82f3
import
React
from
'react'
interface
IObjectStringKeys
{
[
key
:
string
]:
IColumnsValue
;
}
interface
IColumnsValue
{
title
:
string
;
dataIndex
:
string
;
key
:
string
|
number
;
render
?:
Function
}
const
TableColumnsSetting
:
IObjectStringKeys
=
{
order_no
:
{
title
:
'订单号'
,
dataIndex
:
'order_no'
,
key
:
'order_no'
},
class_name
:
{
title
:
'已购课程名称'
,
dataIndex
:
'class_name'
,
key
:
'class_name'
},
name
:
{
title
:
'用户姓名'
,
dataIndex
:
'address'
,
key
:
'name'
,
render
:
(
row
:
any
)
=>
{
return
<
span
>
{
row
.
name
}
</
span
>;
}
},
address
:
{
title
:
'收货地址'
,
dataIndex
:
'address'
,
key
:
'address'
,
render
:
(
row
:
any
)
=>
{
return
(
<
span
>
{
row
.
province
}
{
row
.
city
}
{
row
.
area
}
{
row
.
address
}
</
span
>
);
}
},
phone
:
{
title
:
'联系电话'
,
dataIndex
:
'address'
,
key
:
'phone'
,
render
:
(
row
:
any
)
=>
{
return
<
span
>
{
row
.
phone
}
</
span
>;
}
},
pay
:
{
title
:
'付款金额(元)'
,
dataIndex
:
'pay'
,
key
:
'pay'
},
pay_time
:
{
title
:
'下单时间'
,
dataIndex
:
'pay_time'
,
key
:
'pay_time'
}
}
export
default
TableColumnsSetting
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment