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

crud 中headerToolbar 添加 自定义下载文件action button,如何把filter form 表单的数据传给button #11595

Open
fathpanus opened this issue Feb 12, 2025 · 0 comments

Comments

@fathpanus
Copy link

实现场景:

crud 中headerToolbar 添加下载文件action button,如何把filter form 表单的数据传给button,button 需要把条件数据传给后端

存在的问题:

当前我是给filter 定义name 值,在button 通过name拿数据
浏览器debug网络查看,${daifuForm} 没有取到值

当前方案:

{
type: 'page',
toolbar: [],

                body: {
                    type: 'crud',
                    name: "daifuCRUD",
                    api: {
                        url: commonSet.requestUrl('daifuCode.list'),
                    },
                    filter: {
                        "title": "条件搜索",
                        "name": "daifuForm",
                        "mode": "inline",
                        "body": [
                            {
                                name: 'id',
                                "type": "input-text",
                                "label": "ID",
                                "size": "sm",
                            },
                            {
                                name: 'orderNo',
                                "type": "input-text",
                                "label": "订单号",
                                "size": "md",
                            },
                            {
                                name: 'crsId',
                                "type": "input-text",
                                "label": "自购者id",
                                "size": "sm",
                            },
                            {
                                name: 'actId',
                                "type": "input-text",
                                "label": "活动id",
                                "size": "sm",
                            },
                            {
                                name: 'itemId',
                                "type": "input-text",
                                "label": "商品id",
                                "size": "sm",
                            },
                            {
                                name: 'bsname',
                                "type": "input-text",
                                "label": "快手公司名",
                                "size": "sm",
                            },
                            {
                                name: 'kouling',
                                "type": "input-text",
                                "label": "口令",
                                "size": "md",
                            },
                            {
                                name: 'source',
                                "type": "select",
                                "label": "渠道",
                                size: 'sm',
                                options: [
                                    {
                                        label: '全部',
                                        value: '0',
                                    },
                                    {
                                        label: '抖音',
                                        value: '1',
                                    },
                                    {
                                        label: '快手',
                                        value: '2',
                                    },
                                ],
                            },
                            {
                                name: 'deviceId',
                                "type": "input-text",
                                "label": "设备id",
                                "size": "md",
                            },
                            {
                                "type": "input-datetime",
                                "name": "startDatetime",
                                "label": "开始时间",
                                "valueFormat": "YYYY-MM-DD HH:mm:ss",
                                "value": "today",
                                "shortcuts": [
                                    "yesterday",
                                    "today",
                                ]
                            },
                            {
                                "type": "input-datetime",
                                "name": "endDatetime",
                                "label": "结束时间",
                                "valueFormat": "YYYY-MM-DD HH:mm:ss",
                                isEndDate: true,
                                "shortcuts": [
                                    "yesterday",
                                    "today",
                                    "tomorrow"
                                ]
                            }
                        ],
                        "actions": [
                            {
                                "type": "submit",
                                "label": "搜索",
                                "level": 'primary'
                            },
                            {
                                "type": "reset",
                                "label": "清空",
                            },
                        ],
                        "className": "m-b-sm"
                    },
                    syncLocation: false,
                    columns: [
                        {name: 'id', label: '序号'},
                        {name: 'env', label: 'env'},
                        {name: 'orderNo', label: '订单号'},
                        {name: 'sourceName', label: '渠道'},
                        {name: 'crsUserId', label: '自购者id'},
                        {name: 'agentId', label: '代理id'},
                        {name: 'generalId', label: '总代id'},
                        {name: 'actId', label: '活动id'},
                        {name: 'itemId', label: '商品id'},
                        {name: 'applyerDisplayName', label: '昵称', width: 100},
                        {name: 'codeUrl', label: 'codeUrl'},
                        {name: 'peerPayNoticeInfo', label: 'peerPayNoticeInfo', width: 50},
                        {name: 'statusName', label: 'statusName'},
                        {name: 'realAmount', label: 'realAmount'},
                        {name: 'alipayParseFailMsg', label: '解析失败原因'},
                        {name: 'ksBsName', label: 'ksBsName'},
                        {name: 'ksBsNameFailMsg', label: 'ksBsNameFailMsg'},
                        {name: 'createDatetime', label: '提交时间', width: 180},
                        {
                            "type": "operation",
                            "label": "操作",
                            "buttons": []
                        }
                    ],
                    "headerToolbar": [
                        {
                            "type": "export-excel",
                            "label": "导出 EXCEL",
                            "api": commonSet.requestUrl('daifu.list') + "&export=1",
                            "filename": 'daifu_kouling_${ TIMESTAMP() }',                         
                        },
                        {
                            "label": "下载",
                            "type": "action",
                            "actionType": "ajax",
                            "api": {
                                url: commonSet.requestUrl('daifuStat.daily.list'), 
                                method: 'post',
                                data: "${daifuForm}"
                            }, 
                        },
                        {
                            "label": "刷新",
                            // "icon": "fa fa-repeat",
                            "type": "button",
                            "actionType": "reload",
                            "target": "daifuCRUD",
                            "align": "right"
                        },
                        
                    ],
                    "footerToolbar": [
                        "switch-per-page",
                        'statistics',
                        "pagination",
                    ],
                }

      };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant