ZBLOG

根据你提供的代码片段,有一些语法错误和逻辑问题需要修正。以下是修正后的代码:

<a-row>
  <a-col :span="8">
    <span class="shopid-num"></span>
    <a-form-item label="上传数据表" labelAlign="right">
      <a-upload
        accept=".xlsx"
        name="file"
        :multiple="true"
        :action="url"
        :before-upload="beforeUpload"
        :showUploadList="true"
        v-decorator="['objectKey']"
        @change="uploadFile">
        <a-button class="button-light-blue">导入文件</a-button>
      </a-upload>
    </a-form-item>
  </a-col>
</a-row>

<div class="btn-new-style">
  <a-button style="margin-right: 10px" icon="reload" @click="callOff">取消</a-button>
  <a-button class="button-light-green" @click="handleOk" icon="upload">提交</a-button>
</div>

修改后的handleOk()函数:

handleOk() {
  this.formSubmit.validateFields((err, values) => {
    const { merchantName, shopName, objectKey } = values;
    
    console.log(values);
    
    if (!merchantName) {
      this.$message.error('请选择商户名称');
      return;
    }
    
    if (!shopName) {
      this.$message.error('请选择门店名称');
      return;
    }
    
    if (!objectKey) {
      this.$message.error('请先上传文件');
      return;
    }
    
    let condition = this.formSubmit.getFieldsValue();
    
    this.$http.acm.post(
      `/gw/api/acm-service/limitManage/applyForBatchProcessingQuota?objectKey=${decodeURIComponent(condition.objectKey.file.response.body.objectKey)}&storeCode=${decodeURIComponent(condition.shopName)}&merchantCode=${decodeURIComponent(condition.merchantName)}`)
      .then(r => {
        console.log(r.data.status);
        
        if (r.data.status === 200) {
          this.$message.success('提交成功');
          this.opertaVisible = false;
          this.close();
        } else {
          this.opertaVisible = false;
        }
      })
      .catch(e => {
        console.log(e);
        this.$message.error('提交失败');
      })
      .finally(() => {
        this.allShortName();
      });
  });
}

修正后的uploadFile(info)函数:

uploadFile(info) {
  console.log(info, 'info');
  
  const isLt8M = info.file.size / 1024 / 1024 < 10;
  
  if (!isLt8M) {
    this.$message.error('格式超过10M限制,不允许上传~');
    return;
  }
  
  if (info.file.status === 'done') {
    this.$message.success('文件导入成功');
    console.log(info.file.response, 'response');
    
    // 更新表单字段值
    this.form.setFieldsValue({
      objectKey: info.file.response.body.objectKey,
    });
    
    // 可选:将allData更新为r.data.list
    // this.allData = r.data.list
    
    // 可选:设置shortTimeCondition
    // this.shortTimeCondition = this.form.getFieldsValue()
    
  } else if (info.file.status === 'error') {
    this.$message.error('文件导入失败');
  }
}

请注意,这只是对你提供的代码片段进行了修正和补充,并不能保证整体逻辑的正确性。如果你在具体实现过程中仍然遇到问题,请提供更多详细信息和报错信息,以便我能够更准确地帮助你解决问题。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=11765

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?