|
|
@@ -0,0 +1,101 @@
|
|
|
+import ProTable from '@ant-design/pro-table'
|
|
|
+import { Select, Card } from 'antd'
|
|
|
+import Iconfont from '@/components/SvgIcon'
|
|
|
+import React, { useState, useMemo } from 'react'
|
|
|
+
|
|
|
+const { Option } = Select
|
|
|
+
|
|
|
+const opMap = {
|
|
|
+ soft: '软件锁'
|
|
|
+}
|
|
|
+const colorMap = {
|
|
|
+ 1: 'text-hex-ffc241',
|
|
|
+ 2: 'text-hex-1dc9b7',
|
|
|
+ 3: 'text-hex-868e96'
|
|
|
+}
|
|
|
+const SoftLeaderboard = ({ loading = false, productLeaderBoard = [] }) => {
|
|
|
+ const [activeOp, setActiveOp] = useState('soft')
|
|
|
+ const columns = useMemo(() => {
|
|
|
+ const oColumns = [
|
|
|
+ {
|
|
|
+ title: '排名',
|
|
|
+ dataIndex: 'index',
|
|
|
+ valueType: 'indexBorder',
|
|
|
+ align: 'center',
|
|
|
+ width: '20%',
|
|
|
+ render: (_, record, index) =>
|
|
|
+ index + 1 <= 3 ? <Iconfont type="icon-trophy" className={colorMap[index + 1]} /> : ''
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '姓名',
|
|
|
+ dataIndex: `${activeOp}Name`,
|
|
|
+ align: 'center',
|
|
|
+ width: '20%'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '销售',
|
|
|
+ dataIndex: 'softSales',
|
|
|
+ align: 'center',
|
|
|
+ width: '20%'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '借出',
|
|
|
+ dataIndex: 'softLend',
|
|
|
+ align: 'center',
|
|
|
+ width: '20%'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '赠送',
|
|
|
+ dataIndex: 'softGift',
|
|
|
+ align: 'center',
|
|
|
+ width: '20%'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+
|
|
|
+ let stop = false
|
|
|
+ const bColumns = oColumns.reduce((prev, curr, idx) => {
|
|
|
+ if (idx < 4) {
|
|
|
+ prev.push(curr)
|
|
|
+ return prev
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!stop && curr.dataIndex.startsWith(activeOp)) {
|
|
|
+ stop = true
|
|
|
+ prev.push(curr)
|
|
|
+ return prev
|
|
|
+ }
|
|
|
+ return prev
|
|
|
+ }, [])
|
|
|
+ return bColumns
|
|
|
+ }, [activeOp])
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Card
|
|
|
+ loading={loading}
|
|
|
+ bodyStyle={{ padding: loading ? '24px' : 0 }}
|
|
|
+ title={
|
|
|
+ <div className="px-4 pt-2 pb-0 flex items-center justify-between">
|
|
|
+ <span>产品排行榜</span>
|
|
|
+ <Select defaultValue="soft" onChange={e => setActiveOp(e)}>
|
|
|
+ <Option value="soft">软件锁</Option>
|
|
|
+ </Select>
|
|
|
+ </div>
|
|
|
+ }>
|
|
|
+ <div className="text-center border border-x-0 p-2">{opMap[activeOp]}排行榜</div>
|
|
|
+ <div className="">
|
|
|
+ <ProTable
|
|
|
+ border={true}
|
|
|
+ rowKey={record => record.rank}
|
|
|
+ columns={columns}
|
|
|
+ dataSource={productLeaderBoard}
|
|
|
+ search={false}
|
|
|
+ size="small"
|
|
|
+ toolBarRender={false}
|
|
|
+ pagination={false}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </Card>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+export default SoftLeaderboard
|