alibaba / x-render

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

联动条件显示相反了 #1327

Closed xyy7260 closed 1 year ago

xyy7260 commented 1 year ago

1.依赖仓库的版本(Dependencies versions)

playground 环境中测试 2.问题描述(Bug description): 当我选择 血糖异常情况 选项中的 【是】 则没有按照hidden中的 条件对应显示 选择 【是】 出现 【口服降压药物和 口服降压药物0】 选择 【否】 出现 【口服降压药物1】 反而是相反了,是hidden逻辑出现错误了吗

<!doctype>

<!doctype>

口服降压药物 --

image

3.出现问题的 schema demo(Reproduction schema demo)

{
  "type": "object",
  "title": "封面信息",
  "properties": {
    "hospital": {
      "param": "hospital",
      "title": "中心名称",
      "type": "string",
      "required": true
    },
    "createdAt": {
      "param": "createdAt",
      "title": "创建时间",
      "type": "string",
      "format": "date"
    },
    "blood": {
      "param": "blood",
      "title": "血糖异常情况",
      "type": "object",
      "properties": {
        "history": {
          "param": "history",
          "title": "有无单日剂量",
          "type": "string",
          "hiddenParams": [
            "kou#是",
            "kou0#否",
            "kou1#未知"
          ],
          "widget": "radio",
          "props": {
            "options": [
              {
                "label": "是",
                "value": "history_0"
              },
              {
                "label": "否",
                "value": "history_1"
              },
              {
                "label": "未知",
                "value": "history_2"
              }
            ]
          },
          "parentParam": "blood"
        },
        "kou": {
          "param": "kou",
          "title": "口服降压药物是",
          "type": "string",
          "hiddenCondition": "history.kou#是",
          "hidden": "{{formData.blood.history === 'history_0' }}",
          "parentParam": "blood"
        },
        "kou0": {
          "param": "kou0",
          "title": "口服降压药物否",
          "type": "string",
          "hiddenCondition": "history.kou0#否",
          "hidden": "{{formData.blood.history === 'history_1' }}",
          "parentParam": "blood"
        },
        "kou1": {
          "param": "kou1",
          "title": "口服降压药物未知",
          "type": "string",
          "hiddenCondition": "history.kou1#未知",
          "hidden": "{{formData.blood.history === 'history_2' }}",
          "parentParam": "blood"
        }
      }
    },
    "c": {
      "param": "c",
      "title": "测试1",
      "type": "object",
      "properties": {
        "c2": {
          "param": "c2",
          "title": "测试2",
          "type": "object",
          "properties": {
            "c3": {
              "param": "c3",
              "title": "测试3",
              "type": "string",
              "hiddenParams": [
                "cc3#是",
                "cc4否"
              ],
              "widget": "select",
              "props": {
                "options": [
                  {
                    "label": "是",
                    "value": "c3_0"
                  },
                  {
                    "label": "否",
                    "value": "c3_1"
                  }
                ]
              },
              "parentParam": "c.c2"
            },
            "cc3": {
              "param": "cc3",
              "title": "测试是",
              "type": "string",
              "hiddenCondition": "c3.cc3#是",
              "hidden": "{{!formData.c.c2.c3 || formData.c.c2.c3 === 'c3_0' }}",
              "parentParam": "c.c2"
            },
            "cc4": {
              "param": "cc4",
              "title": "测试否",
              "type": "string",
              "parentParam": "c.c2"
            }
          },
          "parentParam": "c"
        }
      }
    }
  }
}

4.最小复现 demo(Reproduction demo)

把上面的json 复制到
playground 环境中测试

lhbxs commented 1 year ago

"hidden": "{{formData.blood.history === 'history_0' }}",

这个代表的是命中条件就隐藏,

我看你的逻辑应该是这个样吧

"hidden": "{{formData.blood.history !== 'history_0' }}",

=== 改成 !==

xyy7260 commented 1 year ago

OK谢谢