import React, { ReactNode } from "react"; import { Button, Input, Select } from "antd"; import { ButtonGroups, AdvancedSearch, DataTable, Panel } from "@mcf/components"; import { IRListProps, IRListState, IParams, PK, RListPage } from "@mcf/crud"; import { TableProps } from "antd/lib/table/index"; import { ICarAction, IReducerState } from "../interface"; import Model from '../model' interface ListProps extends IRListProps { actions: ICarAction; reducer: IReducerState; items: M[]; } interface ListState extends IRListState {} export default class ListView extends RListPage< ListProps, ListState > { mergeTableConfig(config: TableProps): Object { return {}; } componentDidMount(): void { this.handleFilter(this.searchParams()); } handleFilter(value: Object) { const { actions, match: { params }, } = this.props; actions.fetchPage(Object.assign({}, value, params)); } searchParams(): object { // const { actions, querys } = this.props; // const defaultParams: Object = {}; // return Object.assign(defaultParams, querys("actions.fetchPage")); return { a: 1 }; } handlerMenu(rowkeys: string, actionType: string): void { const { actions } = this.props; if (actionType === "add") { this.goAdd(); } else if (actionType === "edit") { this.goEdit(rowkeys); } else if (actionType === "detail") { this.goDetail(rowkeys); } else if (actionType === "delete") { actions.fetchDelete(rowkeys); } this.clearSelectRows(); } renderOptionItem(item: { label: string; value: string }, idx: PK): ReactNode { return ( {item.label} ); } renderSearchForm(): ReactNode { // const { actions, spins, locale } = this.props; const query: IParams = this.searchParams(); return ( ); } render(): ReactNode { return ( {this.renderSearchForm()} {this.renderToolbar()} {this.renderDataTable()} ); } renderToolbar(): ReactNode { const { selectedRowKeys } = this.state; this.state.selectedRows.map((it: M) => it.name); const { locale } = this.props; return ( this.handlerMenu.bind(selectedRowKeys, actionType) } > ); } renderTableButtonGroups(text: string, row: M): ReactNode { const { locale } = this.props; return ( this.handlerMenu(row.id.toString(), actionType) } size="small" > ); } renderDataTable(): ReactNode { const { items, // spins, locale, } = this.props; items.map((it:M)=>it.title) let tableConf: TableProps = { rowKey: "id", dataSource: items, columns: [ { title: locale("label"), key: "label", dataIndex: "label", }, { title: locale("GLOBAL.COLUMNS.OPTIONS"), key: "options", dataIndex: "options", width: 190, render: this.renderTableButtonGroups, }, ], }; return ; } }