vue iview 導入excel文件(upload)


 <Upload 
                    ref="upload"
                    action="/api/book/excel/import"    
                    name="excel-file"
                    :show-upload-list="true"
                    :on-format-error="handleFormatError"
                    :on-success="handleSuccess"
                    :on-error="handleError"
                    :format ="['xlsx','xls']">
                        <Button type="info" icon="ios-cloud-upload-outline">批量導入</Button>
                </Upload>

 

 handleFormatError(file){
                this.$Notice.warning({
                    title: '文件格式不正確',
                    desc: '文件 ' + file.name + ' 格式不正確,請上傳.xls,.xlsx文件。'
                })
            },
            handleSuccess(res,file){
                if(res.errcode === 0){
                    this.dialoLead = false
                    this.$Message.success("數據導入成功!")
                    this._getBookList()
                    this.$refs.upload.clearFiles()
                }
            },
            handleError(error,file){
                this.$Message.error("數據導入失敗!")
            },

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM