SelectSpec.tsx
1.32 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
import React, { useEffect, useState } from "react";
import {
Table,
Select,
} from "antd";
import {
CarOptionVo,
} from "@/pages/stock/Components/api";
import { ColumnsType } from 'antd/lib/table';
interface Props {
onChange?: (pa: any) => void;
value?: any[];
disabled?: boolean;
specList?: CarOptionVo[]
}
interface Item {
label: string;
value: number;
key?: number;
}
const { Column } = Table;
const { Option } = Select;
const columns: ColumnsType<CarOptionVo> = [
{
title: '车型',
dataIndex: 'name',
},
{
title: '配置代码',
dataIndex: 'specConfigCodeList',
render: (t) => t.map((i: string, key: number) => (<div key={i}>{key + 1}.{i}</div>))
},
];
export default function index({ onChange: onSelected, value, disabled, specList = [] }: Props) {
const rowSelection = {
onChange: (selectedRowKeys: React.Key[], selectedRows: CarOptionVo[]) => {
onSelected && onSelected(selectedRows);
},
};
return (
<>
<Table
rowSelection={{
type: "checkbox",
selectedRowKeys: value && value.map(item => item.id),
...rowSelection,
}}
pagination={false}
// loading={}
rowKey="id"
size="small"
scroll={{ y: 500 }}
columns={columns}
dataSource={specList}
/>
</>
);
}