欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

荐商发布tab点击切换发布表单参数没有切换

程序员文章站 2022-03-07 14:33:18
...

荐商发布tab点击切换发布表单参数没有切换

商铺信息与添加客户是一个顶部tab 它里面的标签都是在view容器里面的。

例如发布表单

{
    "type":"view",
    "style":"view.DefaultViewLogic",
    "name":null,
    "isGrayBg":false,
    "showWaterImg":false,
    "tags":[
        {
            "type":"tag",
            "style":"tag.AppGeneralFormTagLogic",
            "name":null,
            "linearLayout":"body",
            "data":{
                "htmlObj":[
                    {
                        "compare":false,
                        "formType":"hintText",
                        "showValue":"客户购买你的信息可得全部业绩,别人成交了你的信息可获得20%业绩",
                        "canEqual":false,
                        "checkAll":false,
                        "expression":true,
                        "hidden":false,
                        "background":"min-height: 2.25rem;background: rgba(39, 196, 152, 0.05);border-radius: 1.25rem;margin-top:1rem;min-width: 17.31rem;width: fit-content;",
                        "leftIcon":".../png",
                        "tips":"说明"
                    },
                    {
                        "compare":false,
                        "formType":"releaseTypeWidget",
                        "canEqual":false,
                        "checkAll":false,
                        "expression":true,
                        "hidden":false,
                        "formKey":"plugin_id",
                        "itemList":[
                            {
                                "dataStr":false,
                                "isScript":false,
                                "index":"1",
                                "isArray":true,
                                "check":true,
                                "isDisabled":false,
                                "label":"商铺转让",
                                "tempCheck":"true",
                                "isMajorPic":false,
                                "value":"1"
                            },
                            {
                                "dataStr":false,
                                "isScript":false,
                                "index":"1",
                                "isArray":true,
                                "check":false,
                                "isDisabled":false,
                                "label":"商铺出租",
                                "tempCheck":"false",
                                "isMajorPic":false,
                                "value":"2"
                            },
                            {
                                "dataStr":false,
                                "isScript":false,
                                "index":"1",
                                "isArray":true,
                                "check":false,
                                "isDisabled":false,
                                "label":"商铺出售",
                                "tempCheck":"false",
                                "isMajorPic":false,
                                "value":"13"
                            },
                            {
                                "dataStr":false,
                                "isScript":false,
                                "index":"2",
                                "isArray":true,
                                "check":false,
                                "isDisabled":false,
                                "label":"写字楼出租",
                                "tempCheck":"false",
                                "isMajorPic":false,
                                "value":"18"
                            },
                            {
                                "dataStr":false,
                                "isScript":false,
                                "index":"2",
                                "isArray":true,
                                "check":false,
                                "isDisabled":false,
                                "label":"写字楼出售",
                                "tempCheck":"false",
                                "isMajorPic":false,
                                "value":"19"
                            }
                        ],
                        "rules":[
                            {
                                "name":"required",
                                "message":"请选择发布类型",
                                "value":"true"
                            }
                        ],
                        "label":"发布类型",
                        "value":"1"
                    },
                    {
                        "compare":false,
                        "formType":"textInput",
                        "canEqual":false,
                        "checkAll":false,
                        "expression":true,
                        "hidden":false,
                        "formKey":"mobile",
                        "rules":[
                            {
                                "name":"pattern",
                                "message":"请输入正确的手机号码",
                                "value":"[1][3,4,5,6,7,8,9][0-9]{9}"
                            },
                            {
                                "name":"required",
                                "message":"请输入手机号码",
                                "value":"true"
                            }
                        ],
                        "textType":"number",
                        "endIcon":"aaa@qq.com",
                        "value":"",
                        "maxLength":11,
                        "placeHolder":"请填写客户号码"
                    }
                ]
            },
            "paramName":"isJsonArray"
        },
        {
            "type":"tag",
            "style":"tag.AppGeneralButtonTagLogic",
            "name":null,
            "linearLayout":"body",
            "cssStyle":"text-align:center;padding-top:1.5rem",
            "data":[
                {
                    "cssColor":"yellow",
                    "round":"true",
                    "size":"small",
                    "submit":{
                        "id":"publish",
                        "content":{
                            "isJsonArray":""
                        }
                    },
                    "plain":"",
                    "cssStyle":"width:12.5rem;height:3.06rem;border-radius:1.53rem",
                    "action":"submit",
                    "disabled":"",
                    "label":"下一步",
                    "paramName":"isJsonArray"
                }
            ]
        }
    ]
}

这个view里面有一个表单,如果切换到添加客户

荐商发布tab点击切换发布表单参数没有切换

表单里面的内容则会发生变化:

{
    "type":"view",
    "style":"view.DefaultViewLogic",
    "name":null,
    "isGrayBg":false,
    "showWaterImg":false,
    "tags":[
        {
            "type":"tag",
            "style":"tag.AppGeneralFormTagLogic",
            "name":null,
            "linearLayout":"body",
            "data":{
                "htmlObj":[
                    {
                        "compare":false,
                        "formType":"hintText",
                        "showValue":"客户购买你的信息可得全部业绩,别人成交了你的信息可获得20%业绩",
                        "canEqual":false,
                        "checkAll":false,
                        "expression":true,
                        "hidden":false,
                        "background":"min-height: 2.25rem;background: rgba(39, 196, 152, 0.05);border-radius: 1.25rem;margin-top:1rem;min-width: 17.31rem;width: fit-content;",
                        "leftIcon":".../png",
                        "tips":"说明"
                    },
                    {
                        "compare":false,
                        "formType":"releaseTypeWidget",
                        "canEqual":false,
                        "checkAll":false,
                        "expression":true,
                        "hidden":false,
                        "formKey":"plugin_id",
                        "itemList":[
                            {
                                "dataStr":false,
                                "isScript":false,
                                "index":"1",
                                "isArray":true,
                                "check":true,
                                "isDisabled":false,
                                "label":"找店",
                                "tempCheck":"true",
                                "isMajorPic":false,
                                "value":"3"
                            }
                        ],
                        "rules":[
                            {
                                "name":"required",
                                "message":"请选择发布类型",
                                "value":"true"
                            }
                        ],
                        "label":"发布类型",
                        "value":"3"
                    },
                    {
                        "compare":false,
                        "formType":"textInput",
                        "canEqual":false,
                        "checkAll":false,
                        "expression":true,
                        "hidden":false,
                        "formKey":"mobile",
                        "rules":[
                            {
                                "name":"pattern",
                                "message":"请输入正确的手机号码",
                                "value":"[1][3,4,5,6,7,8,9][0-9]{9}"
                            },
                            {
                                "name":"required",
                                "message":"请输入手机号码",
                                "value":"true"
                            }
                        ],
                        "textType":"number",
                        "endIcon":"aaa@qq.com",
                        "value":"",
                        "maxLength":20,
                        "placeHolder":"请填写客户号码"
                    }
                ]
            },
            "paramName":"isJsonArray"
        },
        {
            "type":"tag",
            "style":"tag.AppGeneralButtonTagLogic",
            "name":null,
            "linearLayout":"body",
            "cssStyle":"text-align:center;padding-top:1.5rem",
            "data":[
                {
                    "cssColor":"yellow",
                    "round":"true",
                    "size":"small",
                    "submit":{
                        "id":"publish2",
                        "content":{
                            "isJsonArray":""
                        }
                    },
                    "plain":"",
                    "cssStyle":"width:12.5rem;height:3.06rem;border-radius:1.53rem",
                    "action":"submit",
                    "disabled":"",
                    "label":"下一步",
                    "paramName":"isJsonArray"
                }
            ]
        }
    ]
}

但是表单需要初始化所以我们在表单切换事件中处理表单切换,注意不能用reset来重置表单因为那样原来的控件都清空了,最好是使用删除表单

 async segmentChanged(e: any) {
    const index = e.detail.value;
    const segmentButton = this.segment.nativeElement.children[index];
    segmentButton.scrollIntoView({
      behavior: "smooth",
      inline: "center",
      block: "nearest",
    });
    if (this.tagData.data) {
      this.tagData.currentTab = index;
      // 删除表单信息
      this.http.post(
        "application/part",
        {
          viewId: this.tagData.data[index].partLink.target,
          sessionId: localStorage.getItem("sessionId"),
          params: this.tagData.data[index].partLink.params,
        },
        (res: any) => {
          // #616 修改:点击转让服务和选址服务跳到第一屏的画面
          this.content.scrollToTop(0);
          if (res !== undefined && res != null) {
            const switchData = JSON.parse(res.script);
            if (switchData.tags.length > 0 && switchData.tags[0].style === 'tag.AppGeneralFormTagLogic') {
              const paramName = switchData.tags[0].paramName;
              // 如果包含 tag.AppGeneralFormTagLogic 则清除 form表单
              this.appGlobalService.delFormGroupWithParamName(paramName);
            }
            setTimeout(() => {
              this.tagData.currentData = switchData;
              localStorage.setItem(
                "refreshGrayBgTag",
                "" + this.tagData.currentData.isGrayBg
              );
              this.eventService.eventEmit.emit(
                "refreshGrayBg",
                "refreshGrayBg"
              );
              localStorage.setItem(
                "dataMapTopTabContainer",
                JSON.stringify(this.tagData)
              );
              this.eventService.eventEmit.emit(
                "refreshTopTabContainer",
                "refreshTopTabContainer"
              );
            }, 50);


          }
        }
      );
      // }
    }
  }

 

相关标签: 经验分享