From b81638e53bd74ed789215ad34ff9861c2e380609 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期二, 02 七月 2024 17:17:45 +0800 Subject: [PATCH] 上传文件、下载文件action配置 --- Source/plt-web/plt-web-ui/src/components/actions/base/uploadFile.vue | 89 ++++++++++++++++++++------------------------ 1 files changed, 41 insertions(+), 48 deletions(-) diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFile.vue b/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFile.vue index 433d92d..dc1c5b1 100644 --- a/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFile.vue +++ b/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFile.vue @@ -1,45 +1,35 @@ <template> <el-dialog v-dialogDrag - :width="width" - :visible.sync="visible" - :destroy-on-close="true" :close-on-click-modal="false" + :destroy-on-close="true" + :visible.sync="visible" + :width="width" append-to-body - title="涓婁紶鏂囦欢" class="avue-dialog" + title="涓婁紶鏂囦欢" + style="margin-top: -20vh !important;" > <Divider left="30px" text="瀵煎叆鎻愮ず"></Divider> <ul> <li> - 1.绾㈣壊瀛椾綋琛ㄧず蹇呰緭椤� - </li> - <li> - 2.姣忔浠呰兘鏈�澶氬鍏�10000鏉℃暟鎹� + 璇风偣鍑绘祻瑙堟枃浠惰繘琛屼笂浼� </li> </ul> - <Divider left="30px" text="excel鏂囦欢锛岄�夋嫨鏂囦欢鍚庝細鑷姩涓婁紶"></Divider> + <Divider left="30px" text="閫夋嫨鏂囦欢鍚庝細鑷姩涓婁紶"></Divider> <el-upload :before-upload="beforeUpload" + :data="fileData" :headers="uploadHeaders" :on-change="uploadChange" :on-error="onError" :on-success="onSuccess" :show-file-list="false" - accept=".xlsx, .xls" - action="/api/ubcs-code/codeClassify/importClassify" + action="/api/vciFileUploadController/uploadFile" class="upload-demo"> <el-button size="small" style="margin: 15px 35px" type="primary">娴忚鏂囦欢</el-button> </el-upload> <template #footer> - <el-button - :loading="downloadLoading" - size="small" - type="primary" - @click="downloadTemplateFun" - >涓嬭浇瀵煎叆妯℃澘 - </el-button - > <el-button size="small" @click="visible = false">鍏抽棴</el-button> </template> </el-dialog> @@ -74,8 +64,11 @@ flga: true, pageLoading: null, downloadLoading: false, - visible:false, + visible: false, } + }, + created() { + console.log(this.sourceData); }, watch: { visible: { @@ -87,8 +80,17 @@ computed: { uploadHeaders() { return { - "Blade-Auth": "bearer " + getToken(), + "Authorizationtoken": getToken(), }; + }, + fileData() { + return { + ownbizOid: this.sourceData.oid, + ownBtmName: this.sourceData.btmname, + secretGrade: -1, + fileDocClassify: '', + updateFileFlag: true, + } }, width() { if (!validatenull(this.paramVOS.width)) { @@ -98,14 +100,14 @@ return this.paramVOS.width + "px"; } } else { - return "60%"; + return "40%"; } }, - fullscreen(){ + fullscreen() { console.log(this.paramVOS) - if(this.paramVOS.width || this.paramVOS.height){ + if (this.paramVOS.width || this.paramVOS.height) { return false; - }else if(this.paramVOS.form){ + } else if (this.paramVOS.form) { return false; } return true; @@ -114,49 +116,40 @@ methods: { //鏂囦欢涓婁紶鍓� async beforeUpload(file) { - const fileType = file.name.split(".").pop(); - if (fileType !== "xlsx" && fileType !== "xls") { + // 鑾峰彇鏂囦欢鎵╁睍鍚� + const fileExtension = file.name.split(".").pop().toLowerCase(); // 杞崲涓哄皬鍐欎互閬垮厤澶у皬鍐欎笉鍖归厤鐨勯棶棰� + const allowedExtensions = this.paramVOS.fileType || ['css', 'csv', 'doc', 'gif', 'html', 'jpe', 'jpg', 'jpeg', 'png', 'js', 'json', + 'mp3', 'mp4', 'xlsx', 'xml', 'zip', 'xhtml', 'wps', 'ppt', 'xls', 'word', 'pdf', 'txt']; + + // 妫�鏌ユ枃浠舵墿灞曞悕鏄惁鍦ㄥ厑璁哥殑鏂囦欢鎵╁睍鍚嶆暟缁勪腑 + if (!allowedExtensions.includes(fileExtension)) { // 涓婁紶鏍煎紡涓嶇鍚堣姹傦紝鎻愮ず閿欒淇℃伅骞跺彇娑堜笂浼� - this.$message.error("鍙厑璁镐笂浼爔lsx銆亁ls鏍煎紡鐨勬枃浠�"); + this.$message.error(`鍙厑璁镐笂浼�${allowedExtensions.toString()}鏍煎紡鐨勬枃浠禶); 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) { + if (resbonse.code === 200) { this.$message.success("涓婁紶鎴愬姛锛�"); this.dialogVisible = false; - return; + }else { + this.$message.error(resbonse.msg); } - 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(); + this.$message.error(res); }, //鏂囦欢鐘舵�佹敼鍙� uploadChange(file) { -- Gitblit v1.9.3