Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quickSaveApi为什么不打开就会执行N次 #10908

Closed
lawbc opened this issue Sep 12, 2024 · 1 comment
Closed

quickSaveApi为什么不打开就会执行N次 #10908

lawbc opened this issue Sep 12, 2024 · 1 comment

Comments

@lawbc
Copy link

lawbc commented Sep 12, 2024

描述问题:

弹窗后table2的quickSaveApi会执行n次,只要quickEdit有值的一列就会执行一次,设置了saveImmediately=true的都会执行一次,但是没有输入动作

截图或视频:

quickEdit

如何复现(请务必完整填写下面内容):

  1. 你是如何使用 amis 的?
    sdk

  2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在
    6.6.0

  3. 粘贴有问题的完整 amis schema 代码:

{
            type: 'crud',
            name: 'detail-list',
            id: 'detail-list',
            autoFillHeight: true,
            syncLocation: false,
            api: '/rpup/user/report/detail/list?projectId=${projectId}&type=1&page=${page}&perPage=${perPage}',
            selectable: true,
            autoGenerateFilter: {
                showBtnToolbar: false,
                columnsNum: 3
            },
            footerToolbar: [
                'statistics',
                'switch-per-page',
                'pagination'
            ],
            headerToolbar:[
                'bulkActions',
                {
                    type: 'button',
                    label: '选择目录',
                    align: 'right',
                    icon: 'fa fa-plus pull-left',
                    actionType: 'dialog',
                    dialog: {
                        title: '选择目录',
                        closeOnEsc: true,
                        showErrorMsg: false,
                        size: 'lg',
                        body: catalogSelect,
                    }
                },
                {
                    type: 'button',
                    label: '批量填报',
                    align: 'right',
                    icon: 'fa fa-edit pull-left',
                    actionType: 'dialog',
                    primary: true,
                    dialog: {
                        title: '批量填报',
                        closeOnEsc: true,
                        showErrorMsg: false,
                        size: 'full',
                        body: detailHisEditBulk,
                        actions:[],
                        onEvent:{
                            cancel:{
                                actions:[
                                    {
                                        actionType: 'reload',
                                        componentId: 'detail-list'
                                    }
                                ]
                            },
                            confirm:{
                                actions:[
                                    {
                                        actionType: 'reload',
                                        componentId: 'detail-list'
                                    }
                                ]
                            }
                        }
                    }
                },
            ],
            'bulkActions': [
                {
                    label: '批量删除',
                    actionType: 'ajax',
                    api: 'post:/rpup/user/report/detail/deleteBatch?ids=${ids}',
                    confirmText: '确定要批量删除?'
                }
            ],
            columns: [
                {
                    name: 'catalog.specCode',
                    label: '品规编码',
                },
                {
                    name: 'catalog.catalogName',
                    label: '品种名称',
                },
                {
                    name: 'catalog.specName',
                    label: '规格',
                },
                {
                    name: 'produceEntpName',
                    label: '生产企业',
                },
                {
                    name: 'purchaseAmount',
                    label: '历史采购量(kg)',
                },
                {
                    name: 'purchaseTotal',
                    label: '总采购金额(元)',
                },
                {
                    name: 'purchasePrice',
                    label: '最近采购单价(元/kg)',
                },
                {
                    type: 'operation',
                    label: '操作',
                    buttons: [
                        {
                            label: '填报',
                            type: 'button',
                            level: 'primary',
                            actionType: 'dialog',
                            dialog: {
                                title: '填报-${catalog.catalogName + catalog.specName}',
                                closeOnEsc: true,
                                showErrorMsg: false,
                                body: detailHisEdit
                            }
                        },
                        {
                            label: '删除',
                            type: 'button',
                            level: 'danger',
                            actionType: 'ajax',
                            confirmText: '确认要删除该记录?',
                            api: {
                                url: '/rpup/user/report/detail/delete?id=${id}',
                                method: 'post',
                                data: {}
                            }
                        }
                    ]
                }
            ]
        }

       export default{
    type: 'page',
    trackExpression: 'none',
    initApi: '/rpup/user/report/detail/list/export?projectId=${projectId}&type=1',
    body:{
        type: 'table2',
        name: 'detail-bulk-list',
        id: 'detail-bulk-list',
        autoFillHeight: true,
        syncLocation: false,
        columnsTogglable: false,
        canAccessSuperData: false,
        source: '$items',
        quickSaveItemApi: {
            method: 'post',
            url: '/rpup/user/report/detail/update',
            data:{
                id: '${id}',
                produceEntpName: '${produceEntpName}',
                purchaseAmount: '${purchaseAmount}',
                purchaseTotal: '${purchaseTotal}',
                purchasePrice: '${purchasePrice}',
            }
        },
        columns: [
            {
                name: 'catalog.specCode',
                label: '品规编码',
            },
            {
                name: 'catalog.catalogName',
                label: '品种名称',
            },
            {
                name: 'catalog.specName',
                label: '规格',
            },
            {
                name: 'produceEntpName',
                label: '生产企业',
                quickEdit:{
                    reload: '-',
                    mode: 'inline',
                    type: 'select',
                    name: 'produceEntpName',
                    searchable: true,
                    autoComplete:{
                        url: '/rpup/user/produce/search?page=1&perPage=100&produceEntpName=${term}',
                        adaptor: function (payload, response, api, context) {
                            payload.data = payload.data.items;
                            return {
                                ...payload
                            };
                        },
                        //sendOn: '${term}'
                    },
                    valueField: 'produceEntpName',
                    labelField: 'produceEntpName',
                    saveImmediately: true
                }
            },
            {
                name: 'purchaseAmount',
                label: '历史采购量(kg)',
                quickEdit:{
                    reload: '-',
                    mode: 'inline',
                    type: 'input-number',
                    name: 'purchaseAmount',
                    saveImmediately: true
                }
            },
            {
                name: 'purchaseTotal',
                label: '总采购金额(元)',
                quickEdit:{
                    reload: '-',
                    mode: 'inline',
                    type: 'input-number',
                    name: 'purchaseTotal',
                    saveImmediately: true
                }
            },
            {
                name: 'purchasePrice',
                label: '最近采购单价(元/kg)',
                quickEdit:{
                    reload: '-',
                    mode: 'inline',
                    type: 'input-number',
                    name: 'purchasePrice',
                    saveImmediately: true
                }
            },
        ]
    }
}
  1. 操作步骤
    点击crudheaderToolbar中的按钮,按钮执行动作是一个弹窗,弹窗里面是一个table2,其中有几列是quickEdit的,一打开弹窗就会执行N次的quickSaveItemApi接口
@lawbc
Copy link
Author

lawbc commented Sep 12, 2024

发现是配置问题,"saveImmediately": true,然后配置接口quickSaveItemApi,这样就会出现问题,如果是saveImmediately:{api:{}}这样就可以

@lawbc lawbc closed this as completed Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant