avue-form 附件上传增加参数;上传前检查是否重复 覆盖或者跳过

效果

html:

<el-dialog title="设备台账导入" append-to-body :visible.sync="excelBox" width="555px">
        <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter" :upload-before="uploadBefore">
        </avue-form>
</el-dialog>

js: 

excelOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "文件上传",
            prop: "excelFile",
            type: "upload",
            drag: true,
            loadText: "文件上传中,请稍等",
            span: 24,
            propsHttp: {
              res: "data",
            },
            tip: "请上传 .xls,.xlsx 标准格式文件",
            action: "/api/device/import-device",
          },
        ],
      },
isCovered:"SKIP",
 uploadBefore(file, done) {
      handleBeforeUpload(file).then(res => {
        if (res.data.code == 200) {
          let title = res.data.data
          this.$confirm(`检测到您上传的数据,其中【${title}】重复,请选择【跳过】还是【覆盖】该数据?`, '提示', {
            confirmButtonText: '覆盖',
            cancelButtonText: '跳过',
            type: 'warning'
          }).then(() => {
            // 覆盖
            this.isCovered="COVER"
            done()
          }).catch(() => {
            // 跳过
            this.isCovered="SKIP"
            done()
          });
        }
      })
    },
watch: {
    isCovered() {
      if (this.isCovered !== "") {
        const column = this.findObject(this.excelOption.column, "excelFile");
        column.action = `/api/device/import-device?importStrategy=${this.isCovered}`;
      }
    },
  },

  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值