¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <el-dialog |
| | | title="ä¸ä¼ æä»¶" |
| | | :visible.sync="dialogVisible" |
| | | append-to-body |
| | | > |
| | | <Divider text="导å
¥æç¤º" left="30px"></Divider> |
| | | <ul> |
| | | <li> |
| | | 1.红è²åä½è¡¨ç¤ºå¿
è¾é¡¹ |
| | | </li> |
| | | <li> |
| | | 2.æ¯æ¬¡ä»
è½æå¤å¯¼å
¥10000æ¡æ°æ® |
| | | </li> |
| | | </ul> |
| | | <Divider text="excelæä»¶ï¼éæ©æä»¶åä¼èªå¨ä¸ä¼ " left="30px"></Divider> |
| | | <el-upload |
| | | accept=".xlsx, .xls" |
| | | action="/api/ubcs-code/codeClassify/importClassify" |
| | | :on-success="onSuccess" |
| | | :on-error="onError" |
| | | :headers="uploadHeaders" |
| | | :show-file-list="false" |
| | | :before-upload="beforeUpload" |
| | | :on-change="uploadChange" |
| | | class="upload-demo"> |
| | | <el-button size="small" type="primary" style="margin: 15px 35px">æµè§æä»¶</el-button> |
| | | </el-upload> |
| | | <template #footer> |
| | | <el-button |
| | | type="primary" |
| | | size="small" |
| | | @click="downloadTemplateFun" |
| | | :loading="downloadLoading" |
| | | >ä¸è½½å¯¼å
¥æ¨¡æ¿</el-button |
| | | > |
| | | <el-button size="small" @click="dialogVisible = false">å
³é</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script> |
| | | // import {downloadErrorFile,downloadBatchImportApplyTemplate} from '@/api/template/templateAttr' |
| | | import {getToken} from "@/util/auth"; |
| | | import func from "@/util/func"; |
| | | export default { |
| | | name: "Upload-files", |
| | | props: { |
| | | visible: { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | codeClassifyOid: { |
| | | type: String, |
| | | default: "", |
| | | }, |
| | | }, |
| | | data(){ |
| | | return{ |
| | | flga:true, |
| | | pageLoading: null, |
| | | downloadLoading: false, |
| | | } |
| | | }, |
| | | watch:{ |
| | | visible:{ |
| | | handler(newval,oldval){ |
| | | // console.log('newval',newval) |
| | | } |
| | | } |
| | | }, |
| | | computed:{ |
| | | uploadHeaders() { |
| | | return { |
| | | "Blade-Auth": "bearer " + getToken(), |
| | | }; |
| | | }, |
| | | dialogVisible: { |
| | | get() { |
| | | return this.visible; |
| | | }, |
| | | set(val) { |
| | | this.$emit("update:visible", val); |
| | | }, |
| | | }, |
| | | }, |
| | | methods:{ |
| | | //æä»¶ä¸ä¼ å |
| | | async beforeUpload(file) { |
| | | const fileType = file.name.split(".").pop(); |
| | | if (fileType !== "xlsx" && fileType !== "xls") { |
| | | // ä¸ä¼ æ ¼å¼ä¸ç¬¦åè¦æ±ï¼æç¤ºé误信æ¯å¹¶åæ¶ä¸ä¼ |
| | | this.$message.error("åªå
许ä¸ä¼ xlsxãxlsæ ¼å¼çæä»¶"); |
| | | return Promise.reject(false); |
| | | } |
| | | this.pageLoading = this.$loading({ |
| | | lock: true, |
| | | text: "æä»¶ä¸ä¼ ä¸", |
| | | spinner: "el-icon-loading", |
| | | background: "rgba(0, 0, 0, 0.7)", |
| | | }); |
| | | return true; |
| | | }, |
| | | // æä»¶ä¸ä¼ æå |
| | | onSuccess(resbonse){ |
| | | if (Object.keys(resbonse.data).length === 0) { |
| | | this.$message.success( "ä¸ä¼ æåï¼"); |
| | | this.dialogVisible = false; |
| | | return; |
| | | } |
| | | if (resbonse.data.fileOid) { |
| | | const fileName = resbonse.data.filePath.split("/").pop(); |
| | | this.$message.error("请ä¸è½½éè¯¯ä¿¡æ¯æä»¶è¿è¡æ¥çï¼"); |
| | | downloadErrorFile({ uuid: resbonse.data.fileOid }).then((res) => { |
| | | func.downloadFileByBlobHandler(res); |
| | | }); |
| | | } |
| | | }, |
| | | //ç¹å»ä¸è½½æ¨¡æ¿ |
| | | downloadTemplateFun(){ |
| | | this.downloadLoading = true; |
| | | downloadBatchImportApplyTemplate({codeClassifyOid: this.codeClassifyOid}).then(res=>{ |
| | | this.$utilFunc.downloadFileByBlob(res.data, "æ¨¡æ¿æä»¶.xls"); |
| | | this.downloadLoading = false; |
| | | }).catch((res)=>{ |
| | | this.$message.warning(res) |
| | | this.downloadLoading = false; |
| | | }) |
| | | }, |
| | | //æä»¶ä¸ä¼ 失败 |
| | | onError(res){ |
| | | this.pageLoading.close(); |
| | | }, |
| | | //æä»¶ç¶ææ¹å |
| | | uploadChange(file){ |
| | | if (file.status === "success" || file.status === "error") { |
| | | this.pageLoading.close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | ul { |
| | | color: rgb(188, 188, 188); |
| | | margin: 20px 0 20px 0; |
| | | padding: 0 0 0 30px; |
| | | list-style: none; |
| | | li { |
| | | margin-bottom: 5px; |
| | | font-size: 13px; |
| | | } |
| | | } |
| | | </style> |