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/startWorkFlow.vue | 9 +- Source/plt-web/plt-web-ui/src/App.vue | 4 + Source/plt-web/plt-web-ui/src/api/base/file/index.js | 12 ++++ Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js | 1 Source/plt-web/plt-web-ui/src/components/actions/base/downLoadFile.vue | 13 ++++ Source/plt-web/plt-web-ui/src/components/actions/handlers.js | 2 Source/plt-web/plt-web-ui/vue.config.js | 4 + Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js | 22 ++++++- Source/plt-web/plt-web-ui/src/components/actions/base/uploadFile.vue | 89 +++++++++++++---------------- Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js | 6 + 10 files changed, 102 insertions(+), 60 deletions(-) diff --git a/Source/plt-web/plt-web-ui/src/App.vue b/Source/plt-web/plt-web-ui/src/App.vue index acf45e6..32b2829 100644 --- a/Source/plt-web/plt-web-ui/src/App.vue +++ b/Source/plt-web/plt-web-ui/src/App.vue @@ -40,6 +40,7 @@ } .avue-dialog .el-dialog__body{ padding: 20px; + margin-bottom: 20px !important; } .avue--detail .el-col{ margin-bottom: 0; @@ -92,4 +93,7 @@ .tree-buttons .el-button{ margin: 0 5px 5px 0; } +.el-dialog__footer{ + border-top: 1px solid #e9e7e7; +} </style> diff --git a/Source/plt-web/plt-web-ui/src/api/base/file/index.js b/Source/plt-web/plt-web-ui/src/api/base/file/index.js new file mode 100644 index 0000000..a36c7c2 --- /dev/null +++ b/Source/plt-web/plt-web-ui/src/api/base/file/index.js @@ -0,0 +1,12 @@ +import request from '@/router/axios'; + +// 涓嬭浇鏂囦欢 +export const download = (data) => { + return request({ + url: '/api/vciFileDownloadController/downloadByFileOidPost', + method: 'post', + headers: {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}, + responseType: 'blob', + data: data + }) +} diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js index ddb084d..e81ff9b 100644 --- a/Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js +++ b/Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js @@ -8,7 +8,6 @@ export const doAction = (options,callback) => { - //modelName 娴佺▼鍚嶇О 榛樿涓� 褰撳墠鐢ㄦ埛+'鍚姩娴佺▼'+褰撳墠鍒嗙被 //multi 鏄惁寮�鍚閫� //checknotprocess 鏄惁鍏佽鍙戣捣娴佺▼ diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/downLoadFile.vue b/Source/plt-web/plt-web-ui/src/components/actions/base/downLoadFile.vue new file mode 100644 index 0000000..d9ba6e4 --- /dev/null +++ b/Source/plt-web/plt-web-ui/src/components/actions/base/downLoadFile.vue @@ -0,0 +1,13 @@ +<template> + +</template> + +<script> +export default { + name: "downLoadFile" +} +</script> + +<style scoped> + +</style> diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js index 4c6c358..85da8fe 100644 --- a/Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js +++ b/Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js @@ -5,8 +5,10 @@ import {validatenull} from "@/util/validate"; import Vue from "vue"; import func from "@/util/func"; +import {download} from "@/api/base/file"; export const doAction = (options,callback) => { + console.log(options) options.sourceData = options.sourceData || {}; options.dataStore = options.dataStore || []; if (!options.dataStore || options.dataStore.length < 1) { @@ -33,10 +35,22 @@ */ export const showStartWindow = (options,callback)=> { const paramVOS = options.paramVOS; - if (!paramVOS['form'] && !paramVOS['context']) { - Vue.prototype.$message.error("鎸夐挳閰嶇疆涓嶆纭�"); - return false; - } + const oids = options.dataStore.map(item => item.oid).join(','); + let data = new FormData(); + data.append('fileOid',oids); + download(data).then(res => { + console.log(res); + if (res) { + func.downloadFileByBlobHandler(res); + Vue.prototype.$message.success("涓嬭浇鎴愬姛"); + } + }).catch(err => { + console.log(err); + }); + // if (!paramVOS['form'] && !paramVOS['context']) { + // Vue.prototype.$message.error("鎸夐挳閰嶇疆涓嶆纭�"); + // return false; + // } // func.downloadFileByBlobHandler(); } diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/startWorkFlow.vue b/Source/plt-web/plt-web-ui/src/components/actions/base/startWorkFlow.vue index 7b1d72e..b374b46 100644 --- a/Source/plt-web/plt-web-ui/src/components/actions/base/startWorkFlow.vue +++ b/Source/plt-web/plt-web-ui/src/components/actions/base/startWorkFlow.vue @@ -171,7 +171,7 @@ getWorkByType() { let params = { type: '鏂囨。瀹$娴佺▼', - filterTemplate: "" + filterTemplate: "鏂囨。瀹$娴佺▼" } getTemplateByType(params).then(res => { const data = res.data.data; @@ -179,7 +179,7 @@ this.processTemplateList = data; this.saveParam.processTemplate = data[0].value; - this.saveParam.processName = userInfo.content.userName + '-' + data[0].value; // 瀵规祦绋嬫ā鏉� 娴佺▼鍚嶇О璧嬮粯璁ゅ�� + this.saveParam.processName = this.paramVOS.processName || userInfo.content.userName + '-' + data[0].value; // 瀵规祦绋嬫ā鏉� 娴佺▼鍚嶇О璧嬮粯璁ゅ�� this.getProcessNode(data[0].attributes.oid); // 棣栨杩涘叆璋冪敤绗竴涓ā鏉跨殑鎵�鏈夎妭鐐� }).catch(err => { @@ -222,14 +222,15 @@ }, handleConfirm() { + const oids = this.dataStore.map(item => item.oid).join(','); let params = { deployid:this.processTemplateList[0].attributes.deploymentId, title:this.saveParam.processName, description:this.saveParam.processDesc, btmType:this.processTemplateList[0].attributes.taskType, uiType:this.processTemplateList[0].attributes.taskType, - oids:'', // 褰撳墠鏁版嵁oid锛屽涓敤,鍒嗛殧 - detailInfoUrl:'', // 鐢ㄦ埛閰嶇疆灞炴�� + oids:oids, // 褰撳墠鏁版嵁oid锛屽涓敤,鍒嗛殧 + detailInfoUrl:this.paramVOS.detailInfoUrl || '', // 鐢ㄦ埛閰嶇疆灞炴�� resetStatus:'Editing', nodeUsers:{ ...this.collectParam 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) { diff --git a/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js b/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js index b486c54..13c4f04 100644 --- a/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js +++ b/Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js @@ -5,12 +5,16 @@ import {validatenull} from "@/util/validate"; import Vue from "vue"; import uploadFileDialog from "@/components/actions/base/uploadFile" +import func from "@/util/func"; export const doAction = (options,callback) => { options.sourceData = options.sourceData || {}; options.dataStore = options.dataStore || []; - + if (func.isEmptyObject(options.sourceData)) { + Vue.prototype.$message.error("璇烽�夋嫨瑕佷笂浼犵殑鍒嗙被锛�"); + return false; + } callPreEvent(options, doBefore, function (options) { showStartWindow(options, function () { callPostEvent(options, doAfter, callback,type); diff --git a/Source/plt-web/plt-web-ui/src/components/actions/handlers.js b/Source/plt-web/plt-web-ui/src/components/actions/handlers.js index b3685d3..31752f6 100644 --- a/Source/plt-web/plt-web-ui/src/components/actions/handlers.js +++ b/Source/plt-web/plt-web-ui/src/components/actions/handlers.js @@ -35,7 +35,7 @@ uploadfile: () => {import("@/components/actions/base/uploadFileAction").then(module => { module.doAction(options,callback); })}, - //涓婁紶鏂囦欢 + //涓嬭浇鏂囦欢 downloadfile: () => {import("@/components/actions/base/downloadFileAction").then(module => { module.doAction(options,callback); })}, diff --git a/Source/plt-web/plt-web-ui/vue.config.js b/Source/plt-web/plt-web-ui/vue.config.js index 133f96c..4cf35ab 100644 --- a/Source/plt-web/plt-web-ui/vue.config.js +++ b/Source/plt-web/plt-web-ui/vue.config.js @@ -26,7 +26,9 @@ proxy: { '/api': { //鏈湴鏈嶅姟鎺ュ彛鍦板潃 - target: 'http://localhost:12000/web', + // target: 'http://localhost:12000/web', + target: 'http://192.168.0.105:12005/web', // yxc + // target: 'http://192.168.0.103:12005/web', // ldc // target: 'http://dev.vci-tech.com:37000', //杩滅▼婕旂ず鏈嶅姟鍦板潃,鍙敤浜庣洿鎺ュ惎鍔ㄩ」鐩� //target: 'https://saber.bladex.vip/api/', -- Gitblit v1.9.3