import {
    resourceAddDialog,
    resourceDetailDialog,
    resourceEditeDialog
} from "../../components/resource/dialog-resource.js";
import {apiPost, crudCommonOptions} from "../../components/constants.js";

export function tabData() {
    return {
        title: '数据资源',
        icon: 'fa fa-database',
        body: [
            {
                type: 'crud',
                api: {
                    ...apiPost('${base}/data_resource/list')
                },
                ...crudCommonOptions(),
                headerToolbar: [
                    'reload',
                    {
                        type: 'action',
                        label: '新增数据资源',
                        icon: 'fa fa-plus',
                        ...resourceAddDialog()
                    },
                ],
                columns: [
                    {
                        label: '名称',
                        name: 'name',
                        width: 200,
                    },
                    {
                        label: '描述',
                        name: 'description',
                    },
                    {
                        label: '创建时间',
                        width: 150,
                        align: 'center',
                        type: 'tpl',
                        tpl: "${IF(createdTime, DATETOSTR(createdTime), '-')}"
                    },
                    {
                        label: '操作',
                        width: 200,
                        type: 'operation',
                        fixed: 'right',
                        className: 'nowrap',
                        buttons: [
                            {
                                type: 'action',
                                label: '查看',
                                level: 'link',
                                ...resourceDetailDialog(),
                            },
                            {
                                type: 'action',
                                label: '编辑',
                                level: 'link',
                                ...resourceEditeDialog(),
                            },
                            {
                                type: 'action',
                                label: '删除',
                                level: 'link',
                                className: 'text-danger',
                            },
                        ]
                    },
                ]
            }
        ]
    }
}