田源
2024-07-02 b81638e53bd74ed789215ad34ff9861c2e380609
上传文件、下载文件action配置
已修改8个文件
已添加2个文件
152 ■■■■■ 文件已修改
Source/plt-web/plt-web-ui/src/App.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/api/base/file/index.js 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/components/actions/base/downLoadFile.vue 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/components/actions/base/downloadFileAction.js 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/components/actions/base/startWorkFlow.vue 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/components/actions/base/uploadFile.vue 81 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/components/actions/base/uploadFileAction.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/components/actions/handlers.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/vue.config.js 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>
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
  })
}
Source/plt-web/plt-web-ui/src/components/actions/base/StartWorkflowAction.js
@@ -8,7 +8,6 @@
export const doAction = (options,callback) => {
  //modelName æµç¨‹åç§° é»˜è®¤ä¸º å½“前用户+'启动流程'+当前分类
  //multi æ˜¯å¦å¼€å¯å¤šé€‰
  //checknotprocess æ˜¯å¦å…è®¸å‘起流程
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>
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();
}
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
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>
@@ -77,6 +67,9 @@
      visible:false,
    }
  },
  created() {
    console.log(this.sourceData);
  },
  watch: {
    visible: {
      handler(newval, oldval) {
@@ -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,7 +100,7 @@
          return this.paramVOS.width + "px";
        }
      } else {
        return "60%";
        return "40%";
      }
    },
    fullscreen(){
@@ -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("只允许上传xlsx、xls格式的文件");
        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) {
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);
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);
    })},
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/',