"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * title: "常用场景"
 * description: "表格场景内使用"
 */
var react_1 = __importStar(require("react"));
var console_components_1 = require("@alicloud/console-components");
var console_components_actions_1 = __importStar(require("@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_1.default.createElement(console_components_actions_1.default, null,
        react_1.default.createElement(console_components_actions_1.LinkButton, { onClick: function () {
                alert('on click');
            } }, "\u64CD\u4F5C\u9879"),
        react_1.default.createElement(console_components_actions_1.LinkButton, { onClick: function () {
                alert('on click');
            } }, "\u64CD\u4F5C\u9879"),
        react_1.default.createElement(console_components_actions_1.LinkButton, { onClick: function () {
                alert('on click');
            } }, "\u64CD\u4F5C\u9879")));
};
exports.default = (function () {
    var _a = (0, react_1.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_1.default.createElement("div", null,
            react_1.default.createElement("a", { href: "/" }, value),
            react_1.default.createElement("div", null, name)));
    };
    return (react_1.default.createElement("div", null,
        react_1.default.createElement(console_components_1.Table, { onFilter: onFilter, dataSource: dataSource, hasBorder: false },
            react_1.default.createElement(console_components_1.Table.Column, { title: "\u5B9E\u4F8BID/\u540D\u79F0", dataIndex: "id", width: 200, cell: renderId }),
            react_1.default.createElement(console_components_1.Table.Column, { filters: [
                    {
                        label: '运行中',
                        value: '运行中',
                    },
                    {
                        label: '停用',
                        value: '停用',
                    },
                ], title: "\u72B6\u6001", dataIndex: "status" }),
            react_1.default.createElement(console_components_1.Table.Column, { title: "\u7F51\u7EDC\u7C7B\u578B", dataIndex: "type" }),
            react_1.default.createElement(console_components_1.Table.Column, { title: "\u64CD\u4F5C", cell: render, width: 200 }))));
});
