baidu / amis

前端低代码框架,通过 JSON 配置就能生成各种页面。
https://baidu.github.io/amis/
Apache License 2.0
17.32k stars 2.51k forks source link

弹窗的数据,在提交的时候setValue给了page组件,再次打开的时候,弹窗没有读到数据 #10710

Open hyy984750073 opened 3 months ago

hyy984750073 commented 3 months ago

描述问题:

在6.3.0及以上的版本中,打开弹窗,并在弹窗的表单中录入一些数据,在关闭弹窗的时候将这些数据setValue给了底下的page组件,再次打开弹窗的时候,弹窗没有读到数据新录入的数据

我在6.3.0以下的版本里是可以的,但是form表单在reset的时候没有效果

数据是从外部传进去的,代码与低代码混用的模式

截图或视频:

可以的话,尽可能提供截图或视频来补充描述你的问题... image

image

如何复现(请务必完整填写下面内容):

  1. 你是如何使用 amis 的? sdk

  2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在 6.3.0及以上的版本都有此问题

  3. 粘贴有问题的完整 amis schema 代码:

    {
    "type": "page",
    "id": "myMainPage",
    "body": [
    {
      "id": "u:1f52a5f88d97",
      "name": "demo.ageLine",
      "type": "input-text",
      "label": "年龄基线",
      "value": "14",
      "visible": false
    },
    {
      "id": "myMainForm",
      "body": [
        {
          "id": "u:c9722775fa51",
          "name": "pd_patient.patient_name",
          "type": "input-text",
          "focus": true,
          "label": "姓名",
          "value": "",
          "disabled": false,
          "required": true,
          "dataSource": null,
          "placeholder": "请输入姓名"
        },
        {
          "id": "u:15e9580b0a47",
          "body": [
            {
              "id": "u:dcc370a05f95",
              "name": "pd_patient_ident.0.card_type",
              "type": "input-directory",
              "focus": true,
              "isMap": false,
              "label": "",
              "value": "01",
              "mapLabel": "name",
              "mapValue": "code",
              "required": true,
              "clearable": false,
              "allowClear": false,
              "dataSource": "idType",
              "placeholder": "请选择",
              "columnPropertyLabel": "",
              "columnPropertyValue": ""
            },
            {
              "id": "pd_patient_ident_card_no",
              "name": "pd_patient_ident.0.card_no",
              "type": "input-text",
              "addOn": {
                "id": "u:41d3c7aaf9cb",
                "type": "button",
                "label": "新增",
                "dialog": {
                  "id": "myDialogId",
                  "body": [
                    {
                      "id": "dialogListId",
                      "name": "pd_patient_ident",
                      "type": "combo",
                      "items": [
                        {
                          "id": "u:dcc370a05f95",
                          "name": "card_type",
                          "type": "input-directory",
                          "focus": true,
                          "isMap": false,
                          "label": "",
                          "value": "",
                          "unique": true,
                          "mapLabel": "name",
                          "mapValue": "code",
                          "required": true,
                          "dataSource": "idType",
                          "disabledOn": "${index==0}",
                          "placeholder": "请选择",
                          "columnPropertyLabel": "",
                          "columnPropertyValue": ""
                        },
                        {
                          "id": "pd_patient_ident_${index}_card_no",
                          "name": "card_no",
                          "type": "input-text",
                          "focus": true,
                          "label": false,
                          "value": "",
                          "unique": true,
                          "onEvent": {
                          },
                          "autoFill": {
                          },
                          "required": true,
                          "disabledOn": "${index==0}",
                          "requiredOn": "this.demo.tempAge && this.demo.tempAge>=demo.ageLine",
                          "columnRatio": 8,
                          "validateOnChange": true
                        }
                      ],
                      "label": "",
                      "value": "",
                      "addBtn": {
                        "id": "u:5c8c3c5a11dc",
                        "icon": "fa fa-plus",
                        "size": "sm",
                        "label": "新增",
                        "level": "primary"
                      },
                      "addable": true,
                      "onEvent": {
                      },
                      "visible": true,
                      "multiple": true,
                      "required": true,
                      "deleteBtn": {
                        "id": "u:4b731647b875",
                        "type": "button",
                        "label": "删除",
                        "level": "default",
                        "disabledOn": "${index==0}"
                      },
                      "removable": "${index!==0}",
                      "strictMode": true,
                      "removableMode": "icon",
                      "validateOnChange": true,
                      "canAccessSuperData": true
                    }
                  ],
                  "data": {
                    "&": "$$"
                  },
                  "type": "dialog",
                  "title": "新增证件",
                  "actions": [
                    {
                      "id": "u:11253a293c24",
                      "type": "button",
                      "label": "取消",
                      "actionType": "cancel"
                    },
                    {
                      "id": "submitMultipleCard",
                      "type": "button",
                      "label": "确认",
                      "onEvent": {
                        "click": {
                          "weight": 0,
                          "actions": [
                            {
                              "args": {
                                "value": "${ {       pd_patient_ident: ${pd_patient_ident}     } }"
                              },
                              "actionType": "setValue",
                              "componentId": "myMainPage",
                              "ignoreError": false
                            },
                            {
                              "args": {
                                "value": "${ {       pd_patient_ident:${pd_patient_ident}     } }"
                              },
                              "actionType": "setValue",
                              "componentId": "myMainForm",
                              "ignoreError": false
                            },
                            {
                              "args": {
                                "value": "${ {       pd_patient_ident:${pd_patient_ident}     } }"
                              },
                              "groupType": "component",
                              "actionType": "setValue",
                              "componentId": "myDialogId"
                            },
                            {
                              "outputVar": "validateDialogCardTypeResult",
                              "actionType": "validateFormItem",
                              "componentId": "dialogListId",
                              "ignoreError": false
                            },
                            {
                              "actionType": "closeDialog",
                              "expression": "${event.data.validateDialogCardTypeResult.payload}",
                              "ignoreError": false
                            }
                          ]
                        }
                      },
                      "primary": true,
                      "actionType": "confirm"
                    }
                  ],
                  "dataMap": {
                  },
                  "className": "app-popover :AMISCSSWrapper",
                  "draggable": false,
                  "closeOnEsc": false,
                  "showLoading": true,
                  "showErrorMsg": true,
                  "dataMapSwitch": true,
                  "closeOnOutside": false,
                  "showCloseButton": true,
                  "withDefaultData": false
                },
                "visibleOn": "${!!pd_patient.patient_id}",
                "actionType": "dialog"
              },
              "focus": true,
              "label": false,
              "value": "",
              "onEvent": {
                "change": {
                  "weight": 0,
                  "actions": [
                    {
                      "args": {
                        "value": "${MID(event.data.value,6,8)}"
                      },
                      "groupType": "component",
                      "actionType": "setValue",
                      "expression": "${LEN(event.data.value) > 14}",
                      "componentId": "form_birthday"
                    },
                    {
                      "args": {
                        "value": "${IF(MID(event.data.value,16,1)%2==0,\"2\",\"1\")}"
                      },
                      "actionType": "setValue",
                      "expression": "${LEN(event.data.value)>17}",
                      "componentId": "form_gender",
                      "ignoreError": false
                    },
                    {
                      "args": {
                        "value": "${MID(event.data.value,0,6)}"
                      },
                      "actionType": "setValue",
                      "expression": "${LEN(event.data.value)>5}",
                      "componentId": "household_code",
                      "ignoreError": false
                    }
                  ]
                }
              },
              "autoFill": {
              },
              "disabled": false,
              "requiredOn": "this.demo.tempAge && this.demo.tempAge>=demo.ageLine",
              "columnRatio": 8,
              "validateApi": {
                "url": "/prod-api/_api_/interface?_code_=PD00106",
                "data": {
                  "card_no": "${pd_patient_ident.0.card_no}",
                  "dept_id": "${dept_id}",
                  "del_flag": 0,
                  "campus_id": "${campus_id}",
                  "card_type": "${pd_patient_ident.0.card_type}",
                  "tenant_id": "${tenant_id}",
                  "patient_id": "${patient_id}",
                  "hospital_id": "${hospital_id}"
                },
                "method": "post",
                "sendOn": "isFormDisabled==5&&pd_patient_ident[0].card_type==\"01\"&&pd_patient_ident[0].card_no.length>=15",
                "adaptor": "return {\r\n  status:payload.code==200 && payload.data==false?422:0,\r\n  errors:\"身份证重复\"\r\n}",
                "headers": {
                  "Authorization": "${cookie:access_token|url_decode}"
                },
                "messages": {
                },
                "requestAdaptor": ""
              },
              "validations": {
                "isIdCard": "${pd_patient_ident.0.card_type=='01'}",
                "isAfterTodayForIDCard": "${pd_patient_ident.0.card_type=='01'}"
              },
              "validateOnChange": true,
              "validationErrors": {
                "isIdCard": "身份证号码不合规",
                "isAfterTodayForIDCard": "患者身份证号码的出生日期不能大于今天"
              }
            }
          ],
          "type": "group",
          "label": "证件信息",
          "className": "w-50__percent",
          "requiredOn": "this.demo.tempAge && this.demo.tempAge>=demo.ageLine"
        },
        {
          "id": "form_gender",
          "name": "pd_patient.gender_code",
          "type": "input-directory",
          "focus": true,
          "label": "性别",
          "value": "",
          "mapLabel": "name",
          "mapValue": "code",
          "required": true,
          "dataSource": "gender",
          "disabledOn": "${LEN(pd_patient_ident.card_no)>17}",
          "placeholder": "请选择"
        },
        {
          "id": "form_birthday",
          "utc": false,
          "name": "pd_patient.patient_date_birth",
          "type": "input-date",
          "focus": true,
          "label": "出生日期",
          "value": "",
          "maxDate": "${TODAY()}",
          "onEvent": {
            "change": {
              "weight": 0,
              "actions": [
              ]
            }
          },
          "required": true,
          "dataSource": null,
          "disabledOn": "${LEN(pd_patient_ident.card_no) > 14}",
          "placeholder": "请选择日期",
          "valueFormat": "YYYY-MM-DD",
          "displayFormat": "YYYY-MM-DD"
        },
        {
          "id": "u:b2db8791f84b",
          "api": {
            "url": "/prod-api/_api_/interface?_code_=PD00011&temp=${pd_patient.patient_date_birth}",
            "data": {
              "pattern": "yyyy-MM-dd HH:mm:ss",
              "useRuleEngin": "${true}",
              "patientDateBirth": "${pd_patient.patient_date_birth}"
            },
            "method": "post",
            "sendOn": "pd_patient.patient_date_birth.length > 0",
            "adaptor": "return {\r\n  status: payload.code == 200 ? 0 : payload.code,\r\n  data: payload.data,\r\n  msg:payload.msg\r\n}",
            "headers": {
              "Authorization": "${cookie:access_token | url_decode}"
            },
            "messages": {
            },
            "responseData": {
              "age": "${age}"
            },
            "requestAdaptor": "if (api.data.patientDateBirth.length < 11) {\r\n  api.data.patientDateBirth = api.data.patientDateBirth + \" 00:00:00\";\r\n}\r\nreturn api;"
          },
          "body": [
            {
              "id": "u:f1f95a2648b4",
              "max": 200,
              "min": 0,
              "name": "demo.age",
              "step": 1,
              "type": "input-text",
              "focus": true,
              "label": "年龄",
              "value": "${age}",
              "keyboard": true,
              "required": true,
              "disabledOn": "${pd_patient.patient_date_birth}",
              "placeholder": "请输入年龄",
              "unitOptions": [
                {
                  "label": "岁",
                  "value": "岁"
                }
              ]
            }
          ],
          "type": "service",
          "dsType": "api",
          "onEvent": {
            "fetchInited": {
              "weight": 0,
              "actions": [
                {
                  "args": {
                    "value": "${event.data.responseData.age}"
                  },
                  "actionType": "setValue",
                  "componentId": "u:f1f95a2648b4",
                  "ignoreError": false
                }
              ]
            }
          },
          "visible": true,
          "className": "w-1/4 px-2"
        },
        {
          "id": "u:c053b46b32fa",
          "name": "pd_patient.nation_code",
          "type": "input-directory",
          "focus": true,
          "label": "民族",
          "value": "01",
          "mapLabel": "name",
          "mapValue": "code",
          "required": false,
          "dataSource": "nation",
          "placeholder": "请选择"
        },
        {
          "id": "u:ae70fb416008",
          "name": "pd_patient.nationality_code",
          "type": "input-directory",
          "focus": true,
          "label": "国籍",
          "value": "中国",
          "mapLabel": "name",
          "mapValue": "code",
          "required": false,
          "dataSource": "nationality",
          "placeholder": "请选择"
        },
        {
          "id": "u:46aa272d5ee9",
          "name": "pd_patient.patient_type_code",
          "type": "input-directory",
          "focus": true,
          "label": "收费身份",
          "value": "01",
          "mapLabel": "name",
          "mapValue": "code",
          "required": null,
          "dataSource": "feeIdentity",
          "placeholder": "请选择"
        },
        {
          "id": "u:ac6670c5a29d",
          "name": "pd_patient.patient_phone_number",
          "type": "input-text",
          "focus": true,
          "label": "患者手机号码",
          "value": "",
          "disabled": false,
          "dataSource": null,
          "requiredOn": "this.demo.tempAge && this.demo.tempAge>=demo.ageLine",
          "placeholder": "请输入手机号码",
          "validations": {
            "isPhoneNumber": true
          },
          "validateOnChange": true
        },
        {
          "id": "u:c515205fc3fe",
          "name": "pd_patient.work_unit_name",
          "type": "input-text",
          "label": "工作单位名称",
          "value": "",
          "required": false,
          "dataSource": null,
          "placeholder": "请输入工作单位名称"
        },
        {
          "id": "u:5182ca3d3dce",
          "name": "pd_patient.occup_categ_code",
          "type": "input-directory",
          "focus": true,
          "label": "职业",
          "value": "",
          "mapLabel": "name",
          "mapValue": "code",
          "required": false,
          "dataSource": "work",
          "placeholder": "请选择"
        },
        {
          "id": "u:930f858a2711",
          "body": [
            {
              "id": "household_code",
              "name": "pd_patient.household_code",
              "type": "input-directory",
              "focus": true,
              "label": "",
              "value": "",
              "hidden": false,
              "disabled": false,
              "mapLabel": "name",
              "mapValue": "code",
              "required": false,
              "dataSource": "address",
              "isMatchFill": true,
              "placeholder": "请选择"
            },
            {
              "id": "u:2fab8f146b31",
              "name": "pd_patient.household_detailedaddress",
              "type": "input-text",
              "focus": true,
              "label": false,
              "value": "${validateCardNoResult}",
              "disabled": false,
              "columnRatio": 8
            }
          ],
          "type": "group",
          "label": "籍贯地址",
          "className": "w-75__percent"
        },
        {
          "id": "u:4b3ccada9eae",
          "name": "pd_patient.marit_status_code",
          "type": "input-directory",
          "label": "婚姻",
          "value": "",
          "required": false,
          "dataSource": "marriage",
          "placeholder": "请选择"
        },
        {
          "id": "u:c7876ac3f6bd",
          "name": "pd_patient.contact_name",
          "type": "input-text",
          "focus": true,
          "label": "联系人姓名",
          "value": "",
          "disabled": false,
          "required": false,
          "dataSource": null,
          "placeholder": "请输入联系人姓名"
        },
        {
          "id": "u:ee474b281c69",
          "name": "pd_patient.relationship_contact_code",
          "type": "input-directory",
          "focus": true,
          "label": "联系人关系",
          "value": "",
          "mapLabel": "name",
          "mapValue": "code",
          "required": false,
          "dataSource": "contactRelationship",
          "placeholder": "请选择"
        },
        {
          "id": "u:c8b7444ea76d",
          "name": "pd_patient.contact_phone_number",
          "type": "input-text",
          "focus": true,
          "label": "联系人电话",
          "value": "",
          "disabled": false,
          "dataSource": null,
          "placeholder": "请输入联系人电话",
          "validations": {
            "isPhoneNumber": true
          },
          "validateOnChange": true
        },
        {
          "id": "u:7d7e46710650",
          "body": [
            {
              "id": "u:2fab8f146b31",
              "name": "pd_patient.contact_detail_address",
              "type": "input-text",
              "focus": true,
              "label": false,
              "value": "",
              "disabled": false,
              "columnRatio": 12
            }
          ],
          "type": "group",
          "label": "联系人地址",
          "className": "w-25__percent"
        },
        {
          "id": "u:b6a4ada33bfc",
          "name": "pd_patient.guar_name",
          "type": "input-text",
          "focus": true,
          "label": "监护人姓名",
          "value": "",
          "disabled": false,
          "required": false,
          "dataSource": null,
          "requiredOn": "this.demo.tempAge && this.demo.tempAge<demo.ageLine",
          "placeholder": "请输入监护人姓名",
          "validateOnChange": true
        },
        {
          "id": "u:1551ef9b97db",
          "name": "pd_patient.guar_relationship",
          "type": "input-directory",
          "focus": true,
          "label": "与监护人关系",
          "value": "",
          "mapLabel": "name",
          "mapValue": "code",
          "required": false,
          "dataSource": "guardianshipFee",
          "requiredOn": "this.demo.tempAge && this.demo.tempAge<demo.ageLine",
          "placeholder": "请选择",
          "validateOnChange": true
        },
        {
          "id": "u:f937d1564bd6",
          "name": "pd_patient.guar_id_doc_num",
          "type": "input-text",
          "focus": true,
          "label": "监护人身份证",
          "value": "",
          "onEvent": {
            "change": {
              "weight": 0,
              "actions": [
              ]
            }
          },
          "visible": true,
          "disabled": false,
          "requiredOn": "this.demo.tempAge && this.demo.tempAge<demo.ageLine",
          "placeholder": "请输入监护人身份证",
          "validations": {
            "isIdCard": true,
            "isAfterTodayForIDCard": true
          },
          "validateOnChange": true,
          "validationErrors": {
            "isIdCard": "身份证格式不合法",
            "isAfterTodayForIDCard": "监护人身份证号码的出生日期不能大于今天"
          }
        },
        {
          "id": "u:dd3358209506",
          "name": "pd_patient.guar_phone_number",
          "type": "input-text",
          "label": "监护人手机号码",
          "value": "",
          "dataSource": null,
          "requiredOn": "this.demo.tempAge && this.demo.tempAge<demo.ageLine",
          "placeholder": "请输入监护人手机号码",
          "validations": {
            "isPhoneNumber": true
          },
          "validateOnChange": true
        },
        {
          "id": "form_age",
          "max": 200,
          "min": 0,
          "name": "demo.tempAge",
          "step": 1,
          "type": "input-text",
          "focus": true,
          "label": "计算患者年龄(不可删)",
          "value": "${IFS(LEN(pd_patient.patient_date_birth)==0,\"\",  !YEARS(TODAY(), pd_patient.patient_date_birth),\"0\", YEARS(TODAY(), pd_patient.patient_date_birth) )}",
          "visible": false,
          "keyboard": true,
          "placeholder": "请输入年龄"
        },
        {
          "id": "u:3aaf6c3baf56",
          "api": {
            "url": "/prod-api/_api_/interface?_code_=PD000147",
            "method": "post",
            "sendOn": "this.isEdit==false",
            "adaptor": "return {\r\n  status: payload.code === 200 ? 0 : payload.code,\r\n  msg: payload.msg,\r\n  data: {\r\n    data: payload.data\r\n  }\r\n}",
            "headers": {
              "Authorization": "${cookie:access_token | url_decode}"
            },
            "messages": {
            },
            "responseData": {
              "patient_num_temp": "${data}"
            },
            "requestAdaptor": ""
          },
          "body": [
            {
              "id": "u:32aa7e40767f",
              "name": "pd_patient.patient_num",
              "type": "input-text",
              "label": "生成患者NO",
              "value": "${patient_num_temp}",
              "hidden": false,
              "visible": false
            }
          ],
          "type": "service",
          "dsType": "api"
        },
        {
          "id": "u:b99d9a06b89e",
          "api": {
            "url": "/prod-api/_api_/interface?_code_=PD000148",
            "method": "post",
            "sendOn": "this.isEdit==false",
            "adaptor": "return {\r\n  status: payload.code === 200 ? 0 : payload.code,\r\n  msg: payload.msg,\r\n  data: {\r\n      data:payload.data\r\n  }\r\n}",
            "headers": {
              "Authorization": "${cookie:access_token | url_decode}"
            },
            "messages": {
            },
            "responseData": {
              "outpatient_no_temp": "${data}"
            },
            "requestAdaptor": ""
          },
          "body": [
            {
              "id": "u:1bd93531f515",
              "name": "pd_patient.outpatient_no",
              "type": "input-text",
              "label": "生成门诊号",
              "value": "${outpatient_no_temp}",
              "hidden": false,
              "visible": false
            }
          ],
          "type": "service",
          "dsType": "api"
        }
      ],
      "feat": "Insert",
      "mode": "normal",
      "name": "myMainForm",
      "type": "form",
      "debug": false,
      "rules": [
      ],
      "title": "表单",
      "dsType": "api",
      "actions": [
        {
          "type": "button",
          "label": "提交",
          "level": "primary",
          "onEvent": {
            "click": {
              "actions": [
                {
                  "actionType": "submit"
                }
              ]
            }
          }
        }
      ],
      "onEvent": {
        "submit": {
          "weight": 0,
          "actions": [
          ]
        }
      },
      "autoFocus": false,
      "columnCount": 4,
      "persistData": false,
      "wrapWithPanel": false,
      "persistDataKeys": [
        "pd_patient.gender_code"
      ],
      "resetAfterSubmit": false,
      "canAccessSuperData": false,
      "updatePristineAfterStoreDataReInit": false
    }
    ],
    "data": {
    "dept_id": "",
    "ident_id": "",
    "campus_id": "",
    "tenant_id": "",
    "patient_id": "",
    "hospital_id": "",
    "isFormDisabled": false
    },
    "name": "myMainPage",
    "title": "",
    "onEvent": {
    },
    "regions": [
    "body"
    ],
    "pullRefresh": {
    "disabled": true
    },
    "asideResizor": false
    }
  4. 操作步骤 请简单描述一下复现的操作步骤... (1)打开弹窗,新增一条数据 (2)点击弹窗的【确认】按钮 (3)再次打开弹窗,并未看到(1)里新增的那条数据

github-actions[bot] commented 3 months ago

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

Please review the labels and make any necessary changes.