xiangpei
2025-06-05 d328bd467ffcb660e81d546a0b242e39320acb6d
src/components/FileUpload/index.vue
@@ -56,12 +56,12 @@
    // 大小限制(MB)
    fileSize: {
      type: Number,
      default: 5,
      default: 20,
    },
    // 文件类型, 例如['png', 'jpg', 'jpeg']
    fileType: {
      type: Array,
      default: () => ["doc", "xls", "ppt", "txt", "pdf"],
      default: () => ["doc", "docx", "xls", "xlsx", "ppt", "txt", "pdf", "jpg", "png"],
    },
    // 是否显示提示
    isShowTip: {
@@ -153,7 +153,7 @@
    // 上传成功回调
    handleUploadSuccess(res, file) {
      if (res.code === 200) {
        this.uploadList.push({ name: res.fileName, url: res.fileName });
        this.uploadList.push({ name: res.newFileName, originalName: res.originalFilename , url: res.fileName });
        this.uploadedSuccessfully();
      } else {
        this.number--;
@@ -166,7 +166,9 @@
    // 删除文件
    handleDelete(index) {
      this.fileList.splice(index, 1);
      this.$emit("input", this.listToString(this.fileList));
      // this.$emit("input", this.listToString(this.fileList));
      //修改为返回数组
      this.$emit("input", this.fileList);
    },
    // 上传结束处理
    uploadedSuccessfully() {
@@ -174,7 +176,9 @@
        this.fileList = this.fileList.concat(this.uploadList);
        this.uploadList = [];
        this.number = 0;
        this.$emit("input", this.listToString(this.fileList));
        // this.$emit("input", this.listToString(this.fileList));
        //修改为返回数组
        this.$emit("input", this.fileList);
        this.$modal.closeLoading();
      }
    },