全部
常见问题
产品动态
精选推荐

修复java多商户外贸版多属性规格的情况下,校验失败后无法再次提交

管理 管理 编辑 删除

情况描述:

在多属性规格的情况下,校验失败商品属性会被清除。在单属性或者多属性只有一条的情况下校验失败,把校验失败的字段内容修改后不能再次提交,只能重新打开上传商品并且一次性把所有商品内容按照正确的校验规则填写好才能成功。

238d9202403261725595983.png

修改后再次点击提交无反应。

可以修改如下代码

//提交接口数据更新
    getFromData() {
      if (this.formValidate.specType && this.formValidate.attr.length < 1)
        return this.$message.warning('请填写多规格属性!');
      this.formValidate.cateId = this.formValidate.cateIds.join(',');
      this.formValidate.keyword = this.labelarr.join(',');
      if (this.videoLink) {
        //如果有视频主图,将视频链接插入到轮播图第一的位置
        this.formValidate.sliderImages.unshift(this.videoLink);
      }
      this.formValidate.sliderImage = JSON.stringify(this.formValidate.sliderImages);
      if (!this.isShowGroup) this.formValidate.guaranteeIds = this.formValidate.guaranteeIdsList.join(',');
      if (this.formValidate.specType) {
        this.formValidate.attrValue = this.ManyAttrValue;
        this.formValidate.attr = this.formValidate.attr.map((item) => {
          return {
            attrName: item.attrName,
            id: item.id,
            attrValue: item.attrValue,
            attrValues: item.attrValue.join(','),
          };
        });
        for (var i = 0; i < this.formValidate.attrValue.length; i++) {
          this.$set(this.formValidate.attrValue[i], 'id', 0);
          this.$set(this.formValidate.attrValue[i], 'productId', 0);
          let attrValues = this.formValidate.attrValue[i].attrValue;
          this.$set(this.formValidate.attrValue[i], 'attrValue', JSON.stringify(attrValues)); //
          delete this.formValidate.attrValue[i].value0;
        }
      } else {
        this.formValidate.attr = [
          {
            attrName: '规格',
            attrValues: '默认',
            id: parseFloat(this.$route.params.id) > 0 ? this.formValidate.attr[0].id : 0,
          },
        ];
        this.OneattrValue.map((item) => {
          this.$set(item, 'attrValue', JSON.stringify({ 规格: '默认' }));
          this.$set(item, 'productId', 0);
        });
        this.formValidate.attrValue = this.OneattrValue;
      }
      if (this.formValidate.type === 5 || this.formValidate.type === 6) this.formValidate.tempId = 0;
    },
    // 提交
    handleSubmit(name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          this.getFromData();
          this.loadingBtn = true;
          parseFloat(this.$route.params.id) > 0
            ? productUpdateApi(this.formValidate)
                .then(async (res) => {
                  this.$message.success('编辑成功');
                  setTimeout(() => {
                    this.$router.push({ path: '/product/list' });
                  }, 500);
                  this.closeSelectedTag();
                  this.loadingBtn = false;
                })
                .catch((res) => {
                  this.loadingBtn = false;
                  for (var i = 0; i < this.formValidate.attrValue.length; i++) {
                    let attrValues = this.formValidate.attrValue[i].attrValue;
                    this.$set(this.formValidate.attrValue[i], 'attrValue', JSON.parse(attrValues));
                  }
                  if (this.formValidate.specType) this.ManyAttrValue = this.formValidate.attrValue;
                })
            : productCreateApi(this.formValidate)
                .then(async (res) => {
                  this.$message.success('新增成功');
                  setTimeout(() => {
                    this.$router.push({ path: '/product/list' });
                  }, 500);
                  this.closeSelectedTag();
                  this.loadingBtn = false;
                })
                .catch((res) => {
                  this.loadingBtn = false;
                  for (var i = 0; i < this.formValidate.attrValue.length; i++) {
                    let attrValues = this.formValidate.attrValue[i].attrValue;
                    this.$set(this.formValidate.attrValue[i], 'attrValue', JSON.parse(attrValues));
                  }
                });
        } else {
          if (
            !this.formValidate.name ||
            !this.formValidate.cateId ||
            !this.formValidate.keyword ||
            !this.formValidate.unitName ||
            !this.formValidate.intro ||
            !this.formValidate.image ||
            !this.formValidate.sliderImages
          ) {
            this.$message.warning('请填写完整商品信息!');
          }
        }
      });
    },

更新位置如下:

f8cff202403261733329438.png

请登录后查看

鸿恩?? 最后编辑于2024-03-26 17:37:17

快捷回复
回复({{post_count}}) {{!is_user ? '我的回复' :'全部回复'}}
回复从新到旧

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest==1? '取消推荐': '推荐'}}
{{item.floor}}#
{{item.user_info.title}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
{{item.like_count}}
{{item.showReply ? '取消回复' : '回复'}}
删除
回复
回复

{{itemc.user_info.nickname}}

{{itemc.user_name}}

作者 管理员 企业

回复 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}   {{itemc.ip_address}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
查看更多
回复
回复
1087
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

鸿恩?? 管理员
暂无简介

回答

3101

发布

78

经验

30246

快速安全登录

使用微信扫码登录
{{item.label}} {{item.label}} {{item.label}} 板块推荐 常见问题 产品动态 精选推荐 首页头条 首页动态 首页推荐
加精
取 消 确 定
回复
回复
问题:
问题自动获取的帖子内容,不准确时需要手动修改. [获取答案]
答案:
提交
bug 需求 取 消 确 定

微信登录/注册

切换手机号登录

{{ bind_phone ? '绑定手机' : '手机登录'}}

{{codeText}}
切换微信登录/注册
暂不绑定
CRMEB客服

CRMEB咨询热线 咨询热线

400-8888-794

微信扫码咨询

CRMEB开源商城下载 开源下载 CRMEB官方论坛 帮助文档
返回顶部 返回顶部
CRMEB客服