import CMSPage from './page';
import { React } from '../lib';
import 'cport-nifty/plugins/datatables/media/js/jquery.dataTables.min.js';
import 'cport-nifty/plugins/datatables/media/css/jquery.dataTables.min.css';
import 'cport-nifty/plugins/datatables/extensions/Responsive/css/dataTables.responsive.css';
export default class extends CMSPage {
    async triggerLoad() {
        const flag = this.props.initial === undefined ? true : this.props.initial;
        if (flag) {
            $('#demo-dt-basic').dataTable({
                "paging": false,
                "info": false,
                "search": false,
                "searching": false
            });
        }
    }
    renderHeader() {
        let { operating, header } = this.props;
        if (operating && header.indexReverse(0) !== '操作') {
            header.push('操作');
        }
        let headArr = [];
        for (let i = 0; i < header.length; i++) {
            let item = (React.createElement("th", { className: "min-tablet", key: i }, header[i]));
            headArr.push(item);
        }
        return headArr;
    }
    renderLists() {
        let { lists, header, operating, renderLists } = this.props;
        return renderLists(header, lists, operating);
    }
    render() {
        return (React.createElement("table", { id: "demo-dt-basic", className: "table table-striped table-bordered", cellSpacing: "0", style: { textAlign: 'center', width: '100%' } },
            React.createElement("thead", null,
                React.createElement("tr", null, this.renderHeader())),
            React.createElement("tbody", null, this.renderLists())));
    }
}
