FEMessage / el-data-table

🥘Base on element-ui, makes crud easily
https://femessage.github.io/el-data-table/
MIT License
486 stars 112 forks source link

当返回的数据有多级时编辑失败 #287

Closed xidianwlc closed 4 years ago

xidianwlc commented 4 years ago

Describe the bug

当返回的列表数据为多层级时,比如:

{"_items":[{"_id":"5e4bdc949973f7746d24d6e3","code":"idc","data":{"key":"t1","value":"i1","order":1,"comment":"测试"},"_updated":"Tue, 18 Feb 2020 12:46:12 GMT","_created":"Tue, 18 Feb 2020 12:46:12 GMT","_etag":"49b34b6340c1b5f41b9cd5f12ee76482303e80a2","_links":{"self":{"title":"meta","href":"meta/5e4bdc949973f7746d24d6e3"}}},{"_id":"5e4be4abc6f0922490d181bc","code":"idc","desc":"idc","data":{"key":"t2","value":"i2","order":2,"comment":"测试"},"_updated":"Tue, 18 Feb 2020 13:20:43 GMT","_created":"Tue, 18 Feb 2020 13:20:43 GMT","_etag":"39a8ff3d5992e65fa877a6f036c2a593c1df4071","_links":{"self":{"title":"meta","href":"meta/5e4be4abc6f0922490d181bc"}}}],"_links":{"parent":{"title":"home","href":"/"},"self":{"title":"meta","href":"meta?max_results=30&where={}"}},"_meta":{"page":1,"max_results":30,"total":2}}

如果取第二个层级的数据form表示:

columns: [
            {
              prop: 'code',
              label: '编码'
            },
            {
              prop: 'desc',
              label: '说明'
            },
            {
              label: '元信息',
              prop: 'data',
              columns: [
                {

                  prop: 'data.key',
                  label: '键'
                },
                {
                  prop: 'data.value',
                  label: '值'
                },
                {
                  prop: 'data.order',
                  label: '排序'
                },
                {
                  prop: 'data.comment',
                  label: '注释'
                }
              ]
            }
          ],

该场景下编辑按钮无法使用,会报错,报错内容如下:

Error: please transfer a valid prop path to form item!

Screenshots

To Reproduce

api返回数据为多个层级,然后prop表示为层级的方式即可

Expected behavior

可以正常弹出的编辑修改form

environment information

最新版本的el-data-table

levy9527 commented 4 years ago

从你的描述上来看,建议复杂数据结构,自己写dialog吧