amis icon indicating copy to clipboard operation
amis copied to clipboard

数据域的向下更新问题

Open yanquer opened this issue 1 year ago • 3 comments

测试schema内容大致

// table 测试
                                    {
                                        "type": "service",
                                        "id": "testTableId",
                                        "data": {
                                            "tItems": TestTableDataList,
                                        },
                                        "body": [
                                            {
                                                "name": "tItems",
                                                "type": "switch",
                                                "label": "表格展示一/三个值",
                                                "option": "展示值说明",
                                                "trueValue": [TestTableDataList[1]],
                                                "falseValue": TestTableDataList,
                                            },
                                            {
                                                "type": "page",
                                                "data": {
                                                    "tItems2": "${tItems}",
                                                    "tItems3": "${tItems}",
                                                },
                                                "body": [
                                                    {
                                                        "type": "table",
                                                        "trackExpression": "$tItems",
                                                        "name": "table_test2",
                                                        "source": "$tItems2",
                                                        "affixHeader": false,
                                                        "syncLocation": false,
                                                        "columns": [
                                                            {
                                                                "name": "id",
                                                                "label": "ID",
                                                                "type": "text"
                                                            },
                                                            {
                                                                "name": "text",
                                                                "label": "文本",
                                                                "type": "text"
                                                            },
                                                            {
                                                                "type": "image",
                                                                "label": "图片",
                                                                "name": "image"
                                                            },
                                                            {
                                                                "name": "date",
                                                                "type": "date",
                                                                "label": "日期"
                                                            },
                                                            {
                                                                "name": "progress",
                                                                "label": "进度",
                                                                "type": "progress"
                                                            },
                                                            {
                                                                "name": "boolean",
                                                                "label": "状态",
                                                                "type": "status"
                                                            },
                                                            {
                                                                "name": "boolean",
                                                                "label": "开关",
                                                                "type": "switch"
                                                            },
                                                            {
                                                                "name": "type",
                                                                "label": "映射",
                                                                "type": "mapping",
                                                                "map": {
                                                                    "1": "<span class='label label-info'>漂亮</span>",
                                                                    "2": "<span class='label label-success'>开心</span>",
                                                                    "3": "<span class='label label-danger'>惊吓</span>",
                                                                    "4": "<span class='label label-warning'>紧张</span>",
                                                                    "*": "其他:${type}"
                                                                }
                                                            },
                                                            {
                                                                "name": "list",
                                                                "type": "list",
                                                                "label": "List",
                                                                "placeholder": "-",
                                                                "listItem": {
                                                                    // 自定义数据的显示内容
                                                                    "title": "${title}",
                                                                    "subTitle": "${description}"
                                                                }
                                                            }
                                                        ],
                                                    },
                                                ]
                                            },
                                            {
                                                "type": "table",
                                                "name": "table_test",
                                                "source": "$tItems",
                                                "affixHeader": false,
                                                "syncLocation": false,
                                                "columns": [
                                                    {
                                                        "name": "id",
                                                        "label": "ID",
                                                        "type": "text"
                                                    },
                                                    {
                                                        "name": "text",
                                                        "label": "文本",
                                                        "type": "text"
                                                    },
                                                    {
                                                        "type": "image",
                                                        "label": "图片",
                                                        "name": "image"
                                                    },
                                                    {
                                                        "name": "date",
                                                        "type": "date",
                                                        "label": "日期"
                                                    },
                                                    {
                                                        "name": "progress",
                                                        "label": "进度",
                                                        "type": "progress"
                                                    },
                                                    {
                                                        "name": "boolean",
                                                        "label": "状态",
                                                        "type": "status"
                                                    },
                                                    {
                                                        "name": "boolean",
                                                        "label": "开关",
                                                        "type": "switch"
                                                    },
                                                    {
                                                        "name": "type",
                                                        "label": "映射",
                                                        "type": "mapping",
                                                        "map": {
                                                            "1": "<span class='label label-info'>漂亮</span>",
                                                            "2": "<span class='label label-success'>开心</span>",
                                                            "3": "<span class='label label-danger'>惊吓</span>",
                                                            "4": "<span class='label label-warning'>紧张</span>",
                                                            "*": "其他:${type}"
                                                        }
                                                    },
                                                    {
                                                        "name": "list",
                                                        "type": "list",
                                                        "label": "List",
                                                        "placeholder": "-",
                                                        "listItem": {
                                                            // 自定义数据的显示内容
                                                            "title": "${title}",
                                                            "subTitle": "${description}"
                                                        }
                                                    }
                                                ],
                                        ]
                                    },

数据用的跟官方文档第一个例子的一致,

const TestTableDataList = [
    {
        "id": "91264",
        "text": "衡 阎",
        "progress": 22,
        "type": 4,
        "boolean": true,
        "list": [
            "nisi ex eum123123123",
            {
                "description": "nisi ex eum123123123111",
            },
            "nisi ex eum123123123",
            {
                // "title": "Fasdasdasd",
                "description": "nisi ex eum123123123"
            },
            {
                "title": "District Applications Specialist",
                "description": "ipsam ratione voluptas"
            },
            {
                "title": "Future Operations Manager",
                "description": "ducimus fugit debitis"
            },
            {
                "title": "Dynamic Solutions Associate",
                "description": "saepe consequatur aut"
            }
        ],
        "audio": "https://news-bos.cdn.bcebos.com/mvideo/%E7%9A%87%E5%90%8E%E5%A4%A7%E9%81%93%E4%B8%9C.aac",
        "carousel": [
            {
                "image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
            },
            {
                "html": "<div style=\"width: 100%; height: 200px; background: #e3e3e3; text-align: center; line-height: 200px;\">carousel data in crud</div>"
            },
            {
                "image": "https://video-react.js.org/assets/poster.png"
            }
        ],
        "date": 1591270438,
        "image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg",
        "json": {
            "id": 1,
            "text": "text"
        }
    },
    {
        "id": "34202",
        "text": "吉 卢汉市",
        "progress": 85,
        "type": 1,
        "boolean": true,
        "list": [
            {
                "title": "Dynamic Assurance Orchestrator",
                "description": "ea ullam voluptates"
            },
            {
                "title": "Internal Division Assistant",
                "description": "illum deleniti qui"
            },
            {
                "title": "International Usability Administrator",
                "description": "sit voluptatem quia"
            },
            {
                "title": "Lead Optimization Orchestrator",
                "description": "autem et blanditiis"
            },
            {
                "title": "Future Division Assistant",
                "description": "dolor cupiditate sint"
            },
            {
                "title": "Forward Program Orchestrator",
                "description": "quia distinctio voluptas"
            },
            {
                "title": "Human Implementation Technician",
                "description": "consequatur quaerat ullam"
            },
            {
                "title": "National Identity Administrator",
                "description": "ipsa et reiciendis"
            },
            {
                "title": "Regional Factors Planner",
                "description": "sed deserunt natus"
            },
            {
                "title": "Human Data Administrator",
                "description": "rerum consequatur odit"
            }
        ],
        "audio": "https://news-bos.cdn.bcebos.com/mvideo/%E7%9A%87%E5%90%8E%E5%A4%A7%E9%81%93%E4%B8%9C.aac",
        "carousel": [
            {
                "image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
            },
            {
                "html": "<div style=\"width: 100%; height: 200px; background: #e3e3e3; text-align: center; line-height: 200px;\">carousel data in crud</div>"
            },
            {
                "image": "https://video-react.js.org/assets/poster.png"
            }
        ],
        "date": 1591270438,
        "image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg",
        "json": {
            "id": 1,
            "text": "text"
        }
    },
    {
        "id": "37701",
        "text": "立辉安市",
        "progress": 72,
        "type": 2,
        "boolean": false,
        "list": [
            {
                "title": "Corporate Metrics Liason",
                "description": "aspernatur natus qui"
            },
            {
                "title": "Central Paradigm Analyst",
                "description": "sequi numquam ad"
            },
            {
                "title": "International Data Administrator",
                "description": "sed libero eum"
            },
            {
                "title": "Forward Optimization Assistant",
                "description": "officiis accusantium dolorem"
            },
            {
                "title": "Senior Metrics Executive",
                "description": "commodi sint quod"
            },
            {
                "title": "Corporate Quality Facilitator",
                "description": "aut aperiam est"
            },
            {
                "title": "Forward Operations Producer",
                "description": "sed corporis eaque"
            },
            {
                "title": "National Integration Analyst",
                "description": "quasi ab cumque"
            }
        ],
        "audio": "https://news-bos.cdn.bcebos.com/mvideo/%E7%9A%87%E5%90%8E%E5%A4%A7%E9%81%93%E4%B8%9C.aac",
        "carousel": [
            {
                "image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
            },
            {
                "html": "<div style=\"width: 100%; height: 200px; background: #e3e3e3; text-align: center; line-height: 200px;\">carousel data in crud</div>"
            },
            {
                "image": "https://video-react.js.org/assets/poster.png"
            }
        ],
        "date": 1591270438,
        "image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg",
        "json": {
            "id": 1,
            "text": "text"
        }
    }
]

当点击 switch 切换时, 外部的 table 数据可以正常切换为一个, 然而下面层的 page 内的 table 内定义的数据域

"data": {
                                                    "tItems2": "${tItems}",
                                                    "tItems3": "${tItems}",
                                                },

无法接收到 tItems 的更新, 即使使用了 "trackExpression": "$tItems",

想问下有什么方式可以做到 数据域向下更新 ?

yanquer avatar Oct 10 '24 08:10 yanquer

👍 Thanks for this! 🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

github-actions[bot] avatar Oct 10 '24 08:10 github-actions[bot]

暂时只能用辅助的amis组件解决.

data只能设置初始数据域, 不能自动参与后续的解析, 除非是类似dialog那样每次重新打开一个.

不知到后面会不会有增加自动解析的功能的支持.

yanquer avatar Oct 12 '24 07:10 yanquer

暂时只能用辅助的amis组件解决.

data只能设置初始数据域, 不能自动参与后续的解析, 除非是类似dialog那样每次重新打开一个.

不知到后面会不会有增加自动解析的功能的支持.

辅助的amis组件, 类似

{"type": "input-text", "label": "辅助组件", "name": "tItems2", "value": "${tItems|json|toJson}",  "visible": false}

只处理数据, 不显示, 提交的时候或许还需要再过滤一下.

是否有更好的方式?

yanquer avatar Oct 12 '24 08:10 yanquer