alibaba / x-render

🚴‍♀️ 阿里 - 很易用的中后台「表单 / 表格 / 图表」解决方案
https://xrender.fun
6.98k stars 988 forks source link

数组联动hidden写入条件还是显示。但是切换选择就正常 #1411

Closed xyy7260 closed 11 months ago

xyy7260 commented 11 months ago
image image

在app.tx中查看schema codesandbox Demo 如果不方便查看codesandboxDome 那么下面json 复制 到 https://xrender.fun/playground打开即可查看


{
  "type": "object",
  "title": "重复信息",
  "properties": {
    "xh_yy": {
      "param": "xh_yy",
      "title": "xh_yy",
      "type": "array",
      "labelWidget": "CustomLabel",
      "descWidget": "CustomDesc",
      "items": {
        "type": "object",
        "properties": {
          "xh_yy_zt": {
            "param": "xh_yy_zt",
            "title": "xh_yy_zt",
            "type": "object",
            "labelWidget": "CustomLabel",
            "descWidget": "CustomDesc",
            "properties": {
              "xh_yy_ty_choices": {
                "param": "xh_yy_ty_choices",
                "widget": "card",
                "type": "object",
                "title": "xh_yy_ty",
                "properties": {
                  "xh_yy_ty": {
                    "param": "xh_yy_ty",
                    "title": "xh_yy_ty",
                    "type": "string",
                    "hiddenParams": ["xh_yy_wty#xh_yy_ty_1", "xh_yy_yty#xh_yy_ty_0"],
                    "props": {
                      "options": [
                        {
                          "label": "xh_yy_ty_0",
                          "value": "xh_yy_ty_0"
                        },
                        {
                          "label": "xh_yy_ty_1",
                          "value": "xh_yy_ty_1"
                        }
                      ]
                    },
                    "parentParam": "xh_yy.xh_yy_zt.xh_yy_ty_choices"
                  },
                  "xh_yy_wty": {
                    "param": "xh_yy_wty",
                    "title": "xh_yy_wty",
                    "type": "string",
                    "hiddenCondition": "xh_yy_ty.xh_yy_wty#xh_yy_ty_1",
                    "hidden": "{{!rootValue.xh_yy_zt.xh_yy_ty_choices.xh_yy_ty || ['xh_yy_ty_0'].includes(rootValue.xh_yy_zt.xh_yy_ty_choices.xh_yy_ty) }}",
                    "parentParam": "xh_yy.xh_yy_zt.xh_yy_ty_choices"
                  },
                  "xh_yy_yty": {
                    "param": "xh_yy_yty",
                    "title": "xh_yy_yty",
                    "type": "string",
                    "hiddenCondition": "xh_yy_ty.xh_yy_yty#xh_yy_ty_0",
                    "hidden": "{{!rootValue.xh_yy_zt.xh_yy_ty_choices.xh_yy_ty || ['xh_yy_ty_1'].includes(rootValue.xh_yy_zt.xh_yy_ty_choices.xh_yy_ty) }}",
                    "parentParam": "xh_yy.xh_yy_zt.xh_yy_ty_choices"
                  }
                },
                "parentParam": "xh_yy.xh_yy_zt"
              }
            },
            "parentParam": "xh_yy"
          }
        }
      }
    }
  }
}

联动代码 我在默认隐藏是这样写的

"hidden": "{{!rootValue.xh_yy_zt.xh_yy_ty_choices.xh_yy_ty || ......

上面代码写的是国际化参数,所以看起来有点变扭。 谢谢谢

lhbxs commented 11 months ago

rootValue.xh_yy_zt.xh_yy_ty_choices.xh_yy_ty

这个值怕是没有 rootValue?.xh_yy_zt?.xh_yy_ty_choices?.xh_yy_ty

xyy7260 commented 11 months ago

@lhbxs 噢原来这样写 我Object能行 这个不行呢 哈哈哈