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

文章描述了一个使用Vue框架的表格组件,实现设备台账从Excel文件的导入功能,包含文件上传、数据重复检测和覆盖/跳过选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

效果

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}`;
      }
    },
  },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值