amis icon indicating copy to clipboard operation
amis copied to clipboard

action组件的刷新无效

Open theojia opened this issue 5 years ago • 2 comments

实现场景:

点击action组件去刷新page组件和crud组件,page组件中有类似于“上次加载时间”的文本

存在的问题:

page组件中的“上次加载时间”无法刷新

当前方案:

{
    title: '资源统计',
    remark: '这是资源统计资源统计资源统计资源统计资源统计资源统计资源统计',
    body: [
        {
            type: 'action',
            actionType: 'reload',
            target: 'loadLastTime,tableList,cardList',
            label: '刷新',
        },
        {
            title: '条件过滤',
            type: 'form',
            name: 'server_group_form',
            mode: 'inline',
            wrapWithPanel: false,
            className: 'm-b',
            target: 'loadLastTime,tableList,cardList',
            submitOnChange: true,
            controls: [
                {
                    label: '服务组',
                    type: 'select',
                    size: 'lg',
                    clearable: true,
                    searchable: true,
                    name: 'server_group',
                    source: {
                        method: 'get',
                        url: '/api/cmdb/cmdbback/cmdbback/api/common/api/scope/list/',
                        adaptor: 'return {\n    ...response,\n    data: response.scope_list\n}',
                        responseData: {
                            options: '${items|pick:label~label,value~cmdb_id}',
                        },
                    },
                    description: '通过服务组过滤展示',
                    'en-US': {
                        label: 'Service Group',
                        description: 'Filtering and Displaying by Service Group',
                    },
                },
            ],
        },
        {
            type: 'page',
            name: 'loadLastTime',
            body: [
                '<span style="color: #0aa679">上次加载数据时间:<%= moment().format("YYYY-MM-DD HH:mm:ss") %></span>',
            ],
        },
        {
            type: 'crud',
            name: 'tableList',
            api: {
                url:
                    '/api/cmdb/cmdbback/cmdbback/api/resource/globalrscview/api/global/resource/?scope_id=$server_group',
                method: 'get',
                adaptor: 'return {\n    ...response,\n    data: response.item_list\n}',
            },
            syncLocation: false,
            columns: [
                {
                    label: i18n.OVERVIEW_VMSERVER,
                    name: 'vmserver_total',
                    align: 'center',
                },
                {
                    label: i18n.OVERVIEW_PMSERVER,
                    name: 'pmserver_total',
                    align: 'center',
                },
                {
                    label: i18n.OVERVIEW_DATABASE,
                    name: 'db_total',
                    align: 'center',
                },
                {
                    label: i18n.OVERVIEW_NETWORK_EQUIPMENT,
                    name: 'net_total',
                    align: 'center',
                },
            ],
        },
        {
            type: 'crud',
            api: {
                url: '/api/cmdb/cmdbback/cmdbback/api/resource/mine/?show_all=0&scope_id=$server_group',
                method: 'get',
                adaptor: 'return {\n    ...response,\n    data: response.resources.data_list\n}',
            },
            name: 'cardList',
            mode: 'cards',
            footerToolbar: ['load-more'],
            card: {
                className: 'r-3x',
                header: {
                    title: '<%= data.name || "无数据中心" %>',
                    subTitle:
                        '<%= data.db_count + data.pmserver_not_host + data.pmserver_host + data.vmserver %>' +
                        i18n.OVERVIEW_HOSTS,
                    subTitlePlaceholder: '暂无说明',
                },
                body: [
                    {
                        name: 'vmserver',
                        label: i18n.OVERVIEW_VMSERVER,
                        sortable: true,
                        type: 'tpl',
                        tpl: '<%= data.vmserver %>' + i18n.OVERVIEW_HOSTS,
                    },
                    {
                        name: 'db_count',
                        label: i18n.OVERVIEW_DATABASE,
                        type: 'tpl',
                        tpl: '<%= data.db_count %>' + i18n.OVERVIEW_HOSTS,
                    },
                    {
                        name: 'pmserver_host',
                        label: i18n.OVERVIEW_HOST,
                        type: 'tpl',
                        tpl: '<%= data.pmserver_host %>' + i18n.OVERVIEW_HOSTS,
                    },
                    {
                        name: 'pmserver_not_host',
                        label: i18n.OVERVIEW_NOT_HOST,
                        type: 'tpl',
                        tpl: '<%= data.pmserver_not_host %>' + i18n.OVERVIEW_HOSTS,
                    },
                ],
            },
        },
    ],
}

theojia avatar Jun 16 '21 09:06 theojia

用reload

RickCole21 avatar Jun 16 '21 11:06 RickCole21

@RickCole21 哈喽,reload: loadLastTime用过了也不行。。。。 而且不知道为什么,下面的select组件选完选项以后的target就能使它刷新,而点击action组件就不行

theojia avatar Jun 16 '21 12:06 theojia