/**
 * title: "常用场景"
 * description: "表格场景内使用"
 */
import React, { useState } from 'react';
import { Table } from '@alicloud/console-components';
import Actions, { LinkButton } from '@alicloud/console-components-actions';
var getDataSource = function () {
    var result = [];
    for (var i = 0; i < 2; i++) {
        result.push({
            id: 100306660940 + i,
            status: i % 2 === 0 ? '运行中' : '停用',
            type: '专用网络',
            title: '可以通过 expandedRowRender 额外渲染行',
            name: '实例名称',
        });
    }
    return result;
};
var render = function () {
    return (React.createElement(Actions, null,
        React.createElement(LinkButton, { onClick: function () {
                alert('on click');
            } }, "\u64CD\u4F5C\u9879"),
        React.createElement(LinkButton, { onClick: function () {
                alert('on click');
            } }, "\u64CD\u4F5C\u9879"),
        React.createElement(LinkButton, { onClick: function () {
                alert('on click');
            } }, "\u64CD\u4F5C\u9879")));
};
export default (function () {
    var _a = useState(getDataSource()), dataSource = _a[0], setDataSource = _a[1];
    var onFilter = function (filterParams) {
        var ds = getDataSource();
        Object.keys(filterParams).forEach(function (key) {
            var selectedKeys = filterParams[key].selectedKeys;
            if (selectedKeys.length) {
                ds = ds.filter(function (record) {
                    return selectedKeys.some(function (value) {
                        return record[key].indexOf(value) > -1;
                    });
                });
            }
        });
        setDataSource(ds);
    };
    var renderId = function (value, _index, record) {
        var name = record.name;
        return (React.createElement("div", null,
            React.createElement("a", { href: "/" }, value),
            React.createElement("div", null, name)));
    };
    return (React.createElement("div", null,
        React.createElement(Table, { onFilter: onFilter, dataSource: dataSource, hasBorder: false },
            React.createElement(Table.Column, { title: "\u5B9E\u4F8BID/\u540D\u79F0", dataIndex: "id", width: 200, cell: renderId }),
            React.createElement(Table.Column, { filters: [
                    {
                        label: '运行中',
                        value: '运行中',
                    },
                    {
                        label: '停用',
                        value: '停用',
                    },
                ], title: "\u72B6\u6001", dataIndex: "status" }),
            React.createElement(Table.Column, { title: "\u7F51\u7EDC\u7C7B\u578B", dataIndex: "type" }),
            React.createElement(Table.Column, { title: "\u64CD\u4F5C", cell: render, width: 200 }))));
});
