vue + element ui 批量上傳

<el-dialog
            title="導(dǎo)入頁(yè)面"
            :visible.sync="mergeUploadDialogVisible"
            :destroy-on-close="true"
            width="30%"
        >
                <div>
                <el-upload
                  ref="uploadFile"
                  class="uploadTool"
                  drag
                  action=""
                  multiple
                  :file-list="uploadFileList"
                  accept=".xlsx"
                  :auto-upload="false"
                  :on-change="uploadChange"
                   >
                 <i class="el-icon-upload"></i>
                 <div class="el-upload__text">將文件拖到此處,或<em>點(diǎn)擊上傳</em></div>
                <div class="el-upload__tip" slot="tip">只能上傳excel文件</div>
               </el-upload>
            </div>

            <div class="buttonList">
                <el-button type="primary" @click="confirUpload" size="medium ">確定</el-button>
                <el-button type="info" @click="mergeUploadDialogVisible = false" size="medium ">取消</el-button>
            </div>
        </el-dialog>
 uploadChange(file,files){
            this.uploadFileList.push(file.raw);
         },
 confirUpload () {
              this.uploadFileList.map((el,index)=>{
                this.filedata.append(`file${index}`,el)
            });
              this.handleUploadSuccess();
           },
          handleUploadSuccess(){
             this.$sacpApis.uploadExcel(this.filedata).then(res => {
                if (res.success) {
                    this.$message.success('上傳成功')
                    let obj=this.$refs.uploadExcel
                    this.excelFile = '';
                    this.excelName = '';
                    let fileID={fileId:res.data[0].fileId}
                    this.uploadSuccessCB(fileID);
                }else{
                    let failInfo=res.resultInfo.statusText;
                     this.$message.error(failInfo);
                }
            }).catch(err=>this.$message.error(err)).finally(()=>{
                this.mergeUploadDialogVisible = false;
                this.dialogVisible = false;
            })
        },

入?yún)?


image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容